/Makefile

http://credis.googlecode.com/ · Makefile · 54 lines · 38 code · 13 blank · 3 comment · 0 complexity · bfff3f681921d3959739cdcc14f67411 MD5 · raw file

  1. CFLAGS ?= -g -O2 -Wall
  2. LDFLAGS ?=
  3. #CPPFLAGS += -DPRINTDEBUG
  4. VER_MAJOR = 0
  5. VER_MINOR = 3
  6. VER_PATCH = 0
  7. VER=$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)
  8. INSTALL ?= /usr/bin/install -c
  9. MKDIR ?= /bin/mkdir -p
  10. CP ?= /bin/cp -fd
  11. LN ?= /bin/ln -fs
  12. INSTALLDIR ?= /usr/local
  13. LIBDIR = $(INSTALLDIR)/lib
  14. INCLUDEDIR = $(INSTALLDIR)/include
  15. # build shared lib under OS X or Linux
  16. OS = $(shell uname -s)
  17. ifeq ($(OS),Darwin)
  18. SHAREDLIB_LINK_OPTIONS=-dynamiclib -Wl,-install_name -Wl,
  19. else
  20. SHAREDLIB_LINK_OPTIONS=-shared -Wl,-soname,
  21. endif
  22. # targets to build with 'make all'
  23. TARGETS = credis-test libcredis.a libcredis.so
  24. all: $(TARGETS)
  25. credis-test: credis-test.o libcredis.a
  26. $(CC) $(CFLAGS) $(LDFLAGS) $(CPPFLAGS) -o $@ $^
  27. libcredis.a: credis.o
  28. $(AR) -cvq $@ $^
  29. libcredis.so: credis.o
  30. $(CC) $(SHAREDLIB_LINK_OPTIONS)$@.$(VER_MAJOR) -o $@.$(VER) $^
  31. $(LN) $@.$(VER) $@.$(VER_MAJOR)
  32. $(LN) $@.$(VER_MAJOR) $@
  33. credis.o: credis.c credis.h Makefile
  34. $(CC) -c -fPIC $(CFLAGS) $(CPPFLAGS) -o $@ credis.c
  35. install: all installdirs
  36. $(INSTALL) -m644 *.h $(INCLUDEDIR)
  37. $(INSTALL) -m755 *.so* *.a $(LIBDIR)
  38. installdirs:
  39. $(MKDIR) $(LIBDIR) $(INCLUDEDIR)
  40. clean:
  41. rm -f *.o *~ *.so* $(TARGETS)