diff --git a/.gitignore b/.gitignore index 196cdc3d7..dac38c48b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,9 @@ /bin/ -/emd/ /html/ /info/ -/joy/ /lib/ /libwrk/ -/mou/ -/ser/ -/targetutil/ +/target/ /testwrk/ -/tgi/ /wrk/ +cc65.zip diff --git a/Makefile b/Makefile index e0530e9f0..a10df8db0 100644 --- a/Makefile +++ b/Makefile @@ -3,21 +3,22 @@ .SUFFIXES: all mostlyclean clean install zip: - @$(MAKE) -C src --no-print-directory $@ - @$(MAKE) -C libsrc --no-print-directory $@ - @$(MAKE) -C doc --no-print-directory $@ + @$(MAKE) -C src --no-print-directory $@ + @$(MAKE) -C libsrc --no-print-directory $@ + @$(MAKE) -C doc --no-print-directory $@ + @$(MAKE) -C samples --no-print-directory $@ avail unavail bin: - @$(MAKE) -C src --no-print-directory $@ + @$(MAKE) -C src --no-print-directory $@ lib: - @$(MAKE) -C libsrc --no-print-directory $@ + @$(MAKE) -C libsrc --no-print-directory $@ doc: - @$(MAKE) -C doc --no-print-directory $@ + @$(MAKE) -C doc --no-print-directory $@ %65: - @$(MAKE) -C src --no-print-directory $@ + @$(MAKE) -C src --no-print-directory $@ %: - @$(MAKE) -C libsrc --no-print-directory $@ + @$(MAKE) -C libsrc --no-print-directory $@ diff --git a/doc/Makefile b/doc/Makefile index 967443ef0..862164e1b 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -33,15 +33,17 @@ install: $(if $(prefix),,$(error variable `prefix' must be set)) ifeq ($(wildcard ../html),../html) $(INSTALL) -d $(DESTDIR)$(htmldir) - $(INSTALL) -m644 ../html/*.* $(DESTDIR)$(htmldir) + $(INSTALL) -m0644 ../html/*.* $(DESTDIR)$(htmldir) endif ifeq ($(wildcard ../info),../info) $(INSTALL) -d $(DESTDIR)$(infodir) - $(INSTALL) -m644 ../info/*.* $(DESTDIR)$(infodir) + $(INSTALL) -m0644 ../info/*.* $(DESTDIR)$(infodir) endif zip: +ifneq "$(wildcard ../html)" "" @cd .. && zip cc65 html/*.* +endif doc: html info diff --git a/doc/apple2.sgml b/doc/apple2.sgml index b576ae6c1..00cd565b4 100644 --- a/doc/apple2.sgml +++ b/doc/apple2.sgml @@ -241,7 +241,7 @@ The easiest (and for really large programs in fact the only) way to have a cc65 program use the memory from $800 to $2000 is to link it as binary (as opposed to system) program using the default linker configuration with with diff --git a/doc/atari.sgml b/doc/atari.sgml index f911d568e..e65a7869e 100644 --- a/doc/atari.sgml +++ b/doc/atari.sgml @@ -229,8 +229,8 @@ for C and assembly language programs. The size of a cassette boot file is restricted to 32K. Larger programs would need to be split in more parts and the parts to be loaded manually. -To write the generated file to a cassette, a utility to run -on an Atari is provided in the diff --git a/libsrc/Makefile b/libsrc/Makefile index a4101aecd..99f120f3a 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -1,3 +1,4 @@ + ifneq ($(shell echo),) CMD_EXE = 1 endif @@ -37,13 +38,13 @@ DRVTYPES = emd \ ser \ tgi -OUTPUTDIRS := lib \ - $(DRVTYPES) \ - targetutil \ - asminc \ - cfg \ - include \ - $(subst ../,,$(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*))) +OUTPUTDIRS := lib \ + asminc \ + cfg \ + include \ + $(subst ../,,$(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*)))\ + $(subst ../,,$(wildcard ../target/*/drv/*))\ + $(subst ../,,$(wildcard ../target/*/util))\ .PHONY: all mostlyclean clean install zip lib $(TARGETS) @@ -77,7 +78,7 @@ mostlyclean: $(call RMDIR,../libwrk) clean: - $(call RMDIR,../libwrk ../lib ../targetutil $(addprefix ../,$(DRVTYPES))) + $(call RMDIR,../libwrk ../lib ../target) ifdef CMD_EXE @@ -91,7 +92,7 @@ define INSTALL_recipe $(if $(prefix),,$(error variable `prefix' must be set)) $(INSTALL) -d $(DESTDIR)$(datadir)/$(dir) -$(INSTALL) -m644 ../$(dir)/*.* $(DESTDIR)$(datadir)/$(dir) +$(INSTALL) -m0644 ../$(dir)/*.* $(DESTDIR)$(datadir)/$(dir) endef # INSTALL_recipe @@ -212,7 +213,7 @@ define DRVTYPE_template $1_SRCDIR = $$(SRCDIR)/$1 $1_STCDIR = ../libwrk/$$(TARGET) $1_DYNDIR = ../libwrk/$$(TARGET)/$1 -$1_DRVDIR = ../$1 +$1_DRVDIR = ../target/$$(TARGET)/drv/$1 $1_SRCPAT = $$($1_SRCDIR)/$$(OBJPFX)%.s $1_STCPAT = $$($1_STCDIR)/$$(OBJPFX)%-$1.o @@ -283,7 +284,7 @@ $(EXTRA_OBJPAT): $(EXTRA_SRCPAT) | ../lib ../lib/$(TARGET).lib: $(OBJS) | ../lib $(AR65) a $@ $? -../libwrk/$(TARGET) ../lib ../targetutil: +../libwrk/$(TARGET) ../lib ../target/$(TARGET)/util: @$(call MKDIR,$@) $(TARGET): $(EXTRA_OBJS) ../lib/$(TARGET).lib diff --git a/libsrc/apple2/targetutil/Makefile.inc b/libsrc/apple2/targetutil/Makefile.inc index 105a5324f..d9d727b0a 100644 --- a/libsrc/apple2/targetutil/Makefile.inc +++ b/libsrc/apple2/targetutil/Makefile.inc @@ -3,7 +3,7 @@ DEPS += ../libwrk/$(TARGET)/loader.d ../libwrk/$(TARGET)/loader.o: $(SRCDIR)/targetutil/loader.s | ../libwrk/$(TARGET) $(ASSEMBLE_recipe) -../targetutil/loader.system: ../libwrk/$(TARGET)/loader.o $(SRCDIR)/targetutil/loader.cfg | ../targetutil +../target/$(TARGET)/util/loader.system: ../libwrk/$(TARGET)/loader.o $(SRCDIR)/targetutil/loader.cfg | ../target/$(TARGET)/util $(LD65) -o $@ -C $(filter %.cfg,$^) $(filter-out %.cfg,$^) -$(TARGET): ../targetutil/loader.system +$(TARGET): ../target/$(TARGET)/util/loader.system diff --git a/libsrc/atari/targetutil/Makefile.inc b/libsrc/atari/targetutil/Makefile.inc index 05405f2e6..e78585238 100644 --- a/libsrc/atari/targetutil/Makefile.inc +++ b/libsrc/atari/targetutil/Makefile.inc @@ -3,7 +3,7 @@ DEPS += ../libwrk/$(TARGET)/w2cas.d ../libwrk/$(TARGET)/w2cas.o: $(SRCDIR)/targetutil/w2cas.c | ../libwrk/$(TARGET) $(COMPILE_recipe) -../targetutil/w2cas.com: ../libwrk/$(TARGET)/w2cas.o ../lib/$(TARGET).lib | ../targetutil +../target/$(TARGET)/util/w2cas.com: ../libwrk/$(TARGET)/w2cas.o ../lib/$(TARGET).lib | ../target/$(TARGET)/util $(LD65) -o $@ -t $(TARGET) $^ -$(TARGET): ../targetutil/w2cas.com +$(TARGET): ../target/$(TARGET)/util/w2cas.com diff --git a/libsrc/geos-apple/targetutil/Makefile.inc b/libsrc/geos-apple/targetutil/Makefile.inc index fbe31981c..3d366f913 100644 --- a/libsrc/geos-apple/targetutil/Makefile.inc +++ b/libsrc/geos-apple/targetutil/Makefile.inc @@ -8,7 +8,7 @@ DEPS += ../libwrk/$(TARGET)/convert.d ../lib/apple2enh.lib: @$(MAKE) --no-print-directory apple2enh -../targetutil/convert.system: ../libwrk/$(TARGET)/convert.o ../lib/apple2enh.lib | ../targetutil +../target/$(TARGET)/util/convert.system: ../libwrk/$(TARGET)/convert.o ../lib/apple2enh.lib | ../target/$(TARGET)/util $(LD65) -o $@ -C apple2enh-system.cfg $^ -$(TARGET): ../targetutil/convert.system +$(TARGET): ../target/$(TARGET)/util/convert.system diff --git a/libsrc/nes/Makefile.inc b/libsrc/nes/Makefile.inc index f1dcbf18e..ee43b4ff8 100644 --- a/libsrc/nes/Makefile.inc +++ b/libsrc/nes/Makefile.inc @@ -1,8 +1,9 @@ -../tgi/nes-64-56-2.tgi: ../libwrk/nes/clrscr.o \ - ../libwrk/nes/cputc.o \ - ../libwrk/nes/get_tv.o \ - ../libwrk/nes/gotoxy.o \ - ../libwrk/nes/popa.o \ - ../libwrk/nes/ppu.o \ - ../libwrk/nes/ppubuf.o \ - ../libwrk/nes/setcursor.o +../target/nes/drv/tgi/nes-64-56-2.tgi: \ + ../libwrk/nes/clrscr.o \ + ../libwrk/nes/cputc.o \ + ../libwrk/nes/get_tv.o \ + ../libwrk/nes/gotoxy.o \ + ../libwrk/nes/popa.o \ + ../libwrk/nes/ppu.o \ + ../libwrk/nes/ppubuf.o \ + ../libwrk/nes/setcursor.o diff --git a/samples/Makefile b/samples/Makefile index 951706ce6..d9b51e827 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -12,16 +12,19 @@ SYS = c64 # source tree; otherwise, use the "install" directories. ifeq "$(wildcard ../src)" "" # No source tree -MOUS = /usr/lib/cc65/mou/$(SYS)*.mou -TGI = /usr/lib/cc65/tgi/$(SYS)*.tgi +installdir = /usr/lib/cc65 ifneq "$(wildcard /usr/local/lib/cc65)" "" -MOUS = /usr/local/lib/cc65/mou/$(SYS)*.mou -TGI = /usr/local/lib/cc65/tgi/$(SYS)*.tgi +installdir = /usr/local/lib/cc65 +endif +ifneq "$(wildcard /opt/local/share/cc65)" "" +installdir = /opt/local/share/cc65 endif ifdef CC65_HOME -MOUS = $(CC65_HOME)/mou/$(SYS)*.mou -TGI = $(CC65_HOME)/tgi/$(SYS)*.tgi +installdir = $(CC65_HOME) endif + +MOUS = $(installdir)/target/$(SYS)/drv/mou/$(SYS)*.mou +TGI = $(installdir)/target/$(SYS)/drv/tgi/$(SYS)*.tgi CLIB = --lib $(SYS).lib CL = cl65 CC = cc65 @@ -31,8 +34,8 @@ LD = ld65 else # "samples/" is a part of a complete source tree. export CC65_HOME := $(abspath ..) -MOUS = ../mou/$(SYS)*.mou -TGI = ../tgi/$(SYS)*.tgi +MOUS = ../target/$(SYS)/drv/mou/$(SYS)*.mou +TGI = ../target/$(SYS)/drv/tgi/$(SYS)*.tgi CLIB = ../lib/$(SYS).lib CL = ../bin/cl65 CC = ../bin/cc65 @@ -105,8 +108,11 @@ EXELIST = ascii \ # -------------------------------------------------------------------------- # Rules to make the binaries -.PHONY: all -all: $(EXELIST) +.PHONY: all samples +all: + +samples: + $(EXELIST) # -------------------------------------------------------------------------- # Overlay rules. Overlays need special ld65 configuration files. Also, the @@ -134,9 +140,36 @@ samples.d64: all $(C1541) -attach $@ -write $$mod > /dev/null || exit $$?;\ done +# -------------------------------------------------------------------------- +# Installation rules + +INSTALL = install +samplesdir = $(prefix)/share/cc65 +.PHONY: install +install: + $(if $(prefix),,$(error variable `prefix' must be set)) + $(INSTALL) -d $(DESTDIR)$(samplesdir) + $(INSTALL) -d $(DESTDIR)$(samplesdir)/geos + $(INSTALL) -d $$(DESTDIR)$(samplesdir)/tutorial + $(INSTALL) -m0644 *.* $(DESTDIR)$(samplesdir) + $(INSTALL) -m0644 README $(DESTDIR)$(samplesdir) + $(INSTALL) -m0644 Makefile $(DESTDIR)$(samplesdir) + $(INSTALL) -m0644 geos/*.* $(DESTDIR)$(samplesdir)/geos + $(INSTALL) -m0644 tutorial/*.* $(DESTDIR)$(samplesdir)/tutorial + +# -------------------------------------------------------------------------- +# Packaging rules + +.PHONY: zip +zip: + @cd .. && zip -r cc65 samples/ + # -------------------------------------------------------------------------- # Clean-up rules +.PHONY: mostlyclean +mostlyclean: + .PHONY: clean clean: $(RM) *~ *.map *.o *.s *.lbl