A project on hand, need to write a project makefile
Multi-Directory structure:
csource/
├──common
│└──sqlite3
├──inc
│├──curl
│├──lua
│└──protection
├──lib
│├──arm
│└──linux
├──obj
├──out
│├──arm
│└──linux
├──src
source directory src, output directory out,include Directory inc, Input link library directory lib, common static functions and Sqlite3 Catalogue Common
Makefile as follows:
1Test =libtest.so2Test_a =libtest.a3 4Ldflags =-o2-shared-m32-ldl-pthread-lrt-l./lib/linux-llua-lz-Lcurl5CFLAGS =-wno-Write-strings-m32-o2-d__linux-d_debug-FPIC6CXX = g++7CC =GCC8AR =arRCU9Ranlib =RanlibTen One AInc_dir =./Inc -Com_dir =./Common -Sql_dir =./common/Sqlite3 theLua_dir =./inc/Lua -Pro_dir =./inc/Protection -INCLUDE =-i$ (lua_dir)-i$ (inc_dir)-i$ (com_dir)-i$ (Sql_dir)-i$ (Pro_dir) -DIR_SRC =./src +Dir_obj =./obj -Dir_bin =./out/Linux + ASRC = $ (wildcard ${dir_src}/*. cpp) at OBJ = $ (patsubst%.cpp,${dir_obj}/%.o,$ (Notdir ${src})) $ (dir_obj)/sqlite3.o - - so_target = ${dir_bin}/${test} - lib_target= ${dir_bin}/${test_a} - - all:$ (so_target) $ (lib_target) in - ${so_target}:${obj} to $ (CXX) $ (OBJ)-o [email protected] $ (ldflags) + - ${lib_target}:${obj} the $ (AR) [email protected] $ (objects) * $ (ranlib) [email protected] $ Panax Notoginseng ${dir_obj}/%.o:${dir_src}/%.cpp - $ (CXX) $ (CFLAGS) $ (INCLUDE)-C $<-o [email protected] the + ${dir_obj}/sqlite3.o:${dir_src}/sqlite3.c A $ (CC) $ (CFLAGS) $ (INCLUDE)-C $<-o [email protected] the + . Phony:clean - Clean : $ -find ${dir_obj}-name *.o-exec rm-rf {} \;
Linux makefile Multi-Directory authoring