# 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 -W -I$(COMMON) $(CDEFS)
-CC=gcc
-EBIND=emxbind
-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
# -----------------------------------------------------------------------------
# List of all object files
-OBJS = bin.o \
+OBJS = asserts.o \
+ bin.o \
binfmt.o \
+ cfgexpr.o \
condes.o \
config.o \
- dbginfo.o \
+ dbgfile.o \
dbgsyms.o \
error.o \
exports.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 \
+ atmos.inc \
bbc.inc \
- c64.inc \
c128.inc \
+ c16.inc \
+ c64.inc \
cbm510.inc \
cbm610.inc \
- geos.inc \
+ geos-apple.inc \
+ geos-cbm.inc \
lunix.inc \
- module.inc \
+ lynx.inc \
+ module.inc \
+ nes.inc \
none.inc \
pet.inc \
- plus4.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
-
-
-ld65: $(INCS) $(OBJS) $(LIBS)
- $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS)
- @if [ $(OS2_SHELL) ] ; then $(EBIND) $@ ; fi
+$(EXE): $(INCS) $(OBJS) $(LIBS)
+ $(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
+ @if [ $(OS2_SHELL) ] ; then $(EBIND) $(EXE) ; fi
inc: $(INCS)
clean:
- rm -f *~ core *.map
-
-zap: clean
- rm -f *.o $(INCS) $(EXECS) .depend
+ $(RM) *~ core.* *.map
+zap: clean
+ $(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 -MG $^ > .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
bbc.inc: cfg/bbc.cfg
@$(CVT) $< $@ CfgBBC
+c16.inc: cfg/c16.cfg
+ @$(CVT) $< $@ CfgC16
+
c64.inc: cfg/c64.cfg
@$(CVT) $< $@ CfgC64
cbm610.inc: cfg/cbm610.cfg
@$(CVT) $< $@ CfgCBM610
-geos.inc: cfg/geos.cfg
- @$(CVT) $< $@ CfgGeos
+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
plus4.inc: cfg/plus4.cfg
@$(CVT) $< $@ CfgPlus4
+supervision.inc: cfg/supervision.cfg
+ @$(CVT) $< $@ CfgSupervision
+
+vic20.inc: cfg/vic20.cfg
+ @$(CVT) $< $@ CfgVic20
+