From b7d7614471851d11b763b2ed89d0166bc927f645 Mon Sep 17 00:00:00 2001 From: John Schneiderman Date: Sun, 4 Aug 2024 16:47:25 +0200 Subject: [PATCH 1/9] Determines the directory lcoation of the project. --- make/makefile | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/make/makefile b/make/makefile index 1b609e6..a5ffffe 100644 --- a/make/makefile +++ b/make/makefile @@ -1,12 +1,11 @@ - - -sources = $(wildcard ../oscar64/*.cpp) -objects = $(patsubst ../oscar64/%.cpp,%.o,$(sources)) +project_dir := $(abspath $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))/../) +sources = $(wildcard $(project_dir)/oscar64/*.cpp) +objects = $(patsubst $(project_dir)/oscar64/%.cpp,%.o,$(sources)) CXX = c++ CPPFLAGS = -g -O2 -std=c++11 -Wno-switch - $(shell mkdir -p ../bin) + $(shell mkdir -p $(project_dir)/bin) ifdef WINDIR linklibs = -lpthread @@ -24,21 +23,21 @@ else endif endif -%.o: ../oscar64/%.cpp +%.o: $(project_dir)/oscar64/%.cpp $(CXX) -c $(CPPFLAGS) $< -o $@ -%.d: ../oscar64/%.cpp +%.d: $(project_dir)/oscar64/%.cpp @set -e; rm -f $@; \ $(CC) -MM $(CPPFLAGS) $< > $@.$$$$; \ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ rm -f $@.$$$$ -../bin/oscar64 : $(objects) - $(CXX) $(CPPFLAGS) $(objects) $(linklibs) -o ../bin/oscar64 +$(project_dir)/bin/oscar64 : $(objects) + $(CXX) $(CPPFLAGS) $(objects) $(linklibs) -o $(project_dir)/bin/oscar64 .PHONY : clean clean : - -rm *.o *.d ../bin/oscar64 + -rm *.o *.d $(project_dir)/bin/oscar64 ifeq ($(UNAME_S), Darwin) From 7350b11001965f9f3222298c31d6ddea5484a702 Mon Sep 17 00:00:00 2001 From: John Schneiderman Date: Sun, 4 Aug 2024 17:08:19 +0200 Subject: [PATCH 2/9] Changes to compile all the files in the build directory. --- make/makefile | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/make/makefile b/make/makefile index a5ffffe..8cbdf0d 100644 --- a/make/makefile +++ b/make/makefile @@ -1,6 +1,7 @@ project_dir := $(abspath $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))/../) sources = $(wildcard $(project_dir)/oscar64/*.cpp) objects = $(patsubst $(project_dir)/oscar64/%.cpp,%.o,$(sources)) +srcdir := $(if $(srcdir),$(srcdir),$(project_dir)/build) CXX = c++ CPPFLAGS = -g -O2 -std=c++11 -Wno-switch @@ -24,16 +25,18 @@ else endif %.o: $(project_dir)/oscar64/%.cpp - $(CXX) -c $(CPPFLAGS) $< -o $@ + @echo "Compiling compiler file" $@ "..." + @$(CXX) -c $(CPPFLAGS) $< -o $(srcdir)/$@ %.d: $(project_dir)/oscar64/%.cpp - @set -e; rm -f $@; \ - $(CC) -MM $(CPPFLAGS) $< > $@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$ + @set -e; rm -f $(srcdir)/$@; \ + $(CC) -MM $(CPPFLAGS) $< > $(srcdir)/$@.$$$$; \ + sed 's,\($*\)\.o[ :]*,\1.o $(srcdir)/$@ : ,g' < $(srcdir)/$@.$$$$ > $(srcdir)/$@; \ + rm -f $(srcdir)/$@.$$$$ $(project_dir)/bin/oscar64 : $(objects) - $(CXX) $(CPPFLAGS) $(objects) $(linklibs) -o $(project_dir)/bin/oscar64 + @echo "Linking compiler" $@ "..." + @$(CXX) $(CPPFLAGS) $(objects) $(linklibs) -o $(project_dir)/bin/oscar64 .PHONY : clean clean : From fb5b69ae5ce71c4d70b2ca3c96a03b3f2f867ffa Mon Sep 17 00:00:00 2001 From: John Schneiderman Date: Sun, 4 Aug 2024 17:32:13 +0200 Subject: [PATCH 3/9] Changes to use commands from variables. --- make/makefile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/make/makefile b/make/makefile index 8cbdf0d..6a75329 100644 --- a/make/makefile +++ b/make/makefile @@ -5,7 +5,8 @@ srcdir := $(if $(srcdir),$(srcdir),$(project_dir)/build) CXX = c++ CPPFLAGS = -g -O2 -std=c++11 -Wno-switch - +SED = /usr/bin/sed + $(shell mkdir -p $(project_dir)/bin) ifdef WINDIR @@ -29,10 +30,11 @@ endif @$(CXX) -c $(CPPFLAGS) $< -o $(srcdir)/$@ %.d: $(project_dir)/oscar64/%.cpp - @set -e; rm -f $(srcdir)/$@; \ + @echo "Transforming file" $@ "..." + @set -e; $(RM) $(srcdir)/$@; \ $(CC) -MM $(CPPFLAGS) $< > $(srcdir)/$@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $(srcdir)/$@ : ,g' < $(srcdir)/$@.$$$$ > $(srcdir)/$@; \ - rm -f $(srcdir)/$@.$$$$ + $(SED) 's,\($*\)\.o[ :]*,\1.o $(srcdir)/$@ : ,g' < $(srcdir)/$@.$$$$ > $(srcdir)/$@; \ + $(RM) $(srcdir)/$@.$$$$ $(project_dir)/bin/oscar64 : $(objects) @echo "Linking compiler" $@ "..." @@ -40,7 +42,9 @@ $(project_dir)/bin/oscar64 : $(objects) .PHONY : clean clean : - -rm *.o *.d $(project_dir)/bin/oscar64 + @$(RM) $(srcdir)/*.o + @$(RM) $(srcdir)/*.d + @$(RM) $(project_dir)/bin/oscar64 ifeq ($(UNAME_S), Darwin) From 89ba57e18d8a1135af31610bbbfeb6a80d4f5f83 Mon Sep 17 00:00:00 2001 From: John Schneiderman Date: Wed, 7 Aug 2024 19:43:27 +0200 Subject: [PATCH 4/9] Adds disclean and prep targets for building. --- make/makefile | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/make/makefile b/make/makefile index 6a75329..4853f51 100644 --- a/make/makefile +++ b/make/makefile @@ -6,8 +6,8 @@ srcdir := $(if $(srcdir),$(srcdir),$(project_dir)/build) CXX = c++ CPPFLAGS = -g -O2 -std=c++11 -Wno-switch SED = /usr/bin/sed +REMOVE_FORCE_ALL = $(RM) --recursive --dir - $(shell mkdir -p $(project_dir)/bin) ifdef WINDIR linklibs = -lpthread @@ -24,21 +24,29 @@ else #linklibs = -lversion -lpthread endif endif - + + +all: --prep-build-dir compiler + + %.o: $(project_dir)/oscar64/%.cpp @echo "Compiling compiler file" $@ "..." @$(CXX) -c $(CPPFLAGS) $< -o $(srcdir)/$@ + %.d: $(project_dir)/oscar64/%.cpp @echo "Transforming file" $@ "..." - @set -e; $(RM) $(srcdir)/$@; \ + @set -e; \ + $(RM) $(srcdir)/$@; \ $(CC) -MM $(CPPFLAGS) $< > $(srcdir)/$@.$$$$; \ $(SED) 's,\($*\)\.o[ :]*,\1.o $(srcdir)/$@ : ,g' < $(srcdir)/$@.$$$$ > $(srcdir)/$@; \ $(RM) $(srcdir)/$@.$$$$ -$(project_dir)/bin/oscar64 : $(objects) - @echo "Linking compiler" $@ "..." - @$(CXX) $(CPPFLAGS) $(objects) $(linklibs) -o $(project_dir)/bin/oscar64 + +compiler: $(objects) + @echo "Linking compiler..." + $(CXX) $(CPPFLAGS) $(objects) $(linklibs) -o $(project_dir)/bin/oscar64 + .PHONY : clean clean : @@ -46,10 +54,22 @@ clean : @$(RM) $(srcdir)/*.d @$(RM) $(project_dir)/bin/oscar64 + +.PHONY : distclean +distclean : + @$(REMOVE_FORCE_ALL) $(srcdir) + @$(REMOVE_FORCE_ALL) $(project_dir)/bin + + ifeq ($(UNAME_S), Darwin) else -include $(objects:.o=.d) +include $($(srcdir)/objects:.o=.d) endif + + +--prep-build-dir: + @if [[ ! -d $(srcdir) ]]; then mkdir --parents $(srcdir); fi + @if [[ ! -d $(project_dir)/bin ]]; then mkdir --parents $(project_dir)/bin; fi From 95992df67d64a7589090a30a4df4320bbb376ff9 Mon Sep 17 00:00:00 2001 From: John Schneiderman Date: Wed, 7 Aug 2024 20:14:56 +0200 Subject: [PATCH 5/9] Adds the samples building to the all target. --- make/makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/make/makefile b/make/makefile index 4853f51..9df830e 100644 --- a/make/makefile +++ b/make/makefile @@ -26,7 +26,7 @@ else endif -all: --prep-build-dir compiler +all: --prep-build-dir compiler samples %.o: $(project_dir)/oscar64/%.cpp @@ -53,12 +53,18 @@ clean : @$(RM) $(srcdir)/*.o @$(RM) $(srcdir)/*.d @$(RM) $(project_dir)/bin/oscar64 + $(MAKE) -C $(project_dir)/samples clean .PHONY : distclean distclean : @$(REMOVE_FORCE_ALL) $(srcdir) @$(REMOVE_FORCE_ALL) $(project_dir)/bin + $(MAKE) -C $(project_dir)/samples clean + + +samples: compiler + $(MAKE) -C $(project_dir)/samples all ifeq ($(UNAME_S), Darwin) From eab2a490f4bcf5f2d9568d91b872fdb704edfd9e Mon Sep 17 00:00:00 2001 From: John Schneiderman Date: Wed, 7 Aug 2024 20:39:05 +0200 Subject: [PATCH 6/9] Adds the tests to the all target. Silences the cleaning targets. --- autotest/makefile | 2 +- make/makefile | 14 ++++++++---- samples/fractals/makefile | 2 +- samples/games/makefile | 2 +- samples/hires/makefile | 2 +- samples/hiresmc/makefile | 2 +- samples/kernalio/makefile | 2 +- samples/makefile | 44 +++++++++++++++++++------------------- samples/memmap/makefile | 2 +- samples/particles/makefile | 2 +- samples/rasterirq/makefile | 2 +- samples/scrolling/makefile | 2 +- samples/sprites/makefile | 2 +- samples/stdio/makefile | 2 +- 14 files changed, 44 insertions(+), 38 deletions(-) diff --git a/autotest/makefile b/autotest/makefile index 29ec3cb..801f13b 100644 --- a/autotest/makefile +++ b/autotest/makefile @@ -47,4 +47,4 @@ stripedarraytest: stripedarraytest.c $(CC) -e -O3 -n $< clean: - $(RM) *.asm *.bcs *.int *.lbl *.map *.prg + @$(RM) *.asm *.bcs *.int *.lbl *.map *.prg diff --git a/make/makefile b/make/makefile index 9df830e..504d421 100644 --- a/make/makefile +++ b/make/makefile @@ -26,7 +26,7 @@ else endif -all: --prep-build-dir compiler samples +all: --prep-build-dir compiler samples tests %.o: $(project_dir)/oscar64/%.cpp @@ -53,18 +53,24 @@ clean : @$(RM) $(srcdir)/*.o @$(RM) $(srcdir)/*.d @$(RM) $(project_dir)/bin/oscar64 - $(MAKE) -C $(project_dir)/samples clean + @$(MAKE) -C $(project_dir)/samples clean + @$(MAKE) -C $(project_dir)/autotest clean .PHONY : distclean distclean : @$(REMOVE_FORCE_ALL) $(srcdir) @$(REMOVE_FORCE_ALL) $(project_dir)/bin - $(MAKE) -C $(project_dir)/samples clean + @$(MAKE) -C $(project_dir)/samples clean + @$(MAKE) -C $(project_dir)/autotest clean samples: compiler - $(MAKE) -C $(project_dir)/samples all + @$(MAKE) -C $(project_dir)/samples all + + +tests: compiler + @$(MAKE) -C $(project_dir)/autotest all ifeq ($(UNAME_S), Darwin) diff --git a/samples/fractals/makefile b/samples/fractals/makefile index 0a81c92..3f415c8 100644 --- a/samples/fractals/makefile +++ b/samples/fractals/makefile @@ -13,4 +13,4 @@ mbzoom.prg: mbzoom.c $(CC) $(CFLAGS) -O3 $< clean: - $(RM) *.asm *.int *.lbl *.map *.prg + @$(RM) *.asm *.int *.lbl *.map *.prg diff --git a/samples/games/makefile b/samples/games/makefile index 4b89db4..38582fc 100644 --- a/samples/games/makefile +++ b/samples/games/makefile @@ -16,4 +16,4 @@ hscrollshmup.prg: hscrollshmup.c $(CC) $(CFLAGS) -O2 $< clean: - $(RM) *.asm *.int *.lbl *.map *.prg *.bcs + @$(RM) *.asm *.int *.lbl *.map *.prg *.bcs diff --git a/samples/hires/makefile b/samples/hires/makefile index 1159dda..559cedc 100644 --- a/samples/hires/makefile +++ b/samples/hires/makefile @@ -10,4 +10,4 @@ splitscreen.prg: splitscreen.c $(CC) $< clean: - $(RM) *.asm *.int *.lbl *.map *.prg *.bcs + @$(RM) *.asm *.int *.lbl *.map *.prg *.bcs diff --git a/samples/hiresmc/makefile b/samples/hiresmc/makefile index 750e15f..c9c7f04 100644 --- a/samples/hiresmc/makefile +++ b/samples/hiresmc/makefile @@ -7,4 +7,4 @@ CFLAGS=-n all: func3d.prg polygon.prg floodfill.prg paint.prg clean: - $(RM) *.asm *.int *.lbl *.map *.prg + @$(RM) *.asm *.int *.lbl *.map *.prg diff --git a/samples/kernalio/makefile b/samples/kernalio/makefile index 0c921c2..48021a2 100644 --- a/samples/kernalio/makefile +++ b/samples/kernalio/makefile @@ -7,4 +7,4 @@ CFLAGS= all: diskdir.prg filewrite.prg fileread.prg charwrite.prg charread.prg hireswrite.prg hiresread.prg clean: - $(RM) *.asm *.int *.lbl *.map *.prg *.bcs + @$(RM) *.asm *.int *.lbl *.map *.prg *.bcs diff --git a/samples/makefile b/samples/makefile index adc9956..e649448 100644 --- a/samples/makefile +++ b/samples/makefile @@ -1,25 +1,25 @@ all: - $(MAKE) -C fractals - $(MAKE) -C games - $(MAKE) -C hires - $(MAKE) -C hiresmc - $(MAKE) -C particles - $(MAKE) -C kernalio - $(MAKE) -C memmap - $(MAKE) -C rasterirq - $(MAKE) -C scrolling - $(MAKE) -C sprites - $(MAKE) -C stdio + @$(MAKE) -C fractals + @$(MAKE) -C games + @$(MAKE) -C hires + @$(MAKE) -C hiresmc + @$(MAKE) -C particles + @$(MAKE) -C kernalio + @$(MAKE) -C memmap + @$(MAKE) -C rasterirq + @$(MAKE) -C scrolling + @$(MAKE) -C sprites + @$(MAKE) -C stdio clean: - $(MAKE) -C fractals $@ - $(MAKE) -C games $@ - $(MAKE) -C hires $@ - $(MAKE) -C hiresmc $@ - $(MAKE) -C particles $@ - $(MAKE) -C kernalio $@ - $(MAKE) -C memmap $@ - $(MAKE) -C rasterirq $@ - $(MAKE) -C scrolling $@ - $(MAKE) -C sprites $@ - $(MAKE) -C stdio $@ + @$(MAKE) -C fractals $@ + @$(MAKE) -C games $@ + @$(MAKE) -C hires $@ + @$(MAKE) -C hiresmc $@ + @$(MAKE) -C particles $@ + @$(MAKE) -C kernalio $@ + @$(MAKE) -C memmap $@ + @$(MAKE) -C rasterirq $@ + @$(MAKE) -C scrolling $@ + @$(MAKE) -C sprites $@ + @$(MAKE) -C stdio $@ diff --git a/samples/memmap/makefile b/samples/memmap/makefile index c14cb6d..8f59a02 100644 --- a/samples/memmap/makefile +++ b/samples/memmap/makefile @@ -26,4 +26,4 @@ overlay.prg: overlay.c $(CC) $(CFLAGS) $< -n -d64=overlay.d64 clean: - $(RM) *.asm *.int *.lbl *.map *.prg *.bcs *.d64 *.crt + @$(RM) *.asm *.int *.lbl *.map *.prg *.bcs *.d64 *.crt diff --git a/samples/particles/makefile b/samples/particles/makefile index 3826e7f..0e8aaa2 100644 --- a/samples/particles/makefile +++ b/samples/particles/makefile @@ -7,4 +7,4 @@ CFLAGS=-n all: fireworks_ptr.prg fireworks_hires.prg fireworks_stripe.prg clean: - $(RM) *.asm *.int *.lbl *.map *.prg + @$(RM) *.asm *.int *.lbl *.map *.prg diff --git a/samples/rasterirq/makefile b/samples/rasterirq/makefile index db1239c..8a62c01 100644 --- a/samples/rasterirq/makefile +++ b/samples/rasterirq/makefile @@ -10,4 +10,4 @@ movingbars.prg: movingbars.c $(CC) $(CFLAGS) $< -n clean: - $(RM) *.asm *.int *.lbl *.map *.prg *.bcs + @$(RM) *.asm *.int *.lbl *.map *.prg *.bcs diff --git a/samples/scrolling/makefile b/samples/scrolling/makefile index b20a190..e7c13cd 100644 --- a/samples/scrolling/makefile +++ b/samples/scrolling/makefile @@ -7,4 +7,4 @@ CFLAGS=-n all: bigfont.prg tunnel.prg grid2d.prg colorram.prg cgrid8way.prg clean: - $(RM) *.asm *.int *.lbl *.map *.prg + @$(RM) *.asm *.int *.lbl *.map *.prg diff --git a/samples/sprites/makefile b/samples/sprites/makefile index b5d8df1..f3593c6 100644 --- a/samples/sprites/makefile +++ b/samples/sprites/makefile @@ -13,4 +13,4 @@ sprmux32.prg: sprmux32.c $(CC) $(CFLAGS) $< -O2 -dVSPRITES_MAX=32 -dNUM_IRQS=28 clean: - $(RM) *.asm *.int *.lbl *.map *.prg *.bcs + @$(RM) *.asm *.int *.lbl *.map *.prg *.bcs diff --git a/samples/stdio/makefile b/samples/stdio/makefile index ca86830..bc7e790 100644 --- a/samples/stdio/makefile +++ b/samples/stdio/makefile @@ -7,4 +7,4 @@ CFLAGS= all: helloworld.prg clean: - $(RM) *.asm *.int *.lbl *.map *.prg *.bcs + @$(RM) *.asm *.int *.lbl *.map *.prg *.bcs From 586fab6b6bb555b5c274a1552f20cec78324e082 Mon Sep 17 00:00:00 2001 From: John Schneiderman Date: Wed, 7 Aug 2024 21:24:40 +0200 Subject: [PATCH 7/9] Changes to use a top-level variable for the Oscar compiler uses. --- autotest/makefile | 62 ++++++++++++++++++-------------------- make/makefile | 7 +++-- samples/fractals/makefile | 10 +++--- samples/games/makefile | 12 +++----- samples/hires/makefile | 8 ++--- samples/hiresmc/makefile | 6 ++-- samples/kernalio/makefile | 6 ++-- samples/memmap/makefile | 18 +++++------ samples/particles/makefile | 6 ++-- samples/rasterirq/makefile | 8 ++--- samples/scrolling/makefile | 6 ++-- samples/sprites/makefile | 10 +++--- samples/stdio/makefile | 6 ++-- 13 files changed, 72 insertions(+), 93 deletions(-) diff --git a/autotest/makefile b/autotest/makefile index 801f13b..25c626c 100644 --- a/autotest/makefile +++ b/autotest/makefile @@ -1,5 +1,3 @@ -CC=../bin/oscar64 -CXX=$(CC) SRCS=$(filter-out opp_part1.cpp opp_part2.cpp, $(wildcard *.c *.cpp)) EXES=$(patsubst %.c,%,$(SRCS)) EXES:=$(patsubst %.cpp,%,$(EXES)) @@ -7,44 +5,44 @@ EXES:=$(patsubst %.cpp,%,$(EXES)) all: $(EXES) %: %.c - $(CC) -e -bc $< - $(CC) -e -n $< - $(CC) -e -O2 -bc $< - $(CC) -e -O2 -n $< - $(CC) -e -O0 -bc $< - $(CC) -e -O0 -n $< - $(CC) -e -Os -bc $< - $(CC) -e -Os -n $< - $(CC) -e -O3 -bc $< - $(CC) -e -O3 -n $< + $(OSCAR64_CC) -e -bc $< + $(OSCAR64_CC) -e -n $< + $(OSCAR64_CC) -e -O2 -bc $< + $(OSCAR64_CC) -e -O2 -n $< + $(OSCAR64_CC) -e -O0 -bc $< + $(OSCAR64_CC) -e -O0 -n $< + $(OSCAR64_CC) -e -Os -bc $< + $(OSCAR64_CC) -e -Os -n $< + $(OSCAR64_CC) -e -O3 -bc $< + $(OSCAR64_CC) -e -O3 -n $< %: %.cpp - $(CXX) -e -bc $< - $(CXX) -e -n $< - $(CXX) -e -O2 -bc $< - $(CXX) -e -O2 -n $< - $(CXX) -e -O0 -bc $< - $(CXX) -e -O0 -n $< - $(CXX) -e -Os -bc $< - $(CXX) -e -Os -n $< - $(CXX) -e -O3 -bc $< - $(CXX) -e -O3 -n $< + $(OSCAR64_CXX) -e -bc $< + $(OSCAR64_CXX) -e -n $< + $(OSCAR64_CXX) -e -O2 -bc $< + $(OSCAR64_CXX) -e -O2 -n $< + $(OSCAR64_CXX) -e -O0 -bc $< + $(OSCAR64_CXX) -e -O0 -n $< + $(OSCAR64_CXX) -e -Os -bc $< + $(OSCAR64_CXX) -e -Os -n $< + $(OSCAR64_CXX) -e -O3 -bc $< + $(OSCAR64_CXX) -e -O3 -n $< # testb bitshifttest: bitshifttest.c - $(CC) -e -bc $< - $(CC) -e -bc -O2 $< - $(CC) -e -bc -O0 $< - $(CC) -e -bc -Os $< - $(CC) -e -bc -O3 $< - $(CC) -e -n $< + $(OSCAR64_CC) -e -bc $< + $(OSCAR64_CC) -e -bc -O2 $< + $(OSCAR64_CC) -e -bc -O0 $< + $(OSCAR64_CC) -e -bc -Os $< + $(OSCAR64_CC) -e -bc -O3 $< + $(OSCAR64_CC) -e -n $< # testn stripedarraytest: stripedarraytest.c - $(CC) -e -O2 -n $< - $(CC) -e -O0 -n $< - $(CC) -e -Os -n $< - $(CC) -e -O3 -n $< + $(OSCAR64_CC) -e -O2 -n $< + $(OSCAR64_CC) -e -O0 -n $< + $(OSCAR64_CC) -e -Os -n $< + $(OSCAR64_CC) -e -O3 -n $< clean: @$(RM) *.asm *.bcs *.int *.lbl *.map *.prg diff --git a/make/makefile b/make/makefile index 504d421..52444c8 100644 --- a/make/makefile +++ b/make/makefile @@ -7,6 +7,9 @@ CXX = c++ CPPFLAGS = -g -O2 -std=c++11 -Wno-switch SED = /usr/bin/sed REMOVE_FORCE_ALL = $(RM) --recursive --dir +export OSCAR64_CC = $(project_dir)/bin/oscar64 +export OSCAR64_CFLAGS = +export OSCAR64_CXX = $(project_dir)/bin/oscar64 ifdef WINDIR @@ -38,14 +41,14 @@ all: --prep-build-dir compiler samples tests @echo "Transforming file" $@ "..." @set -e; \ $(RM) $(srcdir)/$@; \ - $(CC) -MM $(CPPFLAGS) $< > $(srcdir)/$@.$$$$; \ + @$(CC) -MM $(CPPFLAGS) $< > $(srcdir)/$@.$$$$; \ $(SED) 's,\($*\)\.o[ :]*,\1.o $(srcdir)/$@ : ,g' < $(srcdir)/$@.$$$$ > $(srcdir)/$@; \ $(RM) $(srcdir)/$@.$$$$ compiler: $(objects) @echo "Linking compiler..." - $(CXX) $(CPPFLAGS) $(objects) $(linklibs) -o $(project_dir)/bin/oscar64 + @$(CXX) $(CPPFLAGS) $(objects) $(linklibs) -o $(project_dir)/bin/oscar64 .PHONY : clean diff --git a/samples/fractals/makefile b/samples/fractals/makefile index 3f415c8..f30655a 100644 --- a/samples/fractals/makefile +++ b/samples/fractals/makefile @@ -1,16 +1,14 @@ -CC=../../bin/oscar64 -CFLAGS=-n - %.prg: %.c - $(CC) $(CFLAGS) $< + @echo "Compiling sample file" $< + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< all: mbtext.prg mbtext.prg mbhires.prg mbmulti.prg mbmulti3d.prg mbfixed.prg mbzoom.prg mbfixed.prg: mbfixed.c - $(CC) $(CFLAGS) -O3 $< + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) -O3 $< mbzoom.prg: mbzoom.c - $(CC) $(CFLAGS) -O3 $< + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) -O3 $< clean: @$(RM) *.asm *.int *.lbl *.map *.prg diff --git a/samples/games/makefile b/samples/games/makefile index 38582fc..1d31617 100644 --- a/samples/games/makefile +++ b/samples/games/makefile @@ -1,19 +1,17 @@ -CC=../../bin/oscar64 -CFLAGS=-n - %.prg: %.c - $(CC) $(CFLAGS) $< + @echo "Compiling sample file" $< + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< all: snake.prg lander.prg maze3d.prg missile.prg breakout.prg connectfour.prg hscrollshmup.prg snake.prg: snake.c - $(CC) $< + @$(OSCAR64_CC) $< missile.prg: missile.c - $(CC) $(CFLAGS) -O3 $< + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) -O3 $< hscrollshmup.prg: hscrollshmup.c - $(CC) $(CFLAGS) -O2 $< + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) -O2 $< clean: @$(RM) *.asm *.int *.lbl *.map *.prg *.bcs diff --git a/samples/hires/makefile b/samples/hires/makefile index 559cedc..6f3e13d 100644 --- a/samples/hires/makefile +++ b/samples/hires/makefile @@ -1,13 +1,11 @@ -CC=../../bin/oscar64 -CFLAGS=-n - %.prg: %.c - $(CC) $(CFLAGS) $< + @echo "Compiling sample file" $< + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< all: splitscreen.prg func3d.prg lines.prg polygon.prg bitblit.prg cube3d.prg fractaltree.prg qsort.prg splitscreen.prg: splitscreen.c - $(CC) $< + @$(OSCAR64_CC) $< clean: @$(RM) *.asm *.int *.lbl *.map *.prg *.bcs diff --git a/samples/hiresmc/makefile b/samples/hiresmc/makefile index c9c7f04..61cd4d1 100644 --- a/samples/hiresmc/makefile +++ b/samples/hiresmc/makefile @@ -1,8 +1,6 @@ -CC=../../bin/oscar64 -CFLAGS=-n - %.prg: %.c - $(CC) $(CFLAGS) $< + @echo "Compiling sample file" $< + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< all: func3d.prg polygon.prg floodfill.prg paint.prg diff --git a/samples/kernalio/makefile b/samples/kernalio/makefile index 48021a2..910e6b0 100644 --- a/samples/kernalio/makefile +++ b/samples/kernalio/makefile @@ -1,8 +1,6 @@ -CC=../../bin/oscar64 -CFLAGS= - %.prg: %.c - $(CC) $(CFLAGS) $< + @echo "Compiling sample file" $< + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< all: diskdir.prg filewrite.prg fileread.prg charwrite.prg charread.prg hireswrite.prg hiresread.prg diff --git a/samples/memmap/makefile b/samples/memmap/makefile index 8f59a02..00d168a 100644 --- a/samples/memmap/makefile +++ b/samples/memmap/makefile @@ -1,29 +1,27 @@ -CC=../../bin/oscar64 -CFLAGS= - %.prg: %.c - $(CC) $(CFLAGS) $< + @echo "Compiling sample file" $< + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< all: largemem.prg allmem.prg charsetlo.prg charsethi.prg charsetcopy.prg charsetexpand.prg \ charsetload.prg easyflash.crt easyflashreloc.crt easyflashshared.crt tsr.prg overlay.prg charsetload.prg: charsetload.c ../resources/charset.bin - $(CC) $(CFLAGS) $< -d64=charsetload.d64 -fz=../resources/charset.bin + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< -d64=charsetload.d64 -fz=../resources/charset.bin easyflash.crt: easyflash.c - $(CC) $(CFLAGS) $< -n -tf=crt + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< -n -tf=crt easyflashreloc.crt: easyflashreloc.c - $(CC) $(CFLAGS) $< -n -tf=crt + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< -n -tf=crt easyflashshared.crt: easyflashshared.c - $(CC) $(CFLAGS) $< -n -tf=crt + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< -n -tf=crt tsr.prg: tsr.c - $(CC) $(CFLAGS) $< -n -dNOFLOAT -dNOLONG + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< -n -dNOFLOAT -dNOLONG overlay.prg: overlay.c - $(CC) $(CFLAGS) $< -n -d64=overlay.d64 + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< -n -d64=overlay.d64 clean: @$(RM) *.asm *.int *.lbl *.map *.prg *.bcs *.d64 *.crt diff --git a/samples/particles/makefile b/samples/particles/makefile index 0e8aaa2..e461620 100644 --- a/samples/particles/makefile +++ b/samples/particles/makefile @@ -1,8 +1,6 @@ -CC=../../bin/oscar64 -CFLAGS=-n - %.prg: %.c - $(CC) $(CFLAGS) $< + @echo "Compiling sample file" $< + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< all: fireworks_ptr.prg fireworks_hires.prg fireworks_stripe.prg diff --git a/samples/rasterirq/makefile b/samples/rasterirq/makefile index 8a62c01..165b064 100644 --- a/samples/rasterirq/makefile +++ b/samples/rasterirq/makefile @@ -1,13 +1,11 @@ -CC=../../bin/oscar64 -CFLAGS= - %.prg: %.c - $(CC) $(CFLAGS) $< + @echo "Compiling sample file" $< + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< all: colorbars.prg openborder.prg textcrawler.prg movingbars.prg movingbars.prg: movingbars.c - $(CC) $(CFLAGS) $< -n + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< -n clean: @$(RM) *.asm *.int *.lbl *.map *.prg *.bcs diff --git a/samples/scrolling/makefile b/samples/scrolling/makefile index e7c13cd..c1e97f0 100644 --- a/samples/scrolling/makefile +++ b/samples/scrolling/makefile @@ -1,8 +1,6 @@ -CC=../../bin/oscar64 -CFLAGS=-n - %.prg: %.c - $(CC) $(CFLAGS) $< + @echo "Compiling sample file" $< + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< all: bigfont.prg tunnel.prg grid2d.prg colorram.prg cgrid8way.prg diff --git a/samples/sprites/makefile b/samples/sprites/makefile index f3593c6..f4ad05b 100644 --- a/samples/sprites/makefile +++ b/samples/sprites/makefile @@ -1,16 +1,14 @@ -CC=../../bin/oscar64 -CFLAGS=-n - %.prg: %.c - $(CC) $(CFLAGS) $< + @echo "Compiling sample file" $< + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< all: joycontrol.prg multiplexer.prg creditroll.prg sprmux32.prg sprmux64.prg joycontrol.prg: joycontrol.c - $(CC) $< + @$(OSCAR64_CC) $< sprmux32.prg: sprmux32.c - $(CC) $(CFLAGS) $< -O2 -dVSPRITES_MAX=32 -dNUM_IRQS=28 + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< -O2 -dVSPRITES_MAX=32 -dNUM_IRQS=28 clean: @$(RM) *.asm *.int *.lbl *.map *.prg *.bcs diff --git a/samples/stdio/makefile b/samples/stdio/makefile index bc7e790..e33d992 100644 --- a/samples/stdio/makefile +++ b/samples/stdio/makefile @@ -1,8 +1,6 @@ -CC=../../bin/oscar64 -CFLAGS= - %.prg: %.c - $(CC) $(CFLAGS) $< + @echo "Compiling sample file" $< + @$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< all: helloworld.prg From 092592a05b53a9fec207a6af7f00c3ffc00b9065 Mon Sep 17 00:00:00 2001 From: John Schneiderman Date: Thu, 8 Aug 2024 20:16:11 +0200 Subject: [PATCH 8/9] Adds an installation target. Adds an uninstallation target. --- make/makefile | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/make/makefile b/make/makefile index 52444c8..bdefab6 100644 --- a/make/makefile +++ b/make/makefile @@ -10,6 +10,15 @@ REMOVE_FORCE_ALL = $(RM) --recursive --dir export OSCAR64_CC = $(project_dir)/bin/oscar64 export OSCAR64_CFLAGS = export OSCAR64_CXX = $(project_dir)/bin/oscar64 +MKDIR_PARENT = /usr/bin/mkdir --parents --mode=755 +INSTALL = /usr/bin/install +INSTALL_PROGRAM = $(INSTALL) --mode=755 +INSTALL_DATA = $(INSTALL) --mode=644 +DESTDIR = +prefix = /usr/local +exec_prefix = $(prefix) +bindir = $(exec_prefix)/bin +includedir = $(prefix)/include ifdef WINDIR @@ -53,6 +62,7 @@ compiler: $(objects) .PHONY : clean clean : + @echo "Cleaning compiler..." @$(RM) $(srcdir)/*.o @$(RM) $(srcdir)/*.d @$(RM) $(project_dir)/bin/oscar64 @@ -62,6 +72,7 @@ clean : .PHONY : distclean distclean : + @echo "Distribution cleaning compiler..." @$(REMOVE_FORCE_ALL) $(srcdir) @$(REMOVE_FORCE_ALL) $(project_dir)/bin @$(MAKE) -C $(project_dir)/samples clean @@ -75,6 +86,28 @@ samples: compiler tests: compiler @$(MAKE) -C $(project_dir)/autotest all +install: compiler + @echo "Installing to" $(DESTDIR)$(prefix) + @$(MKDIR_PARENT) $(DESTDIR)$(bindir) + $(INSTALL_PROGRAM) $(project_dir)/bin/oscar64 $(DESTDIR)$(bindir) + @$(MKDIR_PARENT) $(DESTDIR)$(includedir)/oscar64/{audio,c64,c128,cx16,gfx,nes,opp,plus4,vic20} + $(INSTALL_DATA) $(project_dir)/include/*.h $(DESTDIR)$(includedir)/oscar64 + $(INSTALL_DATA) $(project_dir)/include/audio/*.h $(DESTDIR)$(includedir)/oscar64/audio + $(INSTALL_DATA) $(project_dir)/include/c64/*.h $(DESTDIR)$(includedir)/oscar64/c64 + $(INSTALL_DATA) $(project_dir)/include/c128/*.h $(DESTDIR)$(includedir)/oscar64/c128 + $(INSTALL_DATA) $(project_dir)/include/cx16/*.h $(DESTDIR)$(includedir)/oscar64/cx16 + $(INSTALL_DATA) $(project_dir)/include/gfx/*.h $(DESTDIR)$(includedir)/oscar64/gfx + $(INSTALL_DATA) $(project_dir)/include/nes/*.h $(DESTDIR)$(includedir)/oscar64/nes + $(INSTALL_DATA) $(project_dir)/include/opp/*.h $(DESTDIR)$(includedir)/oscar64/opp + $(INSTALL_DATA) $(project_dir)/include/plus4/*.h $(DESTDIR)$(includedir)/oscar64/plus4 + $(INSTALL_DATA) $(project_dir)/include/vic20/*.h $(DESTDIR)$(includedir)/oscar64/vic20 + + +uninstall: + @echo "Uninstalling..." + @$(RM) $(DESTDIR)$(bindir)/oscar64 + @$(REMOVE_FORCE_ALL) $(DESTDIR)$(includedir)/oscar64/ + ifeq ($(UNAME_S), Darwin) From d67980d79f05ec580cd7e976c3811a475265bd63 Mon Sep 17 00:00:00 2001 From: John Schneiderman Date: Thu, 8 Aug 2024 20:34:19 +0200 Subject: [PATCH 9/9] Updates the instructions on how to build. --- README.md | 13 ++++++++++++- make/makefile | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8350d97..d85e3b0 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,18 @@ You should build from a subdirectory of Oscar64 so that references in the makefi * mkdir build * cd build -* make -f ../make/makefile + +To build just the compiler: + +* make -f ../make/makefile compiler + +To build just game demonstrations: + +* make -f ../make/makefile samples + +To build everything: + +* make -f ../make/makefile all ### Compiler arguments diff --git a/make/makefile b/make/makefile index bdefab6..f493a30 100644 --- a/make/makefile +++ b/make/makefile @@ -119,5 +119,5 @@ endif --prep-build-dir: - @if [[ ! -d $(srcdir) ]]; then mkdir --parents $(srcdir); fi - @if [[ ! -d $(project_dir)/bin ]]; then mkdir --parents $(project_dir)/bin; fi + @if [[ ! -d $(srcdir) ]]; then $(MKDIR_PARENT) $(srcdir); fi + @if [[ ! -d $(project_dir)/bin ]]; then $(MKDIR_PARENT) $(project_dir)/bin; fi