¡¡¡¡
¡¡¡¡×÷ΪLinuxϵijÌÐò¿ª·¢ÈËÔ±£¬´ó¼ÒÒ»¶¨¶¼Óöµ½¹ýMakefile£¬ÓÃmakeÃüÁîÀ´±àÒë×Ô¼ºÐ´µÄ³ÌÐòȷʵÊǺܷ½±ã¡£Ò»°ãÇé¿öÏ£¬´ó¼Ò¶¼ÊÇÊÖ¹¤Ð´Ò»¸ö¼òµ¥Makefile£¬Èç¹ûÒªÏëд³öÒ»¸ö·ûºÏ×ÔÓÉÈí¼þ¹ßÀýµÄMakefile¾Í²»ÄÇôÈÝÒ×ÁË¡£
¡¡¡¡ÔÚ±¾ÎÄÖУ¬½«¸ø´ó¼Ò½éÉÜÈçºÎʹÓÃautoconfºÍautomakeÁ½¸ö¹¤¾ßÀ´°ïÖúÎÒÃÇ×Ô¶¯µØÉú³É·ûºÏ×ÔÓÉÈí¼þ¹ßÀýµÄMakefile£¬ÕâÑù¾Í¿ÉÒÔÏó³£¼ûµÄGNU³ÌÐòÒ»Ñù£¬Ö»ÒªÊ¹Óá°./configure¡±£¬¡°make¡±£¬¡°make instal¡±¾Í¿ÉÒ԰ѳÌÐò°²×°µ½LinuxϵͳÖÐÈ¥ÁË¡£Õ⽫ÌرðÊʺÏÏë×ö¿ª·ÅÔ´´úÂëÈí¼þµÄ³ÌÐò¿ª·¢ÈËÔ±£¬ÓÖ»òÈç¹ûÄãÖ»ÊÇ×Ô¼ºÐ´Ð©Ð¡µÄToy³ÌÐò£¬ÄÇôÕâ¸öÎÄÕ¶ÔÄãÒ²»áÓкܴóµÄ°ïÖú¡£
¡¡¡¡Ò»¡¢Makefile½éÉÜ
¡¡¡¡MakefileÊÇÓÃÓÚ×Ô¶¯±àÒëºÍÁ´½ÓµÄ£¬Ò»¸ö¹¤³ÌÓкܶàÎļþ×é³É£¬Ã¿Ò»¸öÎļþµÄ¸Ä±ä¶¼»áµ¼Ö¹¤³ÌµÄÖØÐÂÁ´½Ó£¬µ«ÊDz»ÊÇËùÓеÄÎļþ¶¼ÐèÒªÖØбàÒ룬MakefileÖмͼÓÐÎļþµÄÐÅÏ¢£¬ÔÚmakeʱ»á¾ö¶¨ÔÚÁ´½ÓµÄʱºòÐèÒªÖØбàÒëÄÄЩÎļþ¡£
¡¡¡¡MakefileµÄ×ÚÖ¼¾ÍÊÇ£ºÈñàÒëÆ÷ÖªµÀÒª±àÒëÒ»¸öÎļþÐèÒªÒÀÀµÆäËûµÄÄÄЩÎļþ¡£µ±ÄÇЩÒÀÀµÎļþÓÐÁ˸ı䣬±àÒëÆ÷»á×Ô¶¯µÄ·¢ÏÖ×îÖÕµÄÉú³ÉÎļþÒѾ¹ýʱ£¬¶øÖØбàÒëÏàÓ¦µÄÄ£¿é¡£
¡¡¡¡MakefileµÄ»ù±¾½á¹¹²»ÊǺܸ´ÔÓ£¬µ«µ±Ò»¸ö³ÌÐò¿ª·¢ÈËÔ±¿ªÊ¼Ð´Makefileʱ£¬¾³£»á»³ÒÉ×Ô¼ºÐ´µÄÊÇ·ñ·ûºÏ¹ßÀý£¬¶øÇÒ×Ô¼ºÐ´µÄMakefile¾³£ºÍ×Ô¼ºµÄ¿ª·¢»·¾³Ïà¹ØÁª£¬µ±ÏµÍ³»·¾³±äÁ¿»ò·¾¶·¢ÉúÁ˱仯ºó£¬Makefile¿ÉÄÜ»¹Òª¸ú×ÅÐ޸ġ£ÕâÑù¾ÍÔì³ÉÁËÊÖ¹¤ÊéдMakefileµÄÖî¶àÎÊÌ⣬automakeÇ¡ºÃÄܺܺõذïÖúÎÒÃǽâ¾öÕâЩÎÊÌâ¡£
¡¡¡¡Ê¹ÓÃautomake£¬³ÌÐò¿ª·¢ÈËÔ±Ö»ÐèҪдһЩ¼òµ¥µÄº¬ÓÐÔ¤¶¨ÒåºêµÄÎļþ£¬ÓÉautoconf¸ù¾ÝÒ»¸öºêÎļþÉú³Éconfigure£¬ÓÉautomake¸ù¾ÝÁíÒ»¸öºêÎļþÉú³ÉMakefile.in£¬ÔÙʹÓÃconfigureÒÀ¾ÝMakefile.inÀ´Éú³ÉÒ»¸ö·ûºÏ¹ßÀýµÄMakefile¡£ÏÂÃæÎÒÃǽ«Ïêϸ½éÉÜMakefileµÄautomakeÉú³É·½·¨¡£
¡¡¡¡¶þ¡¢Ê¹ÓõĻ·¾³
¡¡¡¡±¾ÎÄËùÌáµ½µÄ³ÌÐòÊÇ»ùÓÚLinux·¢Ðа汾£ºFedora Core release 1£¬Ëü°üº¬ÁËÎÒÃÇÒªÓõ½µÄautoconf£¬automake¡£
¡¡¡¡Èý¡¢´ÓhelloworldÈëÊÖ
¡¡¡¡ÎÒÃÇ´Ó´ó¼Ò×ʹÓõÄÀý×Ó³ÌÐòhelloworld¿ªÊ¼¡£
¡¡¡¡ÏÂÃæµÄ¹ý³ÌÈç¹û¼òµ¥µØ˵À´¾ÍÊÇ£º
¡¡¡¡Ð½¨Èý¸öÎļþ£º
¡¡¡¡¡¡helloworld.c
¡¡¡¡¡¡configure.in
¡¡¡¡¡¡Makefile.am
¡¡¡¡È»ºóÖ´ÐУº
aclocal; autoconf; automake --add-missing; ./configure; make; ./helloworld
¡¡¡¡¾Í¿ÉÒÔ¿´µ½Makefile±»²úÉú³öÀ´£¬¶øÇÒ¿ÉÒÔ½«helloworld.c±àÒëͨ¹ý¡£
¡¡¡¡ºÜ¼òµ¥°É£¬¼¸ÌõÃüÁî¾Í¿ÉÒÔ×ö³öÒ»¸ö·ûºÏ¹ßÀýµÄMakefile£¬¸Ð¾õÈçºÎѽ¡£
¡¡¡¡ÏÖÔÚ¿ªÊ¼½éÉÜÏêϸµÄ¹ý³Ì£º
¡¡¡¡1¡¢½¨Ä¿Â¼
¡¡¡¡ÔÚÄãµÄ¹¤×÷Ŀ¼Ï½¨Ò»¸öhelloworldĿ¼£¬ÎÒÃÇÓÃËüÀ´´æ·Åhelloworld³ÌÐò¼°Ïà¹ØÎļþ£¬ÈçÔÚ/home/my/buildÏ£º
$ mkdir helloword
$ cd helloworld
¡¡¡¡2¡¢ helloworld.c
¡¡¡¡È»ºóÓÃÄã×Ô¼º×îϲ»¶µÄ±à¼Æ÷дһ¸öhellowrold.cÎļþ£¬ÈçÃüÁvi helloworld.c¡£Ê¹ÓÃÏÂÃæµÄ´úÂë×÷Ϊhelloworld.cµÄÄÚÈÝ¡£
int main(int argc, char** argv)
{
printf("Hello, Linux World!\n");
return 0;
}
¡¡¡¡Íê³Éºó±£´æÍ˳ö¡£
¡¡¡¡ÏÖÔÚÔÚhelloworldĿ¼Ï¾ÍÓ¦¸ÃÓÐÒ»¸öÄã×Ô¼ºÐ´µÄhelloworld.cÁË¡£
¡¡¡¡3¡¢Éú³Éconfigure
¡¡¡¡ÎÒÃÇʹÓÃautoscanÃüÁîÀ´°ïÖúÎÒÃǸù¾ÝĿ¼ÏµÄÔ´´úÂëÉú³ÉÒ»¸öconfigure.inµÄÄ£°åÎļþ¡£
¡¡¡¡ÃüÁ
$ autoscan
$ ls
configure.scan helloworld.c
¡¡¡¡Ö´ÐкóÔÚhellowroldĿ¼Ï»áÉú³ÉÒ»¸öÎļþ£ºconfigure.scan£¬ÎÒÃÇ¿ÉÒÔÄÃËü×÷Ϊconfigure.inµÄÀ¶±¾¡£
¡¡¡¡ÏÖÔÚ½«configure.scan¸ÄÃûΪconfigure.in£¬²¢ÇÒ±à¼Ëü£¬°´ÏÂÃæµÄÄÚÈÝÐ޸ģ¬È¥µôÎ޹صÄÓï¾ä£º
============================configure.inÄÚÈÝ¿ªÊ¼=========================================
ÒýÓÃ:# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_INIT(helloworld.c)
AM_INIT_AUTOMAKE(helloworld, 1.0)
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_OUTPUT(Makefile)
============================configure.inÄÚÈݽáÊø=========================================
¡¡¡¡È»ºóÖ´ÐÐÃüÁîaclocalºÍautoconf£¬·Ö±ð»á²úÉúaclocal.m4¼°configureÁ½¸öÎļþ£º
ÒýÓÃ:$ aclocal
$ls
aclocal.m4 configure.in helloworld.c
$ autoconf
$ ls
aclocal.m4 autom4te.cache configure configure.in helloworld.c
¡¡¡¡´ó¼Ò¿ÉÒÔ¿´µ½configure.inÄÚÈÝÊÇһЩºê¶¨Ò壬ÕâЩºê¾autoconf´¦Àíºó»á±ä³É¼ì²éϵͳÌØÐÔ¡¢»·¾³±äÁ¿¡¢Èí¼þ±ØÐëµÄ²ÎÊýµÄshell½Å±¾¡£
¡¡¡¡autoconf ÊÇÓÃÀ´Éú³É×Ô¶¯ÅäÖÃÈí¼þÔ´´úÂë½Å±¾£¨configure£©µÄ¹¤¾ß¡£configure½Å±¾ÄܶÀÁ¢ÓÚautoconfÔËÐУ¬ÇÒÔÚÔËÐеĹý³ÌÖУ¬²»ÐèÒªÓû§µÄ¸ÉÔ¤¡£
¡¡¡¡ÒªÉú³ÉconfigureÎļþ£¬Äã±ØÐë¸æËßautoconfÈçºÎÕÒµ½ÄãËùÓõĺꡣ·½Ê½ÊÇʹÓÃaclocal³ÌÐòÀ´Éú³ÉÄãµÄaclocal.m4¡£
¡¡¡¡aclocal¸ù¾Ýconfigure.inÎļþµÄÄÚÈÝ£¬×Ô¶¯Éú³Éaclocal.m4Îļþ¡£aclocalÊÇÒ»¸öperl ½Å±¾³ÌÐò£¬ËüµÄ¶¨ÒåÊÇ£º¡°aclocal - create aclocal.m4 by scanning configure.ac¡±¡£
¡¡¡¡autoconf´Óconfigure.inÕâ¸öÁоٱàÒëÈí¼þʱËùÐèÒª¸÷ÖÖ²ÎÊýµÄÄ£°åÎļþÖд´½¨configure¡£
¡¡¡¡autoconfÐèÒªGNU m4ºê´¦ÀíÆ÷À´´¦Àíaclocal.m4£¬Éú³Éconfigure½Å±¾¡£
¡¡¡¡m4ÊÇÒ»¸öºê´¦ÀíÆ÷¡£½«ÊäÈ뿽±´µ½Êä³ö£¬Í¬Ê±½«ºêÕ¹¿ª¡£ºê¿ÉÒÔÊÇÄÚǶµÄ£¬Ò²¿ÉÒÔÊÇÓû§¶¨ÒåµÄ¡£³ýÁË¿ÉÒÔÕ¹¿ªºê£¬m4»¹ÓÐһЩÄÚ½¨µÄº¯Êý£¬ÓÃÀ´ÒýÓÃÎļþ£¬Ö´ÐÐÃüÁÕûÊýÔËË㣬Îı¾²Ù×÷£¬Ñ»·µÈ¡£m4¼È¿ÉÒÔ×÷Ϊ±àÒëÆ÷µÄÇ°¶Ë£¬Ò²¿ÉÒÔµ¥¶À×÷Ϊһ¸öºê´¦ÀíÆ÷¡£
4¡¢Ð½¨Makefile.am
¡¡¡¡Ð½¨Makefile.amÎļþ£¬ÃüÁ
$ vi Makefile.am
¡¡¡¡ÄÚÈÝÈçÏÂ:
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=helloworld
helloworld_SOURCES=helloworld.c
¡¡¡¡automake»á¸ù¾ÝÄãдµÄMakefile.amÀ´×Ô¶¯Éú³ÉMakefile.in¡£
¡¡¡¡Makefile.amÖж¨ÒåµÄºêºÍÄ¿±ê,»áÖ¸µ¼automakeÉú³ÉÖ¸¶¨µÄ´úÂë¡£ÀýÈ磬ºêbin_PROGRAMS½«µ¼Ö±àÒëºÍÁ¬½ÓµÄÄ¿±ê±»Éú³É¡£
¡¡¡¡5¡¢ÔËÐÐautomake
¡¡¡¡ÃüÁ
$ automake --add-missing
configure.in: installing `./install-sh'
configure.in: installing `./mkinstalldirs'
configure.in: installing `./missing'
Makefile.am: installing `./depcomp'
¡¡¡¡automake»á¸ù¾ÝMakefile.amÎļþ²úÉúһЩÎļþ£¬°üº¬×îÖØÒªµÄMakefile.in¡£
¡¡¡¡6¡¢Ö´ÐÐconfigureÉú³ÉMakefile
$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
configure: creating ./config.status
config.status: creating Makefile
config.status: executing depfiles commands
$ ls -l Makefile
-rw-rw-r-- 1 yutao yutao 15035 Oct 15 10:40 Makefile
Äã¿ÉÒÔ¿´µ½£¬´ËʱMakefileÒѾ²úÉú³öÀ´ÁË¡£
7¡¢Ê¹ÓÃMakefile±àÒë´úÂë
$ make
if gcc -DPACKAGE_NAME="" -DPACKAGE_TARNAME="" -DPACKAGE_VERSION="" -
DPACKAGE_STRING="" -DPACKAGE_BUGREPORT="" -DPACKAGE="helloworld" -DVERSION="1.0"
-I. -I. -g -O2 -MT helloworld.o -MD -MP -MF ".deps/helloworld.Tpo" \
-c -o helloworld.o `test -f 'helloworld.c' || echo './'`helloworld.c; \
then mv -f ".deps/helloworld.Tpo" ".deps/helloworld.Po"; \
else rm -f ".deps/helloworld.Tpo"; exit 1; \
fi
gcc -g -O2 -o helloworld helloworld.o
¡¡¡¡ÔËÐÐhelloworld
$ ./helloworld
Hello, Linux World!
¡¡¡¡ÕâÑùhelloworld¾Í±àÒë³öÀ´ÁË£¬ÄãÈç¹û°´ÉÏÃæµÄ²½ÖèÀ´×öµÄ»°£¬Ó¦¸ÃÒ²»áºÜÈÝÒ׵رàÒë³öÕýÈ·µÄhelloworldÎļþ¡£Ä㻹¿ÉÒÔÊÔ×ÅʹÓÃһЩÆäËûµÄmakeÃüÁÈçmake clean£¬make install£¬make dist£¬¿´¿´ËüÃÇ»á¸øÄãʲôÑùµÄЧ¹û¡£¸Ð¾õÈçºÎ£¿×Ô¼ºÒ²ÄÜд³öÕâôרҵµÄMakefile£¬ÀÏ°åÒ»¶¨»á¶ÔÄã¹ÎÄ¿Ïà¿´¡£
¡¡¡¡ËÄ¡¢ÉîÈëdz³ö
¡¡¡¡Õë¶ÔÉÏÃæÌáµ½µÄ¸÷¸öÃüÁÎÒÃÇÔÙ×öЩÏêϸµÄ½éÉÜ¡£
¡¡¡¡1¡¢ autoscan
¡¡¡¡autoscanÊÇÓÃÀ´É¨ÃèÔ´´úÂëĿ¼Éú³Éconfigure.scanÎļþµÄ¡£autoscan¿ÉÒÔÓÃĿ¼Ãû×öΪ²ÎÊý£¬µ«Èç¹ûÄ㲻ʹÓòÎÊýµÄ»°£¬ÄÇôautoscan½«ÈÏΪʹÓõÄÊǵ±Ç°Ä¿Â¼¡£autoscan½«É¨ÃèÄãËùÖ¸¶¨Ä¿Â¼ÖеÄÔ´Îļþ£¬²¢´´½¨configure.scanÎļþ¡£
¡¡¡¡2¡¢ configure.scan
¡¡¡¡configure.scan°üº¬ÁËϵͳÅäÖõĻù±¾Ñ¡ÏÀïÃ涼ÊÇһЩºê¶¨Òå¡£ÎÒÃÇÐèÒª½«Ëü¸ÄÃûΪconfigure.in
¡¡¡¡3¡¢ aclocal
¡¡¡¡aclocalÊÇÒ»¸öperl ½Å±¾³ÌÐò¡£aclocal¸ù¾Ýconfigure.inÎļþµÄÄÚÈÝ£¬×Ô¶¯Éú³Éaclocal.m4Îļþ¡£aclocalµÄ¶¨ÒåÊÇ£º¡°aclocal - create aclocal.m4 by scanning configure.ac¡±¡£
¡¡¡¡4¡¢ autoconf
¡¡¡¡autoconfÊÇÓÃÀ´²úÉúconfigureÎļþµÄ¡£configureÊÇÒ»¸ö½Å±¾£¬ËüÄÜÉèÖÃÔ´³ÌÐòÀ´ÊÊÓ¦¸÷ÖÖ²»Í¬µÄ²Ù×÷ϵͳƽ̨£¬²¢ÇÒ¸ù¾Ý²»Í¬µÄϵͳÀ´²úÉúºÏÊʵÄMakefile£¬´Ó¶ø¿ÉÒÔʹÄãµÄÔ´´úÂëÄÜÔÚ²»Í¬µÄ²Ù×÷ϵͳƽ̨Éϱ»±àÒë³öÀ´¡£
¡¡¡¡configure.inÎļþµÄÄÚÈÝÊÇһЩºê£¬ÕâЩºê¾¹ýautoconf ´¦Àíºó»á±ä³É¼ì²éϵͳÌØÐÔ¡¢»·¾³±äÁ¿¡¢Èí¼þ±ØÐëµÄ²ÎÊýµÄshell½Å±¾¡£configure.inÎļþÖеĺêµÄ˳Ðò²¢Ã»Óй涨£¬µ«ÊÇÄã±ØÐëÔÚËùÓкêµÄ×îÇ°ÃæºÍ×îºóÃæ·Ö±ð¼ÓÉÏAC_INITºêºÍAC_OUTPUTºê¡£
¡¡¡¡ÔÚconfigure.iniÖУº
¡¡¡¡#ºÅ±íʾעÊÍ£¬Õâ¸öºêºóÃæµÄÄÚÈݽ«±»ºöÂÔ¡£
¡¡¡¡AC_INIT(FILE)
¡¡¡¡Õâ¸öºêÓÃÀ´¼ì²éÔ´´úÂëËùÔڵķ¾¶¡£
AM_INIT_AUTOMAKE(PACKAGE, VERSION)
¡¡¡¡ Õâ¸öºêÊDZØÐëµÄ£¬ËüÃèÊöÁËÎÒÃǽ«ÒªÉú³ÉµÄÈí¼þ°üµÄÃû×Ö¼°Æä°æ±¾ºÅ£ºPACKAGEÊÇÈí¼þ°üµÄÃû×Ö£¬VERSIONÊÇ°æ±¾ºÅ¡£µ±ÄãʹÓÃmake distÃüÁîʱ£¬Ëü»á¸øÄãÉú³ÉÒ»¸öÀàËÆhelloworld-1.0.tar.gzµÄÈí¼þ·¢Ðаü£¬ÆäÖоÍÓжÔÓ¦µÄÈí¼þ°üµÄÃû×ֺͰ汾ºÅ¡£
AC_PROG_CC
¡¡¡¡Õâ¸öºê½«¼ì²éϵͳËùÓõÄC±àÒëÆ÷¡£
AC_OUTPUT(FILE)
¡¡¡¡Õâ¸öºêÊÇÎÒÃÇÒªÊä³öµÄMakefileµÄÃû×Ö¡£
¡¡¡¡ÎÒÃÇÔÚʹÓÃautomakeʱ£¬Êµ¼ÊÉÏ»¹ÐèÒªÓõ½ÆäËûµÄһЩºê£¬µ«ÎÒÃÇ¿ÉÒÔÓÃaclocal À´°ïÎÒÃÇ×Ô¶¯²úÉú¡£Ö´ÐÐaclocalºóÎÒÃÇ»áµÃµ½aclocal.m4Îļþ¡£
¡¡¡¡²úÉúÁËconfigure.inºÍaclocal.m4 Á½¸öºêÎļþºó£¬ÎÒÃǾͿÉÒÔʹÓÃautoconfÀ´²úÉúconfigureÎļþÁË¡£
¡¡¡¡5¡¢ Makefile.am
¡¡¡¡Makefile.amÊÇÓÃÀ´Éú³ÉMakefile.inµÄ£¬ÐèÒªÄãÊÖ¹¤Êéд¡£Makefile.amÖж¨ÒåÁËһЩÄÚÈÝ£º
AUTOMAKE_OPTIONS
¡¡¡¡Õâ¸öÊÇautomakeµÄÑ¡Ïî¡£ÔÚÖ´ÐÐautomakeʱ£¬Ëü»á¼ì²éĿ¼ÏÂÊÇ·ñ´æÔÚ±ê×¼GNUÈí¼þ°üÖÐÓ¦¾ß±¸µÄ¸÷ÖÖÎļþ£¬ÀýÈçAUTHORS¡¢ChangeLog¡¢NEWSµÈÎļþ¡£ÎÒÃǽ«ÆäÉèÖóÉforeignʱ£¬automake»á¸ÄÓÃÒ»°ãÈí¼þ°üµÄ±ê×¼À´¼ì²é¡£
bin_PROGRAMS
¡¡¡¡Õâ¸öÊÇÖ¸¶¨ÎÒÃÇËùÒª²úÉúµÄ¿ÉÖ´ÐÐÎļþµÄÎļþÃû¡£Èç¹ûÄãÒª²úÉú¶à¸ö¿ÉÖ´ÐÐÎļþ£¬ÄÇôÔÚ¸÷¸öÃû×Ö¼äÓÿոñ¸ô¿ª¡£
helloworld_SOURCES
¡¡¡¡Õâ¸öÊÇÖ¸¶¨²úÉú¡°helloworld¡±Ê±ËùÐèÒªµÄÔ´´úÂë¡£Èç¹ûËüÓõ½Á˶à¸öÔ´Îļþ£¬ÄÇôÇëʹÓÿոñ·ûºÅ½«ËüÃǸô¿ª¡£±ÈÈçÐèÒªhelloworld.h£¬helloworld.cÄÇôÇëд³Éhelloworld_SOURCES= helloworld.h helloworld.c¡£
¡¡¡¡Èç¹ûÄãÔÚbin_PROGRAMS¶¨ÒåÁ˶à¸ö¿ÉÖ´ÐÐÎļþ£¬Ôò¶ÔӦÿ¸ö¿ÉÖ´ÐÐÎļþ¶¼Òª¶¨ÒåÏà¶ÔµÄfilename_SOURCES¡£
¡¡¡¡6¡¢ automake
¡¡¡¡ÎÒÃÇʹÓÃautomake --add-missingÀ´²úÉúMakefile.in¡£
¡¡¡¡Ñ¡Ïî--add-missingµÄ¶¨ÒåÊÇ¡°add missing standard files to package¡±£¬Ëü»áÈÃautomake¼ÓÈëÒ»¸ö±ê×¼µÄÈí¼þ°üËù±ØÐëµÄһЩÎļþ¡£
¡¡¡¡ÎÒÃÇÓÃautomake²úÉú³öÀ´µÄMakefile.inÎļþÊÇ·ûºÏGNU Makefile¹ßÀýµÄ£¬½ÓÏÂÀ´ÎÒÃÇÖ»ÒªÖ´ÐÐconfigureÕâ¸öshell ½Å±¾¾Í¿ÉÒÔ²úÉúºÏÊ浀 Makefile ÎļþÁË¡£
¡¡¡¡7¡¢ Makefile
¡¡¡¡ÔÚ·ûºÏGNU Makefiel¹ßÀýµÄMakefileÖУ¬°üº¬ÁËһЩ»ù±¾µÄÔ¤Ïȶ¨ÒåµÄ²Ù×÷£º
make
¡¡¡¡¸ù¾ÝMakefile±àÒëÔ´´úÂ룬Á¬½Ó£¬Éú³ÉÄ¿±êÎļþ£¬¿ÉÖ´ÐÐÎļþ¡£
make clean
¡¡¡¡Çå³ýÉϴεÄmakeÃüÁîËù²úÉúµÄobjectÎļþ£¨ºó׺Ϊ¡°.o¡±µÄÎļþ£©¼°¿ÉÖ´ÐÐÎļþ¡£
make install
¡¡¡¡½«±àÒë³É¹¦µÄ¿ÉÖ´ÐÐÎļþ°²×°µ½ÏµÍ³Ä¿Â¼ÖУ¬Ò»°ãΪ/usr/local/binĿ¼¡£
make dist
¡¡¡¡²úÉú·¢²¼Èí¼þ°üÎļþ£¨¼´distribution package£©¡£Õâ¸öÃüÁ»á½«¿ÉÖ´ÐÐÎļþ¼°Ïà¹ØÎļþ´ò°ü³ÉÒ»¸ötar.gzѹËõµÄÎļþÓÃÀ´×÷Ϊ·¢²¼Èí¼þµÄÈí¼þ°ü¡£
¡¡¡¡Ëü»áÔÚµ±Ç°Ä¿Â¼ÏÂÉú³ÉÒ»¸öÃû×ÖÀàËÆ¡°PACKAGE-VERSION.tar.gz¡±µÄÎļþ¡£PACKAGEºÍVERSION£¬ÊÇÎÒÃÇÔÚconfigure.inÖж¨ÒåµÄAM_INIT_AUTOMAKE(PACKAGE, VERSION)¡£
make distcheck
¡¡¡¡Éú³É·¢²¼Èí¼þ°ü²¢¶ÔÆä½øÐвâÊÔ¼ì²é£¬ÒÔÈ·¶¨·¢²¼°üµÄÕýÈ·ÐÔ¡£Õâ¸ö²Ù×÷½«×Ô¶¯°ÑѹËõ°üÎļþ½â¿ª£¬È»ºóÖ´ÐÐconfigureÃüÁ²¢ÇÒÖ´ÐÐmake£¬À´È·ÈϱàÒë²»³öÏÖ´íÎó£¬×îºóÌáʾÄãÈí¼þ°üÒѾ׼±¸ºÃ£¬¿ÉÒÔ·¢²¼ÁË¡£
===============================================
helloworld-1.0.tar.gz is ready for distribution
===============================================
make distclean
¡¡¡¡ÀàËÆmake clean£¬µ«Í¬Ê±Ò²½«configureÉú³ÉµÄÎļþÈ«²¿É¾³ýµô£¬°üÀ¨Makefile¡£
¡¡¡¡Îå¡¢½áÊøÓï
¡¡¡¡Í¨¹ýÉÏÃæµÄ½éÉÜ£¬ÄãÓ¦¸Ã¿ÉÒÔºÜÈÝÒ×µØÉú³ÉÒ»¸öÄã×Ô¼ºµÄ·ûºÏGNU¹ßÀýµÄMakefileÎļþ¼°¶ÔÓ¦µÄÏîÄ¿Îļþ¡£
¡¡¡¡Èç¹ûÄãÏëд³ö¸ü¸´ÔÓµÄÇÒ·ûºÏ¹ßÀýµÄMakefile£¬Äã¿ÉÒԲο¼Ò»Ð©¿ª·Å´úÂëµÄÏîÄ¿ÖеÄconfigure.inºÍMakefile.amÎļþ£¬±ÈÈ磺ǶÈëʽÊý¾Ý¿âsqlite£¬µ¥Ôª²âÊÔcppunit¡£
wucongdonglai ÓÚ 2010-11-02 15:23:48·¢±í:
Õâ¸ö¶«¶«ºÃ£¬ÔõôûÈ˶¥ÄØ