$(SHARED_LIBS:%.so=%.d): %.d: %.c
@-$(CC) -M -MG $(CFLAGS) $< | \
sed -e 's@^.*\.o:@$*.d $*_sh.o:@' > $@
Q. What doest this mean? $(SHARED_LIBS:%.so=%.d)
Q. What does here two colon mean?
-------------------------------------------------------
Makefile Rule Format:
In general, a rule looks like this:
targets : prerequisites
command
...
or like this:
targets : prerequisites ; command
command
-------------------------------------------------------
Another similar parts.
$(SHARED_LIBS): %.so : %_sh.o
$(CC) -shared $(EXT_LDFLAGS) -o $@ $<
$(SHARED_SE_LIBS:%.so=%.d): %.d: %.c
@-$(CC) -M -MG $(CFLAGS) $< | \
sed -e 's@^.*\.o:@$*.d $*_sh.o:@' > $@
$(SHARED_SE_LIBS): %.so : %_sh.o
$(LD) -shared $(EXT_LDFLAGS) -o $@ $< $(LDLIBS)
This area is my sharing area. Include some technical/believing/life experiences. Hope you can enjoy with me. God bless you. :)
2008年12月7日 星期日
2007年3月20日 星期二
Understand the Linux Makefile system
Makefile 的組成 (compoments)
1. explicit rules
2. implicit rules
3. variable definitions
4. directives
5. comments
1. 利用 origin function 可以知道某一個變數是從何處來的
Example:
ifdef V
ifeq ("$(origin V)", "command line")
The result of this function is a string telling you how the variable variable was defined:
`undefined'
if variable was never defined.
`default'
if variable has a default definition, as is usual with CC and so on. See Variables Used by Implicit Rules. Note that if you have redefined a default variable, the origin function will return the origin of the later definition.
`environment'
if variable was defined as an environment variable and the `-e' option is not turned on (see Summary of Options).
`environment override'
if variable was defined as an environment variable and the `-e' option is turned on (see Summary of Options).
`file'
if variable was defined in a makefile.
`command line'
if variable was defined on the command line.
`override'
if variable was defined with an override directive in a makefile (see The override Directive).
`automatic'
if variable is an automatic variable defined for the execution of the commands for each rule (see Automatic Variables).
1. explicit rules
2. implicit rules
3. variable definitions
4. directives
5. comments
1. 利用 origin function 可以知道某一個變數是從何處來的
Example:
ifdef V
ifeq ("$(origin V)", "command line")
The result of this function is a string telling you how the variable variable was defined:
`undefined'
if variable was never defined.
`default'
if variable has a default definition, as is usual with CC and so on. See Variables Used by Implicit Rules. Note that if you have redefined a default variable, the origin function will return the origin of the later definition.
`environment'
if variable was defined as an environment variable and the `-e' option is not turned on (see Summary of Options).
`environment override'
if variable was defined as an environment variable and the `-e' option is turned on (see Summary of Options).
`file'
if variable was defined in a makefile.
`command line'
if variable was defined on the command line.
`override'
if variable was defined with an override directive in a makefile (see The override Directive).
`automatic'
if variable is an automatic variable defined for the execution of the commands for each rule (see Automatic Variables).
訂閱:
文章 (Atom)