2016-05-16 17:49:43 +00:00
|
|
|
|
2014-03-06 21:32:24 +00:00
|
|
|
ifneq ($(shell echo),)
|
|
|
|
CMD_EXE = 1
|
|
|
|
endif
|
|
|
|
|
2013-05-04 20:15:30 +00:00
|
|
|
CBMS = c128 \
|
|
|
|
c16 \
|
|
|
|
c64 \
|
|
|
|
cbm510 \
|
|
|
|
cbm610 \
|
|
|
|
pet \
|
|
|
|
plus4 \
|
|
|
|
vic20
|
|
|
|
|
|
|
|
GEOS = geos-apple \
|
|
|
|
geos-cbm
|
|
|
|
|
2013-12-05 20:45:20 +00:00
|
|
|
TARGETS = apple2 \
|
|
|
|
apple2enh \
|
|
|
|
atari \
|
|
|
|
atarixl \
|
2014-05-30 11:39:09 +00:00
|
|
|
atari5200 \
|
2013-12-05 20:45:20 +00:00
|
|
|
atmos \
|
|
|
|
$(CBMS) \
|
|
|
|
$(GEOS) \
|
2015-11-14 12:15:29 +00:00
|
|
|
gamate \
|
2013-12-05 20:45:20 +00:00
|
|
|
lynx \
|
|
|
|
nes \
|
2015-02-03 21:42:35 +00:00
|
|
|
osic1p \
|
2014-11-29 14:35:20 +00:00
|
|
|
pce \
|
2013-12-05 20:45:20 +00:00
|
|
|
sim6502 \
|
|
|
|
sim65c02 \
|
2013-05-04 20:15:30 +00:00
|
|
|
supervision
|
|
|
|
|
|
|
|
DRVTYPES = emd \
|
|
|
|
joy \
|
|
|
|
mou \
|
|
|
|
ser \
|
|
|
|
tgi
|
|
|
|
|
2016-05-13 12:28:58 +00:00
|
|
|
OUTPUTDIRS := lib \
|
|
|
|
asminc \
|
|
|
|
cfg \
|
|
|
|
include \
|
2016-05-16 20:14:05 +00:00
|
|
|
$(subst ../,,$(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*)))\
|
|
|
|
$(subst ../,,$(wildcard ../target/*/drv/*))\
|
|
|
|
$(subst ../,,$(wildcard ../target/*/util))\
|
2013-05-04 20:15:30 +00:00
|
|
|
|
2014-03-08 23:19:57 +00:00
|
|
|
.PHONY: all mostlyclean clean install zip lib $(TARGETS)
|
2013-05-04 20:15:30 +00:00
|
|
|
|
2014-03-06 22:42:44 +00:00
|
|
|
.SUFFIXES:
|
2013-05-05 20:33:25 +00:00
|
|
|
|
2014-03-06 21:32:24 +00:00
|
|
|
ifdef CMD_EXE
|
|
|
|
DIRLIST = $(strip $(foreach dir,$1,$(wildcard $(dir))))
|
2013-05-05 20:33:25 +00:00
|
|
|
MKDIR = mkdir $(subst /,\,$1)
|
|
|
|
RMDIR = $(if $(DIRLIST),rmdir /s /q $(subst /,\,$(DIRLIST)))
|
2014-03-06 21:32:24 +00:00
|
|
|
else
|
|
|
|
MKDIR = mkdir -p $1
|
|
|
|
RMDIR = $(RM) -r $1
|
2013-05-05 20:33:25 +00:00
|
|
|
endif
|
|
|
|
|
2013-05-04 20:15:30 +00:00
|
|
|
# Every target requires its individual vpath setting but the vpath directive
|
|
|
|
# acts globally. Therefore each target is built in a separate make instance.
|
|
|
|
|
|
|
|
ifeq ($(words $(MAKECMDGOALS)),1)
|
|
|
|
ifeq ($(MAKECMDGOALS),$(filter $(MAKECMDGOALS),$(TARGETS)))
|
|
|
|
TARGET = $(MAKECMDGOALS)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef TARGET
|
|
|
|
|
2014-01-29 20:42:26 +00:00
|
|
|
datadir = $(prefix)/share/cc65
|
|
|
|
|
2013-05-07 15:49:35 +00:00
|
|
|
all lib: $(TARGETS)
|
2013-05-04 20:15:30 +00:00
|
|
|
|
|
|
|
mostlyclean:
|
2014-03-05 22:24:35 +00:00
|
|
|
$(call RMDIR,../libwrk)
|
2013-05-04 20:15:30 +00:00
|
|
|
|
2013-05-05 20:33:25 +00:00
|
|
|
clean:
|
2016-05-29 14:19:03 +00:00
|
|
|
$(call RMDIR,../libwrk ../lib ../target)
|
2013-05-04 20:15:30 +00:00
|
|
|
|
2014-03-06 21:32:24 +00:00
|
|
|
ifdef CMD_EXE
|
2013-05-04 20:15:30 +00:00
|
|
|
|
2014-01-29 20:42:26 +00:00
|
|
|
install:
|
|
|
|
|
2014-03-06 21:32:24 +00:00
|
|
|
else # CMD_EXE
|
|
|
|
|
|
|
|
INSTALL = install
|
2014-01-29 20:42:26 +00:00
|
|
|
|
|
|
|
define INSTALL_recipe
|
|
|
|
|
|
|
|
$(if $(prefix),,$(error variable `prefix' must be set))
|
2014-03-08 23:19:57 +00:00
|
|
|
$(INSTALL) -d $(DESTDIR)$(datadir)/$(dir)
|
2016-05-16 20:14:05 +00:00
|
|
|
$(INSTALL) -m0644 ../$(dir)/*.* $(DESTDIR)$(datadir)/$(dir)
|
2014-01-29 20:42:26 +00:00
|
|
|
|
2014-03-06 21:32:24 +00:00
|
|
|
endef # INSTALL_recipe
|
|
|
|
|
|
|
|
install:
|
2014-03-08 23:19:57 +00:00
|
|
|
$(foreach dir,$(OUTPUTDIRS),$(INSTALL_recipe))
|
2014-01-29 20:42:26 +00:00
|
|
|
|
2014-03-06 21:32:24 +00:00
|
|
|
endif # CMD_EXE
|
2014-01-29 20:42:26 +00:00
|
|
|
|
2014-03-08 23:19:57 +00:00
|
|
|
define ZIP_recipe
|
|
|
|
|
2014-03-09 00:20:39 +00:00
|
|
|
@cd .. && zip cc65 $(dir)/*.*
|
2014-03-08 23:19:57 +00:00
|
|
|
|
|
|
|
endef # ZIP_recipe
|
|
|
|
|
|
|
|
zip:
|
|
|
|
$(foreach dir,$(OUTPUTDIRS),$(ZIP_recipe))
|
|
|
|
|
2014-03-06 21:32:24 +00:00
|
|
|
$(TARGETS):
|
|
|
|
@$(MAKE) --no-print-directory $@
|
2014-01-29 20:42:26 +00:00
|
|
|
|
2013-05-04 20:15:30 +00:00
|
|
|
else # TARGET
|
|
|
|
|
2013-06-04 21:39:00 +00:00
|
|
|
CA65FLAGS =
|
2014-03-03 20:08:35 +00:00
|
|
|
CC65FLAGS = -Or -W error
|
2013-05-04 20:15:30 +00:00
|
|
|
|
|
|
|
EXTZP = cbm510 \
|
|
|
|
cbm610 \
|
|
|
|
lynx
|
|
|
|
|
|
|
|
MKINC = $(GEOS) \
|
|
|
|
atari \
|
2014-03-04 20:45:55 +00:00
|
|
|
atarixl \
|
2013-05-04 20:15:30 +00:00
|
|
|
nes
|
|
|
|
|
2014-03-04 20:45:55 +00:00
|
|
|
TARGETUTIL = apple2 \
|
|
|
|
apple2enh \
|
|
|
|
atari \
|
2013-05-08 23:12:26 +00:00
|
|
|
geos-apple
|
|
|
|
|
2013-05-04 20:15:30 +00:00
|
|
|
GEOSDIRS = common \
|
|
|
|
conio \
|
|
|
|
disk \
|
|
|
|
dlgbox \
|
|
|
|
file \
|
|
|
|
graph \
|
|
|
|
memory \
|
|
|
|
menuicon \
|
|
|
|
mousesprite \
|
|
|
|
process \
|
|
|
|
runtime \
|
|
|
|
system
|
|
|
|
|
|
|
|
ifeq ($(TARGET),apple2enh)
|
2013-05-28 19:56:37 +00:00
|
|
|
SRCDIR = apple2
|
2013-05-04 20:15:30 +00:00
|
|
|
OBJPFX = a2
|
|
|
|
DRVPFX = a2e
|
2013-05-28 19:56:37 +00:00
|
|
|
else ifeq ($(TARGET),atarixl)
|
|
|
|
SRCDIR = atari
|
|
|
|
OBJPFX = atr
|
|
|
|
DRVPFX = atrx
|
2013-05-20 18:35:42 +00:00
|
|
|
else ifeq ($(TARGET),sim65c02)
|
|
|
|
SRCDIR = sim6502
|
2013-05-04 20:15:30 +00:00
|
|
|
else
|
2013-05-08 23:12:26 +00:00
|
|
|
SRCDIR = $(TARGET)
|
2013-05-04 20:15:30 +00:00
|
|
|
endif
|
|
|
|
|
2013-05-08 23:12:26 +00:00
|
|
|
SRCDIRS = $(SRCDIR)
|
|
|
|
|
2013-05-04 20:15:30 +00:00
|
|
|
ifeq ($(TARGET),$(filter $(TARGET),$(CBMS)))
|
2013-05-08 23:12:26 +00:00
|
|
|
SRCDIRS += cbm
|
2013-05-04 20:15:30 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(TARGET),$(filter $(TARGET),$(GEOS)))
|
2013-05-08 23:12:26 +00:00
|
|
|
SRCDIRS += $(addprefix $(TARGET)/, $(GEOSDIRS))
|
|
|
|
SRCDIRS += $(addprefix geos-common/,$(GEOSDIRS))
|
2013-05-04 20:15:30 +00:00
|
|
|
endif
|
|
|
|
|
2013-05-08 23:12:26 +00:00
|
|
|
SRCDIRS += common \
|
|
|
|
conio \
|
|
|
|
dbg \
|
|
|
|
em \
|
|
|
|
joystick \
|
|
|
|
mouse \
|
|
|
|
runtime \
|
|
|
|
serial \
|
|
|
|
tgi \
|
|
|
|
zlib
|
2013-05-04 20:15:30 +00:00
|
|
|
|
2013-05-08 23:12:26 +00:00
|
|
|
vpath %.s $(SRCDIRS)
|
|
|
|
vpath %.c $(SRCDIRS)
|
2013-05-04 20:15:30 +00:00
|
|
|
|
2013-05-08 23:12:26 +00:00
|
|
|
OBJS := $(patsubst %.s,%.o,$(foreach dir,$(SRCDIRS),$(wildcard $(dir)/*.s)))
|
|
|
|
OBJS += $(patsubst %.c,%.o,$(foreach dir,$(SRCDIRS),$(wildcard $(dir)/*.c)))
|
2013-05-04 20:15:30 +00:00
|
|
|
|
2014-03-05 22:24:35 +00:00
|
|
|
OBJS := $(addprefix ../libwrk/$(TARGET)/,$(sort $(notdir $(OBJS))))
|
2013-05-04 20:15:30 +00:00
|
|
|
|
|
|
|
DEPS = $(OBJS:.o=.d)
|
|
|
|
|
2013-05-08 23:12:26 +00:00
|
|
|
EXTRA_SRCPAT = $(SRCDIR)/extra/%.s
|
2013-05-08 21:27:58 +00:00
|
|
|
EXTRA_OBJPAT = ../lib/$(TARGET)-%.o
|
2013-05-08 23:12:26 +00:00
|
|
|
EXTRA_OBJS := $(patsubst $(EXTRA_SRCPAT),$(EXTRA_OBJPAT),$(wildcard $(SRCDIR)/extra/*.s))
|
2013-05-08 21:27:58 +00:00
|
|
|
|
2014-03-05 22:24:35 +00:00
|
|
|
ZPOBJ = ../libwrk/$(TARGET)/zeropage.o
|
2013-05-04 20:15:30 +00:00
|
|
|
ifeq ($(TARGET),$(filter $(TARGET),$(EXTZP)))
|
2014-03-05 22:24:35 +00:00
|
|
|
ZPOBJ += ../libwrk/$(TARGET)/extzp.o
|
2013-05-04 20:15:30 +00:00
|
|
|
endif
|
|
|
|
|
2014-03-04 20:45:55 +00:00
|
|
|
ifeq ($(TARGET),$(filter $(TARGET),$(MKINC)))
|
2013-05-08 23:12:26 +00:00
|
|
|
include $(SRCDIR)/Makefile.inc
|
|
|
|
endif
|
|
|
|
|
2014-03-04 20:45:55 +00:00
|
|
|
ifeq ($(TARGET),$(filter $(TARGET),$(TARGETUTIL)))
|
2013-05-08 23:12:26 +00:00
|
|
|
include $(SRCDIR)/targetutil/Makefile.inc
|
2013-05-04 20:15:30 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
define DRVTYPE_template
|
|
|
|
|
2013-05-08 23:12:26 +00:00
|
|
|
$1_SRCDIR = $$(SRCDIR)/$1
|
2014-06-04 21:50:18 +00:00
|
|
|
$1_STCDIR = ../libwrk/$$(TARGET)
|
|
|
|
$1_DYNDIR = ../libwrk/$$(TARGET)/$1
|
2016-05-16 17:49:43 +00:00
|
|
|
$1_DRVDIR = ../target/$$(TARGET)/drv/$1
|
2013-05-04 20:15:30 +00:00
|
|
|
|
2014-06-04 21:50:18 +00:00
|
|
|
$1_SRCPAT = $$($1_SRCDIR)/$$(OBJPFX)%.s
|
|
|
|
$1_STCPAT = $$($1_STCDIR)/$$(OBJPFX)%-$1.o
|
|
|
|
$1_DYNPAT = $$($1_DYNDIR)/$$(OBJPFX)%.o
|
2013-05-04 20:15:30 +00:00
|
|
|
$1_DRVPAT = $$($1_DRVDIR)/$$(DRVPFX)%.$1
|
|
|
|
|
2014-06-04 21:50:18 +00:00
|
|
|
$1_SRCS := $$(wildcard $$($1_SRCDIR)/*.s)
|
|
|
|
$1_STCS = $$(patsubst $$($1_SRCPAT),$$($1_STCPAT),$$($1_SRCS))
|
|
|
|
$1_DYNS = $$(patsubst $$($1_SRCPAT),$$($1_DYNPAT),$$($1_SRCS))
|
|
|
|
$1_DRVS = $$(patsubst $$($1_DYNPAT),$$($1_DRVPAT),$$($1_DYNS))
|
2013-05-04 20:15:30 +00:00
|
|
|
|
2014-06-04 21:50:18 +00:00
|
|
|
$$($1_STCPAT): $$($1_SRCPAT)
|
|
|
|
@echo $$(TARGET) - $$< - static
|
|
|
|
@$$(CA65) -t $$(TARGET) -D DYN_DRV=0 $$(CA65FLAGS) --create-dep $$(@:.o=.d) -o $$@ $$<
|
2013-05-04 20:15:30 +00:00
|
|
|
|
2014-06-04 21:50:18 +00:00
|
|
|
OBJS += $$($1_STCS)
|
|
|
|
DEPS += $$($1_STCS:.o=.d)
|
2013-05-04 20:15:30 +00:00
|
|
|
|
2014-06-04 21:50:18 +00:00
|
|
|
$$($1_DYNS): | $$($1_DYNDIR)
|
2013-05-04 20:15:30 +00:00
|
|
|
|
2014-06-04 21:50:18 +00:00
|
|
|
$$($1_DRVPAT): $$($1_DYNPAT) $$(ZPOBJ) | $$($1_DRVDIR)
|
2013-11-25 00:12:27 +00:00
|
|
|
@echo $$(TARGET) - $$(<F)
|
2013-06-04 21:39:00 +00:00
|
|
|
@$$(LD65) -o $$@ -t module $$^
|
2013-05-04 20:15:30 +00:00
|
|
|
|
2014-06-04 21:50:18 +00:00
|
|
|
$$($1_DYNDIR) $$($1_DRVDIR):
|
2013-05-05 20:33:25 +00:00
|
|
|
@$$(call MKDIR,$$@)
|
2013-05-04 20:15:30 +00:00
|
|
|
|
|
|
|
$(TARGET): $$($1_DRVS)
|
|
|
|
|
2014-06-04 21:50:18 +00:00
|
|
|
DEPS += $$($1_DYNS:.o=.d)
|
2013-05-04 20:15:30 +00:00
|
|
|
|
2014-03-06 21:32:24 +00:00
|
|
|
endef # DRVTYPE_template
|
2013-05-04 20:15:30 +00:00
|
|
|
|
|
|
|
$(foreach drvtype,$(DRVTYPES),$(eval $(call DRVTYPE_template,$(drvtype))))
|
|
|
|
|
2013-06-04 21:39:00 +00:00
|
|
|
AR65 := $(if $(wildcard ../bin/ar65*),../bin/ar65,ar65)
|
|
|
|
CA65 := $(if $(wildcard ../bin/ca65*),../bin/ca65,ca65)
|
|
|
|
CC65 := $(if $(wildcard ../bin/cc65*),../bin/cc65,cc65)
|
|
|
|
LD65 := $(if $(wildcard ../bin/ld65*),../bin/ld65,ld65)
|
2013-05-04 20:15:30 +00:00
|
|
|
|
2013-05-31 19:30:14 +00:00
|
|
|
export CC65_HOME := $(abspath ..)
|
|
|
|
|
2013-05-08 23:12:26 +00:00
|
|
|
define ASSEMBLE_recipe
|
|
|
|
|
2014-03-16 20:31:00 +00:00
|
|
|
$(if $(QUIET),,@echo $(TARGET) - $<)
|
2013-06-04 21:39:00 +00:00
|
|
|
@$(CA65) -t $(TARGET) $(CA65FLAGS) --create-dep $(@:.o=.d) -o $@ $<
|
2013-05-08 23:12:26 +00:00
|
|
|
|
2014-03-06 21:32:24 +00:00
|
|
|
endef # ASSEMBLE_recipe
|
2013-05-08 23:12:26 +00:00
|
|
|
|
|
|
|
define COMPILE_recipe
|
|
|
|
|
2014-03-16 20:31:00 +00:00
|
|
|
$(if $(QUIET),,@echo $(TARGET) - $<)
|
2013-06-04 21:39:00 +00:00
|
|
|
@$(CC65) -t $(TARGET) $(CC65FLAGS) --create-dep $(@:.o=.d) --dep-target $@ -o $(@:.o=.s) $<
|
|
|
|
@$(CA65) -t $(TARGET) -o $@ $(@:.o=.s)
|
2013-05-08 23:12:26 +00:00
|
|
|
|
2014-03-06 21:32:24 +00:00
|
|
|
endef # COMPILE_recipe
|
2013-05-08 23:12:26 +00:00
|
|
|
|
2014-03-05 22:24:35 +00:00
|
|
|
../libwrk/$(TARGET)/%.o: %.s | ../libwrk/$(TARGET)
|
2013-05-08 23:12:26 +00:00
|
|
|
$(ASSEMBLE_recipe)
|
2013-05-04 20:15:30 +00:00
|
|
|
|
2014-03-05 22:24:35 +00:00
|
|
|
../libwrk/$(TARGET)/%.o: %.c | ../libwrk/$(TARGET)
|
2013-05-08 23:12:26 +00:00
|
|
|
$(COMPILE_recipe)
|
2013-05-04 20:15:30 +00:00
|
|
|
|
2013-05-08 21:27:58 +00:00
|
|
|
$(EXTRA_OBJPAT): $(EXTRA_SRCPAT) | ../lib
|
2013-11-25 00:12:27 +00:00
|
|
|
@echo $(TARGET) - $(<F)
|
2013-06-04 21:39:00 +00:00
|
|
|
@$(CA65) -t $(TARGET) $(CA65FLAGS) -o $@ $<
|
2013-05-08 21:27:58 +00:00
|
|
|
|
2013-05-04 20:15:30 +00:00
|
|
|
../lib/$(TARGET).lib: $(OBJS) | ../lib
|
2013-06-04 21:39:00 +00:00
|
|
|
$(AR65) a $@ $?
|
2013-05-04 20:15:30 +00:00
|
|
|
|
2016-05-16 17:49:43 +00:00
|
|
|
../libwrk/$(TARGET) ../lib ../target/$(TARGET)/util:
|
2013-05-05 20:33:25 +00:00
|
|
|
@$(call MKDIR,$@)
|
2013-05-04 20:15:30 +00:00
|
|
|
|
2013-05-08 21:27:58 +00:00
|
|
|
$(TARGET): $(EXTRA_OBJS) ../lib/$(TARGET).lib
|
2013-05-04 20:15:30 +00:00
|
|
|
|
|
|
|
-include $(DEPS)
|
|
|
|
|
|
|
|
endif # TARGET
|