Author Topic: How to pass parameter to makefile ?  (Read 14615 times)

Offline comsytec

  • Multiple posting newcomer
  • *
  • Posts: 58
    • www.comsytec.com
How to pass parameter to makefile ?
« on: September 03, 2013, 11:40:23 am »
I want use makefile for building of project but need to pass additional parameters. Of course I could change the makefile. This is the easiest way but pretty solution would be to set custom variable.

Makefile invocation
$make -f $makefile $target $USE_OPT

$USE_OPT is the custom variable

its value

USE_OPT="-gdwarf-2 -falign-function=16"

but when executed C::B adds some additional quotation which is not accepted by make tool


Code
-------------- Build: all in chibios-f3d (compiler: STM32 GCC Compiler)---------------

Running command: make.exe -f Makefile all "USE_OPT="-gdwarf-2 -falign-function=16""
make: align-function=16: No such file or directory
make: *** No rule to make target `align-function=16'.  Stop.
Process terminated with status 2 (0 minutes, 0 seconds)
0 errors, 0 warnings (0 minutes, 0 seconds)

Second parameter is not recognized because of these quotes.
Some workaround to suppress these quotes ?




Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7256
Re: How to pass parameter to makefile ?
« Reply #1 on: September 03, 2013, 12:39:37 pm »
Which version of C::B do you use ?
I  just tested it on windows (latest nightly) and it works as epxected.
When adding the custom variable, C::B asks me whether I want to quote it, because it contains strange characters, after clicking "Leave unquoted",the log shows the correct commandline (only the original quotes, that are parts of the variable).

Offline comsytec

  • Multiple posting newcomer
  • *
  • Posts: 58
    • www.comsytec.com
Re: How to pass parameter to makefile ?
« Reply #2 on: September 03, 2013, 12:59:23 pm »
release 12.11

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7256
Re: How to pass parameter to makefile ?
« Reply #3 on: September 03, 2013, 01:16:41 pm »
I also tested it in 12.11 .

Here is a possible workaround:
It seems to work when I add double-doublequotes around the variable, so the build log with a dummy empty Makefile shows:

Code
-------------- Build: Release in test (compiler: GNU GCC Compiler)---------------

Running command: mingw32-make.exe -f Makefile ""USE_OPTS="-gdwarf-2 -falign-function=16"""
mingw32-make.exe: *** No targets.  Stop.
Process terminated with status 2 (0 minutes, 0 seconds)
0 errors, 0 warnings (0 minutes, 0 seconds)

The variable is:
Code
""USE_OPTS="-gdwarf-2 -falign-function=16"""
.

A little hacky, but it still works in actual nightly.