Makefile 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. ################################################################
  2. # Software API Library #
  3. # Author: NiuJiuRu #
  4. # Copyright ? 2010-20 NiuJiuRu, All Rights Reserved. #
  5. ################################################################
  6. # 头文件
  7. INCS = -I./
  8. # 源文件
  9. # 1, "swutil"函数库
  10. SRCS := swchar.c swstring.c swfile.c swdir.c \
  11. swrand.c swlog.c
  12. # 2, "swos"函数库
  13. SRCS += swsignal.c swmutex.c swmem.c swheap.c swstack.c \
  14. swmsgq.c swthrd.c swthrdpool.c swprogress.c swtimer.c sw_rwlock.c
  15. # 3, "swnetwork"函数库
  16. SRCS += swudp.c swtcp.c
  17. # 4, "swalg"函数库
  18. SRCS += swhash.c
  19. # 源文件编译后对应的.o文件
  20. OBJS := $(SRCS:.c=.o)
  21. # 编译器
  22. CC := gcc
  23. AR := ar
  24. CFLAGS1 := -Wall -fpic -O2
  25. CFLAGS2 := -shared
  26. DEFS := -D_GNU_SOURCE -D_DEBUG
  27. target ?= x86_64
  28. ifeq ($(target),armv7hf)
  29. CC := arm-linux-gnueabihf-gcc
  30. AR := arm-linux-gnueabihf-ar
  31. endif
  32. # 编译规则
  33. all : libswapi.a libswapi.so swapi_test.out
  34. %.o : %.c
  35. $(CC) $(DEFS) $(CFLAGS1) -c $< $(INCS) -o $@
  36. libswapi.a : $(OBJS)
  37. $(AR) -cr $@ $(OBJS)
  38. libswapi.so : $(OBJS)
  39. $(CC) $(CFLAGS2) $(OBJS) -o $@
  40. swapi_test.out : testLib.c logfromgo.c
  41. $(CC) $(DEFS) $(CFLAGS1) $(INCS) testLib.c logfromgo.c -L./ -lswapi -pthread -lrt -static -o $@
  42. .PHONY : clean
  43. clean :
  44. rm -rf $(OBJS) *.o libswapi.a libswapi.so swapi_test.out