背景:
原来知道条件编程这回事,但从来没用过.现在需要了,而且要从Makefile获取宏.感觉不错,做以下记录.
正文:
Macro condition compile
1. macro check in source code
e.g. main.c
#ifdef MACRO1
#include "header1.h"
#endif
#ifdef MACRO2
#indlcude "header2.h"
#endif
2. send macro by Makefile
include Makefile.in
gcc -D $MAC -o $OBJ $SRC #-D means define a macro
3. define macro in Makefile.in
MAC="MACRO1"
4. generate Makefile.in
write a bash or perl script to generate a fit Makefile.in file(multiple macros), in general this script
is named configure and is executable.
阅读(622) | 评论(0) | 转发(0) |