Outline
How to Use Make and Automake Cui Tao
[email protected] The State Key Laboratory of Scientific and Engineering Computing The Institute of Computational Mathematics and Scientific Engineering Computing
April 21, 2005
Cui Tao
[email protected]
make && automake
Outline
Part I: Compile ,Link and Debug Part II: Make and Makefile Part III: Autoconf Automake
Part I: Compile ,Link and Debug Part II: Make and Makefile Part III: Autoconf Automake
Cui Tao
[email protected]
make && automake
Outline
Part I: Compile ,Link and Debug Part II: Make and Makefile Part III: Autoconf Automake
Outline of Part I
1
Compile and Link
2
¥6
3
NÁ
Cui Tao
[email protected]
make && automake
Outline
Part I: Compile ,Link and Debug Part II: Make and Makefile Part III: Autoconf Automake
Outline of Part I
1
Compile and Link
2
¥6
3
NÁ
Cui Tao
[email protected]
make && automake
Outline
Part I: Compile ,Link and Debug Part II: Make and Makefile Part III: Autoconf Automake
Outline of Part I
1
Compile and Link
2
¥6
3
NÁ
Cui Tao
[email protected]
make && automake
Outline
Part I: Compile ,Link and Debug Part II: Make and Makefile Part III: Autoconf Automake
Outline of Part II 4
Makefile{0 o´Makefile? ö{0 Makefile©¶ Makefile¤ Make´XÛó
5
XÛMakefile A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I Cui Tao
[email protected]
make && automake
Outline
Part I: Compile ,Link and Debug Part II: Make and Makefile Part III: Autoconf Automake
Outline of Part II 4
Makefile{0 o´Makefile? ö{0 Makefile©¶ Makefile¤ Make´XÛó
5
XÛMakefile A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I Cui Tao
[email protected]
make && automake
Outline
Part I: Compile ,Link and Debug Part II: Make and Makefile Part III: Autoconf Automake
Outline of Part III
6
Autoconf ÚAutomake {0 {0 A Simple Example ¦^autoconf)¤configure ¦^automake)¤Makefile.in
Cui Tao
[email protected]
make && automake
Compile and Link ¥6 NÁ
Part I Compile ,Link and Debug
Cui Tao
[email protected]
make && automake
Compile and Link ¥6 NÁ
Outline
1
Compile and Link
2
¥6
3
NÁ
Cui Tao
[email protected]
make && automake
Compile and Link ¥6 NÁ
Outline
1
Compile and Link
2
¥6
3
NÁ
Cui Tao
[email protected]
make && automake
Compile and Link ¥6 NÁ
Outline
1
Compile and Link
2
¥6
3
NÁ
Cui Tao
[email protected]
make && automake
Compile and Link ¥6 NÁ
?ÈóL§
ý?n£Pre-Processing¤ Ðm÷ \include餹SN
?È£Compiling¤ ®?£Assembling¤ ó£Linking¤
Cui Tao
[email protected]
make && automake
Compile and Link ¥6 NÁ
?ÈóL§
ý?n£Pre-Processing¤ Ðm÷ \include餹SN
?È£Compiling¤ ®?£Assembling¤ ó£Linking¤
Cui Tao
[email protected]
make && automake
Compile and Link ¥6 NÁ
?ÈóL§
ý?n£Pre-Processing¤ Ðm÷ \include餹SN
?È£Compiling¤ ®?£Assembling¤ ó£Linking¤
Cui Tao
[email protected]
make && automake
Compile and Link ¥6 NÁ
?ÈóL§
ý?n£Pre-Processing¤ Ðm÷ \include餹SN
?È£Compiling¤ ®?£Assembling¤ ó£Linking¤
Cui Tao
[email protected]
make && automake
Compile and Link ¥6 NÁ
?ÈóL§
gcc -E hello.c -o hello.i gcc -c hello.i -o hello.o gcc hello.o -o hello
Cui Tao
[email protected]
make && automake
Compile and Link ¥6 NÁ
1n¼ê¥
Þ©£.h¤Ú¥©£.so½ö.a¤8Ü XÛé¤IÞ©Ú¥©ºº
Cui Tao
[email protected]
make && automake
Compile and Link ¥6 NÁ
XÛ¦^GCC
-I: gcc foo.c -I /home/tcui/include -o foo -L: -l: gcc foo.c -L /home/xiaowp/lib -lfoo -o foo
Cui Tao
[email protected]
make && automake
Compile and Link ¥6 NÁ
XÛ¦^GCC
-I: gcc foo.c -I /home/tcui/include -o foo -L: -l: gcc foo.c -L /home/xiaowp/lib -lfoo -o foo
Cui Tao
[email protected]
make && automake
Compile and Link ¥6 NÁ
Ä¥Ú·¥
Äó¥£Ï~±.so(¤— first choice if without ’-static’ ·ó¥£Ï~±.a(¤
Cui Tao
[email protected]
make && automake
Compile and Link ¥6 NÁ
GDB
GDB´GNUm |uÙrUNIXe§SNÁó ä" 5`§GDBÌa\¤e¡o¡õUµ éÄ\§S§±Uì\g½Â¦%¤$1 §S" 4NÁ§S3\¤½Nä:?Ê4" §SÊ4§±ud\§S¥¤u)¯" ÄUC\§S1¸"
Cui Tao
[email protected]
make && automake
Compile and Link ¥6 NÁ
Example
Example: crash.c #include <stdio.h> int main(void) int input =0; printf(‘‘Input an integer:’’); scanf(‘‘%d’’, input); printf(‘‘The integer you input is %d ’’, input); return 0;
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
Part II Something about Makefile
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
Outline 4
Makefile{0 o´Makefile? ö{0 Makefile©¶ Makefile¤ Make´XÛó
5
XÛMakefile A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
Outline 4
Makefile{0 o´Makefile? ö{0 Makefile©¶ Makefile¤ Make´XÛó
5
XÛMakefile A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
o´Makefile? ö{0 Makefile©¶ Makefile¤ Make´XÛó
o´Makefile?
A makefile details the files, dependencies, and rules by which an executable application is built.
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
o´Makefile? ö{0 Makefile©¶ Makefile¤ Make´XÛó
Richard Stallman m ^+EÚk°§l5vk+LUó]§l5vk¦^ LWindowsöXÚ"ù´¦Ìµhttp://www.stallman.org/
ùpbþܦCìµ
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
o´Makefile? ö{0 Makefile©¶ Makefile¤ Make´XÛó
Roland McGrath
<Ì´µhttp://www.frob.com/ roland/ §e¡´¦
¯,µ Ü? ¿oGNU make" ÚThomas BushnellÓ? GNU Hurd" ?¿oXGNU C library" Ü?¿oXÜ©GNU Emacs"
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
o´Makefile? ö{0 Makefile©¶ Makefile¤ Make´XÛó
Makefile©¶
%@µGNUmakefile, makefile, and Makefile A½µmake -f filename man make
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
o´Makefile? ö{0 Makefile©¶ Makefile¤ Make´XÛó
Makefile¤ w«5K: w«5K`² §XÛ)¤½õ8I© "ù´dMakefileÖö²wѧ)¤©§© 6©§)¤·-" Û©5K: du·makekgÄíõU§¤±Û© 5K±4·'o÷/{Ñ/ÖMakefile§ù´ dmake¤|±" Cþ½Â: 3Makefile¥·½ÂXCþ§Cþ Ñ´iÎG§ùk:Có¥÷§Makefile 1§Ù¥CþѬ*ÐAÚ^ þ" ©«: Ù) nÜ©§´3Makefile¥Ú ^,Makefile§ÒCó¥include¶,´ â, ¹½Makefile¥kÜ©§ÒCó¥ ý?È#if¶kÒ´½Âõ1·-" 5º: Makefile¥k15º§ÚUNIXShell §Ù 5º´^/#0iÎ"XJ\3\Makefile¥¦^ Cui Tao
[email protected] make && automake
Makefile{0 XÛMakefile
o´Makefile? ö{0 Makefile©¶ Makefile¤ Make´XÛó
Ú^Ù§Makefile
3Makefile¦^include'
i±rOMakefile¹?5" include{´µinclude ¡filename¿
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
o´Makefile? ö{0 Makefile©¶ Makefile¤ Make´XÛó
Makeón I
make¬3c8¹eé¶i’makefile’½’Makefile’© " XJ駧¬é©¥A8I"XJmakevk ½§%@é18I" XJ8IØ3§½´8I¤6©©?Um '8I©#§@o§¦Ò¬1 ¡¤½Â·-"
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
o´Makefile? ö{0 Makefile©¶ Makefile¤ Make´XÛó
make1Ú½
Ö\¤kMakefile Ö\includeÙa§Makefile Щz©¥Cþ íÛ©5K§¿©Û¤k5K ¤k8I©Mï6'Xó â6'X§û½= 8I#)¤ 1)¤·-
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
o´Makefile? ö{0 Makefile©¶ Makefile¤ Make´XÛó
make1Ú½
Ö\¤kMakefile Ö\includeÙa§Makefile Щz©¥Cþ íÛ©5K§¿©Û¤k5K ¤k8I©Mï6'Xó â6'X§û½= 8I#)¤ 1)¤·-
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
o´Makefile? ö{0 Makefile©¶ Makefile¤ Make´XÛó
make1Ú½
Ö\¤kMakefile Ö\includeÙa§Makefile Щz©¥Cþ íÛ©5K§¿©Û¤k5K ¤k8I©Mï6'Xó â6'X§û½= 8I#)¤ 1)¤·-
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
o´Makefile? ö{0 Makefile©¶ Makefile¤ Make´XÛó
make1Ú½
Ö\¤kMakefile Ö\includeÙa§Makefile Щz©¥Cþ íÛ©5K§¿©Û¤k5K ¤k8I©Mï6'Xó â6'X§û½= 8I#)¤ 1)¤·-
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
o´Makefile? ö{0 Makefile©¶ Makefile¤ Make´XÛó
make1Ú½
Ö\¤kMakefile Ö\includeÙa§Makefile Щz©¥Cþ íÛ©5K§¿©Û¤k5K ¤k8I©Mï6'Xó â6'X§û½= 8I#)¤ 1)¤·-
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
o´Makefile? ö{0 Makefile©¶ Makefile¤ Make´XÛó
make1Ú½
Ö\¤kMakefile Ö\includeÙa§Makefile Щz©¥Cþ íÛ©5K§¿©Û¤k5K ¤k8I©Mï6'Xó â6'X§û½= 8I#)¤ 1)¤·-
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
o´Makefile? ö{0 Makefile©¶ Makefile¤ Make´XÛó
make1Ú½
Ö\¤kMakefile Ö\includeÙa§Makefile Щz©¥Cþ íÛ©5K§¿©Û¤k5K ¤k8I©Mï6'Xó â6'X§û½= 8I#)¤ 1)¤·-
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
Example I cc = gcc INCLUDE = -I/usr/local/mysql/include/mysql LIBS = -L/usr/local/mysql/lib/mysql CLIENT = -lmysqlclient .PHONY all all: mysqlcli main.o: main.c passwd.h $(cc) $(INCLUDE) -c main.c pro1.o: pro1.c $(cc) $(INCLUDE) -c pro1.c Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
Example II
mysqlcli: main.o pro1.o $(cc) -o mysqlcli main.o pro1.o $(LIBS) $(CLIENT) clean: rm -f main.o pro1.o rm -f mysqlcli
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
5K¥{ target : prerequisites command targetÒ´8I©§±´Object File§±´ 1©"±´I\£Label¤" prerequisitesÒ´§)¤@target¤I©½´8 I" commandÒ´makeI1·-"£?¿Shell· -¤ §J´§3Makefile¥·-§7L± Tab
m©" Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
Example-w«5K edit : main.o kbd.o command.o display.o \ insert.o search.o files.o utils.o cc -o edit main.o kbd.o command.o display.o \ insert.o search.o files.o utils.o main.o : main.c defs.h cc -c main.c kbd.o : kbd.c defs.h command.h cc -c kbd.c command.o : command.c defs.h command.h cc -c command.c display.o : display.c defs.h buffer.h cc -c display.c insert.o : insert.c defs.h buffer.h cc -c insert.c Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
Example(Y)
search.o : search.c defs.h buffer.h cc -c search.c files.o : files.c defs.h buffer.h command.h cc -c files.c utils.o : utils.c defs.h cc -c utils.c clean : rm -f edit main.o kbd.o command.o display.o \ insert.o search.o files.o utils.o
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
o´Û¹5K
/Û¹5K0Ò´«.~§make¬Uìù«/.~0%ì Ø[/5$1"~X§r.c©?Ȥ.o©ù5K§\ ÒØ^Ñ5§make¬gÄíÑù«5K§¿)¤·I .o©"
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
~^Û¹5K ?ÈC§SÛ¹5K: $(CC)t-c $(CPPFLAGS) $(CFLAGS) ?ÈC++§SÛ¹5K: $(CXX) -c $(CPPFLAGS) $(CFLAGS)0" £ïƦ^/.cc0C++ © M§ Ø´ /.C0¤ ?ÈPascal§SÛ¹5: $(PC) t-c $(PFLAGS) ?ÈFortran/Ratfor§SÛ¹5K: /.f0/$(FC) t-c $(FFLAGS) /.F0/$(FC) t-c $(FFLAGS) $(CPPFLAGS)0 /.f0/$(FC) t-c $(FFLAGS) $(RFLAGS)0 ý?nFortran/Ratfor§SÛ¹5K" .. .. .. Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
Û¹5K¥^Cþ
3Û¹5K¥·-¥§ÄþÑ´¦^ ýkC þ"\±3\makefile¥UCù Cþ§½´3make ·-1¥D\ù §½´3\¸Cþ¥ù §ÃØ No§ ù A½Cþ§@oÙÒ¬éÛ¹5Kå ^"
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
Û¹5K¥^Cþ I AR : ar CC : cc CXX : g++ CPP : $(CC) -E FC : f77 PC : pc TEX : tex RM : rm -f CFLAGS : Có?Èìëê CXXFLAGS : C++ó?Èìëê" Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
Û¹5K¥^Cþ II
CPPFLAGS : Cý?nìëê"£C ÚFortran ?Èì¬^ ¤" FFLAGS : Fortranó?Èìëê" LDFLAGS : óìëê"£Xµ/ld0¤ .. .. ..
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
ª5K
¦^ª5K5½ÂÛ¹5K"ª5KÒÐ 5K§´35K¥§8I½ÂIk/%0iÎ" /%0¿g´L«½õ?¿iÎ"
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
ª5K0
ª5K¥§35K8I½Â¥¹/%0§ÄK§Ò ´5K"8I¥/%0½ÂL«é©¶§ /%0L«Ý?¿iÎG"~Xµ /%.c0L«±/.c0(©¶£©¶Ý3¤§
/s.%.c0KL«±/s.0mÞ§/.c0(©¶£©¶ Ý5¤"
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
ª5K«~
%.o : %.c $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
.o.c $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ }
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
5K¥ÏÎ I
make|±n«Ïε/*0§/?0Ú/[.. ..]0"ù´ ÚUnixB-Shell´Ó" clean: rm -f *.o print: *.c lpr -p $? touch print
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
MakefileCþ
3Makefile¥½ÂCþ§Ò´C/C++ó¥÷§¦ L ©iG§3Makefile¥1ÿÙ¬gÄ /Ðm3¤¦^/"
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
Cþ¶
Cþ·¶i±¹iÎ!êi§ey£±´êim Þ¤§ØAT¹k/:0!/#0!/=0½´iΣ! £¤"Cþ´¯a"
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
¸Cþ
make$1XÚ¸Cþ±3makem©$11\ Makefile©¥§´XJMakefile¥®½Â ùCþ§½´ ùCþdmake·-1\§@oXÚ¸CþòC X" XJ·3¸Cþ¥ /CFLAGS0¸Cþ§@o· Ò±3¤kMakefile¥¦^ùCþ "ùéu·¦^Ú ?Èëêk'Ð?"XJMakefile¥½Â
CFLAGS§@oK¬¦^Makefile¥ùCþ§XJvk½ ÂK¦^XÚ¸Cþ§5Ú5Ú§é/ ÛCþ0Ú/ÛÜCþ0A5"
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
gÄzCþI
$@ L«5K¥8I©8"3ª5K¥§XJkõ8I§@ o/$@0Ò´u8I¥ª½Â8Ü"
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
gÄzCþII
$% =8I´¼ê¥©¥§L«5K¥8I¤ ¶"~X§X J8I´/foo.a(bar.o)0§@o§/$%0Ò´/bar.o0§ /$@0Ò´/foo.a0"XJ8IØ´¼ê¥©£Unixe ´[.a]§Windowse´[.lib]¤§@o§Ù"
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
gÄzCþIII
$< 68I¥18I¶i"XJ68I´±ª£= /%0¤½Â§@o/$ <0ò´ÎܪX© 8"5¿§Ù´Ñ5"
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
gÄzCþIV
$? ¤k'8I#68I8Ü"±©
"
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
Cþp?$ I
CþO: $var:a=b rCþ/var0¥¤k±/a0iG/(0/a0O¤ /b0iG"ùp/(0¿g´/0½´/(å Î0 rCþ2¤Cþ x=y y=z a := $($(x))
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
{0
z^5K¥·-ÚöXÚShell·-1´" make¬U^SÅ^1·-§z^·-mÞ7L ±[Tab]
mÞ" make·-%@´//bin/sh0)º1"
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
{0
z^5K¥·-ÚöXÚShell·-1´" make¬U^SÅ^1·-§z^·-mÞ7L ±[Tab]
mÞ" make·-%@´//bin/sh0)º1"
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
{0
z^5K¥·-ÚöXÚShell·-1´" make¬U^SÅ^1·-§z^·-mÞ7L ±[Tab]
mÞ" make·-%@´//bin/sh0)º1"
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
·-1
68I#u8I§Ò´5K8II# §make¬^^1Ù ·-"I5¿´§XJ \4þ^·-(JA^3e^·-§\AT¦^©Ò ©
ùü^·-"
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
Example I
«~µ exec: cd /home/hchen pwd «~µ exec: cd /home/hchen; pwd
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
·-Ñ
z·-$1 §make¬uÿz·-£è§XJ·£¤õ§@omake¬1e^·-§5K¥¤k·¤õ£ §ù5KÒ´¤õ¤ "XJ5K¥, ·-Ñ £·-òÑè"¤§@omakeÒ¬ª1 c5K§ùòkUª¤k5K1" XÛÑ·-Ñ??? 3·-c\þ/- 0
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
·-Ñ
z·-$1 §make¬uÿz·-£è§XJ·£¤õ§@omake¬1e^·-§5K¥¤k·¤õ£ §ù5KÒ´¤õ¤ "XJ5K¥, ·-Ñ £·-òÑè"¤§@omakeÒ¬ª1 c5K§ùòkUª¤k5K1" XÛÑ·-Ñ??? 3·-c\þ/- 0
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
·-Ñ
z·-$1 §make¬uÿz·-£è§XJ·£¤õ§@omake¬1e^·-§5K¥¤k·¤õ£ §ù5KÒ´¤õ¤ "XJ5K¥, ·-Ñ £·-òÑè"¤§@omakeÒ¬ª1 c5K§ùòkUª¤k5K1" XÛÑ·-Ñ??? 3·-c\þ/- 0
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
o´8I?
"/8I0¿Ø´©§´I\§du/8I0 Ø´©§¤±makeÃ{)¤§6'XÚû½§´Ä 1"·kÏLw«/²ù/8I0âU4Ù)" ,§/8I0¶ØUÚ©¶¶§Ø,ÙÒ / 8I0¿Â " ~Xµ clean: rm *.o temp
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
8I(²
;Ú©¶ù«¹§·±¦^AÏIP /.PHONY0 .PHONY: clean clean: rm *.o temp
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
8I6© I 8Ivk6©"´§·±8I½¤ 6©"~Xµ all : prog1 prog2 prog3 .PHONY : all prog1 cc -o prog2 cc -o prog3 cc -o
: prog1.o utils.o prog1 prog1.o utils.o : prog2.o prog2 prog2.o : prog3.o sort.o utils.o prog3 prog3.o sort.o utils.o
Cui Tao
[email protected]
make && automake
Makefile{0 XÛMakefile
A Simple Example Makefile5K MakefileCþ Makefile·Makefile8I
8I6© II
Makefile¥18I¬Ù%@8I"·(² /all08I§Ù6uÙ§n8I"du8IA5 ´§o´1§¤±Ù6@n8IÒo´ØX/all0 ù8I#"¤±§Ù§n8I5Ko´¬ûÆ"Ò ·í)¤õ8I8"
Cui Tao
[email protected]
make && automake
Autoconf ÚAutomake {0
Part III Autoconf Automake
Cui Tao
[email protected]
make && automake
Autoconf ÚAutomake {0
Outline
6
Autoconf ÚAutomake {0 {0 A Simple Example ¦^autoconf)¤configure ¦^automake)¤Makefile.in
Cui Tao
[email protected]
make && automake
Autoconf ÚAutomake {0
{0 A Simple Example ¦^autoconf)¤configure ¦^automake)¤Makefile.in
{0
Autoconf´^u)¤±gÄ/^ è±·Aõ «UnixaXÚshell óä"Autoconf)¤ Ï~ ¡configure"Automake´±^ugÄ)¤Makefile.in© óä"
Cui Tao
[email protected]
make && automake
Autoconf ÚAutomake {0
{0 A Simple Example ¦^autoconf)¤configure ¦^automake)¤Makefile.in
Cui Tao
[email protected]
make && automake
6§
Autoconf ÚAutomake {0
{0 A Simple Example ¦^autoconf)¤configure ¦^automake)¤Makefile.in
{ü~f I Hello.c autoscan : )¤configure.scan configure.scan >>> configure.in # -*- Autoconf -*# Process this file with autoconf to produce a # configure script. AC_PREREQ(2.59) AC_INIT(HH, 1.0,
[email protected]) AM_INIT_AUTOMAKE(hello,1.0) AC_CONFIG_SRCDIR([hello.c]) # Checks for programs. Cui Tao
[email protected]
make && automake
Autoconf ÚAutomake {0
{0 A Simple Example ¦^autoconf)¤configure ¦^automake)¤Makefile.in
{ü~f II AC_PROG_CC # Checks for libraries. # Checks for header files. # Checks for typedefs, structures, and compiler # characteristics. # Checks for library functions. AC_OUTPUT(Makefile) aclocal : )¤aclocal.m4 autoconf: )¤configure Cui Tao
[email protected]
make && automake
Autoconf ÚAutomake {0
{0 A Simple Example ¦^autoconf)¤configure ¦^automake)¤Makefile.in
{ü~f III
MïMakefile.am AUTOMAKE_OPTIONS=foreign bin_PROGRAMS=hello hello_SOURCES=hello.c automake :)¤Makefile.in
Cui Tao
[email protected]
make && automake
Autoconf ÚAutomake {0
{0 A Simple Example ¦^autoconf)¤configure ¦^automake)¤Makefile.in
Mïconfigure.in I ¦^autoscan·-)¤configure.scan", Ãó?U ¤configure.in"configure.in¥~^÷k: AC INIT AM INIT AUTOMAKE(PACKAGE,VERSION) AC CONFIG HEADER (header-to-create): ^¦^ Þ© AC OUTPUT COMMANDS (extra-cmds [, init-cmds]) AC PREFIX DEFAULT(prefix) AC PREFIX PROGRAM(program) AC PREREQ(version) : +nÒ§(v # Autoconf Cui Tao
[email protected]
make && automake
Autoconf ÚAutomake {0
{0 A Simple Example ¦^autoconf)¤configure ¦^automake)¤Makefile.in
Mïconfigure.in II AC PROG AWK : U^Sémawk!gawk!nawkÚawk§ ¿
rÑÑCþAWK ¤1é§S¶"Ä kÏémawk´Ïâ`§´¯¢y" AC PROG CC : (½C?Èì"XJ3¸¥vk ½CC§Òégcc§XJvké§Ò¦^cc"rÑÑC þCCé?Èì¶i" AC PROG CXX AC PROG F77 AC CHECK FILES(files[, action-if-found [, action-if-not-found]]) z3files¥Ñ©$1AC CHECK FILE"
Cui Tao
[email protected]
make && automake
Autoconf ÚAutomake {0
{0 A Simple Example ¦^autoconf)¤configure ¦^automake)¤Makefile.in
Mïconfigure.in III AC CHECK LIB(library,function[,action-if-found[,action-if-notfound[,other-libraries]]]) 6ucó£ëéóÀJ¤§ÁãÏLu ÿÁ§S´Ä±Ú¥library?1ë±¼C!C++½ öFortran 77¼êfunction§l (@¼êfunction ´±¦ ^"library´¥Ä¶i¶~X§ u’-lmp’§Ò r’mp’ëêlibrary" action-if-found´3¥¤õ/?1 ëÿ$1 shell·-L¶action-if-not-found´3¥ë }ÿ$1shell·-L"XJvk Ñaction-if-found§"ÄÒ´r’-llibrary’V\ LIBS¥§¿
½Â‘HAVE LIBlibrary’£¿ ܦ^i 1¤" Cui Tao
[email protected]
make && automake
Autoconf ÚAutomake {0
{0 A Simple Example ¦^autoconf)¤configure ¦^automake)¤Makefile.in
Mïconfigure.in IV
.. .. .. .. .. .. AC OUTPUT(filename)
Cui Tao
[email protected]
make && automake
Autoconf ÚAutomake {0
{0 A Simple Example ¦^autoconf)¤configure ¦^automake)¤Makefile.in
Mïconfigure I
aclocal : )aclocal.m4 autoconf: )configure
Cui Tao
[email protected]
make && automake
Autoconf ÚAutomake {0
{0 A Simple Example ¦^autoconf)¤configure ¦^automake)¤Makefile.in
¦^automake)¤Makefile.in I
)¤Makefile.am automake –add-missing –add-missing : wautomake·\\u1^¤ 7aquinstallóä"
Cui Tao
[email protected]
make && automake
Autoconf ÚAutomake {0
{0 A Simple Example ¦^autoconf)¤configure ¦^automake)¤Makefile.in
Makefile.am I
AUTOMAKE OPTIONS ½automake À"Automake Ì´ÏmuGNU ^ N< o^N@§¤±31automake §¬u 8¹e´Ä3IOGNU ^N@¥Aä© Y§ ~X’NEWS’!’AUTHOR’!’ChangeLog’ © " ¤foreign §automake ¬U^^N@IO5u " bin PROGRAMS ½Â·¤)1 ¶"XJ)õ1 § z ¶^xi
m"
Cui Tao
[email protected]
make && automake
Autoconf ÚAutomake {0
{0 A Simple Example ¦^autoconf)¤configure ¦^automake)¤Makefile.in
Makefile.am II
hello SOURCES ½Â’hello’ ù1 ¤I© "XJ’hello’ ù§ ª´dõ© ¤)§7Lr§¤^© ÑÑ 5§±xi
m"b’hello’ ù§ªI ’hello.c’!’main.c’!’hello.h’ n Y{§K½ Âhello SOURCES= hello.c main.c hello.h XJ·½Âõ 1 §Kéz1 ѽÂé filename SOURCES"
Cui Tao
[email protected]
make && automake
Autoconf ÚAutomake {0
{0 A Simple Example ¦^autoconf)¤configure ¦^automake)¤Makefile.in
¦^Makefile I
make all )·½8I§=d~¥1 "make ±§d¬m©?È©è§,àë(§¿
)1 " make clean Øc¤?È1 98 (object file, *.o)" make distclean Ø Ø1 Ú8 §rconfigure ¤) MakefileØK"
Cui Tao
[email protected]
make && automake
Autoconf ÚAutomake {0
{0 A Simple Example ¦^autoconf)¤configure ¦^automake)¤Makefile.in
¦^Makefile II make install ò§ªSCXÚ¥"XJ©è?ÈÃا
1(J (§B±r§ªSCXÚý1 ´»"XJ ·^bin PROGRAMS ã8{§§ª¬SC /usr/local/bin ù8¹" make dist ò§ªÚ' YC¤Ø ±øÑ Â(distribution) "138¹e¬) ±PACKAGE-VERSION.tar.gz ¶¡ Y"PACKAGE ÚVERSION ùüCê´âconfigure.in ¥AM INIT AUTOMAKE(PACKAGE, VERSION) ½Â"
Cui Tao
[email protected]
make && automake
Autoconf ÚAutomake {0
{0 A Simple Example ¦^autoconf)¤configure ¦^automake)¤Makefile.in
¦^Makefile III
make distcheck Úmake dist aq§´\\uCàØ ´Ä ~"ù8IØ r§ªÚ' YC¤tar.gz § ¬gÄrùØ )m§1configure§¿
?1make all ħ(@?ÈÃØ৬w«ùtar.gz ®²O ÐøÑ "ùu~k^§uL'@§Ä þ±?ÛäGNU uи<#?È"
Cui Tao
[email protected]
make && automake
Autoconf ÚAutomake {0
{0 A Simple Example ¦^autoconf)¤configure ¦^automake)¤Makefile.in
Thanks! '© 3http : //lsec.cc.ac.cn/ v tcui e1
Cui Tao
[email protected]
make && automake