# $Id: Makefile.os2,v 8.11 2000/06/22 01:07:11 darren Exp $
#
# A Makefile for OS/2 using gcc (EMX 0.9)
# You may want to use the OS/2 port of autoconf to create
# and outcomment the according statement below
#
# Provided and supported by Alexander Mai
#   <st002279@hrzpub.tu-darmstadt.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"               \
	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 -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 -Zomf"         \
	LFLAGS="-s -Zomf -Zsys -Zlinker /PM:VIO"

# Use the line below if you have created config.h
# (manually or by running configure)
# Otherwise use built-in defaults (#ifdef OS2)!
# DEFINES=-DHAVE_CONFIG_H
DEFINES=-DOS2


# General rules and definitions

.SUFFIXES: .c .exe .h .o .obj

include source.mak

ctags: ctags.exe
etags: etags.exe

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

etags.exe: ctags.exe
	@copy $< $@

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

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

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