kzidane
kzidane

Reputation: 763

How to Change the Default Command That make Executes?

By default, when running make to compile a C source code file named prog.c

make prog

the default command that executes is

cc     prog.c   -o prog

Sometimes I really need to include some additional flags. I know that when there are no Makefiles, make relies on some environment variables.

On Ubuntu 14.04, how to configure these variables to change the command that gets executed by default?

Step by step answers will be appreciated!

Upvotes: 1

Views: 375

Answers (1)

Etan Reisner
Etan Reisner

Reputation: 80931

When no makefile is present (or no rule exists in that makefile) make relies on a default built-in database of rules. Run make -p to get make to spit out all the rules it knows about (in the no makefile case that will be the default ones).

When you look at that list you will find a pattern rule for building C source into object files or executables. Those rules have variables in them (like CFLAGS, LDFLAGS, etc.) that can be used to control exactly what you are trying to. That's why they are there (and are why that default command has such funny spacing, in case you ever wondered about that).

Upvotes: 1

Related Questions