I'm having a problem using conditional target-specific variables in what I
thought was a relatively simple and obvious way.
I've condensed the problem down to this trivial example:
#---------  Makefile ---------
CFLAGS = -c -DF_CPU=$(AVR_FREQ)

foo.o:  AVR_FREQ ?= 16000000
#-------- End of Makefile ------

On various flavors of linux (I tested on ubuntu12, it's also be reported on
Suse), attempting to specify the variable on the Make command line results
in the expansion containing "random" characters (sometimes blank, sometimes
non-printable garbage characters.)  Just like "make AVR_FREQ=1000 foo.o"

On MacOSX it works fine.  I've attached two log files.  (Make 3.81 on both,
BTW.)

Any ideas what could be wrong?  There are a couple of bugs reported against
target-specific variables, but they're more complex situations and I can't
tell whether they are the same thing (and why does it work on MacOS?)

Any idea for a workaround that will accomplish the same thing?  (for make
3.81; that what the target audience has got.)
(the idea is that there are several targets with different default values
of AVR_FREQ, but each could be overridden from the command line.)

Thanks
WestfW
Script started on Sat Jun 21 21:04:08 2014
BillW-MacOSX-2<4977> uname -a
Darwin BillW-MacOSX-2.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 
16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64
BillW-MacOSX-2<4978> make --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
BillW-MacOSX-2<4979> rm foo.c
BillW-MacOSX-2<4981> touch foo.c

BillW-MacOSX-2<4982> cat Makefile
CFLAGS = -c -DF_CPU=$(AVR_FREQ)

foo.o:  AVR_FREQ ?= 16000000
BillW-MacOSX-2<4983> make foo.o
cc -c -DF_CPU=16000000   -c -o foo.o foo.c

BillW-MacOSX-2<4984> rm foo.o
BillW-MacOSX-2<4985> make foo.o AVR_FREQ=1000
cc -c -DF_CPU=1000   -c -o foo.o foo.c
BillW-MacOSX-2<4986> exit

Script done on Sat Jun 21 21:05:00 2014
Script started on Sat 21 Jun 2014 09:05:42 PM PDT
billw@VB-Ubuntu:~/tmp$ uname -a
Linux VB-Ubuntu 3.2.0-64-generic #97-Ubuntu SMP Wed Jun 4 22:03:48 UTC 2014 
i686 i686 i386 GNU/Linux
billw@VB-Ubuntu:~/tmp$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.4 LTS
Release:        12.04
Codename:       precise
billw@VB-Ubuntu:~/tmp$ make --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i686-pc-linux-gnu
billw@VB-Ubuntu:~/tmp$ rm foo.c
billw@VB-Ubuntu:~/tmp$ touch foo.c
billw@VB-Ubuntu:~/tmp$ cat Makefile
CFLAGS = -c -DF_CPU=$(AVR_FREQ)

foo.o:  AVR_FREQ ?= 16000000
billw@VB-Ubuntu:~/tmp$ make foo.o
cc -c -DF_CPU=16000000   -c -o foo.o foo.c

billw@VB-Ubuntu:~/tmp$ rm foo.o
billw@VB-Ubuntu:~/tmp$ make AVR_FREQ=1000 foo.o
cc -c -DF_CPU=Hñ          -c -o foo.o foo.c
billw@VB-Ubuntu:~/tmp$ exit

Script done on Sat 21 Jun 2014 09:06:50 PM PDT
_______________________________________________
Help-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to