| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- ################################################################
- # Software API Library #
- # Author: NiuJiuRu #
- # Copyright ? 2010-20 NiuJiuRu, All Rights Reserved. #
- ################################################################
- # 头文件
- INCS = -I./
- # 源文件
- # 1, "swutil"函数库
- SRCS := swchar.c swstring.c swfile.c swdir.c \
- swrand.c swlog.c
- # 2, "swos"函数库
- SRCS += swsignal.c swmutex.c swmem.c swheap.c swstack.c \
- swmsgq.c swthrd.c swthrdpool.c swprogress.c swtimer.c sw_rwlock.c
- # 3, "swnetwork"函数库
- SRCS += swudp.c swtcp.c
- # 4, "swalg"函数库
- SRCS += swhash.c
- # 源文件编译后对应的.o文件
- OBJS := $(SRCS:.c=.o)
- # 编译器
- CC := gcc
- AR := ar
- CFLAGS1 := -Wall -fpic -O2
- CFLAGS2 := -shared
- DEFS := -D_GNU_SOURCE -D_DEBUG
- target ?= x86_64
- ifeq ($(target),armv7hf)
- CC := arm-linux-gnueabihf-gcc
- AR := arm-linux-gnueabihf-ar
- endif
- # 编译规则
- all : libswapi.a libswapi.so swapi_test.out
- %.o : %.c
- $(CC) $(DEFS) $(CFLAGS1) -c $< $(INCS) -o $@
- libswapi.a : $(OBJS)
- $(AR) -cr $@ $(OBJS)
- libswapi.so : $(OBJS)
- $(CC) $(CFLAGS2) $(OBJS) -o $@
- swapi_test.out : testLib.c logfromgo.c
- $(CC) $(DEFS) $(CFLAGS1) $(INCS) testLib.c logfromgo.c -L./ -lswapi -pthread -lrt -static -o $@
- .PHONY : clean
- clean :
- rm -rf $(OBJS) *.o libswapi.a libswapi.so swapi_test.out
|