{"id":285340,"date":"2023-10-18T03:01:59","date_gmt":"2023-10-17T19:01:59","guid":{"rendered":"https:\/\/lrxjmw.cn\/lnhzdmwjjjjb.html"},"modified":"2023-10-18T03:01:59","modified_gmt":"2023-10-17T19:01:59","slug":"lnhzdmwjjjjb","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/lnhzdmwjjjjb.html","title":{"rendered":"Linux\u5185\u6838\u4e2d\u7684Makefile\u6587\u4ef6\u53ca\u89e3\u51b3\u529e\u6cd5\u2014\u2014Makefile"},"content":{"rendered":"
\u4f17\u6240\u5468\u77e5\uff0cLinux<\/a>\u5185\u6838\u662f\u4f7f\u7528make\u547d\u4ee4<\/a>\u6765\u914d\u7f6e\u5e76\u7f16\u8bd1\u7684\uff0c\u90a3\u5fc5\u7136\u5c11\u4e0d\u4e86Makefile\u3002\u8fd9\u4e48\u590d\u6742\u3001\u5e9e\u5927\u7684\u5185\u6838\u6e90\u7801\u7edd\u4e0d\u53ef\u80fd\u4f7f\u7528\u4e00\u4e2a\u6216\u51e0\u4e2aMakefile\u6587\u4ef6\u6765\u5b8c\u6210\u914d\u7f6e\u7f16\u8bd1\uff0c\u800c\u662f\u987b\u8981\u4e00\u5957\u540c\u6837\u590d\u6742\u3001\u5e9e\u5927\uff0c\u4e14\u4e3aLinux\u5185\u6838\u8ba2\u5236\u7684Makefile\u7cfb\u7edf<\/a>\u3002<\/p>\n \u672c\u6587\u5f15\u7528\u5730\u5740\uff1a<\/p>\n \u867d\u7136\u5979\u662f\u4e00\u4e2a\u590d\u6742\u7684\u7cfb\u7edf\uff0c\u4f46\u5bf9\u7edd\u5927\u90e8\u4efd\u5185\u6838\u5f00\u53d1\u8005\u6765\u8bf4\u53ea\u987b\u8981\u6653\u5f97\u600e\u6837\u4f7f\u7528\uff0c\u800c\u65e0\u9700\u4e86\u89e3\u5176\u4e2d\u7684\u7ec6\u8282\u3002\u5979\u5bf9\u7edd\u5927\u90e8\u4efd\u5185\u6838\u5f00\u53d1\u8005\u57fa\u672c\u4e0a\u662f\u900f\u660e\u7684\uff0c\u9690\u85cf\u4e86\u5927\u90e8\u4efd\u5b9e\u73b0\u7ec6\u8282\uff0c\u6709\u6548\u5730\u51cf\u5c11\u4e86\u5f00\u53d1\u8005\u7684\u8d1f\u62c5\uff0c\u80fd\u4f7f\u5176\u80fd\u4e13\u6ce8\u4e8e\u5185\u6838\u5f00\u53d1\uff0c\u800c\u4e0d\u81f3\u4e8e\u8017\u8d39\u65f6\u95f4\u548c\u7cbe\u529b\u5728\u7f16\u8bd1\u8fc7\u7a0b\u4e0a\u3002<\/p>\n 1.1Linux\u5185\u6838\u4e2d\u7684Makefile\u6587\u4ef6<\/p>\n 1.1.1\u9876\u697cMakefile<\/p>\n \u6e90\u7801\u76ee\u5f55\u6811\u9876\u697cMakefile\u662f\u6574\u4e2a\u5185\u6838\u6e90\u7801\u7ba1\u7406\u7684\u5165\u53e3\uff0c\u5bf9\u6574\u4e2a\u5185\u6838\u7684\u6e90\u7801\u7f16\u8bd1\u8d77\u7740\u51b3\u5b9a\u6027\u4f5c\u7528\u3002\u7f16\u8bd1\u5185\u6838\u65f6\uff0c\u9876\u697cMakefile\u4f1a\u6309\u89c4\u5219\u9012\u5f52\u5386\u904d\u5185\u6838\u6e90\u7801\u7684\u6240\u6709\u5b50\u76ee\u5f55\u4e0b\u7684Makefile\u6587\u4ef6\uff0c\u5b8c\u6210\u5404\u5b50\u76ee\u5f55\u4e0b\u5185\u6838\u6a21\u5757\u7684\u7f16\u8bd1\u3002\u719f\u6089\u4e00\u4e0b\u8be5Makefile\uff0c\u5bf9\u5185\u6838\u7f16\u8bd1\u7b49\u65b9\u9762\u4f1a\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n 1.\u5185\u6838\u7248\u672c\u53f7<\/p>\n \u6253\u5f00\u9876\u697cMakefile\uff0c\u5f00\u5934\u7684\u51e0\u884c\u8bb0\u5f55\u4e86\u5185\u6838\u6e90\u7801\u7684\u7248\u672c\u53f7\uff0c\u4e00\u822c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n 620)this.width=620;\"\/><\/p>\n \u8bf4\u660e\u4ee3\u7801\u7248\u672c\u4e3a2.6.35.3\uff0c\u7f16\u8bd1\u5f97\u5230\u7684\u5185\u6838\u5728\u76ee\u6807\u677f\u8fd0\u884c\u540e\uff0c\u8f93\u5165uname-a\u547d\u4ee4\u53ef\u4ee5\u5f97\u5230\u5370\u8bc1\uff1a<\/p>\n 620)this.width=620;\"\/><\/p>\n 2.\u7f16\u8bd1\u63a7\u5236<\/p>\n (1)\u4f53\u7cfb\u7ed3\u6784<\/p>\n Linux\u662f\u4e00\u4e2a\u652f\u6301\u8bf8\u591a\u4f53\u7cfb\u7ed3\u6784\u7684\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5728\u7f16\u8bd1\u8fc7\u7a0b\u4e2d\u9700\u6307\u5b9a\u4f53\u7cfb\u7ed3\u6784\uff0c\u4ee5\u4e0e\u5b9e\u9645\u5e73\u53f0\u5bf9\u5e94\u3002\u5728\u9876\u697cMakefile\u4e2dLINUX\u793e\u533a\uff0c\u901a\u8fc7\u53d8\u91cfARCH\u6765\u6307\u5b9a\uff1a<\/p>\n <\/p>\n 620)this.width=620;\"\/><\/p>\n \u82e5\u679c\u6ca1\u6709\u5728\u7f16\u8bd1\u547d\u4ee4\u884c\u98df\u6307\u5b9aARCH\u53c2\u6570\uff0c\u7cfb\u7edf\u5c06\u4f1a\u8fdb\u884c\u672c\u5730\u7f16\u8bd1\uff0c\u901a\u8fc7\u83b7\u53d6\u672c\u673a\u4fe1\u606f\u6765\u624b\u52a8\u6307\u5b9a\uff1a<\/p>\n <\/p>\n 620)this.width=620;\"\/><\/p>\n \u5047\u5982\u8fdb\u884cARM\u5d4c\u5165\u5f0fLinux\u5f00\u53d1linux\u57f9\u8bad\u73ed\uff0c\u5219\u5fc5\u987b\u6307\u5b9aARCH\u4e3aarm(\u6ce8\u610f\u5927\u5c0f\u5199\uff0c\u987b\u4e0earch\/\u76ee\u5f55\u4e0b\u7684arm\u4e00\u81f4)\uff0c\u5982\uff1a<\/p>\n 620)this.width=620;\"\/><\/p>\n \u5176\u5b9e\uff0c\u4e5f\u53ef\u4ee5\u66f4\u6539Makefilelinux\u4fee\u6539\u5185\u6838\u53c2\u6570<\/strong>\uff0c\u5c06\u66f4\u6539\u4e3aARCH?=$(SUBARCH)\u66f4\u6539\u4e3aARCH=arm\uff0c\u5728\u547d\u4ee4\u884c\u76f4\u63a5make\u5373\u53ef\u3002<\/p>\n (2)\u7f16\u8bd1\u5668<\/p>\n \u5018\u82e5\u4e0d\u662f\u8fdb\u884c\u672c\u5730\u7f16\u8bd1\uff0c\u5219\u987b\u6307\u5b9a\u4ea4\u53c9\u7f16\u8bd1\u5668\uff0c\u901a\u8fc7CROSS_COMPILE\u6765\u6307\u5b9a\u3002Makefile\u4e2d\u4e0e\u4ea4\u53c9\u7f16\u8bd1\u5668\u7684\u6307\u5b9a\u5982\u4e0b\uff1a<\/p>\n <\/p>\n 620)this.width=620;\"\/><\/p>\n CONFIG_CROSS_COMPILE\u662f\u4e00\u4e2a\u914d\u7f6e\u9009\u9879\uff0c\u53ef\u5728\u5185\u6838\u914d\u7f6e\u65f6\u4faf\u6307\u5b9a\u3002\u82e5\u679c\u5728\u914d\u7f6e\u5185\u6838\u65f6\u4faf\u6ca1\u6709\u6307\u5b9aCONFIG_CROSS_COMPILE\uff0c\u4e5f\u6ca1\u6709\u5728\u7f16\u8bd1\u53c2\u6570\u6307\u5b9aCROSS_COMPILE\uff0c\u5219\u4f1a\u91c7\u7528\u672c\u5730\u7f16\u8bd1\u5668\u8fdb\u884c\u7f16\u8bd1\u3002<\/p>\n \u8fdb\u884cARM\u5d4c\u5165\u5f0fLinux\u5f00\u53d1\uff0c\u5fc5\u987b\u6307\u5b9a\u4ea4\u53c9\u7f16\u8bd1\u5668\uff0c\u53ef\u4ee5\u5728\u5185\u6838\u914d\u7f6e\u901a\u8fc7CONFIG<\/p>\n _CROSS_COMPILE\u6307\u5b9a\u4ea4\u53c9\u7f16\u8bd1\u5668\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7CROSS_COMPILE\u6307\u5b9a\u3002\u5047\u8bbe\u4f7f\u7528\u7684\u4ea4\u53c9\u7f16\u8bd1\u5668\u662farm-linux-gnueabihf-gcc\uff0c\u5219\u6307\u5b9aCROSS_COMPILE\u4e3aarm-linux-gnueabihf-\uff1a<\/p>\n <\/p>\n 620)this.width=620;\"\/><\/p>\n \u6216\u5219\u5728Makefile\u4e2d\uff0c\u76f4\u63a5\u6307\u5b9aCROSS_COMPILE\u7684\u503c\uff1a<\/p>\n 620)this.width=620;\"\/><\/p>\n \u6ce8\u610f\uff1aCROSS_COMPILE\u6307\u5b9a\u7684\u4ea4\u53c9\u7f16\u8bd1\u5668\u5fc5\u987b\u4e8b\u5148\u5b89\u88c5\u5e76\u6b63\u786e\u8bbe\u7f6e\u7cfb\u7edf\u73af\u5883\u53d8\u91cf;\u5047\u5982\u6ca1\u6709\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u5219\u9700\u4f7f\u7528\u7edd\u5bf9\u5730\u5740\uff0c\u6bd4\u5982\uff1a<\/p>\n 620)this.width=620;\"\/><\/p>\n \u5047\u5982\u540c\u65f6\u6307\u5b9a\u4e86ARCH\u548cCROSS_COMPILE\uff0c\u5219\u5728\u7f16\u8bd1\u7684\u65f6\u4faf\uff0c\u53ea\u9700\u7b80\u5355\u7684make\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n 1.1.2\u5b50\u76ee\u5f55\u7684Makefile<\/p>\n \u5728\u5185\u6838\u6e90\u7801\u7684\u5b50\u76ee\u5f55\u4e2d\uff0c\u51e0\u4e4e\u6bcf\u4f4d\u5b50\u76ee\u5f55\u90fd\u6709\u76f8\u5e94\u7684Makefile\u6587\u4ef6\uff0c\u7ba1\u7406\u7740\u5bf9\u5e94\u76ee\u5f55\u4e0b\u7684\u4ee3\u7801\u3002\u5bf9\u8be5\u76ee\u5f55\u7684\u6587\u4ef6\u6216\u5219\u5b50\u76ee\u5f55\u7684\u7f16\u8bd1\u63a7\u5236\uff0cMakefile\u4e2d\u6709\u4e24\u79cd\u8868\u793a\u65b9\u6cd5\uff0c\u4e00\u79cd\u662f\u9ed8\u8ba4\u9009\u62e9\u7f16\u8bd1\uff0c\u7528obj-y\u8868\u793a\uff0c\u5982\uff1a<\/p>\n 620)this.width=620;\"\/><\/p>\n \u53e6\u4e00\u79cd\u8868\u793a\u5219\u4e0e\u5185\u6838\u914d\u7f6e\u9009\u9879\u76f8\u5173\u8054\uff0c\u7f16\u8bd1\u4e0e\u5426\u4ee5\u53ca\u7f16\u8bd1\u65b9\u6cd5\u53d6\u51b3\u4e8e\u5185\u6838\u914d\u7f6elinux\u4fee\u6539\u5185\u6838\u53c2\u6570<\/strong>\uff0c\u6bd4\u5982\uff1a<\/p>\n 620)this.width=620;\"\/><\/p>\n \u662f\u5426\u7f16\u8bd1wdt.c\u6587\u4ef6\uff0c\u6216\u5219\u4ee5\u4f55\u79cd\u5f62\u5f0f\u7f16\u8bd1\uff0c\u53d6\u51b3\u4e8e\u5185\u6838\u914d\u7f6e\u540e\u7684\u53d8\u91cfCONFIG_WDT\u503c\uff1a\u5047\u5982\u5728\u914d\u7f6e\u4e2d\u8bbe\u7f6e\u4e3a[*]\uff0c\u5219\u9759\u6001\u7f16\u8bd1\u5230\u5185\u6838\uff0c\u5047\u5982\u914d\u7f6e\u4e3a[M]\uff0c\u5219\u7f16\u8bd1\u4e3awdt.ko\u6a21\u5757\uff0c\u5426\u5219\u4e0d\u7f16\u8bd1\u3002<\/p>\n \u8bf4\u660e\uff1a\u53d7\u63a7\u76ee\u6807\u662f\u4e00\u4e2a\u76ee\u5f55\uff0cobj-y\u5e76\u4e0d\u76f4\u63a5\u51b3\u5b9a\u53d7\u63a7\u76ee\u5f55\u7684\u6587\u4ef6\u4ee5\u53ca\u5b50\u76ee\u5f55\u7684\u6587\u4ef6\uff0c\u4ec5\u4ec5\u662f\u4e0e\u53d7\u63a7\u76ee\u5f55Makefile\u4ea4\u4e92\uff0c\u5b9e\u9645\u7f16\u8bd1\u63a7\u5236\u5728\u53d7\u63a7\u5b50\u76ee\u5f55\u7684Makefile\u4e2d\u3002\u8bf8\u5982\u201cobj-y+=gpio\/\u201d\uff0c\u6700\u7ec8gpio\u76ee\u5f55\u4e0b\u4ec0\u4e48\u6587\u4ef6\u88ab\u7f16\u8bd1\uff0c\u5b8c\u5168\u53d6\u51b3\u4e8egpio\u76ee\u5f55\u4e0b\u7684Makefile\u3002\u201cobj-$(CONFIG_PCI)+=pci\/\u201d\u7684\u6db5\u4e49\u540c\u7406\u3002<\/p>\n","protected":false},"excerpt":{"rendered":" \u5982\u6b64\u590d\u6742\u3001\u5e9e\u5927\u7684\u5185\u6838\u6e90\u7801\u7edd\u4e0d\u53ef\u80fd\u4f7f\u7528\u4e00\u4e2a\u6216\u51e0\u4e2aMakefile\u6587\u4ef6\u6765\u5b8c\u6210\u914d\u7f6e\u7f16\u8bd1\uff0c\u800c\u662f\u9700\u8981\u4e00\u5957\u540c\u6837\u590d\u6742\u3001\u5e9e\u5927\uff0c\u4e14\u4e3aLinux\u5185\u6838\u5b9a\u5236\u7684Makefile\u7cfb\u7edf\u3002\u5728\u5185\u6838\u6e90\u7801\u7684\u5b50\u76ee\u5f55\u4e2d\uff0c\u51e0\u4e4e\u6bcf\u4e2a\u5b50\u76ee\u5f55\u90fd\u6709\u76f8\u5e94\u7684Makefile\u6587\u4ef6\uff0c\u7ba1\u7406\u7740\u5bf9\u5e94\u76ee\u5f55\u4e0b\u7684\u4ee3\u7801\u3002<\/p>\n","protected":false},"author":1,"featured_media":285341,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[999],"class_list":["post-285340","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tougao","tag-999"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/285340","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=285340"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/285340\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/285341"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=285340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=285340"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=285340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}