张艺兴情定孙红雷,神探高伦布结局,1366 768壁纸
cc = gcc ld = $(cc) target = $(notdir $(curdir)) src_dir = . include_dir += . c_flags = -g -wall ld_flafs = ld_libs = includes = -i$(include_dir) ifeq ($(cc), g++) type = cpp srcs += $(wildcard $(src_dir)/*.$(type)) objs += $(patsubst %.$(type), %.o, $(srcs)) else type = c srcs += $(wildcard $(src_dir)/*.$(type)) objs += $(patsubst %.$(type), %.o, $(srcs)) endif all : $(target) @echo "builded target:" $^ @echo "done" $(target) : $(objs) @echo "linking" $@ "from" $^ "..." $(ld) -o $@ $^ $(ld_flags) $(ld_libs) @echo "link finished\n" $(objs) : %.o:%.$(type) @echo "compiling" $@ "from" $< "..." $(cc) -c -o $@ $< $(c_flags) $(includes) @echo "compiled finished\n" .phony : clean cleanobj clean : cleanobj @echo "remove all executable file" rm -f $(target) cleanobj : @echo "remove binary files" rm -f *.o
make
make cc=g++
target
指定生成的可执行文件名,我这里用的是当前所在目录名
src_dir
指定源文件(.c .cpp)文件的路径
include_dir
指定头文件路径
c_flags
指定编译参数选项
ld_flafs
指定链接参数选项
ld_libs
指定链接库
清除生成的文件:
# 清空全部生成文件 make clean # 清空生成的中间文件 make cleanobj
对于ubuntu系统,可以将makefile文件复制到~/templates(中文环境为~/模板)目录下,这样就可以在任意目录下右键添加该makefile模板。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
如何在没有core文件的情况下用dmesg+addr2line定位段错误
用QT制作3D点云显示器——QtDataVisualization
网友评论