In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
We learned about path search in makefile earlier, so let's practice it today. Needs analysis: 1, the project does not need the source folder to be changed at compilation time (read-only folder); 2, the compilation time automatically create a folder (build) to store compilation results; 3, the compilation process can automatically search for needed files; 3, the compilation process can automatically search for needed files; 4, makefile is easy to expand, can be reused for the same type of projects; 5, support the debug version of the compilation option.
Let's take a look at the types of projects, as follows
So the tool materials we need are: a > $(wildcard $(DIR) / _ pattern) to get the files in the $(DIR) folder that satisfy _ pattern; b > $(notdir _ names) to remove the path prefix of each filename in _ names; c > $(patsubst _ pattern, replacement, _ text) to replace the part of _ text that conforms to _ pattern with replacement. The key skills are: 1, automatically get the source file list (function call): SRCS: = $(wildcard src/*.c); 2, generate the target file list according to the source file list (variable value replacement): OBJS: = $(SRCS:.c=.o); 3, replace each target file path prefix (function call): OBJS: = $(patsubst src/%, build/%, $(OBJS)). Let's look at the dependencies of the compilation rules, as shown in the following figure
Let's see how to write makefile. The src and inc folders are still the same as before.
.PHONY: all clean rebuildDIR_BUILD: = buildDIR_SRC: = srcDIR_INC: = incTYPE_INC: = .hTYPE _ SRC: = .cTYPE _ OBJ: = .oCC: = gccCFLAGS: =-I $(DIR_INC) ifeq ($(DEBUG) True) CFLAGS + =-gendifMKDIR: = rm-rfAPP: = $(DIR_BUILD) / app.outHDRS: = $(wildcard $(DIR_INC) / * $(TYPE_INC)) HDRS: = $(notdir $(HDRS)) OBJS: = $(wildcard $(DIR_SRC) / * $(TYPE_SRC)) OBJS: = $(OBJS:$ (TYPE_SRC) = $(TYPE_OBJ) OBJS: = $(patsubst $(DIR_SRC) /%, $(DIR_BUILD) /% $(OBJS)) vpath% $(TYPE_INC) $(DIR_INC) vpath% $(TYPE_SRC) $(DIR_SRC) all: $(DIR_BUILD) $(APP) @ echo "Target File = > $(APP)" $(DIR_BUILD): $(MKDIR) $@ $(APP): $(OBJS) $(CC)-o $@ $^ $(DIR_BUILD) /% $(TYPE_OBJ):% $(TYPE_SRC) $ (HDRS) $(CC) $(CFLAGS)-o $@-c $
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.