[cc65] Makefiles again

From: MagerValp <MagerValp1cling.gu.se>
Date: 2005-10-11 10:15:47
On my laptop I ran into the same problem with stdint/C99 that I did on
my Mac. Here's a proposed fix that will make the makefiles in src/
inherit CC and CFLAGS from the top level makefile:

First a perl oneliner that removes all occurences of CC = gcc, and
changes -g -O2 -Wall -W into $(CFLAGS).

  perl -i -p -e 's/^CFLAGS\s+= (-g -O2|-O2 -g) -Wall( -W)?/CFLAGS = \$(CFLAGS)/; s/^CC\s*=.*$//;' src/*/make/gcc.mak src/make/gcc.mak src/sim65/chips/make/gcc.mak

Then the patch to make/gcc.mak:

-------------------------------- make/gcc.mak --------------------------------

--- gcc.mak.org	2005-10-11 09:56:06.000000000 +0200
+++ gcc.mak	2005-10-11 10:11:09.000000000 +0200
@@ -29,6 +29,10 @@
 CC65INC		= $(CC65DATA)/include
 CC65LIB		= $(CC65DATA)/lib
 
+# The compiler and flags
+CC		= gcc -std=gnu99
+CFLAGS		= -g -O2 -Wall -W
+
 # Programs
 
 MKDIR		= mkdir -m 755
@@ -51,30 +55,30 @@
 all:	bins libs docs $(SYS:%=samples tests)
 
 bins:
-	@$(MAKE) -C src -f make/gcc.mak
+	@$(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" -C src -f make/gcc.mak
 
 libs:
-	@$(MAKE) -C libsrc
+	@$(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" -C libsrc
 
 # A host system might not have LinuxDoc Tools, so this rule ignores errors.
 docs:
-	-@$(MAKE) -C doc html
+	-@$(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" -C doc html
 
 # Some platforms cannot compile all of the sample and library-test programs.
 # So, these rules ignore errors.
 
 samples:
-	-@$(MAKE) -k -C samples $(SYS:%=SYS=%)
+	-@$(MAKE) -k CC="$(CC)" CFLAGS="$(CFLAGS)" -C samples $(SYS:%=SYS=%)
 
 tests:
-	-@$(MAKE) -k -C testcode/lib $(SYS:%=SYS=%)
+	-@$(MAKE) -k CC="$(CC)" CFLAGS="$(CFLAGS)" -C testcode/lib $(SYS:%=SYS=%)
 
 clean zap:
-	$(MAKE) -C src -f make/gcc.mak $@
-	$(MAKE) -C libsrc $@
-	$(MAKE) -C doc $@
-	$(MAKE) -C samples $@
-	$(MAKE) -C testcode/lib $@ $(SYS:%=SYS=%)
+	$(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" -C src -f make/gcc.mak $@
+	$(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" -C libsrc $@
+	$(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" -C doc $@
+	$(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" -C samples $@
+#	$(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" -C testcode/lib $@ $(SYS:%=SYS=%)
 
 uninstall:	install-test
 	cd $(bindir) && $(RM) ar65 ca65 cc65 cl65 co65 da65 ld65 od65 grc ca65html

-------------------------------- make/gcc.mak --------------------------------


Also, there's no clean target in testcode/lib (actually no makefile at
all):

  make[1]: Entering directory `/cygdrive/c/prog/cc65-2.11.0/testcode/lib'
  make[1]: *** No rule to make target `clean'.  Stop.
  make[1]: Leaving directory `/cygdrive/c/prog/cc65-2.11.0/testcode/lib'
  make: *** [clean] Error 2

I commented out the cleaning of testcode/lib in the makefile patch.

-- 
    ___          .     .  .         .       . +  .         .      o   
  _|___|_   +   .  +     .     +         .  Per Olofsson, arkadspelare
    o-o    .      .     .   o         +          MagerValp@cling.gu.se
     -       +            +    .     http://www.cling.gu.se/~cl3polof/
----------------------------------------------------------------------
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 Oct 11 10:15:54 2005

This archive was generated by hypermail 2.1.8 : 2005-10-11 10:15:56 CEST