#
-# CC65 Makefile for the Watcom compiler
+# CC65 Makefile for the Watcom compiler (using GNU make) and wine
#
# ------------------------------------------------------------------------------
# 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
+# Programs
+AR = $(WINE) wlib
+CC = $(WINE) wcc386
+LD = $(WINE) wlink
LIB = common.lib
-!if !$d(TARGET)
-!if $d(__OS2__)
-TARGET = OS2
-!else
-TARGET = NT
-!endif
-!endif
+# Program arguments
+CFLAGS = -d1 -obeilr -zp4 -5 -zq -w2
-# target specific macros.
-!if $(TARGET)==OS2
+# Create NT programs by default
+ifndef TARGET
+TARGET = NT
+endif
# --------------------- OS2 ---------------------
-SYSTEM = os2v2
-CC = WCC386
-CCCFG = -bt=$(TARGET) -d1 -onatx -zp4 -5 -zq -w2
-
-!elif $(TARGET)==DOS32
+ifeq ($(TARGET),OS2)
+SYSTEM = os2v2
+CFLAGS += -bt=$(TARGET)
+endif
# -------------------- DOS4G --------------------
-SYSTEM = dos4g
-CC = WCC386
-CCCFG = -bt=$(TARGET) -d1 -onatx -zp4 -5 -zq -w2
-
-!elif $(TARGET)==DOS
-
-# --------------------- DOS ---------------------
-SYSTEM = dos
-CC = WCC
-CCCFG = -bt=$(TARGET) -d1 -onatx -zp2 -2 -ml -zq -w2
-
-!elif $(TARGET)==NT
+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
+ifeq ($(TARGET),NT)
+SYSTEM = nt
+CFLAGS += -bt=$(TARGET)
+endif
# ------------------------------------------------------------------------------
# Implicit rules
-.c.obj:
- $(CC) $(CCCFG) $<
+%.obj: %.c
+ $(CC) $(CFLAGS) -fo=$@ $^
# ------------------------------------------------------------------------------
# All library OBJ files
-OBJS = bitops.obj \
+OBJS = abend.obj \
+ addrsize.obj \
+ bitops.obj \
+ chartype.obj \
+ check.obj \
cmdline.obj \
+ coll.obj \
+ cpu.obj \
+ debugflag.obj \
+ exprdefs.obj \
+ filepos.obj \
+ filetype.obj \
+ fname.obj \
+ fp.obj \
hashstr.obj \
- wildargv.obj \
+ hashtab.obj \
+ intstack.obj \
+ matchpat.obj \
+ mmodel.obj \
+ print.obj \
+ searchpath.obj \
+ segdefs.obj \
+ segnames.obj \
+ shift.obj \
+ strbuf.obj \
+ strpool.obj \
+ strstack.obj \
+ strutil.obj \
+ target.obj \
+ tgttrans.obj \
+ version.obj \
+ wildargv.obj \
+ xmalloc.obj \
xsprintf.obj
-.PRECIOUS $(OBJS:.obj=.cc) $(LIB)
-
# ------------------------------------------------------------------------------
# Main targets
$(LIB): $(OBJS)
@echo Creating library...
- &@$(AR) -q -b -P=32 $(LIB) +-$?
+ $(AR) -q -b -P=32 $(LIB) $(foreach OBJ, $(OBJS), +-$(OBJ))
@echo Done!
+wildargv.obj:
+ $(CC) $(CFLAGS) -fo=$@ $(WATCOM)\\src\\startup\\wildargv.c
+
clean:
- @if exist *.obj del *.obj
- @if exist $(LIB) del $(LIB)
+ @rm -f *~ core
+
+zap: clean
+ @rm -f *.obj $(LIB)
+
+strip:
+ @true
+