GNUmakefile 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. DESTDIR ?=
  2. PREFIX ?= /usr
  3. COMPRESS_MAN ?= yes
  4. STRIP_BINARY ?= yes
  5. EXAMPLES ?= yes
  6. CSECFLAGS ?= -fstack-protector-all -Wall --param ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -fstack-check -DPARANOID -std=gnu99
  7. CFLAGS ?= -pipe -O2
  8. CFLAGS += $(CSECFLAGS) -fpic
  9. DEBUGCFLAGS ?= -pipe -Wall -ggdb3 -export-dynamic -Wno-error=unused-variable -O0 -pipe $(CSECFLAGS) -fpic
  10. CARCHFLAGS ?= -march=native
  11. LIBS :=
  12. LDSECFLAGS ?= -Xlinker -zrelro
  13. LDFLAGS += $(LDSECFLAGS) -pthread -shared
  14. INC := $(INC)
  15. INSTDIR = $(DESTDIR)$(PREFIX)
  16. objs=\
  17. pftw.o\
  18. binary=libpftw.so
  19. .PHONY: doc
  20. all: $(objs)
  21. $(CC) $(CARCHFLAGS) $(CFLAGS) $(LDFLAGS) $(objs) $(LIBS) -o $(binary)
  22. %.o: %.c
  23. $(CC) $(CARCHFLAGS) $(CFLAGS) $(INC) $< -c -o $@
  24. debug:
  25. $(CC) $(CARCHFLAGS) -DDEBUG2 $(DEBUGCFLAGS) $(INC) $(LDFLAGS) *.c $(LIBS) -o $(binary)
  26. clean:
  27. rm -f $(binary) *.o test
  28. distclean: clean
  29. doc:
  30. doxygen .doxygen
  31. install:
  32. install -d "$(INSTDIR)/bin" "$(INSTDIR)/share/man/man3"
  33. ifeq ($(STRIP_BINARY),yes)
  34. strip --strip-unneeded -R .comment -R .GCC.command.line -R .note.gnu.gold-version $(binary)
  35. endif
  36. install -m 755 $(binary) "$(INSTDIR)"/bin/
  37. install -m 644 man/man3/pftw.3 "$(INSTDIR)"/share/man/man3/
  38. ifeq ($(COMPRESS_MAN),yes)
  39. rm -f "$(INSTDIR)"/share/man/man3/pftw.3.gz
  40. gzip "$(INSTDIR)"/share/man/man3/pftw.3
  41. endif
  42. deinstall:
  43. rm -f "$(INSTDIR)"/bin/$(binary)
  44. test: all
  45. $(CC) -O3 test.c -lpftw -L. -o test
  46. debugtest: debug
  47. $(CC) -O0 -ggdb test.c -lpftw -L. -o test
  48. dotest: test
  49. LD_LIBRARY_PATH=. ./test