Makefile Notes

A quick guide on Makefile variables

1.Variables

Reference: https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html

One quick example

main: dependency1.o dependency2.o

$(CC) $^ -o $@ $(LDFLAGS)

using $^ (all prerequistes, in this case dependency1.o and dependency2.o)

$@ (target, in this case “main”)

 

2.Set flags

ifeq ($(DEBUG), 1)

else

endif

make DEBUG=1

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s