From 5bcafa2b6d4611193a92c1c31f6e45531769024d Mon Sep 17 00:00:00 2001 From: Michael Hayes Date: Sat, 27 Aug 2011 11:34:21 +0000 Subject: [PATCH] Add -cc and --cflags options --- etc/Makefile | 6 +++--- etc/Makefile.template | 2 +- etc/makemake.py | 20 ++++++++++++++++---- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/etc/Makefile b/etc/Makefile index b5d6af4..4bee0f0 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -33,11 +33,11 @@ testmakefiles: $(TESTMAKEFILES) appmakefiles: $(APPMAKEFILES) ../%/Makefile.test: Makefile.test.template Makefile - (cd $(dir $@); ../../etc/makemake.py --relpath --objext=-test.o --template ../../etc/Makefile.test.template . . ../../utils ../../drivers ../../drivers/test > Makefile.test) + (cd $(dir $@); ../../etc/makemake.py --cc="gcc" --cflags="" --relpath --objext=-test.o --template ../../etc/Makefile.test.template . . ../../utils ../../drivers ../../drivers/test > Makefile.test) ../%/Makefile: Makefile.template Makefile makemake.py - (cd $(dir $@); ../../etc/makemake.py --relpath --template ../../etc/Makefile.template . . ../../utils ../../fonts ../../drivers ../../drivers/avr > Makefile) + (cd $(dir $@); ../../etc/makemake.py --cc="avr-gcc" --cflags="-Os -mmcu=atmega32u2" --relpath --template ../../etc/Makefile.template . . ../../utils ../../fonts ../../drivers ../../drivers/avr > Makefile) appfiledeps: $(APPFILEDEPS) @@ -69,7 +69,7 @@ appcallgraph: $(APPCALLGRAPH) (cd $(dir $@); ../../etc/makemake.py --relpath --modules . . ../../drivers ../../drivers/avr ../../utils --exclude system > modules.d) ../%/callgraph.d: ../%/Makefile - (cd $(dir $@); ../../etc/makemake.py --relpath --calls . . ../../drivers ../../drivers/avr ../../utils --exclude system > callgraph.d) + (cd $(dir $@); ../../etc/makemake.py --cc="avr-gcc" --cflags="-Os -mmcu=atmega32u2" --relpath --calls . . ../../drivers ../../drivers/avr ../../utils --exclude system > callgraph.d) # Compile all the applications. diff --git a/etc/Makefile.template b/etc/Makefile.template index 4fa959c..fd38cb4 100644 --- a/etc/Makefile.template +++ b/etc/Makefile.template @@ -4,7 +4,7 @@ # Descr: Makefile for @PROJECT@ # Definitions. -CC = avr-gcc +CC = @CC@ CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g @INCLUDES@ OBJCOPY = avr-objcopy SIZE = avr-size diff --git a/etc/makemake.py b/etc/makemake.py index 30e59fe..f8ef0c8 100755 --- a/etc/makemake.py +++ b/etc/makemake.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -"""makemake V0.03 +"""makemake V0.04 Copyright (c) 2010 Michael P. Hayes, UC ECE, NZ This program tries to make a Makefile from a template. Given a C file @@ -27,6 +27,8 @@ The --modules option also needs fixing. FIXME! There are special strings that are replaced in the template file: @PROJECT@ Project name @VPATH@ List of source directories + @CC@ Compiler name + @CFLAGS@ Compiler flags @INCLUDES@ List of include directories each prefixed by -I @SRC@ List of source files @OBJ@ List of object files @@ -157,6 +159,8 @@ def makefile_print (options, template, maincfilename, filedeps, text = re.sub (r'@PROJECT@', project, text) text = re.sub (r'@VPATH@', vpath, text) + text = re.sub (r'@CC@', options.cc, text) + text = re.sub (r'@CFLAGS@', options.cflags, text) text = re.sub (r'@INCLUDES@', includes, text) text = re.sub (r'@SRC@', src, text) @@ -386,6 +390,14 @@ def main(argv = None): default = '.out', help = 'executable file extension') + parser.add_option('--cc', dest = 'cc', + default = 'gcc', + help = 'compiler name') + + parser.add_option('--cflags', dest = 'cflags', + default = '', + help = 'CFLAGS') + parser.add_option('--relpath', action = 'store_true', dest = 'relpath', default = False, help = 'use relative paths') @@ -440,9 +452,9 @@ def main(argv = None): print >> sys.stderr, 'Found C file ' + maincfilename includes = '-I' + ' -I'.join (search_list) - cflags = '-mmcu=atmega32u2' - opts = '-Os' - gcc = 'avr-gcc' + ' ' + cflags + ' ' + opts + ' ' + includes + gcc = options.cc + ' ' + options.cflags + ' ' + includes + + print >> sys.stderr, gcc # Search main c file looking for header files included with #include # and any header files included by the header files