You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NTMakefile 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. UNAME := $(shell uname)
  2. CXX = g++
  3. CC = gcc
  4. GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags)
  5. ifdef DEBUG
  6. CXXFLAGS = -Og -g3 -fstack-protector-strong -fPIE -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
  7. CFLAGS = -Og -g3 -fstack-protector-strong -fPIE -std=c11 -DVERSION=\"$(GIT_VERSION)\"
  8. else
  9. ifdef RELEASE_PACK
  10. CXXFLAGS = -O3 -march=i686 -mtune=generic -fstack-protector-strong -fPIE -flto=8 -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
  11. CFLAGS = -O3 -march=i686 -mtune=generic -fstack-protector-strong -fPIE -flto=8 -std=c11 -DVERSION=\"$(GIT_VERSION)\"
  12. else
  13. CXXFLAGS = -O3 -march=core2 -mfpmath=sse -fstack-protector-strong -fPIE -flto=8 -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
  14. CFLAGS = -O3 -march=core2 -mfpmath=sse -fstack-protector-strong -fPIE -flto=8 -std=c11 -DVERSION=\"$(GIT_VERSION)\"
  15. endif
  16. endif
  17. ifdef AMD64_DEBUG
  18. CXXFLAGS = -Og -g3 -fstack-protector-strong -fPIE -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
  19. CFLAGS = -Og -g3 -fstack-protector-strong -fPIE -std=c11 -DVERSION=\"$(GIT_VERSION)\"
  20. else
  21. ifdef AMD64_RELEASE
  22. CXXFLAGS = -O3 -march=opteron -mtune=opteron -mfpmath=sse -fstack-protector-strong -fPIE -flto=8 -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
  23. CFLAGS = -O3 -march=opteron -mtune=opteron -mfpmath=sse -fstack-protector-strong -fPIE -flto=8 -std=c11 -DVERSION=\"$(GIT_VERSION)\"
  24. else
  25. ifdef AMD64
  26. CXXFLAGS = -O3 -march=core2 -mfpmath=sse -fstack-protector-strong -fPIE -flto=8 -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
  27. CFLAGS = -O3 -march=core2 -mfpmath=sse -fstack-protector-strong -fPIE -std=c11 -DVERSION=\"$(GIT_VERSION)\" -flto=8
  28. endif
  29. endif
  30. endif
  31. WARNINGS = -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
  32. 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
  33. # i686 builds
  34. ifdef DEBUG
  35. LIBS = -lglfw -lopenGL32 -lGLEW32 -lgdi32 -lpolarssl -lws2_32 -lharfbuzz -lfreetype -lpng -lbz2 -lz
  36. LDFLAGS = -L ./deps/lib/nt_i386 -Og -g3 -fstack-protector-strong -fPIE
  37. else
  38. ifdef RELEASE_PACK
  39. LIBS = -lglfw -lopenGL32 -lGLEW32 -lgdi32 -lpolarssl -lws2_32 -lharfbuzz -lfreetype -lpng -lbz2 -lz
  40. LDFLAGS = -L ./deps/lib/nt_i386/release -O3 -flto=8 -march=i686 -mtune=generic -fstack-protector-strong -fPIE
  41. else
  42. LIBS = -lglfw -lopenGL32 -lGLEW32 -lgdi32 -lpolarssl -lws2_32 -lharfbuzz -lfreetype -lpng -lbz2 -lz
  43. LDFLAGS = -L ./deps/lib/nt_i386 -O3 -flto=8 -march=core2 -mfpmath=sse -fstack-protector-strong -fPIE
  44. endif
  45. endif
  46. ifdef AMD64_DEBUG
  47. LIBS = -lglfw -lopenGL32 -lglew32 -lgdi32 -lpolarssl -lws2_32 -lharfbuzz -lfreetype -lpng -lbz2 -lz
  48. LDFLAGS = -L ./deps/lib/nt_amd64 -Og -g3 -fstack-protector-strong -fPIE
  49. else
  50. ifdef AMD64_RELEASE
  51. LIBS = -lglfw -lopenGL32 -lglew32 -lgdi32 -lpolarssl -lws2_32 -lharfbuzz -lfreetype -lpng -lbz2 -lz
  52. LDFLAGS = -L ./deps/lib/nt_amd64/release -O3 -flto=8 -march=opteron -mtune=opteron -mfpmath=sse -fstack-protector-strong -fPIE
  53. else
  54. ifdef AMD64
  55. LIBS = -lglfw -lopenGL32 -lglew32 -lgdi32 -lpolarssl -lws2_32 -lharfbuzz -lfreetype -lpng -lbz2 -lz
  56. LDFLAGS = -L ./deps/lib/nt_amd64 -O3 -march=core2 -mfpmath=sse -fstack-protector-strong -fPIE -flto=8
  57. endif
  58. endif
  59. endif
  60. INCPATH = -I ./deps/include
  61. EXECUTABLE = netrunner
  62. LINK = g++
  63. SRCDIR = src
  64. OBJDIR = gen
  65. DEPDIR = d
  66. SOURCES = $(subst ./,,$(shell find src -name \*.cpp))
  67. OBJECTS = $(subst $(SRCDIR),$(OBJDIR),$(SOURCES:.cpp=.o))
  68. all: $(SOURCES) netrunner
  69. netrunner.res.o: netrunner.rc
  70. @openssl des3 -d -in data.enc -out favicon.ico -k exdf8OWpNn -a
  71. windres $^ -o $@
  72. @rm favicon.ico
  73. netrunner: $(OBJECTS) $(OBJDIR)/tlsf.o netrunner.res.o
  74. $(LINK) $(LDFLAGS) -o $@ $^ $(LIBS)
  75. shaders:
  76. ifneq ($(shell cat src/graphics/opengl/shaders/FontShader.vert src/graphics/opengl/shaders/FontShader.frag src/graphics/opengl/shaders/TextureShader.vert src/graphics/opengl/shaders/TextureShader.frag | md5sum), $(shell cat src/graphics/opengl/shaders/gen/hashsum))
  77. @mkdir -p "src/graphics/opengl/shaders/gen"
  78. @cat src/graphics/opengl/shaders/FontShader.vert src/graphics/opengl/shaders/FontShader.frag src/graphics/opengl/shaders/TextureShader.vert src/graphics/opengl/shaders/TextureShader.frag | md5sum > src/graphics/opengl/shaders/gen/hashsum;
  79. @/bin/echo -ne "#ifndef FONTSHADER_H\n#define FONTSHADER_H\n\nconst char *fontVertexShaderSource =\n" > src/graphics/opengl/shaders/gen/FontShader.h;
  80. @cat src/graphics/opengl/shaders/FontShader.vert | awk '{if ($$0!="}") {print "\t\""$$0"\\n\""} else {print "\t\""$$0"\";\n"}}' >> src/graphics/opengl/shaders/gen/FontShader.h;
  81. @/bin/echo -ne "const char *fontFragmentShaderSource =\n" >> src/graphics/opengl/shaders/gen/FontShader.h;
  82. @cat src/graphics/opengl/shaders/FontShader.frag | awk '{if ($$0!="}") {print "\t\""$$0"\\n\""} else {print "\t\""$$0"\";\n"}}' >> src/graphics/opengl/shaders/gen/FontShader.h;
  83. @/bin/echo -ne "#endif\n" >> src/graphics/opengl/shaders/gen/FontShader.h;
  84. @/bin/echo -ne "#ifndef TEXTURESHADER_H\n#define TEXTURESHADER_H\n\nconst char *textureVertexShaderSource =\n" > src/graphics/opengl/shaders/gen/TextureShader.h;
  85. @cat src/graphics/opengl/shaders/TextureShader.vert | awk '{if ($$0!="}") {print "\t\""$$0"\\n\""} else {print "\t\""$$0"\";\n"}}' >> src/graphics/opengl/shaders/gen/TextureShader.h;
  86. @/bin/echo -ne "const char *textureFragmentShaderSource =\n" >> src/graphics/opengl/shaders/gen/TextureShader.h;
  87. @cat src/graphics/opengl/shaders/TextureShader.frag | awk '{if ($$0!="}") {print "\t\""$$0"\\n\""} else {print "\t\""$$0"\";\n"}}' >> src/graphics/opengl/shaders/gen/TextureShader.h;
  88. @/bin/echo -ne "#endif\n" >> src/graphics/opengl/shaders/gen/TextureShader.h;
  89. endif
  90. $(OBJDIR)/%.o: $(SRCDIR)/%.cpp | shaders
  91. @mkdir -p $(@D)
  92. @mkdir -p $(subst gen,d,$(@D))
  93. $(CXX) -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td $(CXXFLAGS) $(INCPATH) $(WARNINGS) -c -o $@ $<
  94. @mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d && touch $@
  95. $(OBJDIR)/tlsf.o: $(SRCDIR)/tlsf.c
  96. $(CC) $(INCPATH) $(CWARN) -DTLSF_USE_LOCKS=0 -DUSE_SBRK=1 -c -o $@ $<
  97. $(DEPDIR)/%d: ;
  98. .PRECIOUS: $(DEPDIR)/%.d
  99. test-url.o: tests/testPrograms/URLtest.cpp
  100. $(CXX) -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td $(CXXFLAGS) $(INCPATH) $(WARINGS) -c -o $@ $<
  101. ntr-run-tests: test-url.o $(OBJDIR)/URL.o $(OBJDIR)/StringUtils.o
  102. $(LINK) $(LDFLAGS) -o $@ test-url.o $(OBJDIR)/URL.o $(OBJDIR)/StringUtils.o $(LIBS)
  103. clean:
  104. -@rm -rf src/graphics/opengl/shaders/gen $(OBJDIR) $(EXECUTABLE) 2>/dev/null || true
  105. include $(addsuffix .d,$(subst $(SRCDIR),$(DEPDIR),$(basename $(SOURCES))))