# This file is part of the CJK package Version 2.5 (10-Apr-1995)

# GNU Makefile for hbf2gf

.PHONY: unix unixdebug os2 bound bounddebug dos dosdebug \
        documentation all clean default
.CAUTIOUS: hbf2gf.c

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 "    dos dosdebug                         "
	@echo "    documentation                        "
	@echo "    clean                                "


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

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

# for OS/2 only (using emx-gcc)
os2:
	$(MAKE) all CC="gcc -Wall -Zomf -Zmtd -O -s" O=.obj EXE=.exe \
		    LIB=hbf2gf.def 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


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

%.c: %.w %.ch
	$(CTANGLE) $^ $@
%.c: %.w
	$(CTANGLE) $<

%.tex: %.w %.ch
	$(CWEAVE) +ai $^ $@
%.tex: %.w
	$(CWEAVE) +ai $<

%.dvi: %.tex
	$(TEX) $*


all: hbf2gf$(EXE)

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

hbf$O: hbf.c hbf.h


# this builds the .dvi-file

documentation: hbf2gf.dvi


# 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) *.scn
	-$(RM) *.toc
	-$(RM) *.idx
	-$(RM) *.log
	-$(RM) *.o
