寫乙個常用makefile

2021-09-22 18:18:24 字數 1096 閱讀 3191

dir_inc = ./include

dir_src = ./src

dir_obj = ./obj

dir_bin = ./bin

dir_lib = ./lib

#wildcard : 擴充套件萬用字元

#notdir : 去除路徑

#patsubst :替換萬用字元

src = $(wildcard $/*.c)

obj = $(patsubst %.c,$/%.o,$(notdir $))

#target = test

target = libsm2.so

bin_target = $(dir_bin)/$

#lib = -l$(dir_lib) -lssl -lcrypto -ldl #-lpthread

lib = -l$(dir_lib) -lssl -lcrypto -ldl

#-i /home/hello/include表示將/home/hello/include目錄作為第乙個尋找標頭檔案的目錄,

#尋找的順序是:/home/hello/include-->/usr/include-->/usr/local/include

#-l /home/hello/lib表示將/home/hello/lib目錄作為第乙個尋找庫檔案的目錄,

#尋找的順序是:/home/hello/lib-->/lib-->/usr/lib-->/usr/local/lib

#-lworld表示在上面的lib的路徑中尋找libworld.so動態庫檔案(如果gcc編譯選項中加入了「-static」表示尋找libworld.a靜態庫檔案)

cc = arm-linux-androideabi-gcc#gcc

cflags = -wall -i$ $(lib)

$:$ $(cc) -fpic -shared $^ -o $@ $(cflags)

$/%.o:$/%.c

$(cc) -fpic -c $< -o $@ -i$

.phony:clean

clean:

find $ -name *.o | xargs rm -rf

編寫乙個makefile

什麼是makefile?對於大多數的windows程式設計師來講,makefile可能不是那麼重要,因為windows的ide都為程式設計師做好了這個工作。但是在linux下程式設計,會不會寫makefile,從側面上說明乙個人是否具備完成大型工程的能力。makefile的作用 makefile是用...

乙個Makefile例子

main.c include log.h intmain sum.c include log.h void sum sub.c include log.h void sub dev.c include log.h void sub mul.c include log.h void sub log.h...

python寫乙個服務 Python寫乙個服務

coding utf 8 import json from urllib.parse import parse qs from wsgiref.server import make server 定義函式,引數是函式的兩個引數,都是python本身定義的,預設就行了。定義檔案請求的型別和當前請求成功...