# 安装路径
INSTALL_PATH = \
~/application
# 头文件包含路径
INCLUDES = \
-I. -I./ -I/usr/local/include \
# 主要目标文件
MAINOBJS= \
test.o \
calc.o \
printTest.o \
# 所有要编译的目标文件
ALLOBJS = $(MAINOBJS)
# 最终程序
PROGRAM_NAME = TheTestProgram.exe
# 编译器
CC = gcc
# 编译指令
#COMPIL_FLAGS = -O3
all: $(PROGRAM_NAME)
# 安装
install: $(PROGRAM_NAME)
if [ ! -d $(INSTALL_PATH) ]; then mkdir $(INSTALL_PATH); fi
cp $(PROGRAM_NAME) $(INSTALL_PATH)/$(PROGRAM_NAME)
@echo 'install: Done'
# 卸载
uninstall:
rm -f $(INSTALL_PATH)/$(PROGRAM_NAME)
@echo 'uninstall: Done'
# 清除
clean:
rm -f $(ALLOBJS) $(PROGRAM_NAME)
@echo 'clean: Done'
$(PROGRAM_NAME) : $(ALLOBJS)
$(CC) -o $(PROGRAM_NAME) $(ALLOBJS)
$(ALLOBJS) : %.o: %.c
$(CC) -c $(COMPIL_FLAGS) $(INCLUDES) $< -o $@
makefile 基础用法示例
最新推荐文章于 2023-08-30 10:31:01 发布