No Description

Makefile 3.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. UNAME := $(shell uname)
  2. CXX = g++
  3. CC = gcc
  4. GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags)
  5. PLATFORM := $(shell g++ -dumpmachine)
  6. CXXFLAGS = -O3 -flto=8 -std=c++14 -DVERSION=\"$(GIT_VERSION)\" -DPLATFORM=\"$(PLATFORM)\"
  7. CFLAGS = -O3 -flto=8 -std=c11 -DVERSION=\"$(GIT_VERSION)\"
  8. CWARN = -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow=5 -Wswitch-default -Wundef -Wno-unused
  9. WARNINGS = -Werror -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Wno-unused -Wzero-as-null-pointer-constant -Wuseless-cast -Wno-strict-overflow
  10. LIBS = -lglfw -lGL -lGLEW -lfreetype -lharfbuzz -lmbedtls -lmbedcrypto -lmbedx509
  11. LDFLAGS = -O3 -flto=8
  12. INCPATH = -I./deps/include # Usable headers are in ./deps - you still need the libraries installed in the usual places
  13. MD5SUM = md5sum
  14. ifeq ($(UNAME), Darwin)
  15. CXXFLAGS = -O3 -std=c++1y -DVERSION=\"$(GIT_VERSION)\" -DPLATFORM=\"$(PLATFORM)\"
  16. CFLAGS = -O3 -std=c11 -DVERSION=\"$(GIT_VERSION)\"
  17. WARNINGS =
  18. ifeq ("$(wildcard /usr/local/lib/libglfw3.dylib)","")
  19. LIBS = -lglfw3 -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo -lGLEW -lfreetype -lharfbuzz -lmbedtls -lmbedcrypto -lmbedx509
  20. else
  21. ifeq ("$(wildcard /usr/local/lib/libglfw.3.dylib)","")
  22. LIBS = -lglfw.3 -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo -lGLEW -lfreetype -lharfbuzz -lmbedtls -lmbedcrypto -lmbedx509
  23. else
  24. LIBS = -lglfw -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo -lGLEW -lfreetype -lharfbuzz -lmbedtls -lmbedcrypto -lmbedx509
  25. endif
  26. endif
  27. LDFLAGS = -O3 -L/usr/local/lib
  28. INCPATH = -I./deps/include
  29. MD5SUM = md5
  30. endif
  31. EXECUTABLE = netrunner
  32. LINK = g++
  33. SRCDIR = src
  34. OBJDIR = gen
  35. DEPDIR = d
  36. PREFIX = /usr/local
  37. RESPREFIX = /usr/local/share
  38. SOURCES = $(subst ./,,$(shell find src -name \*.cpp))
  39. OBJECTS = $(subst $(SRCDIR),$(OBJDIR),$(SOURCES:.cpp=.o))
  40. RES = res/
  41. all: $(SOURCES) netrunner
  42. netrunner: $(OBJECTS) $(OBJDIR)/tlsf.o $(OBJDIR)/slre.o
  43. $(LINK) $(LDFLAGS) -o $@ $^ $(LIBS)
  44. $(OBJDIR)/%.o: $(SRCDIR)/%.cpp
  45. @mkdir -p $(@D)
  46. @mkdir -p $(subst gen,d,$(@D))
  47. $(CXX) -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td $(CXXFLAGS) $(INCPATH) $(WARNINGS) -c -o $@ $<
  48. @mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d && touch $@
  49. $(OBJDIR)/tlsf.o: $(SRCDIR)/tlsf.c
  50. $(CC) $(INCPATH) $(CWARN) -DTLSF_USE_LOCKS=0 -DUSE_MMAP=1 -DUSE_SBRK=1 -c -o $@ $<
  51. $(OBJDIR)/slre.o: $(SRCDIR)/slre.c
  52. $(CC) $(INCPATH) $(CWARN) -c -o $@ $<
  53. $(DEPDIR)/%d: ;
  54. .PRECIOUS: $(DEPDIR)/%.d
  55. test-url.o: tests/testPrograms/URLtest.cpp
  56. $(CXX) -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td $(CXXFLAGS) $(INCPATH) $(WARINGS) -c -o $@ $<
  57. ntr-run-tests: test-url.o $(OBJDIR)/URL.o $(OBJDIR)/StringUtils.o
  58. $(LINK) $(LDFLAGS) -o $@ test-url.o $(OBJDIR)/URL.o $(OBJDIR)/StringUtils.o $(LIBS)
  59. ntr-test-cfg: test-cfg.o $(OBJDIR)/CFGFileParser.o $(OBJDIR)/slre.o $(OBJDIR)/tlsf.o $(OBJDIR)/Murmur3.o
  60. $(LINK) $(LDFLAGS) -o $@ $^ $(LIBS)
  61. test-cfg.o: tests/TestCFG.cpp
  62. $(CXX) -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td $(CXXFLAGS) -Isrc $(INCPATH) -DDEBUG $(WARNINGS) -c -o $@ $<
  63. clean:
  64. -@rm -rf $(OBJDIR) $(EXECUTABLE) 2>/dev/null || true
  65. .PHONY: install
  66. install: netrunner
  67. mkdir -p $(DESTDIR)$(PREFIX)/bin
  68. cp $< $(DESTDIR)$(PREFIX)/bin/netrunner
  69. mkdir -p $(DESTDIR)$(RESPREFIX)/netrunner
  70. cp -R $(RES) $(DESTDIR)$(RESPREFIX)/netrunner/
  71. .PHONY: uninstall
  72. uninstall:
  73. rm -f $(DESTDIR)$(PREFIX)/bin/netrunner
  74. rm -rf $(DESTDIR)$(RESPREFIX)/netrunner
  75. include $(addsuffix .d,$(subst $(SRCDIR),$(DEPDIR),$(basename $(SOURCES))))