Make better

As time passes it becomes easier to understand the subtleties of usage and below is an example of a quick way to compile a set of .c sources in a directory using the built-in defined variables. This also uses a flag for Werror, which tells the compiler to make warnings into errors so the code will not compile with warnings. Wall is of course warn for all things. The hash include function of C files for the CPP ( C preprocessor ) is convenient for global search and replace, however it can take that convenience and make code that can't be read or easily understood. The best approach is to make code that is easy to understand for two reasons. If you want others to be able to use it, and when you try to use it for some other purpose next month then you don't have to rewrite everything.

TARGETS = $(filter-out dont_want% ,$(patsubst %.c,%,$(wildcard *.c)))
LDLIBS = -lglut -lm
CC=gcc
CFLAGS=-Wall -Werror

all : $(TARGETS)

 

0 comments:

Contributors

Automated Intelligence

Automated Intelligence
Auftrag der unendlichen LOL katzen