# This file is part of the FreeType project.
#
# It builds the library and test programs for gcc under Win32.
#
# You will need GNU make.
#
# Use this file while in the 'test' directory with the following statement:
#
#   make -f arch/win32/Makefile.gcc
#
#
# If you have the GNU gettext package installed, you can also try
#
#   make -f arch/win32/Makefile.gcc HAVE_GETTEXT

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

CC = gcc

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

ifndef GETTEXT
GETTEXT=NO_GETTEXT
endif

CFLAGS = -Wall -ansi -O2 -g $(INCDIRS)
# -D$(GETTEXT)
# CFLAGS = -ansi -Wall -O2 -s $(INCDIRS) -D$(GETTEXT)


# 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 $@ $<


ifeq ($(GETTEXT),HAVE_GETTEXT)
%.exe:
	$(CC) $(CFLAGS) -o $@ $^ -lintl
else
%.exe:
	$(CC) $(CFLAGS) -o $@ $^
endif


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)

HAVE_GETTEXT:
	$(MAKE) -f $(FT_MAKEFILE) GETTEXT=HAVE_GETTEXT all

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 $(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
