当前位置:网站首页>Makefile common functions notdir, wildcard, patsubst
Makefile common functions notdir, wildcard, patsubst
2022-07-23 17:36:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
notdir,wildcard and patsubst yes makefile Several useful functions in , I haven't noticed before makefile Usage of functions in , Take a look today ~
1、makefile The function in
makefile Function use in , It is similar to taking the value of a variable , It's with a ‘$’ Start , Then there is a parenthesis, which is the function name and the required parameter list , Multiple variables are separated by commas , like this
return = $(functionname arg1,arg2,arg3…).
Maybe here ’$’ It's more like taking a value from an address .
2、 wildcard
Use :SRC = $(wildcard *.c ./foo/*.c)
Search the current directory and ./foo/ All to .c Final document , Generate a list of file names separated by spaces , And assign it to SRC. The current directory file only has a file name , The file name under the subdirectory contains path information , such as ./foor/bar.c.
3、notdir
Use :SRC = $(notdir wildcard)
Remove all directory information ,SRC The list of file names in will only have file names .
4、patsubst
Use :OBJ = (patsubst %.o %.c (SRC))
patsubst yes patten substitude Abbreviation , The meaning of matching substitution . This sentence is in SRC Find everything in .c Final document , And then put all the .c Switch to .o.
Legendary omnipotence makefile
###########################################################
# Generic makefile
#
# by George Foot
# email: [email protected]
#
# Copyright (c)
1997 George Foot
# All rights reserved.
# All rights reserved
#
# No warranty, no liability;
# you use
this at your own risk.
# No insurance , Not responsible for
# You need this , At your own risk
#
# You are free to modify and
# distribute
this without giving
# credit to the original author.
# You can change and distribute this file at will
# There is no need to honor the original author .
# ( What do you mean ?)
#
######################################
### Customising
#
# Adjust the following
if necessary; EXECUTABLE
is the target
# executable
‘
s filename, and LIBS is a list of libraries to link in
# (e.g. alleg, stdcx, iostr, etc). You can
override these on make
‘
s
# command line of course,
if you prefer to
do it that way.
#
# if necessary , Adjust the following things . EXECUTABLE Is the executable name of the target , LIBS
# Is a list of packages that need to be connected ( for example alleg, stdcx, iostr wait ). Of course you
# Can be in make Command line overrides them , It's no problem if you like .
#
EXECUTABLE := mushroom.exe
LIBS := alleg
# Now alter any
implicit rules
‘
variables if you like, e.g.:
#
# Now change the variables in any implicit rules you want to change , for example
CFLAGS := -g -Wall -O3 -m486
CXXFLAGS := $(CFLAGS)
# The next bit checks to see whether rm
is
in your djgpp bin
# directory;
if not it uses del instead, but
this can cause (harmless)
# `File not found
‘
error messages. If you are not using DOS at all,
#
set the variable to something which will unquestioningly remove
# files.
#
# Now check your djgpp Is there... Under the command directory rm command , If not , We use
# del Order instead of , But it may give us
‘
File not found
‘ This error message , This is not
# What a big problem . If you don't use DOS , Set it as a command to delete files without nonsense .
# ( In fact, this step is UNIX Class is redundant , It's just convenient DOS Users . UNIX
# Users can delete this 5 Line command .)
ifneq ($(wildcard $(DJDIR)/bin/rm.exe),)
RM-F := rm -f
else
RM-F := del
endif
# You shouldn
‘
t need to change anything below this point.
#
# Start here , You should not need to change anything .( I don't quite believe , too NB 了 !)
SOURCE := $(wildcard *.c) $(wildcard *.cc)
OBJS := $(patsubst %.c,%.o,$(patsubst %.cc,%.o,$(SOURCE)))
DEPS := $(patsubst %.o,%.d,$(OBJS))
MISSING_DEPS := $(filter-
out $(wildcard $(DEPS)),$(DEPS))
MISSING_DEPS_SOURCES := $(wildcard $(patsubst %.d,%.c,$(MISSING_DEPS)) \
$(patsubst %.d,%.cc,$(MISSING_DEPS)))
CPPFLAGS += -MD
.PHONY : everything deps objs clean veryclean rebuild
everything : $(EXECUTABLE)
deps : $(DEPS)
objs : $(OBJS)
clean :
@$(RM-F) *.o
@$(RM-F) *.d
veryclean: clean
@$(RM-F) $(EXECUTABLE)
rebuild: veryclean everything
ifneq ($(MISSING_DEPS),)
$(MISSING_DEPS) :
@$(RM-F) $(patsubst %.d,%.o,[email protected])
endif
-include $(DEPS)
$(EXECUTABLE) : $(OBJS)
gcc -o $(EXECUTABLE) $(OBJS) $(addprefix -l,$(LIBS))
###
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/126487.html Link to the original text :https://javaforall.cn
边栏推荐
- Mysql: MySQL problem that is not a MySQL problem
- 工业物联网中的时序数据
- Food safety | ham sausage lunch meat, is it really so unbearable?
- MySQL:不是MySQL问题的MySQL问题
- Kubernetes Kubelet管理pod核心流程
- Failure analysis and solution of vscode PIO creation project
- JS tool CECP
- LeetCode_724_寻找数组的中心下标
- 日期格式化
- 【flask高级】从源码深入理解flask路由之endpoint
猜你喜欢

Don't ask me again why MySQL hasn't left the index? For these reasons, I'll tell you all

SQL bool盲注和时间盲注详解

Software configuration | pychart download, installation, environment configuration and uninstall

工业物联网中的时序数据

别再问我MySQL为啥没走索引?就这几种原因,全都告诉你

Food safety | what is the origin of plant meat that sounds very healthy?

工業物聯網中的時序數據

网络基础设施可视化

Deeply understand the mode and vibration of mechanical system

SQL報錯盲注詳解
随机推荐
SQL bool盲注和时间盲注详解
封玩家IP和机器码以及解开被封的教程
[operation] Yan Yi (Internet new technology operation)
Program environment and pretreatment
Repository XXX does not have a Realease file「建议收藏」
Date formatting
使用 PreparedStatement 的 JDBC 程序示例
Emgu CV3+C#图像处理(四):使用EmguCV获取摄像头、读取视频
Leetcode question brushing record
Preliminary understanding of string
Failure analysis and solution of vscode PIO creation project
食品安全|巧克力也有真假?关于它你了解多少
USB通信协议深入理解
阿里二面:什么是CAS?
Mysql: MySQL problem that is not a MySQL problem
nVisual综合布线管理软件与网管软件的区别
Detailed explanation of SQL error reporting and blind annotation
A series of specifications of oneplus 10t were disclosed before the product was released
Food safety | drinking fresh milk may infect tuberculosis? Take you to know what is milk sterilization
PPPoE协议讲解以及拨号过程Wireshark抓包解析