Reputation: 85
I'm new using makefiles and I have some makefiles. One of them has these statements I tried to understand but I can't.
# debugging support
ifeq ($(DEBUG), true)
CFLAGS+=-DDEBUG -g
endif
ifeq ($(DEBUG), gdb)
CFLAGS+=-g
endif
ifeq ($(PROFILING), true)
CFLAGS+=-p
endif
# symbolic names debugging
ifeq ($(DEBUG_NAMES), true)
CFLAGS+=-DDEBUG_NAMES
endif
# architecture TODO: add others
ifeq ($(ARCH), unix)
CFLAGS+=-DUNIX
endif
# TODO: GC settings
ifeq ($(HEAP), malloc)
CFLAGS+=-DHEAP_MALLOC
endif
ifeq ($(STACK), malloc)
CFLAGS+=-DSTACK_MALLOC
endif
# class loading method
ifeq ($(CLASS), external)
CFLAGS+=-DEXTERNAL_TUK
endif
# monitor allocation
ifeq ($(MONITORS), ondemand)
CFLAGS+=-DON_DEMAND_MONITORS
endif
Amri
Upvotes: 3
Views: 1860
Reputation: 48111
CFLAGS is a string of arguments that will be passed to the C compiler when it is called.
If you don't know what the arguments mean, you need to look at the help for your C compiler. For example:
man cc
man gcc
cc --help
gcc --help
Upvotes: 2
Reputation: 46813
Essentially the makefile is doing a bunch of checks and adding compiler flags based on the state of certain variables. For instance:
ifeq ($(DEBUG), true)
CFLAGS+=-DDEBUG -g
endif
If the DEBUG variable $(DEBUG) is set to true, then define the macro DEBUG, and set the compiler to output debug binaries (-g).
Every other statement is roughly the same pattern.
Upvotes: 6
Reputation: 96767
This checks for the values of environmental variables and configures the build process with specific options for the compiler ( I think ) .
Upvotes: 5