Makefile 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. SOURCES = $(wildcard *.c)
  2. DEPS=toxcore
  3. CC=gcc
  4. CFLAGS=-g -Wall #-std=c99
  5. CFLAGS += $(shell pkg-config --cflags $(DEPS))
  6. LDFLAGS=-g -pthread -lm -static
  7. LDFLAGS += $(shell pkg-config --static --libs $(DEPS))
  8. DSO_LDFLAGS=-g -pthread -lm
  9. DSO_LDFLAGS += $(shell pkg-config --libs $(DEPS))
  10. OBJECTS=$(SOURCES:.c=.o)
  11. INCLUDES = $(wildcard *.h)
  12. PYTHON = /usr/bin/env python3
  13. INSTALL = install -C
  14. INSTALL_MKDIR = $(INSTALL) -d -m 755
  15. OS=$(shell uname)
  16. ifneq ($(OS),Darwin)
  17. LDFLAGS += -lrt
  18. DSO_LDFLAGS += -lrt
  19. endif
  20. prefix ?= /usr
  21. bindir ?= $(prefix)/bin
  22. # Targets
  23. all: tuntox tuntox_nostatic
  24. gitversion.h: FORCE
  25. @if [ -f .git/HEAD ] ; then echo " GEN $@"; echo "#define GITVERSION \"$(shell git rev-parse HEAD)\"" > $@; fi
  26. FORCE:
  27. tox_bootstrap.h:
  28. $(PYTHON) generate_tox_bootstrap.py
  29. %.o: %.c $(INCLUDES) gitversion.h tox_bootstrap.h
  30. @echo " CC $@"
  31. @$(CC) -c $(CFLAGS) $< -o $@
  32. tuntox: $(OBJECTS) $(INCLUDES)
  33. $(CC) -o $@ $(OBJECTS) -lpthread $(LDFLAGS)
  34. tuntox_nostatic: $(OBJECTS) $(INCLUDES)
  35. $(CC) -o $@ $(OBJECTS) -lpthread $(DSO_LDFLAGS)
  36. cscope.out:
  37. @echo " GEN $@"
  38. @cscope -bv ./*.[ch] &> /dev/null
  39. clean:
  40. rm -f *.o tuntox cscope.out gitversion.h tox_bootstrap.h
  41. install: tuntox_nostatic
  42. $(INSTALL_MKDIR) -d $(DESTDIR)$(bindir)
  43. cp tuntox_nostatic $(DESTDIR)$(bindir)/tuntox
  44. .PHONY: all clean tuntox