#
-# CL65 Makefile for the Watcom compiler
+# CL65 Makefile for the Watcom compiler (using GNU make)
#
# ------------------------------------------------------------------------------
# Generic stuff
-.AUTODEPEND
-.SUFFIXES .ASM .C .CC .CPP
-.SWAP
+# Environment variables for the watcom compiler
+export WATCOM = c:\\watcom
+export INCLUDE = $(WATCOM)\\h
-AR = WLIB
-LD = WLINK
+# We will use the windows compiler under linux (define as empty for windows)
+export WINEDEBUG=fixme-all
+WINE = wine
-!if !$d(TARGET)
-!if $d(__OS2__)
-TARGET = OS2
-!else
-TARGET = NT
-!endif
-!endif
-
-# target specific macros.
-!if $(TARGET)==OS2
+# Programs
+AR = $(WINE) wlib
+CC = $(WINE) wcc386
+LD = $(WINE) wlink
+WSTRIP = $(WINE) wstrip -q
-# --------------------- OS2 ---------------------
-SYSTEM = os2v2
-CC = WCC386
-CCCFG = -bt=$(TARGET) -d1 -onatx -zp4 -5 -zq -w2
+LNKCFG = ld.tmp
-!elif $(TARGET)==DOS32
+# Program arguments
+CFLAGS = -d1 -obeilr -zp4 -5 -zq -w2 -i=..\\common
-# -------------------- DOS4G --------------------
-SYSTEM = dos4g
-CC = WCC386
-CCCFG = -bt=$(TARGET) -d1 -onatx -zp4 -5 -zq -w2
+# Target files
+EXE = cl65.exe
-!elif $(TARGET)==DOS
+# Create NT programs by default
+ifndef TARGET
+TARGET = NT
+endif
-# --------------------- DOS ---------------------
-SYSTEM = dos
-CC = WCC
-CCCFG = -bt=$(TARGET) -d1 -onatx -zp2 -2 -ml -zq -w2
+# --------------------- OS2 ---------------------
+ifeq ($(TARGET),OS2)
+SYSTEM = os2v2
+CFLAGS += -bt=$(TARGET)
+endif
-!elif $(TARGET)==NT
+# -------------------- DOS4G --------------------
+ifeq ($(TARGET),DOS32)
+SYSTEM = dos4g
+CFLAGS += -bt=$(TARGET)
+endif
# --------------------- NT ----------------------
-SYSTEM = nt
-CC = WCC386
-CCCFG = -bt=$(TARGET) -d1 -onatx -zp4 -5 -zq -w2
-
-!else
-!error
-!endif
-
-# Add the include dir
-CCCFG = $(CCCFG) -i=..\common
+ifeq ($(TARGET),NT)
+SYSTEM = nt
+CFLAGS += -bt=$(TARGET)
+endif
# ------------------------------------------------------------------------------
# Implicit rules
-.c.obj:
- $(CC) $(CCCFG) $<
+%.obj: %.c
+ $(CC) $(CFLAGS) -fo=$@ $^
# ------------------------------------------------------------------------------
global.obj \
main.obj
-.PRECIOUS $(OBJS:.obj=.c)
+LIBS = ../common/common.lib
+
# ------------------------------------------------------------------------------
# Main targets
-all: cl65
-
-cl65: cl65.exe
+all: $(EXE)
# ------------------------------------------------------------------------------
# Other targets
-cl65.exe: $(OBJS)
- $(LD) system $(SYSTEM) @&&|
-DEBUG ALL
-OPTION QUIET
-NAME $<
-FILE error.obj
-FILE global.obj
-FILE main.obj
-LIBRARY ..\common\common.lib
-|
-
+$(EXE): $(OBJS) $(LIBS)
+ @echo "DEBUG ALL" > $(LNKCFG)
+ @echo "OPTION QUIET" >> $(LNKCFG)
+ @echo "OPTION MAP" >> $(LNKCFG)
+ @echo "OPTION STACK=65536" >> $(LNKCFG)
+ @echo "NAME $@" >> $(LNKCFG)
+ @for i in $(OBJS); do echo "FILE $${i}"; done >> $(LNKCFG)
+ @for i in $(LIBS); do echo "LIBRARY $${i}"; done >> $(LNKCFG)
+ @$(LD) system $(SYSTEM) @$(LNKCFG)
+ @rm $(LNKCFG)
clean:
- @if exist *.obj del *.obj
- @if exist cl65.exe del cl65.exe
+ @rm -f *~ core
-strip:
- @-wstrip cl65.exe
+zap: clean
+ @rm -f $(OBJS) $(EXE) $(EXE:.exe=.map)
+strip:
+ @-$(WSTRIP) $(EXE)