Payton Byrd wrote: > I know we have some real GNU experts here. I by no means am among > that group. I got my hands on /Managing Projects with GNU Make/ and > after a cursory scan of the first third of it I believe I have a > pretty solid makefile. Please critique the attached makefile. > > Thanks, > -- > Payton Byrd > <http://www.paytonbyrd.com> > <http://it.toolbox.com/blogs/paytonbyrd> Nice Makefile but I would like to add some cc65 specific things there. In Program declarations I would add more tools. And you don't need .exe extensions: CL := cl65 CC := cc65 AS := ca65 AR := ar65 SPRPCK := sprpck CP := cp RM := rm ECHO := echo TOUCH := touch cp.exe, rm.exe, echo.exe touch.exe, make.exe can easily be found as native Windows compilations. Using these binaries in addition to cc65 takes away all Windows/Linux headaches in Makefiles. Sprite packers (sprpck) may not be relevant except on Lynx targets. The use of segments for controlling where the code goes: CODE_SEGMENT := INTRO_CODE DATA_SEGMENT := INTRO_DATA RODATA_SEGMENT := INTRO_RODATA BSS_SEGMENT := INTRO_BSS # The name of the final executable target := Hello.com # System libraries needed for linking libraries := c128.lib # Name of the system T := c128 In Windows the command line is far too short. We cannot give all the object files as parameters on the command line. So I would go for a different approach and use object files instead of source files for describing what to compile. This technique will make the Makefile scalable to larger projects later. objects := \ Hello.o \ Text.o In order to get these compiled we then need some rules. # The flag for adding stuff to a library ARFLAGS=a # The flags for compiling C-code CFLAGS=-I . -t $(T) --add-source -O -Or -Cl -Os SEGMENTS=--code-name $(CODE_SEGMENT) \ --rodata-name $(RODATA_SEGMENT) \ --bss-name $(BSS_SEGMENT) \ --data-name $(DATA_SEGMENT) # Include paths we may need for compilations ifeq ($(CC65_INC),) CC65_INC=/usr/lib/cc65/include endif ifeq ($(CC65_ASMINC),) CC65_ASMINC="$(CC65_INC)/../asminc" endif # Rule for making a *.o file out of a *.c file %.o: %.c $(CC) $(CFLAGS) $(SEGMENTS) -o $(patsubst %c, %s, $(notdir $<)) $< $(AS) -o $@ $(AFLAGS) $(*).s $(RM) $*.s # Rule for making a *.o file out of a *.s file %.o: %.s $(AS) -t $(T) -I $(CC65_ASMINC) -o $@ $(AFLAGS) $< # Bitmap creation may be different for other platforms # Rule for making a *.o file out of a *.bmp file %.o : %.bmp $(SPRPCK) -t6 -p2 $< $(ECHO) .global _$* > $*.s $(ECHO) .segment \"$(RODATA_SEGMENT)\" >> $*.s $(ECHO) _$*: .incbin \"$*.spr\" >> $*.s $(AS) -t $(T) -o $@ $(AFLAGS) $*.s $(RM) $*.s $(RM) $*.pal $(RM) $*.spr all = $(target) $(target) : $(objects) $(CL) -t $(T) -o $@ -m Hello.map -C Hello.cfg $(objects) $(libraries) clean : $(TOUCH) $(objects) $(RM) $(objects) $(TOUCH) target $(RM) target ------------------------------------------------------ This Makefile can easily be modified to become a component of a larger framework. Just remove the line all := $(target) And replace it with all: $(objects) $(TOUCH) objlist $(RM) objlist for obj in $(objects); do $(ECHO) ../intro/$$obj >> objlist; done Now the compilation will be as before but instead of linking the stuff together here we just make a list file called "objlist" that can be used for linking later. In the main Makefile you can easily link all subprojects together by: objlists = \ ../resident/objlist \ ../miniloader/objlist \ ../abcmusic/objlist \ ../soundtool/objlist \ ../intro/objlist \ ../password/objlist \ ../chopperx/objlist \ ../parafly/objlist \ ../pontiac/objlist \ ../blackjack/objlist \ ../lsketch/objlist \ ../dicee/objlist \ ../treasure/objlist \ ../music/objlist others = \ @../resident/objlist \ @../miniloader/objlist \ @../abcmusic/objlist \ @../soundtool/objlist \ @../intro/objlist \ @../password/objlist \ @../chopperx/objlist \ @../parafly/objlist \ @../pontiac/objlist \ @../blackjack/objlist \ @../lsketch/objlist \ @../dicee/objlist \ @../treasure/objlist \ @../music/objlist all := $(target) $(target) : $(objlists) $(CL) -t $(T) -o $@ -m Hello.map -C Hello.cfg $(others) $(libraries) ------------------------------------------------ If you are using loadable drivers that you want to link statically then you may need to define the inclusion of the drivers separately at the end of the Makefile. c128-stdjoy.o: $(CP) "$(CC65_INC)/../joy/$*.joy" . $(CO) --code-label _joycode $*.joy $(AS) -t $(T) -o $@ $(AFLAGS) $*.s $(RM) $*.joy $(RM) $*.s c128-160-102-16.o: $(CP) "$(CC65_INC)/../tgi/$*.tgi" . $(CO) --code-label _tgicode $*.tgi $(AS) -t $(T) -o $@ $(AFLAGS) $*.s $(RM) $*.tgi $(RM) $*.s And of course you need to add these objects to the objlist. objects := \ Hello.o \ Text.o \ c128-stdjoy.o \ c128-160-102-16.o -- Regards, Karri ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo@musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.Received on Wed Apr 21 07:15:54 2010
This archive was generated by hypermail 2.1.8 : 2010-04-21 07:15:56 CEST