{"id":1649,"date":"2015-12-22T18:40:33","date_gmt":"2015-12-22T10:40:33","guid":{"rendered":"http:\/\/www.51cos.com\/?p=1649"},"modified":"2015-12-26T22:02:14","modified_gmt":"2015-12-26T14:02:14","slug":"%e8%b0%83%e8%af%95%e9%81%87%e5%88%b0%e7%9a%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/www.51cos.com\/?p=1649","title":{"rendered":"\u5982\u4f55\u6839\u636econfigure.ac\u548cMakefile.am\u4e3a\u5f00\u6e90\u4ee3\u7801\u4ea7\u751f\u5f53\u524d\u5e73\u53f0\u7684Makefile"},"content":{"rendered":"<p>&nbsp;<\/p>\n<pre class=\"prettyprint linenums\">\/\/\u6839\u636econfigure.in\u548cMakefile.am\u751f\u6210makefile\u7684\u6b65\u9aa4\uff0c\u57fa\u4e8eUBUNTU 12.04<br \/>\n1.autoscan \uff08\u53ef\u9009\uff09<br \/>\n2.aclocal<br \/>\n3.autoconf<br \/>\n4.autoheader\uff08\u53ef\u9009\uff09<br \/>\n5.libtoolize --automake --copy --debug --force\uff08\u53ef\u9009\uff09<br \/>\n6.automake --add-missing<br \/>\n7.autoreconf \u2013f \u2013i \u2013Wall,no\u2013obsolete\uff08\u53ef\u9009\uff09<br \/>\n8..\/configure<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u7b80\u5355\u7684\u65b9\u5f0f\uff1a<\/strong><\/p>\n<p>\u5982\u679c\u62ff\u5230\u7684\u5de5\u7a0b\u6587\u4ef6\u4e2d\uff0c\u6ca1\u6709Makefile\u6587\u4ef6\uff0c\u800c\u53ea\u6709configure.in\u548cMakefile.am\u6587\u4ef6\uff0c\u6211\u4eec\u662f\u4e0d\u80fd\u591f\u76f4\u63a5\u8fdb\u884c\u7f16\u8bd1\u7684\uff0c\u5fc5\u987b\u5728UBUNTU\u7b49Linux\u7cfb\u7edf\u4e0b\uff0c\u6839\u636econfigure.in\u548cMakefile.am\u6587\u4ef6\u751f\u6210\u7f16\u8bd1\u6240\u9700\u7684Makefile\u6587\u4ef6\u3002\u5177\u4f53\u64cd\u4f5c\u6b65\u9aa4\u5982\u4e0b\uff1a<br \/>\n<strong>1\u3001\u6267\u884cautoscan\uff0c\u7136\u540e\u6267\u884caclocal\uff0c\u4ea7\u751faclocal.m4\u6587\u4ef6<\/strong><br \/>\naclocal\u662f\u4e00\u4e2aperl \u811a\u672c\u7a0b\u5e8f\uff0c\u5b83\u7684\u5b9a\u4e49\u662f\uff1a\u201caclocal - create aclocal.m4 by scanning configure.ac\u201d\u3002 aclocal\u6839\u636econfigure.in\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u81ea\u52a8\u751f\u6210aclocal.m4\u6587\u4ef6\u3002\u800caclocal.m4\u6587\u4ef6\u4e2d\uff0c\u5305\u542b\u4e86\u751f\u6210configure\u6587\u4ef6\u6240\u5fc5\u987b\u7684\u5b8f\u3002<br \/>\n<strong>2\u3001\u6267\u884cautoconf\uff0c\u751f\u6210configure\u6587\u4ef6<\/strong><br \/>\nautoconf\u4f1a\u6839\u636econfigure.in\u548caclocal.m4\u6587\u4ef6\uff0c\u751f\u6210configure\u6587\u4ef6\u3002\u5176\u5b9e\uff0cautoconf\u5c31\u662f\u628aconfigure.in\u548caclocal.m4\u6587\u4ef6\u4e2d\u5b9a\u4e49\u7684\u5185\u5bb9\uff0c \u53d8\u6210\u68c0\u67e5\u7cfb\u7edf\u7279\u6027\u3001\u73af\u5883\u53d8\u91cf\u3001\u8f6f\u4ef6\u5fc5\u987b\u7684\u53c2\u6570\u7684shell\u811a\u672c\u3002<br \/>\n<strong>3\u3001\u6267\u884cautomake\u547d\u4ee4\uff0c\u4ea7\u751fMakefile.in<\/strong><br \/>\n\u5177\u4f53\u547d\u4ee4\u4e3a\uff1aautomake --add-missing<br \/>\nautomake\u4f1a\u6839\u636eMakefile.am\u6587\u4ef6\u4ea7\u751f\u4e00\u4e9b\u6587\u4ef6\uff0c\u5305\u542b\u6700\u91cd\u8981\u7684Makefile.in\u3002\u524d\u9762\u6240\u751f\u6210\u7684configure\uff0c\u4f1a\u6839\u636eMakefile.in\u6587\u4ef6\uff0c\u6765\u751f\u6210\u6700\u7ec8\u7684Makefile\u6587\u4ef6\u3002<br \/>\n<strong>4\u3001\u6267\u884cconfigure\u547d\u4ee4\uff0c\u751f\u6210Makefile\u6587\u4ef6<\/strong><br \/>\n\u8fd9\u6837\uff0c\u5c31\u4ea7\u751f\u4e86\u7f16\u8bd1\u6240\u9700\u8981\u7684Makefile\u6587\u4ef6\u3002\u8fd0\u884cmake\uff0c\u5373\u53ef\u7f16\u8bd1\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u590d\u6742\u70b9\u7684\u65b9\u5f0f\uff1a<\/strong><\/p>\n<p>\u4e3a\u4e00\u4e2a\u9879\u76ee\u6e90\u6587\u4ef6\u751f\u6210makefile\u5e76make\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<p>\u64cd\u4f5c\u5728\u5305\u542b\u6e90\u6587\u4ef6\u7684\u9879\u76ee\u76ee\u5f55\u4e0b\u8fdb\u884c\u3002<\/p>\n<ul>\n<li>(1)\u8fd0\u884cautoscan\uff0c\u751f\u6210\u6587\u4ef6configure.scan<\/li>\n<li>(2)\u4fee\u6539configure.scan\uff0c\u6539\u540d\u4e3aconfigure.in<\/li>\n<li>(3)\u8fd0\u884cautoheader\uff0c\u751f\u6210\u6587\u4ef6configure.h.in\uff08\u73b0\u5728\u4e00\u822c\u6539\u4e3aconfigure.ac\uff09<\/li>\n<li>(4)\u8fd0\u884clibtoolize\uff0c\u751f\u6210ltmain.sh<\/li>\n<li>(5)\u8fd0\u884callocal\uff0c\u751f\u6210aclocal.m4<\/li>\n<li>(6)\u8fd0\u884cautoconf\uff0c\u751f\u6210configure<\/li>\n<li>(7)\u8fd0\u884cautomake\uff0c\u751f\u6210makefile.in\uff0c\u6bcf\u4e2a\u5305\u542bmakefile.am\u7684\u5b50\u76ee\u5f55\u90fd\u751f\u6210makefile.in\u3002automake -a\u9009\u9879\u53ef\u4ee5\u8865\u9f50\u6587\u4ef6config.guess\uff0cconfig.sub\uff0cinstall-sh\uff0cmissing\uff0cdepcomp<\/li>\n<li>(8)\u8fd0\u884c.\/configure\uff0c\u751f\u6210config.status\uff0cconfig.h\uff0cmakefile<\/li>\n<li>(9)\u8fd0\u884cmake\uff0c\u751f\u6210\u4e2d\u95f4\u6587\u4ef6\u5bf9\u8c61\u6587\u4ef6\uff0c\u5e93\u6587\u4ef6\uff0c\u6700\u540e\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6<\/li>\n<li>(10)\u8fd0\u884cmake install\uff0c\u76f8\u5e94\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u5e93\u6587\u4ef6\uff0c\u5934\u6587\u4ef6\u62f7\u8d1d\u5230\u7cfb\u7edf\u76f8\u5e94\u4f4d\u7f6e\u3002<\/li>\n<li><\/li>\n<\/ul>\n<p><strong>configure\u8fd0\u884c<\/strong><\/p>\n<p>configure\u662f\u4e00\u4e2ashell\u811a\u672c\u6587\u4ef6\uff0c\u7531autoconf\u751f\u6210\uff0c\u5b83\u81ea\u52a8\u4e3a\u6e90\u7801\u5305\u914d\u7f6e\u7f16\u8bd1\u8fde\u63a5\u9009\u9879\uff0c\u9002\u5e94\u4e0d\u540c\u7684\u786c\u4ef6\u5e73\u53f0\u548cPOSIX\u64cd\u4f5c\u7cfb\u7edf\uff0c\u8f93\u51fa\u6240\u9700\u8981\u7684Makefile\u3002<\/p>\n<p>configure\u4e3b\u7ba1\u68c0\u67e5\u4f60\u7684\u7cfb\u7edf\uff0c\u628a\u7ed3\u679c\u5b58\u653e\u5230config.status\u4e2d\uff0cconfig.status\u6839\u636e\u5b83\u7684\u68c0\u67e5\u7ed3\u679c\u5b9e\u9645\u6267\u884c\u6b63\u786e\u7684\u52a8\u4f5c\u3002<\/p>\n<p>configure\u68c0\u67e5\u4e0e\u7cfb\u7edf\u76f8\u5173\u7684\u4e00\u7cfb\u5217\u53d8\u91cf\uff0c\u8fd9\u4e9b\u53d8\u91cf\u5b58\u50a8\u5230\u6587\u4ef6config.status\u4e2d\uff0c\u4f9bmakefile\u8c03\u7528\u3002\u8fd9\u4e9b\u53d8\u91cf\u5305\u62ec\u7f16\u8bd1\u8fde\u63a5\u65f6\u9700\u8981\u7684\u7a0b\u5e8f\uff0c\u8fd9\u4e9b\u7a0b\u5e8f\u5728\u7cfb\u7edf\u4e2d\u7684\u4f4d\u7f6e\uff08\u76ee\u5f55\uff09\uff0c\u8c03\u7528\u8fd9\u4e9b\u7a0b\u5e8f\u7684\u9009\u9879\uff0c\u6bd4\u5982\u7f16\u8bd1\u5668\u7684\u76ee\u5f55\uff0c\u7f16\u8bd1\u5668\u7684\u9009\u9879-g\u662f\u5426\u652f\u6301\u7b49\u3002configure\u80fd\u731c\u51fa\u5b83\u8fd0\u884c\u7684\u7cfb\u7edf\u7684\u89c4\u8303\u540d\u5b57<em>cpu<\/em><span class=\"samp\">-<\/span>vendor<span class=\"samp\">-<\/span>os\uff0c\u5b83\u901a\u8fc7\u8fd0\u884c\u811a\u672c\u6587\u4ef6config.guess\u8f93\u51fa\u53d8\u91cfuname\u6765\u731c\u51fa\u3002configure\u80fd\u8bc6\u522b\u5f88\u591a\u7cfb\u7edf\u540d\u5b57\u7684\u522b\u540d\uff0c\u5b83\u901a\u8fc7\u8fd0\u884c\u811a\u672c\u6587\u4ef6config.sub\u628a\u7cfb\u7edf\u540d\u5b57\u53d8\u6210\u89c4\u8303\u540d\u5b57\u3002<\/p>\n<p><strong>make\u8fd0\u884c<\/strong><\/p>\n<p>makefile.am\u5bf9makefile\u7684\u5f71\u54cd\uff1a\u5b83\u6839\u636eSUBDIRS = add sub\u8ba9make\u9012\u5f52\u8fdb\u5165\u6bcf\u4e2a\u5b50\u76ee\u5f55\u5904\u7406\u5b50\u76ee\u5f55\u7684Makefile\u3002\u6839\u636emain_LDADD = add\/libadd.la sub\/libsub.la\u4e3amain\u8fde\u63a5libadd.la\u548clibsub.la\u5e93\u3002<\/p>\n<p>configure.in\u5bf9makefile\u7684\u5f71\u54cd\uff1a<\/p>\n<p>\u6839\u636eAC_PROG_LIBTOOL\u8ba9libtool\u5b8c\u6210\u7f16\u8bd1\u8fde\u63a5\u5de5\u4f5c\u3002<\/p>\n<p>\u6839\u636eAC_CONFIG_HEADERS([config.h])\u53ea\u9700\u4f20\u9012\u9884\u5904\u7406\u5b8f-DHAVE_CONFIG_H\u7ed9\u7f16\u8bd1\u5668\u3002<\/p>\n<p>makefile\u4e2d\u5f88\u591a\u4e0e\u7cfb\u7edf\u76f8\u5173\u7684\u4fe1\u606f\u90fd\u662f\u901a\u8fc7\u53d8\u91cf\u83b7\u53d6\u7684\uff0c\u8fd9\u4e9b\u53d8\u91cf\u4e4b\u524d\u5df2\u7ecf\u7531configure\u68c0\u67e5\u597d\u5b58\u653e\u5728config.status\u91cc\u9762\uff0c\u9884\u5904\u7406 \u5b8f\u5b58\u653e\u5728config.h\u91cc\u9762\u3002\u6bd4\u5982\u6211\u4eec\u8981\u7528\u5230\u7684\u7f16\u8bd1\u5668CC\uff0c\u7f16\u8bd1\u5668\u9009\u9879CFLAGS\u7b49\u3002makefile\u4e2d\u7684\u53d8\u91cf\u5b8c\u6210\u66ff\u6362\u540e\uff0c\u5f00\u59cb\u5b9e\u9645\u6267\u884c\u547d\u4ee4\uff0c\u5b83\u4f1a\u9012 \u5f52\u6267\u884c\u6bcf\u4e00\u4e2a\u5b50\u76ee\u5f55\u4e0b\u7684makefile\uff0c\u751f\u6210\u5bf9\u8c61\u6587\u4ef6\uff0c\u8fde\u63a5\u5e93\u6587\u4ef6\uff0c\u6700\u540e\u8fde\u63a5\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n<p><strong>\u4ea4\u53c9\u7f16\u8bd1 Cross-compiling<\/strong><\/p>\n<p>Q\uff1a\u4e3a\u522b\u7684\u5e73\u53f0\u7f16\u8bd1\u53ef\u6267\u884c\u7a0b\u5e8f\u600e\u4e48\u505a\uff1f<\/p>\n<p>\u4ea4\u53c9\u7f16\u8bd1\u5c31\u662f\u5728\u76ee\u524d\u7684\u5e73\u53f0\u4e0a\u4e3a\u522b\u7684\u76ee\u6807\u5e73\u53f0\u751f\u6210\u53ef\u6267\u884c\u7a0b\u5e8f\u6216\u5e93\u3002\u53ef\u4ee5\u5728\u8fd0\u884cconfigure\u65f6\u901a\u8fc7--build\uff0c--host\uff0c--target\u53c2\u6570\u5b9e\u73b0\u4ea4\u53c9\u7f16\u8bd1\u3002<\/p>\n<p>\u4f8b\u5982:<\/p>\n<pre class=\"prettyprint linenums\">.\/configure --build=i686-pc-linux-gnu --host=m68k-coff<\/p>\n<p>&nbsp;<\/p>\n<p><span class=\"option\">--build=<\/span>build-type \uff1aconfigure\u548ccompile\u8f6f\u4ef6\u5305\u7684\u7cfb\u7edf\u7c7b\u578b\u3002\u9ed8\u8ba4\u60c5\u51b5\u7b49\u4e8econfig.guess\u7ed9\u51fa\u7684\u7cfb\u7edf\u7c7b\u578b<\/p>\n<p><span class=\"option\">--host=<\/span>host-type \uff1a\u8fd0\u884c\u8f6f\u4ef6\u5305\u7684\u7cfb\u7edf\u7c7b\u578b\u3002\u9ed8\u8ba4\u60c5\u51b5\u7b49\u4e8ebuild\u7c7b\u578b<\/p>\n<p><span class=\"option\">--target=<\/span>target-type \uff1a\u5f88\u5c11\u7528\uff0c\u9ed8\u8ba4\u60c5\u51b5\u7b49\u4e8ehost\u7c7b\u578b\u3002<\/p>\n<p>\u4ea4\u53c9\u7f16\u8bd1\u65f6\uff0c\u5982\u679c\u7f16\u8bd1\u5668\uff0c\u8fde\u63a5\u5668\uff0c\u6c47\u7f16\u5668\u540d\u5b57\u4e0d\u662f\u4ee5host_type\u4e3a\u524d\u7f00\uff0cconfigure\u90fd\u4f1a\u53d1\u51fa\u8b66\u544a\u3002<\/p>\n<p>\u8981\u642d\u5efa\u4ea4\u53c9\u53d8\u5f02\u73af\u5883\uff0c\u5982\u4ea4\u53c9\u7f16\u8bd1\u7528\u7684\u7f16\u8bd1\u5668\uff0c\u8fde\u63a5\u5668\uff0c\u6c47\u7f16\u5668\u8ddf\u672c\u5730\u7684\u4e0d\u4e00\u6837\uff0c\u4e00\u822c\u4ee5host_type\u4e3a\u524d\u7f00\uff0c\u5982arm-pc-linux-gcc\u3002<\/p>\n<p><strong>\u5b89\u88c5\u76ee\u5f55<\/strong><\/p>\n<p>Q\uff1amake install\u65f6\uff0c\u6587\u4ef6\u90fd\u5b89\u88c5\u5230\u54ea\u91cc\u53bb\u4e86\uff1f<\/p>\n<p>prefix\uff1a\u5b89\u88c5\u76ee\u5f55\u7684\u524d\u7f00\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\/usr\/local \u3002<\/p>\n<p>bindir\uff1a\u5b89\u88c5\u65f6\u62f7\u8d1d\u53ef\u6267\u884c\u6587\u4ef6\u5230\u6b64\u76ee\u5f55\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\/usr\/local\/bin \u3002<\/p>\n<p>includir\uff1a\u5b89\u88c5\u65f6\u62f7\u8d1d\u5934\u6587\u4ef6\u5230\u6b64\u76ee\u5f55\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\/usr\/local\/include \u3002<\/p>\n<p>libdir\uff1a\u5b89\u88c5\u65f6\u62f7\u8d1d\u5e93\u6587\u4ef6\u5230\u6b64\u76ee\u5f55\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\/usr\/local\/libs \u3002<\/p>\n<p>\u5b9a\u5236\u81ea\u5df1\u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u53ef\u4ee5<span class=\"option\">--prefix<\/span> \u548c <span class=\"option\">--exec-prefix<\/span> \u7ed9configure\u3002<\/p>\n<p>\u4f8b\u5982\uff1a.\/configure --prefix=\/usr \u3002<\/p>\n<p>&nbsp;<\/p>\n<div class=\"blog_title\">\n<h3>Configure\uff0cMakefile.am, Makefile.in, Makefile\u6587\u4ef6\u4e4b\u95f4\u5173\u7cfb<\/h3>\n<\/div>\n<div id=\"blog_content\" class=\"blog_content\">\n<div class=\"cnt\"><img decoding=\"async\" src=\"http:\/\/www.51cos.com\/wp-content\/uploads\/2015\/12\/0229c674c768a4b3fdc9ca516abd81ee.gif\" alt=\"\" \/><\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"prettyprint linenums\">1.autoscan (autoconf): \u626b\u63cf\u6e90\u4ee3\u7801\u4ee5\u641c\u5bfb\u666e\u901a\u7684\u53ef\u79fb\u690d\u6027\u95ee\u9898\uff0c\u6bd4\u5982\u68c0\u67e5\u7f16\u8bd1\u5668\uff0c\u5e93\uff0c\u5934\u6587\u4ef6\u7b49\uff0c\u751f\u6210\u6587\u4ef6configure.scan,\u5b83\u662fconfigure.ac\u7684\u4e00\u4e2a\u96cf\u5f62\u3002<\/p>\n<p>    your source files --- [autoscan*] --- [configure.scan] --- configure.ac<br \/>\n2.aclocal (automake):\u6839\u636e\u5df2\u7ecf\u5b89\u88c5\u7684\u5b8f\uff0c\u7528\u6237\u5b9a\u4e49\u5b8f\u548cacinclude.m4\u6587\u4ef6\u4e2d\u7684\u5b8f\u5c06configure.ac\u6587\u4ef6\u6240\u9700\u8981\u7684\u5b8f\u96c6\u4e2d\u5b9a\u4e49\u5230\u6587\u4ef6 aclocal.m4\u4e2d\u3002aclocal\u662f\u4e00\u4e2aperl \u811a\u672c\u7a0b\u5e8f\uff0c\u5b83\u7684\u5b9a\u4e49\u662f\uff1a\u201caclocal - create aclocal.m4 by scanning configure.ac\u201d<\/p>\n<p>user input files   optional input     process          output files<br \/>\n================   ==============     =======          ============<\/p>\n<p>                    acinclude.m4 - - - - -.<br \/>\n                                          V<br \/>\n                                      .-------,<br \/>\nconfigure.ac -------------------------|aclocal|<br \/>\n                 {user macro files} --|       |------- aclocal.m4<br \/>\n                                      `-------'<br \/>\n3.autoheader(autoconf): \u6839\u636econfigure.ac\u4e2d\u7684\u67d0\u4e9b\u5b8f\uff0c\u6bd4\u5982cpp\u5b8f\u5b9a\u4e49\uff0c\u8fd0\u884cm4\uff0c\u58f0\u79f0config.h.in<\/p>\n<p>user input files    optional input     process          output files<br \/>\n================    ==============     =======          ============<\/p>\n<p>                    aclocal.m4 - - - - - - - .<br \/>\n                                             |<br \/>\n                                             V<br \/>\n                                     .----------,<br \/>\nconfigure.ac ------------------------|autoheader|----- autoconfig.h.in<br \/>\n                                     `----------'<\/p>\n<p>4.automake: automake\u5c06Makefile.am\u4e2d\u5b9a\u4e49\u7684\u7ed3\u6784\u5efa\u7acbMakefile.in\uff0c\u7136\u540econfigure\u811a\u672c\u5c06\u751f\u6210\u7684Makefile.in\u6587\u4ef6\u8f6c\u6362 \u4e3aMakefile\u3002\u5982\u679c\u5728configure.ac\u4e2d\u5b9a\u4e49\u4e86\u4e00\u4e9b\u7279\u6b8a\u7684\u5b8f\uff0c\u6bd4\u5982AC_PROG_LIBTOOL\uff0c\u5b83\u4f1a\u8c03\u7528libtoolize\uff0c\u5426\u5219\u5b83 \u4f1a\u81ea\u5df1\u4ea7\u751fconfig.guess\u548cconfig.sub<\/p>\n<p>user input files   optional input   processes          output files<br \/>\n================   ==============   =========          ============<\/p>\n<p>                                     .--------,<br \/>\n                                     |        | - - -- COPYING<br \/>\n                                     |        | - - -- INSTALL<br \/>\n                                     |        |------- install-sh<br \/>\n                                     |        |------- missing<br \/>\n                                     |automake|------- mkinstalldirs<br \/>\nconfigure.ac ------------------------|        |<br \/>\nMakefile.am  ------------------------|        |------- Makefile.in<br \/>\n                                     |        |------- stamp-h.in<br \/>\n                                 .---+        | - - -- config.guess<br \/>\n                                 |   |        | - - -- config.sub<br \/>\n                                 |   `------+-'<br \/>\n                                 |          | - - - -- config.guess<br \/>\n                                 |libtoolize| - - - -- config.sub<br \/>\n                                 |          |--------- ltmain.sh<br \/>\n                                 |          |--------- ltconfig<br \/>\n                                 `----------'<\/p>\n<p>5.autoconf:\u5c06configure.ac\u4e2d\u7684\u5b8f\u5c55\u5f00\uff0c\u751f\u6210configure\u811a\u672c\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u53ef\u80fd\u8981\u7528\u5230aclocal.m4\u4e2d\u5b9a\u4e49\u7684\u5b8f\u3002<\/p>\n<p>user input files   optional input   processes          output files<br \/>\n================   ==============   =========          ============<\/p>\n<p>aclocal.m4 ,autoconfig.h.in - - - - - - -.<br \/>\n                                         V<br \/>\n                                     .--------,<br \/>\nconfigure.ac ------------------------|autoconf|------- configure<\/p>\n<p>6. .\/configure\u7684\u8fc7\u7a0b<\/p>\n<p>                                           .-------------- [config.cache]<br \/>\n     configure* --------------------------+-------------- config.log<br \/>\n                                          |<br \/>\n              [config.h.in] -.            v            .--- [autoconfig.h]<br \/>\n                             +-------&gt; config.status* -+<br \/>\n              Makefile.in ---'                         `---  Makefile<\/p>\n<p>7. make\u8fc7\u7a0b<\/p>\n<p>[autoconfig.h] -+--- make* ----  \u7a0b\u5e8f<br \/>\n  Makefile   ---'<\/p>\n<p>                                     ----------<br \/>\n                   config.site - - --|         |<br \/>\n                  config.cache - - --|configure| - - -- config.cache<br \/>\n                                     |         +-,<br \/>\n                                     `-+-------' |<br \/>\n                                       |         |----- config.status<br \/>\n                   config.h.in --------|config-  |----- config.h<br \/>\n                   Makefile.in --------|  .status|----- Makefile<br \/>\n                                       |         |----- stamp-h<br \/>\n                                       |         +--,<br \/>\n                                     .-+         |  |<br \/>\n                                     | `------+--'  |<br \/>\n                   ltmain.sh --------|ltconfig|-------- libtool<br \/>\n                                     |        |     |<br \/>\n                                     `-+------'     |<br \/>\n                                       |config.guess|<br \/>\n                                       | config.sub |<br \/>\n                                       `------------'<\/p>\n<p>                                   ----------<br \/>\n                   Makefile -------|        |<br \/>\n                   config.h -------|  make  |<br \/>\n{project sources} -----------------|        |--------- {project targets}<br \/>\n                                 .-+        +--,<br \/>\n                                 | `--------'  |<br \/>\n                                 |   libtool   |<br \/>\n                                 |   missing   |<br \/>\n                                 |  install-sh |<br \/>\n                                 |mkinstalldirs|<br \/>\n                                 `-------------'<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h3>\u9488\u5bf9\u4e0a\u9762\u63d0\u5230\u7684 \u5404\u4e2a\u547d\u4ee4,\u6211\u4eec\u518d\u505a\u4e9b\u8be6\u7ec6\u7684\u4ecb\u7ecd<\/h3>\n<h3>\/\/http:\/\/www.laruence.com\/2009\/11\/18\/1154.html<\/h3>\n<pre>\u3000<br \/>\n1. autoscan<br \/>\n\u3000\u3000autoscan\u662f \u7528\u6765\u626b\u63cf\u6e90\u4ee3\u7801\u76ee\u5f55\u751f\u6210configure.scan\u6587\u4ef6\u7684 .autoscan<br \/>\n\u53ef\u4ee5\u7528\u76ee\u5f55\u540d\u505a\u4e3a\u53c2\u6570,\u4f46\u5982\u679c\u4f60\u4e0d\u4f7f\u7528\u53c2\u6570\u7684 \u8bdd,\u90a3\u4e48autoscan\u5c06\u8ba4\u4e3a\u4f7f\u7528\u7684\u662f\u5f53\u524d\u76ee\u5f55.<br \/>\nautoscan\u5c06\u626b\u63cf\u4f60\u6240\u6307\u5b9a\u76ee\u5f55\u4e2d\u7684 \u6e90\u6587\u4ef6,\u5e76\u521b\u5efaconfigure.scan\u6587\u4ef6.<br \/>\n2. configure.scan<br \/>\n\u3000\u3000configure.scan\u5305\u542b\u4e86\u7cfb\u7edf\u914d\u7f6e\u7684 \u57fa\u672c\u9009\u9879,\u91cc\u9762\u90fd\u662f \u4e00\u4e9b\u5b8f\u5b9a\u4e49.\u6211\u4eec\u9700\u8981\u5c06\u5b83\u6539\u540d\u4e3a<br \/>\nconfigure.in<br \/>\n3. aclocal<br \/>\n\u3000\u3000aclocal\u662f \u4e00\u4e2aperl \u811a\u672c\u7a0b\u5e8f.aclocal\u6839\u636econfigure.in\u6587\u4ef6\u7684 \u5185\u5bb9<br \/>\n,\u81ea\u52a8\u751f\u6210aclocal.m4\u6587\u4ef6.aclocal\u7684 \u5b9a\u4e49\u662f \uff1a\"aclocal - create<br \/>\naclocal.m4 by scanning configure.ac\".<br \/>\n4. autoconf<br \/>\n\u3000\u3000autoconf\u662f \u7528\u6765\u4ea7\u751fconfigure\u6587\u4ef6\u7684 .configure\u662f \u4e00\u4e2a\u811a\u672c,\u5b83\u80fd\u8bbe\u7f6e<br \/>\n\u6e90\u7a0b\u5e8f\u6765\u9002\u5e94\u5404\u79cd\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\u5e73\u53f0,\u5e76\u4e14\u6839\u636e\u4e0d\u540c\u7684 \u7cfb\u7edf\u6765\u4ea7\u751f\u5408\u9002\u7684 Makefile,\u4ece\u800c\u53ef\u4ee5\u4f7f<br \/>\n\u4f60\u7684\u6e90\u4ee3\u7801\u80fd\u5728\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\u5e73\u53f0\u4e0a\u88ab\u7f16\u8bd1\u51fa\u6765.<br \/>\n\u3000\u3000configure.in\u6587\u4ef6\u7684 \u5185\u5bb9\u662f \u4e00\u4e9b\u5b8f,\u8fd9\u4e9b\u5b8f\u7ecf\u8fc7autoconf \u5904\u7406\u540e\u4f1a\u53d8\u6210\u68c0\u67e5\u7cfb\u7edf<br \/>\n\u7279\u6027.\u73af\u5883\u53d8\u91cf.\u8f6f\u4ef6\u5fc5\u987b\u7684 \u53c2\u6570\u7684 shell\u811a\u672c.configure.in\u6587\u4ef6\u4e2d\u7684 \u5b8f\u7684 \u987a\u5e8f\u5e76\u6ca1<br \/>\n\u6709\u89c4\u5b9a,\u4f46\u662f \u4f60\u5fc5\u987b\u5728 \u6240\u6709\u5b8f\u7684 \u6700\u524d\u9762\u548c\u6700\u540e\u9762\u5206\u522b\u52a0\u4e0aAC_INIT\u5b8f\u548cAC_OUTPUT\u5b8f.<br \/>\n\u3000\u3000\u5728 configure.ini\u4e2d\uff1a<br \/>\n\u3000\u3000#\u53f7\u8868\u793a\u6ce8\u91ca,\u8fd9\u4e2a\u5b8f\u540e\u9762\u7684 \u5185\u5bb9\u5c06\u88ab\u5ffd\u7565.<br \/>\n\u3000\u3000AC_INIT(FILE)<br \/>\n\u3000\u3000\u8fd9\u4e2a\u5b8f\u7528\u6765\u68c0\u67e5\u6e90\u4ee3\u7801\u6240\u5728 \u7684 \u8def\u5f84.<br \/>\nAM_INIT_AUTOMAKE(PACKAGE, VERSION)<br \/>\n\u3000\u3000 \u8fd9\u4e2a\u5b8f\u662f \u5fc5\u987b\u7684 ,\u5b83\u63cf\u8ff0\u4e86\u6211\u4eec\u5c06\u8981\u751f\u6210\u7684 \u8f6f\u4ef6\u5305\u7684 \u540d\u5b57\u53ca\u5176\u7248\u672c\u53f7\uff1aPACKAGE\u662f\u8f6f\u4ef6\u5305<br \/>\n\u7684\u540d\u5b57,VERSION\u662f \u7248\u672c\u53f7.\u5f53\u4f60\u4f7f\u7528make dist\u547d\u4ee4\u65f6,\u5b83\u4f1a\u7ed9\u4f60\u751f\u6210\u4e00\u4e2a\u7c7b\u4f3c<br \/>\nhelloworld-1.0.tar.gz\u7684 \u8f6f\u4ef6\u53d1\u884c\u5305,\u5176\u4e2d\u5c31\u6709\u5bf9\u5e94\u7684 \u8f6f\u4ef6\u5305\u7684 \u540d\u5b57\u548c\u7248\u672c\u53f7.<br \/>\nAC_PROG_CC<br \/>\n\u3000\u3000\u8fd9\u4e2a\u5b8f\u5c06\u68c0\u67e5\u7cfb\u7edf\u6240\u7528\u7684 C\u7f16\u8bd1\u5668.<br \/>\nAC_OUTPUT(FILE)<br \/>\n\u3000\u3000\u8fd9\u4e2a\u5b8f\u662f \u6211\u4eec\u8981\u8f93\u51fa\u7684 Makefile\u7684 \u540d\u5b57.<br \/>\n\u3000\u3000\u6211\u4eec\u5728 \u4f7f\u7528automake\u65f6,\u5b9e\u9645\u4e0a\u8fd8\u9700\u8981\u7528\u5230\u5176\u4ed6\u7684 \u4e00\u4e9b\u5b8f,\u4f46\u6211\u4eec\u53ef\u4ee5\u7528aclocal \u6765\u5e2e<br \/>\n\u6211\u4eec\u81ea\u52a8\u4ea7\u751f.\u6267\u884caclocal\u540e\u6211\u4eec\u4f1a\u5f97\u5230aclocal.m4\u6587\u4ef6.<br \/>\n\u3000\u3000\u4ea7\u751f\u4e86configure.in\u548caclocal.m4 \u4e24\u4e2a\u5b8f\u6587\u4ef6\u540e,\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528autocon<br \/>\nf\u6765\u4ea7\u751fconfigure\u6587\u4ef6\u4e86.<br \/>\n5. Makefile.am<br \/>\n\u3000\u3000Makefile.am\u662f \u7528\u6765\u751f\u6210Makefile.in\u7684 ,\u9700\u8981\u4f60\u624b\u5de5\u4e66\u5199.Makefile.<br \/>\nam\u4e2d\u5b9a\u4e49\u4e86\u4e00\u4e9b\u5185\u5bb9\uff1a<br \/>\nAUTOMAKE_OPTIONS<br \/>\n\u3000\u3000\u8fd9\u4e2a\u662f automake\u7684 \u9009\u9879.\u5728 \u6267\u884cautomake\u65f6,\u5b83\u4f1a\u68c0\u67e5\u76ee\u5f55\u4e0b\u662f \u5426\u5b58\u5728 \u6807\u51c6<br \/>\nGNU\u8f6f\u4ef6\u5305\u4e2d\u5e94\u5177\u5907\u7684\u5404\u79cd\u6587\u4ef6,\u4f8b\u5982AUTHORS.ChangeLog.NEWS\u7b49\u6587\u4ef6.<br \/>\n\u6211\u4eec\u5c06\u5176\u8bbe\u7f6e\u6210foreign\u65f6,automake\u4f1a\u6539\u7528\u4e00\u822c\u8f6f\u4ef6\u5305\u7684 \u6807\u51c6\u6765\u68c0\u67e5.<br \/>\nbin_PROGRAMS<br \/>\n\u3000\u3000\u8fd9\u4e2a\u662f \u6307\u5b9a\u6211\u4eec\u6240\u8981\u4ea7\u751f\u7684 \u53ef\u6267\u884c\u6587\u4ef6\u7684 \u6587\u4ef6\u540d.\u5982\u679c\u4f60\u8981\u4ea7\u751f\u591a\u4e2a\u53ef\u6267\u884c\u6587\u4ef6,<br \/>\n\u90a3\u4e48\u5728\u5404\u4e2a\u540d\u5b57\u95f4\u7528\u7a7a\u683c\u9694\u5f00.<br \/>\nhelloworld_SOURCES<br \/>\n\u3000\u3000\u8fd9\u4e2a\u662f \u6307\u5b9a\u4ea7\u751f\"helloworld\"\u65f6\u6240\u9700\u8981\u7684 \u6e90\u4ee3\u7801.\u5982\u679c\u5b83\u7528\u5230\u4e86\u591a\u4e2a\u6e90\u6587\u4ef6,<br \/>\n\u90a3\u4e48\u8bf7\u4f7f\u7528\u7a7a\u683c\u7b26\u53f7\u5c06\u5b83\u4eec\u9694\u5f00.\u6bd4\u5982\u9700\u8981helloworld.h,helloworld.c\u90a3\u4e48\u8bf7\u5199\u6210:<br \/>\nhelloworld_SOURCES= helloworld.h helloworld.c.<br \/>\n\u3000\u3000\u5982\u679c\u4f60\u5728 bin_PROGRAMS\u5b9a\u4e49\u4e86\u591a\u4e2a\u53ef\u6267\u884c\u6587\u4ef6,\u5219\u5bf9\u5e94\u6bcf\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u90fd\u8981\u5b9a\u4e49\u76f8\u5bf9\u7684<br \/>\nfilename_SOURCES.<br \/>\n6. automake<br \/>\n\u3000\u3000\u6211\u4eec\u4f7f\u7528automake --add-missing\u6765\u4ea7\u751fMakefile.in.<br \/>\n\u3000\u3000\u9009\u9879--add-missing\u7684 \u5b9a\u4e49\u662f \"add missing standard files<br \/>\n to package\",\u5b83\u4f1a\u8ba9automake\u52a0\u5165\u4e00\u4e2a\u6807\u51c6\u7684 \u8f6f\u4ef6\u5305\u6240\u5fc5\u987b\u7684 \u4e00\u4e9b\u6587\u4ef6.<br \/>\n\u3000\u3000\u6211\u4eec\u7528automake\u4ea7\u751f\u51fa\u6765\u7684 Makefile.in\u6587\u4ef6\u662f \u7b26\u5408GNU Makefile\u60ef\u4f8b<br \/>\n\u7684 ,\u63a5\u4e0b\u6765\u6211\u4eec\u53ea\u8981\u6267\u884cconfigure\u8fd9\u4e2ashell \u811a\u672c\u5c31\u53ef\u4ee5\u4ea7\u751f\u5408\u9002\u7684 Makefile \u6587<br \/>\n\u4ef6\u4e86.<br \/>\n7. Makefile<br \/>\n\u3000\u3000\u5728 \u7b26\u5408GNU Makefiel\u60ef\u4f8b\u7684 Makefile\u4e2d,\u5305\u542b\u4e86\u4e00\u4e9b\u57fa\u672c\u7684 \u9884\u5148\u5b9a\u4e49\u7684 \u64cd\u4f5c\uff1a<\/p>\n<p>make<br \/>\n\u3000\u3000\u6839\u636eMakefile\u7f16\u8bd1\u6e90\u4ee3\u7801,\u8fde\u63a5,\u751f\u6210\u76ee\u6807\u6587\u4ef6,\u53ef\u6267\u884c\u6587\u4ef6.<br \/>\nmake clean<br \/>\n\u3000\u3000\u6e05\u9664\u4e0a\u6b21\u7684 make\u547d\u4ee4\u6240\u4ea7\u751f\u7684 object\u6587\u4ef6\uff08\u540e\u7f00\u4e3a\".o\"\u7684 \u6587\u4ef6\uff09\u53ca\u53ef\u6267\u884c\u6587\u4ef6.<br \/>\nmake install<br \/>\n\u3000\u3000\u5c06\u7f16\u8bd1\u6210\u529f\u7684 \u53ef\u6267\u884c\u6587\u4ef6\u5b89\u88c5\u5230\u7cfb\u7edf\u76ee\u5f55\u4e2d,\u4e00\u822c\u4e3a\/usr\/local\/bin\u76ee\u5f55.<br \/>\nmake dist<br \/>\n\u3000\u3000\u4ea7\u751f\u53d1\u5e03\u8f6f\u4ef6\u5305\u6587\u4ef6\uff08\u5373distribution package\uff09.\u8fd9\u4e2a\u547d\u4ee4\u5c06\u4f1a\u5c06\u53ef\u6267\u884c\u6587\u4ef6\u53ca\u76f8\u5173<br \/>\n\u6587\u4ef6\u6253\u5305\u6210\u4e00\u4e2atar.gz\u538b\u7f29\u7684 \u6587\u4ef6\u7528\u6765\u4f5c\u4e3a\u53d1\u5e03\u8f6f\u4ef6\u7684 \u8f6f\u4ef6\u5305.<br \/>\n\u3000\u3000\u5b83\u4f1a\u5728 \u5f53\u524d\u76ee\u5f55\u4e0b\u751f\u6210\u4e00\u4e2a\u540d\u5b57\u7c7b\u4f3c\"PACKAGE-VERSION.tar.gz\"\u7684 \u6587\u4ef6.PA<br \/>\nCKAGE\u548cVERSION,\u662f \u6211\u4eec\u5728 configure.in\u4e2d\u5b9a\u4e49\u7684 AM_INIT_AUTOM<br \/>\nAKE(PACKAGE, VERSION).<br \/>\nmake distcheck<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u9519\u8bef\u5904\u7406\uff1a<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"text-decoration: underline;\">When try to configure an open source code, I get error like this :<\/span><\/p>\n<p><span style=\"text-decoration: underline;\"><strong>configure: error: cannot find install-sh, install.sh, or shtool in \u201c.\u201d \u201c.\/..\u201d \u201c.\/..\/..\u201d<\/strong><\/span><\/p>\n<p>&lt;pre&gt;<\/p>\n<div class=\"crayon-pre\">\n<div id=\"crayon-5679320366769241968041-1\" class=\"crayon-line\"><span class=\"crayon-v\">autoreconf<\/span> <span class=\"crayon-o\">-<\/span><span class=\"crayon-v\">f<\/span> <span class=\"crayon-o\">-<\/span><span class=\"crayon-v\">i<\/span> <span class=\"crayon-o\">-<\/span><span class=\"crayon-v\">Wall<\/span><span class=\"crayon-sy\">,<\/span><span class=\"crayon-v\">no<\/span><span class=\"crayon-o\">-<\/span><span class=\"crayon-i\">obsolete<\/span><\/div>\n<div id=\"crayon-5679320366769241968041-2\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-sy\">.<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-v\">configure<\/span><\/div>\n<\/div>\n<p>&lt;\/pre&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h1><span style=\"text-decoration: underline;\"><span class=\"title text_overflow\">\"Libtool library used but 'LIBTOOL' is undefined\"<\/span><\/span><\/h1>\n<p>&lt;pre&gt;sudo\u00a0apt-get\u00a0install\u00a0autoconf<br \/>\nsudo\u00a0apt-get\u00a0install\u00a0automake<br \/>\nsudo\u00a0apt-get\u00a0install\u00a0libtool<\/p>\n<p>\u91cd\u65b0\u6267\u884caclocal\/autoheader&lt;\/pre&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>required file `build\/ltmain.sh' not found<\/strong><\/span><\/p>\n<p><span class=\"katex math inline\">automake --add-missing<br \/>\n....<br \/>\nconfigure.in:18: required file `build\/ltmain.sh' not found<br \/>\n....<br \/>\n\u89e3\u51b3\u65b9\u6848(libtoolize\u914d\u7f6e\u5373\u53ef)\uff1a<\/span>libtoolize --version<br \/>\n-libtoolize (GNU libtool) 1.4.2<br \/>\n.....<br \/>\n$libtoolize --automake --copy --debug --force<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; \/\/\u6839\u636econfigure.in\u548cMakefile.am\u751f\u6210makefile\u7684\u6b65\u9aa4\uff0c\u57fa\u4e8eUBUN [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-1649","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/1649","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1649"}],"version-history":[{"count":18,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/1649\/revisions"}],"predecessor-version":[{"id":1678,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/1649\/revisions\/1678"}],"wp:attachment":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1649"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}