GNUmakefile 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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) $(shell pkg-config --cflags glib-2.0)
  9. DEBUGCFLAGS ?= -pipe -Wall -ggdb3 -export-dynamic -Wno-error=unused-variable -O0 -pipe $(CSECFLAGS)
  10. CARCHFLAGS ?= -march=native
  11. LIBS :=
  12. LDSECFLAGS ?= -Xlinker -zrelro
  13. LDFLAGS += $(LDSECFLAGS) -pthread $(shell pkg-config --libs glib-2.0)
  14. INC := $(INC)
  15. INSTDIR = $(DESTDIR)$(PREFIX)
  16. objs=\
  17. main.o\
  18. binary=kiosk-hangup-sensor
  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. rm -f *.orig
  30. doc:
  31. doxygen .doxygen
  32. install:
  33. install -d "$(INSTDIR)/bin" "$(INSTDIR)/share/man/man3"
  34. ifeq ($(STRIP_BINARY),yes)
  35. strip --strip-unneeded -R .comment -R .GCC.command.line -R .note.gnu.gold-version $(binary)
  36. endif
  37. install -m 755 $(binary) "$(INSTDIR)"/bin/
  38. deinstall:
  39. rm -f "$(INSTDIR)"/bin/$(binary)
  40. format:
  41. astyle --style=linux --indent=tab --indent-cases --indent-switches --indent-preproc-define --break-blocks --pad-oper --pad-paren --delete-empty-lines *.[ch] | grep -v Unchanged || true