This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
makefile [2015/07/30 12:27] pendor created |
makefile [2015/09/04 05:59] (current) pendor [conditional] |
||
|---|---|---|---|
| Line 4: | Line 4: | ||
| main.bin: main.c lib.c2 | main.bin: main.c lib.c2 | ||
| gcc -o main.bin main.c lib.c | gcc -o main.bin main.c lib.c | ||
| + | </code> | ||
| + | |||
| + | ==== conditional ==== | ||
| + | checking the value of a variable | ||
| + | <code> | ||
| + | ifeq ($(PLATFORM),Linux) | ||
| + | CMD = ls -lh | ||
| + | else | ||
| + | CMD = dir | ||
| + | endif | ||
| + | </code> | ||
| + | For just checking eistence of a variable use ''ifdef'' and ''ifndef'' | ||
| + | <code> | ||
| + | ifdef VARNAME | ||
| + | do something | ||
| + | endif | ||
| </code> | </code> | ||