{"id":197,"date":"2013-01-21T21:47:09","date_gmt":"2013-01-21T13:47:09","guid":{"rendered":"http:\/\/www.freezhongzi.info\/?p=197"},"modified":"2013-01-21T21:47:09","modified_gmt":"2013-01-21T13:47:09","slug":"%e5%b8%ae%e5%90%8c%e4%ba%8b%e5%88%86%e6%9e%90makefile%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/bl4kraven.com\/index.php\/2013\/01\/21\/%e5%b8%ae%e5%90%8c%e4%ba%8b%e5%88%86%e6%9e%90makefile%e6%96%87%e4%bb%b6\/","title":{"rendered":"\u5e2e\u540c\u4e8b\u5206\u6790Makefile\u6587\u4ef6"},"content":{"rendered":"<p>\u540c\u4e8b\u60f3\u770b\u5f00\u6e90\u9879\u76ee<a href=\"https:\/\/github.com\/contiki\/contiki-mirror\">contiki<\/a>\uff0c\u65e0\u5948\u88ab\u5176\u590d\u6742\u7684Makefile\u641e\u6655\u800c\u627e\u6211\u5e2e\u5fd9\u3002\u6211\u5927\u81f4\u770b\u4e86\u4e00\u4e9b\uff0c\u7531\u4e8e\u8fd9\u4e2a\u9879\u76ee\u6d89\u53ca\u5230\u591a\u4e2a\u76ee\u6807\u5e73\u53f0\uff0c\u7ed3\u6784\u590d\u6742\u53ef\u60f3\u800c\u77e5\u5566-_-!!!\u3002\u8fd9\u91cc\u7528\u76f8\u5bf9\u7b80\u5355\u7684\u539f\u751f\u5e73\u53f0(native)\u6765\u5256\u6790\u4e00\u4e0b\u3002<\/p>\n<p>\u5927\u81f4\u4e0a\u6709\u56db\u4e2a\u91cd\u8981\u7684Makefile\u6587\u4ef6\uff1a<\/p>\n<ol>\n<li>\n<p>\u81ea\u5df1\u7684\u5e94\u7528\u7a0b\u5e8fMakefile\uff0c\u5982examples\/email\/Makefile\uff1a<\/p>\n<p>\u8fd9\u4e2a\u5b9a\u4e49\u4e86\u6700\u7ec8\u7684\u76ee\u6807\u5e94\u7528\u7a0b\u5e8f\u540d\uff0c\u5982email\uff1a<\/p>\n<pre><code>CONTIKI_PROJECT = email-client\nall: $(CONTIKI_PROJECT)\n\nAPPS = email\n\nCONTIKI = ..\/..\ninclude $(CONTIKI)\/Makefile.include\n<\/code><\/pre>\n<\/li>\n<li>\n<p>\u6839\u76ee\u5f55\u7684Makefile.include\uff1a<\/p>\n<p>\u8fd9\u4e2a\u63d0\u4f9b\u4e86\u7edf\u4e00\u7684Makefile\u6846\u67b6\uff0c\u63d0\u4f9b\u4e00\u822c\u7684\u7f16\u8bd1\u9009\u9879\u548c\u529f\u80fd\uff0c\u5404\u4e2a\u5e73\u53f0\u53ef\u4ee5\u8986\u76d6\u8fd9\u4e9b\u9ed8\u8ba4\u89c4\u5219\u3002<\/p>\n<\/li>\n<li>\n<p>platform\/native\/Makefile.native:<\/p>\n<p>\u8fd9\u4e2a\u662f\u5e73\u53f0\u76f8\u5173\u7684\u786c\u4ef6\uff0c\u5982\u4e32\u53e3\u3001led\u7b49\uff0c\u4ee5\u53ca\u5b9a\u4e49\u6700\u7ec8\u94fe\u63a5\u751f\u6210\u7684\u76ee\u6807\u6587\u4ef6%.$(Target)\u7684\u7f16\u8bd1\u89c4\u5219\u3002<strong>\u539f\u751f\u5e73\u53f0\uff08native\uff09\u76f4\u63a5\u5728Makefile.include\u91cc\u5b9a\u4e49\u4e86\u6700\u7ec8\u76ee\u6807%.$(Target)\u7684\u89c4\u5219\u4e86<\/strong>\u3002\u5176\u4ed6\u7684\u5e73\u53f0\u8981\u5b9a\u4e49\u5b8fCUSTOM_RULE_LINK\u6765\u8fdb\u884c\u8986\u76d6\u3002<\/p>\n<\/li>\n<li>\n<p>cpu\/native\/Makefile.native<\/p>\n<p>\u8fd9\u4e2a\u5b9a\u4e49\u76ee\u6807\u6587\u4ef6\u548c\u5e93\u7684\u7f16\u8bd1\u3002\u5982\u679c\u8fd9\u91cc\u4e0d\u662fnative\u5e73\u53f0\uff0c\u8981\u5b9a\u4e49\u81ea\u5df1\u7684\u94fe\u63a5\u548c\u7f16\u8bd1\u89c4\u5219\uff0c\u8981\u9884\u5148\u5b9a\u4e49\u51e0\u4e2a\u5b8f\u8986\u76d6\u7cfb\u7edf\u9ed8\u8ba4\u7684\u89c4\u5219\uff1a<\/p>\n<pre><code>CUSTOM_RULE_LINK=1\nCUSTOM_RULE_C_TO_OBJECTDIR_O=1\nCUSTOM_RULE_ALLOBJS_TO_TARGETLIB=1\n<\/code><\/pre>\n<p>\u4e0a\u9762\u5206\u522b\u5bf9\u5e94\u94fe\u63a5\u3001\u7f16\u8bd1\u548c\u6253\u5305\u6210\u5e93\u3002\u7f16\u8bd1\u548c\u6253\u5305\u6210\u5e93\u76f4\u63a5\u5728\u8fd9\u4e2aMakefile\u91cc\uff0c\u6700\u7ec8\u7684\u94fe\u63a5\u5728platform\/<em>\/Makefile.<\/em>\u91cc\u3002<\/p>\n<\/li>\n<\/ol>\n<p>\u8bb2\u4e86\u8fd9\u4e48\u591a\uff0c\u6765\u770b\u4e00\u4e0b\u6700\u6280\u5de7\u6027\u7684\u5730\u65b9\u3002<\/p>\n<pre><code>CONTIKI_PROJECT = email-client\nall: $(CONTIKI_PROJECT)\n<\/code><\/pre>\n<p>\u8fd9\u91cc\u53ea\u6307\u5b9a\u4e86\u4e00\u4e2aemail-client\uff0c\u4e0d\u5e26\u4efb\u4f55\u6269\u5c55\u540d\u3002\u90a3make\u5982\u679c\u77e5\u9053\u4f9d\u8d56\u4ec0\u4e48\u80fd\uff1f\u8fd9\u91cc\u5c31\u8981\u7528\u5230make\u7684\u9690\u5f0f\u89c4\u5219\u4e86\u3002<\/p>\n<h2>\u9690\u5f0f\u89c4\u5219<\/h2>\n<p>make\u770b\u5230email-client\u8fd9\u4e2a\u76ee\u6807\u4f1a\u91c7\u7528\u4e24\u6761\u9690\u5f0f\u89c4\u5219\uff1a<\/p>\n<pre><code>%:%.c\n    gcc $(CFLAGS) %&lt; -o $@\n<\/code><\/pre>\n<p>\u6216\u8005<\/p>\n<pre><code># \u8fd9\u4e2a\u4f1a\u751f\u6210\u4e2d\u95f4\u6587\u4ef6xxx.o,make\u4f1a\u5728\u5b8c\u6210\u65f6\u5220\u9664\u3002\n%:%.o\n    gcc %&lt; -o $@\n\n%.o:%.c\n    gcc $(CFLAGS) -c %&lt; -o $@  \n<\/code><\/pre>\n<p>\u90a3\u5982\u679c\u8981\u8ba9make\u6267\u884c\u6211\u9884\u5b9a\u4e49\u7684\u4f9d\u8d56\u9879\uff1a<\/p>\n<pre><code># @ \u8868\u793a\u5360\u4f4d\u7b26\uff0c\u5982\u679c\u6ca1\u6709\u5219\u4ee3\u8868\u5220\u9664\u8fd9\u6761\u89c4\u5219\n%:%.$(TAGET)\n    @\n<\/code><\/pre>\n<p>\u5219\u8981\u5220\u9664%:%.c\u8fd9\u6761\u9690\u5f0f\u89c4\u5219\u624d\u80fd\u6267\u884c\u6211\u7684%:%.$(TAGET)\u3002\u81f3\u4e8e\u7b2c\u4e8c\u6761\u9690\u5f0f\u89c4\u5219\u76f8\u6bd4\u6211\u7684%:%.$(TAGET)\u8981\u590d\u6742\uff0cmake\u662f\u6bd4\u8f83\u806a\u660e\u7684\u4e0d\u56de\u7ed5\u8fdc\u8def\u7684\u3002<\/p>\n<p>\u5220\u9664%:%.c\u89c4\u5219(\u4e0d\u52a0\u547d\u4ee4\u9879)\uff1a<\/p>\n<pre><code>%:%.c\n<\/code><\/pre>\n<h2>\u91cd\u770bMakefile.include<\/h2>\n<p>\u6709\u4e86\u4e0a\u9762\u7684\u77e5\u8bc6\uff0c\u4e0b\u9762\u5c31\u6bd4\u8f83\u597d\u7406\u89e3\u4e86\uff0c\u6700\u7ec8\u7684\u76ee\u6807\u662femail-client.native\uff0c\u94fe\u63a5\u89c4\u5219\u662f\uff1a<\/p>\n<pre><code>ifndef CUSTOM_RULE_LINK\n%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a\n    $(LD) $(LDFLAGS) $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@\nendif\n<\/code><\/pre>\n<p>\u7f16\u8bd1\u89c4\u5219\u662f\uff1a<\/p>\n<pre><code>ifndef CUSTOM_RULE_C_TO_OBJECTDIR_O\n$(OBJECTDIR)\/%.o: %.c\n    $(CC) $(CFLAGS) -MMD -c $&lt; -o $@\n    @$(FINALIZE_DEPENDENCY)\nendif\n<\/code><\/pre>\n<p>\u6253\u5305\u751f\u4ea7\u5e93\u89c4\u5219\uff1a<\/p>\n<pre><code>ifndef CUSTOM_RULE_ALLOBJS_TO_TARGETLIB\ncontiki-$(TARGET).a: $(CONTIKI_OBJECTFILES)\n    $(AR) $(AROPTS) $@ $^\nendif\n<\/code><\/pre>\n<p>\u5176\u4ed6\u5e73\u53f0\u7684\u7c7b\u4f3c\uff0c\u53ea\u662f\u4e2d\u95f4\u6709\u5f88\u591a\u6b65\u9aa4\uff0c\u8fd9\u91cc\u4e0d\u7ec6\u8bb2\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u540c\u4e8b\u60f3\u770b\u5f00\u6e90\u9879\u76eecontiki\uff0c\u65e0\u5948\u88ab\u5176\u590d\u6742\u7684Makefile\u641e\u6655\u800c\u627e\u6211\u5e2e\u5fd9\u3002\u6211 &hellip; <a href=\"https:\/\/bl4kraven.com\/index.php\/2013\/01\/21\/%e5%b8%ae%e5%90%8c%e4%ba%8b%e5%88%86%e6%9e%90makefile%e6%96%87%e4%bb%b6\/\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a> <a href=\"https:\/\/bl4kraven.com\/index.php\/2013\/01\/21\/%e5%b8%ae%e5%90%8c%e4%ba%8b%e5%88%86%e6%9e%90makefile%e6%96%87%e4%bb%b6\/\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-197","post","type-post","status-publish","format-standard","hentry","category-program"],"_links":{"self":[{"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/posts\/197","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/comments?post=197"}],"version-history":[{"count":0,"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/posts\/197\/revisions"}],"wp:attachment":[{"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/media?parent=197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/categories?post=197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/tags?post=197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}