# This file is part of the FreeType project.
#
# It builds the library and test programs for MinGW32 gcc under Win9x.
#
# You will need a port of GNU make; the MingW32 port works.
#
# Use this file while in the 'test' directory with the following statement:
#
#   make -f arch/win32/Makefile.min

ARCH = arch/win32
FT_MAKEFILE = $(ARCH)/Makefile.min

CC = gcc

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

ifdef DEBUG

CFLAGS  = -ansi -pedantic -Wall -O2 -g $(INCDIRS)
LDFLAGS = -g -luser32 -lgdi32

else

CFLAGS  = -ansi -pedantic -Wall -O2 -s $(INCDIRS)
LDFLAGS = -s -luser32 -lgdi32

endif


# graphic Windows driver
GDRIVER = $(ARCH)/gw_win32.c

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

GSRC = gmain.c display.c blitter.c $(GDRIVER)
GOBJ = $(GSRC:.c=.o)


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


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


EXEFILES = ftdump.exe \
           fterror.exe \
           ftlint.exe \
           ftmetric.exe \
           ftsbit.exe \
           ftstring.exe \
           ftstrpnm.exe \
           ftstrtto.exe \
           fttimer.exe \
           ftview.exe \
           ftzoom.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: $(GOBJ) ftzoom.o common.o $(LIBDIR)/libttf.a
ftview.exe: $(GOBJ) 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
fterror.exe: fterror.o common.o $(LIBDIR)/libttf.a
ftstring.exe: $(GOBJ) ftstring.o common.o $(LIBDIR)/libttf.a
fttimer.exe: $(GOBJ) fttimer.o common.o $(LIBDIR)/libttf.a
ftstrpnm.exe: ftstrpnm.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: $(GOBJ) 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
	-del *.exe
	-del core

do_clean:
	-del *.o
	-del response
	-del $(subst /,\,$(GDRIVER:.c=.o))

depend: $(SRC) $(GSRC)
	$(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.gcc
