# gcc Makefile for ld65
#
+# ------------------------------------------------------------------------------
+
+# The executable to build
+EXE = ld65
+
# Library dir
COMMON = ../common
-# Default for the compiler lib search path as compiler define
-CDEFS=-DCC65_LIB=\"/usr/lib/cc65/lib/\"
-CFLAGS = -g -O2 -Wall -I$(COMMON) $(CDEFS)
-CC=gcc
-LDFLAGS=
+# Several search paths. You may redefine these on the command line
+LD65_LIB = \"/usr/lib/cc65/lib/\"
+LD65_OBJ = \"/usr/lib/cc65/lib/\"
+LD65_CFG = \"/usr/lib/cc65/cfg/\"
+
+#
+CC = gcc
+CFLAGS = -g -O2 -Wall -W -std=c89
+override CFLAGS += -I$(COMMON)
+override CFLAGS += -DLD65_LIB=$(LD65_LIB) -DLD65_OBJ=$(LD65_OBJ) -DLD65_CFG=$(LD65_CFG)
+EBIND = emxbind
+LDFLAGS =
+
+# Perl script for config file conversion
+CVT=cfg/cvt-cfg.pl
-OBJS = bin.o \
+# -----------------------------------------------------------------------------
+# List of all object files
+
+OBJS = asserts.o \
+ bin.o \
binfmt.o \
+ cfgexpr.o \
+ condes.o \
config.o \
+ dbgfile.o \
dbgsyms.o \
error.o \
exports.o \
expr.o \
extsyms.o \
+ fileinfo.o \
fileio.o \
+ filepath.o \
+ fragment.o \
global.o \
library.o \
+ lineinfo.o \
main.o \
mapfile.o \
+ memarea.o \
o65.o \
objdata.o \
objfile.o \
scanner.o \
+ scopes.o \
segments.o \
- tgtcfg.o
+ span.o \
+ spool.o \
+ tgtcfg.o \
+ tpool.o
+
+# -----------------------------------------------------------------------------
+# List of all config includes
+
+INCS = apple2.inc \
+ apple2enh.inc \
+ atari.inc \
+ atmos.inc \
+ bbc.inc \
+ c128.inc \
+ c16.inc \
+ c64.inc \
+ cbm510.inc \
+ cbm610.inc \
+ geos-apple.inc \
+ geos-cbm.inc \
+ lunix.inc \
+ lynx.inc \
+ module.inc \
+ nes.inc \
+ none.inc \
+ pet.inc \
+ plus4.inc \
+ supervision.inc \
+ vic20.inc
LIBS = $(COMMON)/common.a
-EXECS = ld65
+# ------------------------------------------------------------------------------
+# Makefile targets
+# Main target - must be first
.PHONY: all
ifeq (.depend,$(wildcard .depend))
-all : $(EXECS)
+all: $(EXE)
include .depend
else
all: depend
@$(MAKE) -f make/gcc.mak all
endif
+$(EXE): $(INCS) $(OBJS) $(LIBS)
+ $(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
+ @if [ $(OS2_SHELL) ] ; then $(EBIND) $(EXE) ; fi
-
-ld65: $(OBJS) $(LIBS)
- $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS)
+inc: $(INCS)
clean:
- rm -f *~ core *.map
+ $(RM) *~ core.* *.map
zap: clean
- rm -f *.o $(EXECS) .depend
-
+ $(RM) *.o $(INCS) $(EXE) .depend
# ------------------------------------------------------------------------------
# Make the dependencies
.PHONY: depend dep
-depend dep: $(OBJS:.o=.c)
+depend dep: $(INCS) $(OBJS:.o=.c)
@echo "Creating dependency information"
- $(CC) -I$(COMMON) -MM $^ > .depend
+ $(CC) $(CFLAGS) -MM $(OBJS:.o=.c) > .depend
+
+# -----------------------------------------------------------------------------
+# Rules to make config includes
+
+apple2.inc: cfg/apple2.cfg
+ @$(CVT) $< $@ CfgApple2
+
+apple2enh.inc: cfg/apple2enh.cfg
+ @$(CVT) $< $@ CfgApple2Enh
+
+atari.inc: cfg/atari.cfg
+ @$(CVT) $< $@ CfgAtari
+
+atmos.inc: cfg/atmos.cfg
+ @$(CVT) $< $@ CfgAtmos
+
+bbc.inc: cfg/bbc.cfg
+ @$(CVT) $< $@ CfgBBC
+
+c16.inc: cfg/c16.cfg
+ @$(CVT) $< $@ CfgC16
+
+c64.inc: cfg/c64.cfg
+ @$(CVT) $< $@ CfgC64
+
+c128.inc: cfg/c128.cfg
+ @$(CVT) $< $@ CfgC128
+
+cbm510.inc: cfg/cbm510.cfg
+ @$(CVT) $< $@ CfgCBM510
+
+cbm610.inc: cfg/cbm610.cfg
+ @$(CVT) $< $@ CfgCBM610
+
+geos-apple.inc: cfg/geos-apple.cfg
+ @$(CVT) $< $@ CfgGeosApple
+
+geos-cbm.inc: cfg/geos-cbm.cfg
+ @$(CVT) $< $@ CfgGeosCBM
+
+lunix.inc: cfg/lunix.cfg
+ @$(CVT) $< $@ CfgLunix
+
+lynx.inc: cfg/lynx.cfg
+ @$(CVT) $< $@ CfgLynx
+
+module.inc: cfg/module.cfg
+ @$(CVT) $< $@ CfgModule
+
+nes.inc: cfg/nes.cfg
+ @$(CVT) $< $@ CfgNES
+
+none.inc: cfg/none.cfg
+ @$(CVT) $< $@ CfgNone
+
+pet.inc: cfg/pet.cfg
+ @$(CVT) $< $@ CfgPET
+
+plus4.inc: cfg/plus4.cfg
+ @$(CVT) $< $@ CfgPlus4
+
+supervision.inc: cfg/supervision.cfg
+ @$(CVT) $< $@ CfgSupervision
+
+vic20.inc: cfg/vic20.cfg
+ @$(CVT) $< $@ CfgVic20