from makefile which i did not make it as a file

本文提供了一个实用的Makefile模板,该模板详细展示了如何通过Makefile自动化编译C和C++源文件,设置编译选项,管理依赖关系以及执行清理操作等关键任务。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

it is very easy to start from google search engine that we can study a dozen of workable such files

key word makefile template there is very nice one from google doc

but it is not easy make non-innovation, non-creation non-new non-exciting things

note its better replace all indent with a tab



#
SAMPLE_NAME := lxi
SAMPLE_CSRC := $(wildcard *.c) 
SAMPLE_CXXSRC := $(wildcard *.cpp) 


SAMPLE_COBJS := ${SAMPLE_CSRC:.c=.o}
SAMPLE_CXXOBJS := ${SAMPLE_CXXSRC:.cpp=.o}
SAMPLE_OBJS := $(SAMPLE_CXXOBJS) $(SAMPLE_COBJS)


SAMPLE_INC_DIRS :=
SAMPLE_LIB_DIRS :=
SAMPLE_LIBS := 
###libcutils
CPPFLAGS += $(foreach includedir, $(SAMPLE_INC_DIRS),-I$(includedir))
LDFLAGS += $(foreach librarydir, $(SAMPLE_LIB_DIRS),-L$(librarydir)) 
LDFLAGS += $(foreach library, $(SAMPLE_LIBS),-l$(library)) 
CPPFLAGS += -std=c++0x -w -pthread -g
LDFLAGS += -lm
.PHONY: depend clean all distclean
all:    $(SAMPLE_NAME)
@echo  Simple compiler named something has been compiled
$(SAMPLE_MKDIRBIN)
mv ./$(SAMPLE_NAME) $(SAMPLE_BIN)


$(SAMPLE_NAME): $(SAMPLE_OBJS)
$(LINK.cc) $(SAMPLE_OBJS) -o $(SAMPLE_NAME)

SAMPLE_BIN := ../bin/
SAMPLE_MKDIRBIN := mkdir -p $(SAMPLE_BIN)
SAMPLE_OUT := ../out/
SAMPLE_MKDIROUT := mkdir -p $(SAMPLE_OUT)


clean:
@- $(RM) -f $(SAMPLE_NAME).tar.gz
@- $(RM) -rf $(SAMPLE_BIN)
@- $(RM) -rf $(SAMPLE_OUT)
@- $(RM) $(SAMPLE_NAME)
@- $(RM) $(SAMPLE_OBJS)
@- $(RM) *.d
distclean: clean
run: all
@echo Running test case....
$(SAMPLE_BIN)$(SAMPLE_NAME)
tarball: $(SAMPLE_NAME)
$(SAMPLE_MKDIROUT)
tar -czf ./* $(SAMPLE_NAME).tar.gz
disp:
@echo $(SAMPLE_OBJS)


define OBJECT_DEPENDS_ON_CORRESPONDING_HEADER
$(1) : ${1:.o=.h}
endef
$(foreach object_file,$(program_OBJS),$(eval $(call OBJECT_DEPENDS_ON_CORRESPONDING_HEADER,$(object_file))))


depend:
makedepend -- $(CPPFLAGS) $(CFLAGS) -- $(SAMPLE_CSRCS)
# Don't place anything below this line, since
# the make depend program will overwrite it
# DO NOT DELETE THIS LINE -- make depend depends on it.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值