{"id":54,"date":"2025-10-14T14:33:16","date_gmt":"2025-10-14T06:33:16","guid":{"rendered":"http:\/\/47.99.178.170\/?p=54"},"modified":"2025-10-14T14:35:27","modified_gmt":"2025-10-14T06:35:27","slug":"%e3%80%90%e7%bc%96%e7%a8%8b%e8%af%ad%e8%a8%80%e5%ad%a6%e4%b9%a0%e3%80%91gnu-make-3%e5%ae%9e%e6%88%98","status":"publish","type":"post","link":"https:\/\/www.garfield-blog.top\/?p=54","title":{"rendered":"\u3010\u7f16\u7a0b\u8bed\u8a00\u5b66\u4e60\u3011GNU make (3)\u5b9e\u6218"},"content":{"rendered":"\n<p>\u6709\u5982\u4e0b\u9879\u76ee\u76ee\u5f55\u7ed3\u6784<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u2514\u2500C_build_demo\n    \u251c\u2500inc\n    \u2514\u2500src<\/code><\/pre>\n\n\n\n<p>\u53ef\u4ee5\u4f7f\u7528\u8fd9\u6837\u7684\u4e07\u80fd\u6a21\u677f\u6765\u8fdb\u884c\u7f16\u8bd1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CC := gcc\nSRCS := $(wildcard .\/src\/*.c)\nTARGETS := $(patsubst %.c, %.o, $(SRCS))\nCFLAGS := -g -Wall \nINC_DIR = -I .\/inc\/                     #\u94fe\u63a5\u81ea\u5b9a\u4e49\u5934\u6587\u4ef6\u8def\u5f84\nLIB := -lm                              #\u94fe\u63a5\u5e93 \nLDFLAGS = -L.\/lib -Wl,-rpath=.\/lib      #\u81ea\u5b9a\u4e49\u52a8\u6001\u5e93\u8def\u5f84\uff0c\u5e76\u8bbe\u7f6e\u7a0b\u5e8f\u5141\u8bb8\u65f6\u4ece\u8fd9\u4e2a\u8def\u5f84\u8bfb\u53d6\u52a8\u6001\u5e93\nEXEC_BIN := a.out                       #\u7f16\u8bd1\u4ea7\u7269,\u53ef\u6267\u884c\u6587\u4ef6\nEXEC_LIB := liba.so                     #\u7f16\u8bd1\u4ea7\u7269,\u52a8\u6001\u5e93\n\nall: $(EXEC_BIN) $(EXEC_LIB)\n\trm $(TARGETS)\n\n$(EXEC_BIN): $(TARGETS)\n\t$(CC) $^ -o $@ $(LDFLAGS) $(LIB)\n\t\n$(EXEC_LIB): $(TARGETS)\n\t$(CC) -shared -fPIC -o $@ $(TARGETS)\n\n$(TARGETS): %.o: %.c\n\t$(CC) -c $(CFLAGS) $(INC_DIR) $&lt; -o $@\n\n.PHONY: clean\nclean:\n\trm $(EXEC_BIN) $(EXEC_LIB)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u5982\u4e0b\u9879\u76ee\u76ee\u5f55\u7ed3\u6784 \u53ef\u4ee5\u4f7f\u7528\u8fd9\u6837\u7684\u4e07\u80fd\u6a21\u677f\u6765\u8fdb\u884c\u7f16\u8bd1<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[7],"tags":[],"class_list":["post-54","post","type-post","status-publish","format-standard","hentry","category-learning-programming-languages"],"_links":{"self":[{"href":"https:\/\/www.garfield-blog.top\/index.php?rest_route=\/wp\/v2\/posts\/54","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.garfield-blog.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garfield-blog.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garfield-blog.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garfield-blog.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=54"}],"version-history":[{"count":2,"href":"https:\/\/www.garfield-blog.top\/index.php?rest_route=\/wp\/v2\/posts\/54\/revisions"}],"predecessor-version":[{"id":56,"href":"https:\/\/www.garfield-blog.top\/index.php?rest_route=\/wp\/v2\/posts\/54\/revisions\/56"}],"wp:attachment":[{"href":"https:\/\/www.garfield-blog.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=54"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garfield-blog.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=54"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garfield-blog.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}