Makefile 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. SOURCES = $(wildcard *.c)
  2. DEPS=toxcore
  3. CC?=$(CC)
  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 [ -d .git ]; then \
  26. echo " GEN $@"; \
  27. echo "#define GITVERSION \"$(shell git rev-parse HEAD)\"" > $@; \
  28. fi
  29. termux: PREFIX=/data/data/com.termux/files/usr
  30. termux: CFLAGS += -I$(PREFIX)/include
  31. termux: TERMUX_LDFLAGS = -L$(PREFIX)/lib -ltoxcore -ltoxencryptsave -lsodium -lm
  32. termux:
  33. $(MAKE) clean
  34. $(MAKE) gitversion.h tox_bootstrap.h $(OBJECTS)
  35. $(CC) -o tuntox $(OBJECTS) $(TERMUX_LDFLAGS)
  36. FORCE:
  37. tox_bootstrap.h:
  38. $(PYTHON) generate_tox_bootstrap.py
  39. %.o: %.c $(INCLUDES) gitversion.h tox_bootstrap.h
  40. @echo " CC $@"
  41. @$(CC) -c $(CFLAGS) $< -o $@
  42. tuntox: $(OBJECTS) $(INCLUDES)
  43. $(CC) -o $@ $(OBJECTS) -lpthread $(LDFLAGS)
  44. tuntox_nostatic: $(OBJECTS) $(INCLUDES)
  45. $(CC) -o $@ $(OBJECTS) -lpthread $(DSO_LDFLAGS)
  46. cscope.out:
  47. @echo " GEN $@"
  48. @cscope -bv ./*.[ch] &> /dev/null
  49. clean:
  50. $(RM) *.o tuntox cscope.out gitversion.h tox_bootstrap.h
  51. install: tuntox_nostatic
  52. $(INSTALL_MKDIR) -d $(DESTDIR)$(BINDIR)
  53. $(INSTALL) tuntox_nostatic $(DESTDIR)$(BINDIR)/tuntox
  54. .PHONY: all clean tuntox termux