Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
programming:makefiles [2007/12/16 23:44] 127.0.0.1 external edit |
programming:makefiles [2010/03/26 14:15] cyril |
||
---|---|---|---|
Line 2: | Line 2: | ||
Makefiles are very useful to automate compilation of multi-file projects in c/c++ with Linux. | Makefiles are very useful to automate compilation of multi-file projects in c/c++ with Linux. | ||
+ | |||
+ | ===== Syntax ===== | ||
+ | * variables: | ||
+ | < | ||
+ | < | ||
+ | $(< | ||
+ | </ | ||
+ | |||
+ | * targets: | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | * template targets: | ||
+ | < | ||
+ | %.o:%.cpp | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | * automatic variables ([[http:// | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | * functions ([[http:// | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | * **Mini Example** | ||
+ | < | ||
+ | COMPILO=g++ | ||
+ | SRCSCPP = $(wildcard src/*.cpp) | ||
+ | OBJS = $(patsubst %.cpp, | ||
+ | prog: $(OBJS) | ||
+ | $(COMPILO) -o build/$@ $(OBJS) | ||
+ | build/ | ||
+ | $(COMPILO) -c -o $@ $^ | ||
+ | </ | ||
+ | |||
===== Example ===== | ===== Example ===== | ||
Line 56: | Line 97: | ||
$(COMPILO) $(FLAGS) $(INCLUDE) -o file2.o file2.cpp | $(COMPILO) $(FLAGS) $(INCLUDE) -o file2.o file2.cpp | ||
</ | </ | ||
+ | |||
===== pkg-config ===== | ===== pkg-config ===== |