LeTigre
LeTigre

Reputation: 460

how to change default behavior of make

heyho,

I want to change the default behavior of "make".
I want it to run the following commands when compiling a c file:

clang file.c -std=c99 -Wall -Werror -fcolor-diagnostics -lcs50 -lm

is there a "nooby" way to do so?

thx in advance,

tom


if searched the forums and tried google - nothing came up. but chances are, that i did not know what exactly to search for... so if this is answered somwhere else, I'm realy sry...

Upvotes: 1

Views: 383

Answers (1)

rici
rici

Reputation: 241721

Put this into your bash start-up script:

export CC=clang CFLAGS="-std=c99 -Wall -Werror -fcolor-diagnostics" LDLIBS="-lcs50 -lm"

Better is to put these lines in your Makefile (for simple cases, you don't need anything more, but you probably want to add dependency lines):

CC=clang
CFLAGS=-std=c99 -Wall -Werror -fcolor-diagnostics
LDLIBS=-lcs50 -lm

Even better is to create a proper Makefile, but the above will get you started.

You can create a Makefile with any text editor. make looks in the current directory for the Makefile (which is usually called Makefile but it can also be called makefile). Just put it in the same directory as the C program.

Upvotes: 2

Related Questions