[Home]History of MakefileDeMystified

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

Revision 10 . . (edit) July 20, 2011 6:01 am by MichaelHaberler [*note -O0 for debugging]
Revision 9 . . July 5, 2011 10:27 am by MichaelHaberler [*how to pass non-standard compiler and linker flags to Makefile]
Revision 8 . . June 20, 2009 8:43 am by JeffEpler

Difference (from prior major revision) (minor diff, author diff)

Added: 45a46,61

Passing flags to the Makefile

to see actual compilation commands:
make V=1

The default optimizer flag is -Os (optimize for size) which might be inconvenient for debugging as code rearrangement and optimized-out variables
get in the way; to turn off all optimization for easier debugging, call make as 'make OPT=-O0' (disable optimization)

non-standard compiler flags: pass via a DEBUG= argument to make (default is currently = '-g -Wall' - see DEBUG= in src/Makefile?)

non-standard linker flags: pass via a LDFLAGS= argument to make (see LDFLAGS= in src/Makefile?)

for instance, compile and link for gprof profiling, which involves adding '-pg' to compile and link phases:

. scripts/emc-environment
make V=1 DEBUG='-g -Wall -pg' LDFLAGS="-L"$LD_LIBRARY_PATH" -Wl,-rpath,"$LD_LIBRARY_PATH" -pg"

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
Published under a Creative Commons License