Hi, >> After all it's just a proposal. > And an interesting and tempting one, especially knowing that you can do such stuff with little finger of your left hand ;-) Let me try be more clear now: the answet is "yes, please - only have the two points in head when structuring and commenting it". Here you go: http://www.pascalschmidt.de/Makefile Beside the structuring and commenting asked for I added another (and from my perspective final) "magic" of allowing to save and load the "abstract" options. Apart from leveraging Uz' soon-to-come new relative-include-path semantics this could be the final thing - at least when it's about making use of "GNU make magic"... Regards, Oliver ------------------------------------------------------------------------------------------- PROGRAM := CC65_TARGET := SRCDIR := OBJDIR := CFLAGS = ASFLAGS = LDFLAGS = EMULATOR := x64 EMUFLAGS = -kernal kernal -VICIIdsize -keymap 1 +autostart-warp -soundsync 2 -autoload $(PROGRAM) ############################################################################### ### Abstract options and their mapping to cc65 (2.14.x) options ### ############################################################################### # Optimize for speed. define _optspeed_ CFLAGS += -Oris endef # Optimize for size. define _optsize_ CFLAGS += -Or endef # Generate assembler listings. define _listing_ CFLAGS += -l REMOVES += $$(SRCDIR)/*.lst endef # Generate map file. define _mapfile_ LDFLAGS += -m $$@.map REMOVES += $$(PROGRAM).map endef # Generate VICE label file. define _labelfile_ LDFLAGS += -Ln $$@.lbl REMOVES += $$(PROGRAM).lbl endef ### DO NOT EDIT BELOW THIS LINE, UNLESS YOU REALLY KNOW WHAT YOU ARE DOING! ### ############################################################################### ### Defaults to be used if nothing defined above ### ############################################################################### # Presume we're in a project directory so name the program like the current # directory. Just set PROGRAM to override. ifeq ($(PROGRAM),) PROGRAM := $(notdir $(CURDIR)) endif # Presume the C64 target like the cl65 compile & link utility does. Just set # CC65_TARGET to override. ifeq ($(CC65_TARGET),) CC65_TARGET := c64 endif # Presume the C and asm source files to be located in the subdirectory 'src'. # Just set SRCDIR to override. ifeq ($(SRCDIR),) SRCDIR := src endif # Presume the object and dependency files to be located in the subdirectory # 'obj' (which will be created). Just set OBJDIR to override. ifeq ($(OBJDIR),) OBJDIR := obj endif # On Windows it is mandatory to have CC65_HOME set. So do not unnecessarily # rely on cl65 being added to the PATH in this scenario. ifdef $(CC65_HOME) CC := $(CC65_HOME)/bin/cl65 else CC := cl65 endif ############################################################################### ### The magic begins ### ############################################################################### # Set SOURCES to something like 'src/foo.c src/bar.s'. SOURCES := $(wildcard $(SRCDIR)/*.c) SOURCES += $(wildcard $(SRCDIR)/*.s) # Set OBJECTS to something like 'obj/foo.o obj/bar.o'. OBJECTS := $(addsuffix .o,$(basename $(SOURCES:$(SRCDIR)%=$(OBJDIR)%))) # Set DEPENDS to something like 'obj/foo.d obj/bar.d'. DEPENDS := $(OBJECTS:.o=.d) # Read saved OPTIONS from Makefile.options if none are set so far. ifeq ($(OPTIONS),) -include Makefile.options ifneq ($(OPTIONS),) $(info Using saved OPTIONS=$(OPTIONS)) endif endif # Transform the abstract OPTIONS to the actual cc65 options. COMMA := , SPACE := $(N/A) $(N/A) $(foreach o,$(subst $(COMMA),$(SPACE),$(OPTIONS)),$(eval $(_$o_))) .SUFFIXES: .PHONY: all clean save love all: $(PROGRAM) ifneq ($(MAKECMDGOALS),clean) -include $(DEPENDS) endif $(OBJDIR): mkdir $@ $(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR) $(CC) -t $(CC65_TARGET) -c --create-dep $(@:.o=.d) --include-dir $(SRCDIR) $(CFLAGS) -o $@ $< $(OBJDIR)/%.o: $(SRCDIR)/%.s | $(OBJDIR) $(CC) -t $(CC65_TARGET) -c --create-dep $(@:.o=.d) --asm-include-dir $(SRCDIR) --asm-args --bin-include-dir,$(SRCDIR) $(ASFLAGS) -o $@ $< $(PROGRAM): $(OBJECTS) $(CC) -t $(CC65_TARGET) $(LDFLAGS) -o $@ $^ test: $(PROGRAM) $(EMULATOR) $(EMUFLAGS) clean: rm -f $(OBJECTS) $(DEPENDS) $(PROGRAM) $(REMOVES) rmdir $(OBJDIR) save: -@rm -f Makefile.options @echo "Saving OPTIONS=$(OPTIONS)" @echo "OPTIONS=$(OPTIONS)" > Makefile.options love: @echo "Not war, eh?" ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo@musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.Received on Tue May 18 21:21:35 2010
This archive was generated by hypermail 2.1.8 : 2010-05-18 21:21:37 CEST