Linux下多目录的Makefile编写
来源:互联网 发布:南宁java培训多少钱 编辑:程序博客网 时间:2024/05/21 17:44
手头一个项目,需要编写项目的makefile
多目录结构:
csource/
├── common
│ └── sqlite3
├── inc
│ ├── curl
│ ├── lua
│ └── Protection
├── lib
│ ├── arm
│ └── linux
├── obj
├── out
│ ├── arm
│ └── linux
├── src
源码目录src,输出目录out,include目录inc,输入链接库目录lib,常用静态函数和sqlite3目录common
src:源代码目录
lib:链接库目录
out:输出目录
obj:中间文件目录
inc:include目录
common:常用函数目录
PLAT= noneCC=CXX=CFLAGS=LDFLAGS=MKDIR_P=mkdir -pPLATS= linux armroot= libroot.soroot_a= libroot.aINC_DIR= ./incCOM_DIR= ./commonSQL_DIR= ./common/sqlite3LUA_DIR= ./inc/luaPRO_DIR= ./inc/ProtectionINCLUDE= -I$(LUA_DIR) -I$(INC_DIR) -I$(COM_DIR) -I$(SQL_DIR) -I$(PRO_DIR)DIR_SRC= ./srcSRC = $(wildcard ${DIR_SRC}/*.cpp)OBJ = $(patsubst %.cpp,${DIR_OBJ}/%.o,$(notdir ${SRC})) $(DIR_OBJ)/sqlite3.oSO_TARGET = ${DIR_BIN}/${root}LIB_TARGET= ${DIR_BIN}/${root_a}# Targets start here.default: $(PLAT)none: @echo "Please do 'make PLATFORM' where PLATFORM is one of these:" @echo " $(PLATS)"${SO_TARGET}:${OBJ} $(CXX) $(OBJ) -o $@ $(LDFLAGS) cp ${DIR_BIN}/${root} ./test/ -f${LIB_TARGET}:${OBJ} $(AR) $@ ${OBJ} $(RANLIB) $@dir: $(MKDIR_P) $(DIR_OBJ) $(DIR_BIN);all:$(SO_TARGET) $(LIB_TARGET)ALL = dir alllinux: $(MAKE) $(ALL) DIR_OBJ="./obj_linux/" DIR_BIN="./out/linux" \ CC="gcc" CXX="g++" AR="ar rcu" RANLIB="ranlib" \ CFLAGS="-Wno-write-strings -m32 -O2 -D_DEBUG -D_LINUX -fPIC" \ LDFLAGS="-O2 -shared -m32 -ldl -pthread -lrt -L./lib/linux -llua -lProtection -lz -lcurl"arm: $(MAKE) $(ALL) DIR_OBJ="./obj_arm/" DIR_BIN="./out/arm" \ CC="arm-linux-gnueabihf-gcc" CXX="arm-linux-gnueabihf-g++" \ AR="arm-linux-gnueabihf-ar rcu" RANLIB="arm-linux-gnueabihf-ranlib" \ CFLAGS="-Wno-write-strings -O2 -D_ARM -D__LINUX -fPIC" \ LDFLAGS="-O2 -shared -ldl -pthread -lrt -L./lib/arm -llua -lProtection -lz -lcurl"# list targets that do not create files (but not all makes understand .PHONY).PHONY: all $(PLATS) default clean none${DIR_OBJ}/%.o:${DIR_SRC}/%.cpp $(CXX) $(CFLAGS) $(INCLUDE) -c $< -o $@${DIR_OBJ}/sqlite3.o:${DIR_SRC}/sqlite3.c $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@.PHONY:cleanclean: -find ${DIR_OBJ} -name *.o -exec rm -rf {} \;
0 0
- Linux下多目录的Makefile编写
- Linux Makefile多目录的编写
- linux下C工程层级目录的Makefile编写
- Linux下makefile的编写
- linux下的makefile 编写
- Linux下makefile的编写
- Linux下Makefile的编写
- linux下makefile的编写
- 多文件及多目录下MakeFile文件的编写
- 多目录下多文件 makefile编写
- 单目录下多文件 makefile编写
- 多目录Makefile编写
- 多目录工程构建Makefile的编写
- 多目录时Makefile 的编写方法
- Linux系统下Makefile的编写
- Linux下的makefile编写详解
- Linux下makefile脚本的编写
- linux下软件项目的Makefile编写
- Codeforces #292C. Drazil and Factorial 数学
- 计算音频帧的播放时间(音频码流 音频帧)
- Android学习笔记day9
- linux中根据进程的PID值来查找执行文件的及其路径
- 为什么要使用存储过程?
- Linux下多目录的Makefile编写
- Activity生命周期详解
- hibernate基础配置
- 排它平方数
- bitset+DFS序+线段树 Codeforces633G Yash And Trees
- Android Studio初体验之导入eclipse项目
- sudo:无法解析主机
- Study Note: Instruction Optimisation of CUDA programming
- C语言(函数与宏)