-2

I have some project with alot of files and i want to compile them all with -Wall,
how can I do it on linux, without changing makefile.

make -Wall 

doesn't help.

Any help appreciated.

Laser
  • 6,652
  • 8
  • 54
  • 85
  • 2
    It depends on how the makefile is written - there is not necessarily a way to do this - definitely not a general way for all cases. Give th emakefile and we might be able to help but it would be better if you could learn the makefile syntax an suggest ways that we can correct when it does not work. – mmmmmm Feb 13 '13 at 18:18
  • This question might help for editing the makefile: http://stackoverflow.com/questions/2826029/passing-additional-variables-from-command-line-to-make – ajp15243 Feb 13 '13 at 18:21

1 Answers1

2

You might be able to do something like

make CC='gcc -Wall' CXX='g++ -Wall'

which will tell make to use 'gcc -Wall' as the C compiler and g++ -Wall as the C++ compiler

This assumes all the sources are C and C++ and that the makefile uses the CC and CXX variables, and that it uses GCC as the compiler, and probably several other assumptions.

Typically compilation flags are stored in make variables such as CFLAGS and CXXFLAGS but if you override them you might replace existing options that are necessary for correct operation, so adding options to CC and/or CXX is sometimes safer.

Jonathan Wakely
  • 166,810
  • 27
  • 341
  • 521
  • Can i anyhow do not change options, i mean only add? – Laser Feb 13 '13 at 18:39
  • Sorry, I don't understand the question. There is no way to add to existing variables on the command line, you can only override them. To add to the options you must edit the makefile – Jonathan Wakely Feb 13 '13 at 18:50