Makefile 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. CFLAGS1 := -Wall -fpic -O2
  24. CFLAGS2 := -shared
  25. DEFS := -D_GNU_SOURCE -D_DEBUG
  26. target ?= x86_64
  27. ifeq ($(target),armv7hf)
  28. CC := arm-linux-gnueabihf-gcc
  29. AR := arm-linux-gnueabihf-ar
  30. endif
  31. # 编译规则
  32. all : libswapi.a libswapi.so swapi_test.out
  33. %.o : %.c
  34. $(CC) $(DEFS) $(CFLAGS1) -c $< $(INCS) -o $@
  35. libswapi.a : $(OBJS)
  36. $(AR) -cr $@ $(OBJS)
  37. libswapi.so : $(OBJS)
  38. $(CC) $(CFLAGS2) $(OBJS) -o $@
  39. swapi_test.out : testLib.c logfromgo.c
  40. $(CC) $(DEFS) $(CFLAGS1) testLib.c logfromgo.c $(INCS) -static -L./ -lswapi -pthread -lrt -o $@
  41. .PHONY : clean
  42. clean :
  43. rm -rf $(OBJS) ./libswapi.a ./libswapi.so ./testLib.o ./swapi_test.out