# GNU Makefile for ttf2pk

.PHONY: unix unixdebug os2 bound bounddebug dos dosdebug \
        depend all clean default

default:
	@echo "say                                      "
	@echo "                                         "
	@echo "    make TARGET                          "
	@echo "                                         "
	@echo "where TARGET can be one of the following:"
	@echo "                                         "
	@echo "    unix unixdebug                       "
	@echo "    os2 bound bounddebug                 "
	@echo "    depend                               "
	@echo "    dos dosdebug                         "
	@echo "    clean                                "


# for UNIX systems
unix:                                              
	$(MAKE) all CC="gcc -Wall -O -s" O=.o LIB=-lm FS=UNIX

# for UNIX debugging
unixdebug:
	$(MAKE) all CC="gcc -Wall -O -g" O=.o LIB=-lm FS=UNIX

# for OS/2 only (using emx-gcc)
os2:
	$(MAKE) all CC="gcc -Wall -Zomf -Zmtd -O -s" O=.obj EXE=.exe FS=MSDOS

# for OS/2 and DOS (using emx-gcc)
bound:
	$(MAKE) all CC="gcc -Wall -O -s" O=.o EXE=.exe FS=MSDOS

# for OS/2 and DOS debugging (using emx-gcc)
bounddebug:
	$(MAKE) all CC="gcc -Wall -O -g" O=.o EXE=.exe FS=MSDOS

# for DOS (using djgpp)
dos:
	$(MAKE) all CC="gcc -Wall -O -s" O=.ooo EXE=.exe FS=MSDOS

# for DOS debugging (using djgpp)
dosdebug:
	$(MAKE) all CC="gcc -Wall -O -g" O=.ooo EXE=.exe FS=MSDOS


OBJ = basic$O bitmap$O error$O findex$O loadtabl$O render$O ttf2bmp$O ttf2pk$O


%$O: %.c
	$(CC) $(CFLAGS) -funroll-loops -c -D$(FS) -o $@ $<


all: ttf2pk$(EXE)

ttf2pk$(EXE): $(OBJ)
  ifeq ($O,.ooo)
	$(CC) $(CFLAGS) -o $(basename $@) $^ $(LIB)
	strip $(basename $@)
	coff2exe $(basename $@)
	-del $(basename $@)
  else
	$(CC) $(CFLAGS) -o $@ $^ $(LIB)
  endif


# remove the unnecessary files;
# this will also work under DOS and OS/2 if you have
#
#     set RM=del
#
# in your autoexec.bat (DOS) or config.sys (OS/2)

clean:
	-$(RM) *.o


# Dependencies.

depend:
	gcc -E -M *.c > dep.end

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