# This file is part of the FreeType project.
#
# It builds the library and test programs for emx-gcc under OS/2.
#
# You will need GNU make.
#
# Use this file while in the 'test' directory with the following statement:
#
#   make -f arch/os2/Makefile.emx

ARCH = arch/os2
FT_MAKEFILE = $(ARCH)/Makefile.emx

CC = gcc

LIBDIR = ../lib
INCDIRS = -I$(LIBDIR) -I$(LIBDIR)/extend -I$(LIBDIR)/$(ARCH) -I.

CFLAGS = -Wall -ansi -O0 -g $(INCDIRS)
# CFLAGS = -ansi -Wall -O2 -s -Zcrtdll $(INCDIRS)

GFSDRIVER = $(ARCH)/gfs_os2.c
GPMDRIVER = $(ARCH)/gpm_os2.c
GPM_DEF = $(ARCH)/gpm_os2.def

SRC = fttimer.c ftview.c ftlint.c ftzoom.c ftdump.c ftstring.c ftstrpnm.c \
      ftsbit.c common.c blitter.c ftmetric.c ftstrtto.c arabic.c

GSRC = gmain.c display.c blitter.c
GFSSRC = $(GSRC) $(GFSDRIVER)
GPMSRC = $(GSRC) $(GPMDRIVER)
GFSOBJ = $(GFSSRC:.c=.o)
GPMOBJ = $(GPMSRC:.c=.o)

ALLSRC = $(SRC) $(GSRC) $(GFSDRIVER) $(GPMDRIVER)
ALLOBJ = $(ALLSRC:.c=.o)


%.o: %.c
	$(CC) $(CFLAGS) -c -o $@ $<

%.exe:
	$(CC) $(CFLAGS) -o $@ $^


EXEFILES = ftview.exe ftviewfs.exe \
           fttimer.exe fttimefs.exe \
           ftlint.exe \
           ftstring.exe ftstrfs.exe \
           ftstrpnm.exe \
           ftzoom.exe ftzoomfs.exe  \
           ftsbit.exe \
           ftdump.exe \
           ftmetric.exe \
           ftstrtto.exe ftstrtfs.exe

.PHONY: all debug freetype freetype_debug \
        clean distclean do_clean depend


all: freetype $(EXEFILES)

debug: freetype_debug $(EXEFILES)

freetype:
	$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) all

freetype_debug:
	$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) debug

ftzoom.exe: $(GPMOBJ) ftzoom.o common.o $(LIBDIR)/libttf.a $(GPM_DEF)
ftzoomfs.exe: $(GFSOBJ) ftzoom.o common.o $(LIBDIR)/libttf.a
ftview.exe: $(GPMOBJ) ftview.o common.o $(LIBDIR)/libttf.a $(GPM_DEF)
ftviewfs.exe: $(GFSOBJ) ftview.o common.o $(LIBDIR)/libttf.a 
ftlint.exe: ftlint.o common.o $(LIBDIR)/libttf.a
ftdump.exe: ftdump.o common.o $(LIBDIR)/libttf.a
ftstring.exe: $(GPMOBJ) ftstring.o common.o $(LIBDIR)/libttf.a $(GPM_DEF)
ftstrfs.exe: $(GFSOBJ) ftstring.o common.o $(LIBDIR)/libttf.a
ftstrpnm.exe: ftstrpnm.o common.o $(LIBDIR)/libttf.a
fttimer.exe: $(GPMOBJ) fttimer.o common.o $(LIBDIR)/libttf.a $(GPM_DEF)
fttimefs.exe: $(GFSOBJ) fttimer.o common.o $(LIBDIR)/libttf.a
ftsbit.exe: ftsbit.o common.o $(LIBDIR)/libttf.a
ftmetric.exe: ftmetric.o common.o $(LIBDIR)/libttf.a
ftstrtto.exe: $(GPMOBJ) ftstrtto.o common.o arabic.o \
              $(LIBDIR)/libttf.a $(GPM_DEF)
ftstrtfs.exe: $(GFSOBJ) ftstrtto.o common.o arabic.o $(LIBDIR)/libttf.a


clean: do_clean
	$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) clean

distclean: do_clean
	$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) distclean
	-del dep.end $(EXEFILES) core

do_clean:
	-del $(subst /,\,$(ALLOBJ))


depend: $(ALLSRC)
	$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) depend
	$(CC) -E -M $(INCDIRS) $^ > dep.end

ifeq (dep.end,$(wildcard dep.end))
  include dep.end
endif

# end of Makefile.emx
