Makefile 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # $Id: Makefile,v 1.7 2009/01/23 19:05:04 nanard Exp $
  2. # This Makefile is designed for use with GNU make
  3. # libnatpmp
  4. # (c) 2007-2009 Thomas Bernard
  5. # http://miniupnp.free.fr/libnatpmp.html
  6. CC = gcc
  7. INSTALL = install
  8. # APIVERSION is used in soname
  9. APIVERSION = 0
  10. CFLAGS = -O -fPIC -Wall -DENABLE_STRNATPMPERR
  11. LIBOBJS = natpmp.o getgateway.o
  12. OBJS = $(LIBOBJS) testgetgateway.o natpmpc.o
  13. STATICLIB = libnatpmp.a
  14. SHAREDLIB = libnatpmp.so
  15. SONAME = $(SHAREDLIB).$(APIVERSION)
  16. HEADERS = natpmp.h
  17. EXECUTABLES = testgetgateway natpmpc-shared natpmpc-static
  18. INSTALLPREFIX ?= $(PREFIX)/usr
  19. INSTALLDIRINC = $(INSTALLPREFIX)/include
  20. INSTALLDIRLIB = $(INSTALLPREFIX)/lib
  21. INSTALLDIRBIN = $(INSTALLPREFIX)/bin
  22. .PHONY: all clean depend install cleaninstall
  23. all: $(STATICLIB) $(SHAREDLIB) $(EXECUTABLES)
  24. clean:
  25. $(RM) $(OBJS) $(EXECUTABLES) $(STATICLIB) $(SHAREDLIB)
  26. depend:
  27. makedepend -f$(MAKEFILE_LIST) -Y $(OBJS:.o=.c) 2>/dev/null
  28. install: $(HEADERS) $(STATICLIB) $(SHAREDLIB)
  29. $(INSTALL) -d $(INSTALLDIRINC)
  30. $(INSTALL) --mode=644 $(HEADERS) $(INSTALLDIRINC)
  31. $(INSTALL) -d $(INSTALLDIRLIB)
  32. $(INSTALL) --mode=644 $(STATICLIB) $(INSTALLDIRLIB)
  33. $(INSTALL) --mode=644 $(SHAREDLIB) $(INSTALLDIRLIB)/$(SONAME)
  34. $(INSTALL) --mode=755 natpmpc-shared $(INSTALLDIRBIN)/natpmpc
  35. ln --symbolic --force $(SONAME) $(INSTALLDIRLIB)/$(SHAREDLIB)
  36. cleaninstall:
  37. $(RM) $(addprefix $(INSTALLDIRINC), $(HEADERS))
  38. $(RM) $(INSTALLDIRLIB)/$(SONAME)
  39. $(RM) $(INSTALLDIRLIB)/$(SHAREDLIB)
  40. $(RM) $(INSTALLDIRLIB)/$(STATICLIB)
  41. testgetgateway: testgetgateway.o getgateway.o
  42. natpmpc-static: natpmpc.o $(STATICLIB)
  43. $(CC) -o $@ $^
  44. natpmpc-shared: natpmpc.o $(SHAREDLIB)
  45. $(CC) -o $@ $^
  46. $(STATICLIB): $(LIBOBJS)
  47. $(AR) crs $@ $?
  48. $(SHAREDLIB): $(LIBOBJS)
  49. $(CC) -shared -Wl,-soname,$(SONAME) -o $@ $^
  50. # DO NOT DELETE
  51. natpmp.o: natpmp.h getgateway.h
  52. getgateway.o: getgateway.h
  53. testgetgateway.o: getgateway.h
  54. natpmpc.o: natpmp.h