user40341
user40341

Reputation: 85

What is this Makefile Doing?

I'm new using makefiles and I have some makefiles. One of them has these statements I tried to understand but I can't.

What is this makefile doing?

# 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

Answers (3)

Dave Costa
Dave Costa

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

Alan
Alan

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

Geo
Geo

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

Related Questions