# A Makefile for OS/2 using EMX gcc 0.9
#
# Provided and supported by Alexander Mai
#   <st002279@hrzpub.tu-darmstadt.de> or
#   <am@os-2.de>

default:
	@echo "Enter $(MAKE) -f makefile.os2 target"
	@echo "where target is one of:"
	@echo "   small    (small executable req. EMX runtime)"
	@echo "   debug    (executable for debugging purposes)"
	@echo "   release  (stand-alone executable)"
	@echo "   clean    (remove all files built)"

# Use this to create a small binary
# (which requires EMX runtime)  
small: 
	$(MAKE) -f makefile.os2 ctags                         \
	CC="gcc"                                              \
	CFLAGS="-O2 -Wall -fno-strength-reduce -DOS2"         \
	LFLAGS="-Zcrtdll -s"

# Use this to create a binary for debugging purposes
# (which requires EMX runtime)  
debug: 
	$(MAKE) -f makefile.os2 ctags                         \
	CC="gcc"                                              \
	CFLAGS="-O0 -Wall -fno-strength-reduce -DOS2 -g"      \
	LFLAGS="-Zcrtdll -g"

# Use this to create a stand-alone binary for distribution
# (requires link386 for linking but no EMX runtime)
release: 
	$(MAKE) -f makefile.os2 ctags                         \
	CC="gcc"                                              \
	CFLAGS="-O2 -Wall -fno-strength-reduce -DOS2 -Zomf"   \
	LFLAGS="-s -Zomf -Zsys -Zlinker /PM:VIO"


# General rules and definitions

SOURCES	= eiffel.c entry.c fortran.c get.c keyword.c main.c options.c \
	parse.c read.c sort.c vstring.c
OBJECTS	= eiffel.o entry.o fortran.o get.o keyword.o main.o options.o \
	parse.o read.o sort.o vstring.o

ctags: ctags.exe

ctags.exe: $(OBJECTS)
	$(CC) $(CFLAGS) $(LFLAGS) -o $@ $^

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

# Delete all files that are not part of the source distribution
clean:
	@if exist ctags.exe del ctags.exe
	@if exist *.obj     del *.obj
	@if exist *.o       del *.o
