#
-# ld65 Makefile for the Watcom compiler
+# ld65 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 = ld65.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=$@ $^
# ------------------------------------------------------------------------------
# All OBJ files
-OBJS = bin.obj \
+OBJS = asserts.obj \
+ bin.obj \
binfmt.obj \
+ cfgexpr.obj \
condes.obj \
config.obj \
+ dbgfile.obj \
+ dbginfo.obj \
dbgsyms.obj \
error.obj \
exports.obj \
expr.obj \
- extsyms.obj \
+ extsyms.obj \
fileinfo.obj \
fileio.obj \
+ filepath.obj \
fragment.obj \
global.obj \
library.obj \
objfile.obj \
scanner.obj \
segments.obj \
+ spool.obj \
tgtcfg.obj
-LIBS = ..\common\common.lib
+LIBS = ../common/common.lib
# ------------------------------------------------------------------------------
# Main targets
-all: ld65
-
-ld65: ld65.exe
+all: $(EXE)
# ------------------------------------------------------------------------------
# Other targets
-ld65.exe: $(OBJS) $(LIBS)
- $(LD) system $(SYSTEM) @&&|
-DEBUG ALL
-OPTION QUIET
-NAME $<
-FILE bin.obj
-FILE binfmt.obj
-FILE condes.obj
-FILE config.obj
-FILE dbgsyms.obj
-FILE error.obj
-FILE exports.obj
-FILE expr.obj
-FILE extsyms.obj
-FILE fileio.obj
-FILE fragment.obj
-FILE global.obj
-FILE library.obj
-FILE main.obj
-FILE mapfile.obj
-FILE o65.obj
-FILE objdata.obj
-FILE objfile.obj
-FILE scanner.obj
-FILE segments.obj
-FILE tgtcfg.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 *.obj del ld65.exe
+ @rm -f *~ core
+
+zap: clean
+ @rm -f $(OBJS) $(EXE) $(EXE:.exe=.map)
strip:
- @-wstrip ld65.exe
+ @-$(WSTRIP) $(EXE)