Linux Makefile多目录的编写
来源:互联网 发布:同学录制作软件 编辑:程序博客网 时间:2024/05/22 08:18
手头一个项目,需要编写项目的makefile
多目录结构:
csource/
├── common
│ └── sqlite3
├── inc
│ ├── curl
│ ├── lua
│ └── Protection
├── lib
│ ├── arm
│ └── linux
├── obj
├── out
│ ├── arm
│ └── linux
├── src
源码目录src,输出目录out,include目录inc,输入链接库目录lib,常用静态函数和sqlite3目录common
makefile如下:
1 PLAT= none 2 CC= 3 CXX= 4 CFLAGS= 5 LDFLAGS= 6 MKDIR_P=mkdir -p 7 8 PLATS= linux arm 9 10 root= libroot.so11 root_a= libroot.a12 13 INC_DIR= ./inc14 COM_DIR= ./common15 SQL_DIR= ./common/sqlite316 LUA_DIR= ./inc/lua17 PRO_DIR= ./inc/Protection18 INCLUDE= -I$(LUA_DIR) -I$(INC_DIR) -I$(COM_DIR) -I$(SQL_DIR) -I$(PRO_DIR)19 DIR_SRC= ./src20 21 SRC = $(wildcard ${DIR_SRC}/*.cpp)22 OBJ = $(patsubst %.cpp,${DIR_OBJ}/%.o,$(notdir ${SRC})) $(DIR_OBJ)/sqlite3.o23 24 SO_TARGET = ${DIR_BIN}/${root}25 LIB_TARGET= ${DIR_BIN}/${root_a}26 27 28 # Targets start here.29 default: $(PLAT)30 31 none:32 @echo "Please do 'make PLATFORM' where PLATFORM is one of these:"33 @echo " $(PLATS)"34 35 ${SO_TARGET}:${OBJ}36 $(CXX) $(OBJ) -o $@ $(LDFLAGS)37 cp ${DIR_BIN}/${root} ./test/ -f38 39 ${LIB_TARGET}:${OBJ} 40 $(AR) $@ ${OBJ} 41 $(RANLIB) $@42 43 dir:44 $(MKDIR_P) $(DIR_OBJ) $(DIR_BIN);45 46 all:$(SO_TARGET) $(LIB_TARGET)47 48 ALL = dir all49 50 linux:51 $(MAKE) $(ALL) DIR_OBJ="./obj_linux/" DIR_BIN="./out/linux" \52 CC="gcc" CXX="g++" AR="ar rcu" RANLIB="ranlib" \53 CFLAGS="-Wno-write-strings -m32 -O2 -D_DEBUG -D_LINUX -fPIC" \54 LDFLAGS="-O2 -shared -m32 -ldl -pthread -lrt -L./lib/linux -llua -lProtection -lz -lcurl"55 56 arm:57 $(MAKE) $(ALL) DIR_OBJ="./obj_arm/" DIR_BIN="./out/arm" \58 CC="arm-linux-gnueabihf-gcc" CXX="arm-linux-gnueabihf-g++" \59 AR="arm-linux-gnueabihf-ar rcu" RANLIB="arm-linux-gnueabihf-ranlib" \60 CFLAGS="-Wno-write-strings -O2 -D_ARM -D__LINUX -fPIC" \61 LDFLAGS="-O2 -shared -ldl -pthread -lrt -L./lib/arm -llua -lProtection -lz -lcurl"62 63 64 # list targets that do not create files (but not all makes understand .PHONY)65 .PHONY: all $(PLATS) default clean none66 67 ${DIR_OBJ}/%.o:${DIR_SRC}/%.cpp 68 $(CXX) $(CFLAGS) $(INCLUDE) -c $< -o $@69 70 ${DIR_OBJ}/sqlite3.o:${DIR_SRC}/sqlite3.c 71 $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@72 73 .PHONY:clean74 clean: 75 -find ${DIR_OBJ} -name *.o -exec rm -rf {} \;
0 0
- Linux Makefile多目录的编写
- Linux下多目录的Makefile编写
- 多目录Makefile编写
- 多目录工程构建Makefile的编写
- 多目录时Makefile 的编写方法
- linux下C工程层级目录的Makefile编写
- 【Linux】多文件标准工程目录的Makefile编写及通用模板
- makefile编写小结:多目录,单Makefile
- 【Linux】 Makefile的编写
- 多文件、多目录的Makefile的编写
- 多个目录编译的makefile的编写
- 多个目录编译的makefile的编写
- 多源文件的linux驱动Makefile编写
- 多文件多目录的Makefile文件编写
- 多文件及多目录下MakeFile文件的编写
- 多层目录编译的makefile文件编写
- Linux下makefile的编写
- linux下的makefile 编写
- java中Keytool的使用总结
- cocos2dx 3.4之旅
- Android 百度定位SDK配置和实现当前位置定位
- 【SCOI2010】【BZOJ1853】幸运数字
- jQuery获得客户端/浏览器的IP地址信息
- Linux Makefile多目录的编写
- Android 简单实现圆形ImageView添加双层圆形边框
- 学《何以》五招收服女友心
- 递归学习(一)--判断回文字符串
- Core Animation详解(三)-UIDynamic Animation
- 开源ECSHOP中SQL SELECT操作集锦,练习SQL
- 01背包问题和完全背包问题
- 数据结构(陈越)PAT练习题 第五周:图(上)
- 码农提高工作效率