X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libsrc%2FMakefile;h=dc944ee05b45ba9368d3289a70b38cb1c9f9cee5;hb=1365afa845117e44dec57e33b682abe59a3d3090;hp=214885b70d6f37144afbed84f8b3d905fec38597;hpb=db71d5e9e4207d1de79990ff92a474023525aeee;p=cc65 diff --git a/libsrc/Makefile b/libsrc/Makefile index 214885b70..dc944ee05 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -1,293 +1,291 @@ -# -# makefile for CC65 runtime library -# - -.SUFFIXES: .o .obj .s .c - -# Defines for executables. AR is used within this makefile, the others are -# passed to the submakes and contain paths relative to the subdirectories -# handled by the make subprocesses. -AR = ../src/ar65/ar65 -AS = ../../src/ca65/ca65 -CC = ../../src/cc65/cc65 -LD = ../../src/ld65/ld65 - -# List of all targets -ALLTARGETS = apple2 \ - apple2enh \ - atari \ - atmos \ - c16 \ - c128 \ - c64 \ - cbm510 \ - cbm610 \ - geos \ - lynx \ - nes \ - pet \ - plus4 \ - supervision \ - vic20 - -#----------------------------------------------------------------------------- - -.PHONY: all -all: - for tgt in $(ALLTARGETS); do \ - $(MAKE) clean "$$tgt"lib || exit 1; \ - done - -#----------------------------------------------------------------------------- -# Apple ][ - -apple2lib: - for i in apple2 common runtime conio dbg em joystick mouse serial tgi zlib; do \ - $(MAKE) SYS=apple2 -C $$i || exit 1; \ - $(AR) a apple2.lib $$i/*.o || exit 1; \ - done - cp apple2/apple2-auxmem.emd a2.auxmem.emd - cp apple2/apple2-stdjoy.joy a2.stdjoy.joy - cp apple2/apple2-stdmou.mou a2.stdmou.mou - cp apple2/apple2-ssc.ser a2.ssc.ser - cp apple2/apple2-280-192-8.tgi a2.hi.tgi - cp apple2/apple2-40-48-16.tgi a2.lo.tgi - if [ -d apple2/extra ]; then \ - for i in apple2/extra/*.o; do \ - cp $$i apple2-`basename $$i`; \ - done \ - fi \ - -#----------------------------------------------------------------------------- -# enhanced Apple //e - -apple2enhlib: - for i in apple2enh common runtime conio dbg em joystick mouse serial tgi zlib; do \ - $(MAKE) SYS=apple2enh -C $$i || exit 1; \ - $(AR) a apple2enh.lib $$i/*.o || exit 1; \ - done - cp apple2enh/apple2-auxmem.emd a2e.auxmem.emd - cp apple2enh/apple2-stdjoy.joy a2e.stdjoy.joy - cp apple2enh/apple2-stdmou.mou a2e.stdmou.mou - cp apple2enh/apple2-ssc.ser a2e.ssc.ser - cp apple2enh/apple2-280-192-8.tgi a2e.hi.tgi - cp apple2enh/apple2-40-48-16.tgi a2e.lo.tgi - if [ -d apple2enh/extra ]; then \ - for i in apple2enh/extra/*.o; do \ - cp $$i apple2enh-`basename $$i`; \ - done \ - fi \ - -#----------------------------------------------------------------------------- -# Atari - -atarilib: - for i in atari common runtime conio dbg em joystick tgi zlib; do \ - $(MAKE) SYS=atari -C $$i || exit 1; \ - $(AR) a atari.lib $$i/*.o || exit 1; \ - done - cp atari/atari-stdjoy.joy ataristd.joy - cp atari/atari-multijoy.joy atarimj8.joy - cp atari/atari-10.tgi atari10.tgi - cp atari/atari-10p2.tgi atr10p2.tgi - cp atari/atari-11.tgi atari11.tgi - cp atari/atari-14.tgi atari14.tgi - cp atari/atari-15.tgi atari15.tgi - cp atari/atari-15p2.tgi atr15p2.tgi - cp atari/atari-3.tgi atari3.tgi - cp atari/atari-4.tgi atari4.tgi - cp atari/atari-5.tgi atari5.tgi - cp atari/atari-6.tgi atari6.tgi - cp atari/atari-7.tgi atari7.tgi - cp atari/atari-8.tgi atari8.tgi - cp atari/atari-8p2.tgi atr8p2.tgi - cp atari/atari-9.tgi atari9.tgi - cp atari/atari-9p2.tgi atr9p2.tgi - - -#----------------------------------------------------------------------------- -# Oric Atmos - -atmoslib: - for i in atmos common conio runtime em joystick tgi zlib; do \ - $(MAKE) SYS=atmos -C $$i || exit 1; \ - $(AR) a atmos.lib $$i/*.o || exit 1; \ - done - cp atmos/*.joy . - cp atmos/*.tgi . - -#----------------------------------------------------------------------------- -# C16, C116 - -c16lib: - for i in c16 cbm common runtime conio dbg em joystick tgi zlib; do \ - $(MAKE) SYS=c16 -C $$i || exit 1; \ - $(AR) a c16.lib $$i/*.o || exit 1; \ - done - cp c16/*.joy . - cp c16/*.emd . - -#----------------------------------------------------------------------------- -# C64 - -c64lib: - for i in c64 cbm common runtime conio dbg em joystick mouse serial tgi zlib; do \ - $(MAKE) SYS=c64 -C $$i || exit 1; \ - $(AR) a c64.lib $$i/*.o || exit 1; \ - done - cp c64/*.emd . - cp c64/*.joy . - cp c64/c64-1351.mou . - cp c64/c64-joymouse.mou c64-joy.mou - cp c64/c64-potmouse.mou c64-pot.mou - cp c64/*.ser . - cp c64/c64-320-200-2.tgi c64-hi.tgi - -#----------------------------------------------------------------------------- -# C128 - -c128lib: - for i in c128 cbm common runtime conio dbg em joystick mouse serial tgi zlib; do \ - $(MAKE) SYS=c128 -C $$i || exit 1; \ - $(AR) a c128.lib $$i/*.o || exit 1; \ - done - cp c128/*.emd . - cp c128/*.joy . - cp c128/c128-1351.mou . - cp c128/c128-joymouse.mou c128-joy.mou - cp c128/c128-potmouse.mou c128-pot.mou - cp c128/*.ser . - cp c128/c128-640-200-2.tgi c128-vdc.tgi - cp c128/c128-640-480-2.tgi c128-vdc2.tgi - -#----------------------------------------------------------------------------- -# Commdore P500 / CBM 5x0 - -cbm510lib: - for i in cbm510 cbm common runtime conio dbg em joystick serial tgi zlib; do \ - $(MAKE) SYS=cbm510 -C $$i || exit 1; \ - $(AR) a cbm510.lib $$i/*.o || exit 1; \ - done - cp cbm510/*.emd . - cp cbm510/cbm510-stdjoy.joy cbm510-std.joy - cp cbm510/cbm510-stdser.ser cbm510-std.ser - -#----------------------------------------------------------------------------- -# PET-II series - -cbm610lib: - for i in cbm610 cbm common runtime conio dbg em joystick serial tgi zlib; do \ - $(MAKE) SYS=cbm610 -C $$i || exit 1; \ - $(AR) a cbm610.lib $$i/*.o || exit 1; \ - done - cp cbm610/*.emd . - cp cbm610/cbm610-stdser.ser cbm610-std.ser - -#----------------------------------------------------------------------------- -# GEOS on the C64/128 - -geoslib: - CC=../$(CC) \ - AS=../$(AS) \ - AR=../$(AR) \ - LD=../$(LD) \ - AFLAGS="-t geos -I../../../asminc" \ - CFLAGS="-Osir -g -T -t geos --forget-inc-paths -I. -I../../../include" \ - $(MAKE) -C geos || exit 1 - for i in em joystick tgi conio common runtime zlib; do \ - CC=$(CC) \ - AS=$(AS) \ - LD=$(LD) \ - AR=$(AR) \ - AFLAGS="-t geos -I../../asminc" \ - CFLAGS="-Osir -g -T -t geos --forget-inc-paths -I. -I../../include" \ - $(MAKE) SYS=geos -C $$i || exit 1; \ - for objfile in $$i/*.o; do \ - if [ -f geos/$$objfile ]; then \ - $(AR) a geos.lib geos/$$objfile || exit 1; \ - else \ - $(AR) a geos.lib $$objfile || exit 1; \ - fi; \ - done \ - done - cp geos/devel/*.emd . - cp geos/devel/*.joy . - cp geos/devel/geos-tgi.tgi geos-tgi.tgi - -#----------------------------------------------------------------------------- -# Lynx - -lynxlib: - for i in lynx common conio runtime em joystick serial tgi zlib; do \ - $(MAKE) SYS=lynx -C $$i || exit 1; \ - $(AR) a lynx.lib $$i/*.o || exit 1; \ - done - cp lynx/*.joy . - cp lynx/*.tgi . - cp lynx/*.ser . - -#----------------------------------------------------------------------------- -# NES - -neslib: - for i in nes common runtime conio em joystick tgi zlib; do \ - $(MAKE) SYS=nes -C $$i || exit 1; \ - $(AR) a nes.lib $$i/*.o || exit 1; \ - done - cp nes/*.joy . - -#----------------------------------------------------------------------------- -# CBM PET machines - -petlib: - for i in pet cbm common runtime conio dbg em joystick tgi zlib; do \ - $(MAKE) SYS=pet -C $$i || exit 1; \ - $(AR) a pet.lib $$i/*.o || exit 1; \ - done - cp pet/*.joy . - -#----------------------------------------------------------------------------- -# Commodore Plus/4 - -plus4lib: - for i in plus4 cbm common runtime conio dbg em joystick serial tgi zlib; do \ - $(MAKE) SYS=plus4 -C $$i || exit 1; \ - $(AR) a plus4.lib $$i/*.o || exit 1; \ - done - cp plus4/*.joy . - cp plus4/*.ser . - -#----------------------------------------------------------------------------- -# Supervision - -supervisionlib: - for i in supervision common runtime; do \ - $(MAKE) SYS=supervision -C $$i || exit 1; \ - $(AR) a supervision.lib $$i/*.o || exit 1; \ - done - -#----------------------------------------------------------------------------- -# Vic20 - -vic20lib: - for i in vic20 cbm common runtime conio dbg em joystick tgi zlib; do \ - $(MAKE) SYS=vic20 -C $$i || exit 1; \ - $(AR) a vic20.lib $$i/*.o || exit 1; \ - done - cp vic20/*.joy . - -#----------------------------------------------------------------------------- -# Dummy targets - -.PHONY: clean +ifneq ($(shell echo),) + CMD_EXE = 1 +endif + +CBMS = c128 \ + c16 \ + c64 \ + cbm510 \ + cbm610 \ + pet \ + plus4 \ + vic20 + +GEOS = geos-apple \ + geos-cbm + +TARGETS = apple2 \ + apple2enh \ + atari \ + atarixl \ + atari5200 \ + atmos \ + $(CBMS) \ + $(GEOS) \ + lynx \ + nes \ + pce \ + sim6502 \ + sim65c02 \ + supervision + +DRVTYPES = emd \ + joy \ + mou \ + ser \ + tgi + +OUTPUTDIRS := lib \ + $(DRVTYPES) \ + targetutil \ + asminc \ + cfg \ + include \ + $(subst ../,,$(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*))) + +.PHONY: all mostlyclean clean install zip lib $(TARGETS) + +.SUFFIXES: + +ifdef CMD_EXE + DIRLIST = $(strip $(foreach dir,$1,$(wildcard $(dir)))) + MKDIR = mkdir $(subst /,\,$1) + RMDIR = $(if $(DIRLIST),rmdir /s /q $(subst /,\,$(DIRLIST))) +else + MKDIR = mkdir -p $1 + RMDIR = $(RM) -r $1 +endif + +# 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 + +datadir = $(prefix)/share/cc65 + +all lib: $(TARGETS) + +mostlyclean: + $(call RMDIR,../libwrk) + clean: - @for i in cbm common conio dbg em joystick mouse runtime serial tgi zlib $(ALLTARGETS); do\ - $(MAKE) -C $$i clean; \ - done - -.PHONY: zap -zap: clean - @for i in cbm common conio dbg em joystick mouse runtime tgi zlib $(ALLTARGETS); do\ - $(MAKE) -C $$i zap; \ - done - @$(RM) *.o *.emd *.joy *.lib *.tgi *.ser *.mou + $(call RMDIR,../libwrk ../lib ../targetutil $(addprefix ../,$(DRVTYPES))) + +ifdef CMD_EXE + +install: + +else # CMD_EXE + +INSTALL = install + +define INSTALL_recipe + +$(if $(prefix),,$(error variable `prefix' must be set)) +$(INSTALL) -d $(DESTDIR)$(datadir)/$(dir) +$(INSTALL) -m644 ../$(dir)/*.* $(DESTDIR)$(datadir)/$(dir) + +endef # INSTALL_recipe + +install: + $(foreach dir,$(OUTPUTDIRS),$(INSTALL_recipe)) + +endif # CMD_EXE + +define ZIP_recipe + +@cd .. && zip cc65 $(dir)/*.* + +endef # ZIP_recipe + +zip: + $(foreach dir,$(OUTPUTDIRS),$(ZIP_recipe)) + +$(TARGETS): + @$(MAKE) --no-print-directory $@ + +else # TARGET + +CA65FLAGS = +CC65FLAGS = -Or -W error + +EXTZP = cbm510 \ + cbm610 \ + lynx + +MKINC = $(GEOS) \ + atari \ + atarixl \ + nes + +TARGETUTIL = apple2 \ + apple2enh \ + atari \ + geos-apple + +GEOSDIRS = common \ + conio \ + disk \ + dlgbox \ + file \ + graph \ + memory \ + menuicon \ + mousesprite \ + process \ + runtime \ + system + +ifeq ($(TARGET),apple2enh) + SRCDIR = apple2 + OBJPFX = a2 + DRVPFX = a2e +else ifeq ($(TARGET),atarixl) + SRCDIR = atari + OBJPFX = atr + DRVPFX = atrx +else ifeq ($(TARGET),sim65c02) + SRCDIR = sim6502 +else + SRCDIR = $(TARGET) +endif + +SRCDIRS = $(SRCDIR) + +ifeq ($(TARGET),$(filter $(TARGET),$(CBMS))) + SRCDIRS += cbm +endif + +ifeq ($(TARGET),$(filter $(TARGET),$(GEOS))) + SRCDIRS += $(addprefix $(TARGET)/, $(GEOSDIRS)) + SRCDIRS += $(addprefix geos-common/,$(GEOSDIRS)) +endif + +SRCDIRS += common \ + conio \ + dbg \ + em \ + joystick \ + mouse \ + runtime \ + serial \ + tgi \ + zlib + +vpath %.s $(SRCDIRS) +vpath %.c $(SRCDIRS) + +OBJS := $(patsubst %.s,%.o,$(foreach dir,$(SRCDIRS),$(wildcard $(dir)/*.s))) +OBJS += $(patsubst %.c,%.o,$(foreach dir,$(SRCDIRS),$(wildcard $(dir)/*.c))) + +OBJS := $(addprefix ../libwrk/$(TARGET)/,$(sort $(notdir $(OBJS)))) + +DEPS = $(OBJS:.o=.d) + +EXTRA_SRCPAT = $(SRCDIR)/extra/%.s +EXTRA_OBJPAT = ../lib/$(TARGET)-%.o +EXTRA_OBJS := $(patsubst $(EXTRA_SRCPAT),$(EXTRA_OBJPAT),$(wildcard $(SRCDIR)/extra/*.s)) + +ZPOBJ = ../libwrk/$(TARGET)/zeropage.o +ifeq ($(TARGET),$(filter $(TARGET),$(EXTZP))) + ZPOBJ += ../libwrk/$(TARGET)/extzp.o +endif + +ifeq ($(TARGET),$(filter $(TARGET),$(MKINC))) + include $(SRCDIR)/Makefile.inc +endif + +ifeq ($(TARGET),$(filter $(TARGET),$(TARGETUTIL))) + include $(SRCDIR)/targetutil/Makefile.inc +endif + +define DRVTYPE_template + +$1_SRCDIR = $$(SRCDIR)/$1 +$1_STCDIR = ../libwrk/$$(TARGET) +$1_DYNDIR = ../libwrk/$$(TARGET)/$1 +$1_DRVDIR = ../$1 + +$1_SRCPAT = $$($1_SRCDIR)/$$(OBJPFX)%.s +$1_STCPAT = $$($1_STCDIR)/$$(OBJPFX)%-$1.o +$1_DYNPAT = $$($1_DYNDIR)/$$(OBJPFX)%.o +$1_DRVPAT = $$($1_DRVDIR)/$$(DRVPFX)%.$1 + +$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)) + +$$($1_STCPAT): $$($1_SRCPAT) + @echo $$(TARGET) - $$< - static + @$$(CA65) -t $$(TARGET) -D DYN_DRV=0 $$(CA65FLAGS) --create-dep $$(@:.o=.d) -o $$@ $$< + +OBJS += $$($1_STCS) +DEPS += $$($1_STCS:.o=.d) + +$$($1_DYNS): | $$($1_DYNDIR) + +$$($1_DRVPAT): $$($1_DYNPAT) $$(ZPOBJ) | $$($1_DRVDIR) + @echo $$(TARGET) - $$(