Programmer

makefile -- 动态库、进程

2019-01-08  本文已影响0人  github_lincy

动态库 makefile 示例

CC:=$(shell sh -c 'type $(CC) >/dev/null 2>/dev/null && echo $(CC) || echo gcc')
CFLAG = $(CFLAGS) -shared -O3 -Wall -g -ggdb -DUSE_DL_PREFIX  -DMSPACES -DUSE_LOCKS=1 -fPIC
LDFLAG = $(LINKFLAGS) -lpthread -lrt
LIB_DIR_SRC = $(wildcard *.c)
SO_NAME =xx.so

PLATFORM=device
ifeq ($(PLATFORM),device)
        CFLAG += -DUSE_DEVICE
endif

default: all

.DEFAULT:
        @echo " "
        @echo ">      Make xx lib     <"
        $(CC) $(CFLAG) $(LIB_DIR_SRC) -o $(SO_NAME ) $(LDFLAG)

clean:
        rm -rf $(SO_NAME)

进程 makefile 示例

CC:=$(shell sh -c 'type $(CC) >/dev/null 2>/dev/null && echo $(CC) || echo gcc')
CFLAG = $(CFLAGS) -O3 -Wall -g -ggdb
LDFLAG = $(LINKFLAGS) -lpthread -lrt
PRO_DIR_SRC = $(wildcard *.c)
PRO_NAME = xx

PLATFORM=device
ifeq ($(PLATFORM),device)
        CFLAG += -DUSE_DEVICE
endif

default: all

.DEFAULT:
        @echo " "
        @echo ">      Make xx process     <"
        $(CC) $(CFLAG) $(PRO_DIR_SRC ) -o $(PRO_NAME) $(LDFLAG)

clean:
        rm -rf $(PRO_NAME)

可以看出,动态库与进程范式基本一样,主要区别在于CFLAG

上一篇下一篇

猜你喜欢

热点阅读