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.

97 lines
3.9 KiB

UNAME := $(shell uname)
6 years ago
CXX = g++
5 years ago
CC = gcc
GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags)
PLATFORM := $(shell g++ -dumpmachine)
CXXFLAGS = -O3 -flto=8 -std=c++14 -DVERSION=\"$(GIT_VERSION)\" -DPLATFORM=\"$(PLATFORM)\"
CFLAGS = -O3 -flto=8 -std=c11 -DVERSION=\"$(GIT_VERSION)\"
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
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
5 years ago
LIBS = -lglfw -lGL -lGLEW -lfreetype -lharfbuzz -lmbedtls -lmbedcrypto -lmbedx509
LDFLAGS = -O3 -flto=8
INCPATH = -I./deps/include # Usable headers are in ./deps - you still need the libraries installed in the usual places
MD5SUM = md5sum
ifeq ($(UNAME), Darwin)
5 years ago
CXXFLAGS = -O3 -std=c++1y -DVERSION=\"$(GIT_VERSION)\" -DPLATFORM=\"$(PLATFORM)\"
CFLAGS = -O3 -std=c11 -DVERSION=\"$(GIT_VERSION)\"
WARNINGS =
ifeq ("$(wildcard /usr/local/lib/libglfw3.dylib)","")
LIBS = -lglfw3 -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo -lGLEW -lfreetype -lharfbuzz -lmbedtls -lmbedcrypto -lmbedx509
else
ifeq ("$(wildcard /usr/local/lib/libglfw.3.dylib)","")
LIBS = -lglfw.3 -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo -lGLEW -lfreetype -lharfbuzz -lmbedtls -lmbedcrypto -lmbedx509
5 years ago
else
LIBS = -lglfw -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo -lGLEW -lfreetype -lharfbuzz -lmbedtls -lmbedcrypto -lmbedx509
5 years ago
endif
endif
LDFLAGS = -O3 -L/usr/local/lib
INCPATH = -I./deps/include
MD5SUM = md5
endif
6 years ago
EXECUTABLE = netrunner
LINK = g++
6 years ago
SRCDIR = src
OBJDIR = gen
DEPDIR = d
6 years ago
PREFIX = /usr/local
RESPREFIX = /usr/local/share
SOURCES = $(subst ./,,$(shell find src -name \*.cpp))
6 years ago
OBJECTS = $(subst $(SRCDIR),$(OBJDIR),$(SOURCES:.cpp=.o))
RES = res/
6 years ago
all: $(SOURCES) netrunner
netrunner: $(OBJECTS) $(OBJDIR)/tlsf.o $(OBJDIR)/slre.o
$(LINK) $(LDFLAGS) -o $@ $^ $(LIBS)
6 years ago
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
6 years ago
@mkdir -p $(@D)
@mkdir -p $(subst gen,d,$(@D))
$(CXX) -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td $(CXXFLAGS) $(INCPATH) $(WARNINGS) -c -o $@ $<
6 years ago
@mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d && touch $@
$(OBJDIR)/tlsf.o: $(SRCDIR)/tlsf.c
$(CC) $(INCPATH) $(CWARN) -DTLSF_USE_LOCKS=0 -DUSE_MMAP=1 -DUSE_SBRK=1 -c -o $@ $<
$(OBJDIR)/slre.o: $(SRCDIR)/slre.c
$(CC) $(INCPATH) $(CWARN) -c -o $@ $<
6 years ago
$(DEPDIR)/%d: ;
.PRECIOUS: $(DEPDIR)/%.d
test-url.o: tests/testPrograms/URLtest.cpp
$(CXX) -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td $(CXXFLAGS) $(INCPATH) $(WARINGS) -c -o $@ $<
ntr-run-tests: test-url.o $(OBJDIR)/URL.o $(OBJDIR)/StringUtils.o
$(LINK) $(LDFLAGS) -o $@ test-url.o $(OBJDIR)/URL.o $(OBJDIR)/StringUtils.o $(LIBS)
ntr-test-cfg: test-cfg.o $(OBJDIR)/CFGFileParser.o $(OBJDIR)/slre.o $(OBJDIR)/tlsf.o $(OBJDIR)/Murmur3.o
$(LINK) $(LDFLAGS) -o $@ $^ $(LIBS)
test-cfg.o: tests/TestCFG.cpp
$(CXX) -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td $(CXXFLAGS) -Isrc $(INCPATH) -DDEBUG $(WARNINGS) -c -o $@ $<
6 years ago
clean:
-@rm -rf $(OBJDIR) $(EXECUTABLE) 2>/dev/null || true
6 years ago
.PHONY: install
install: netrunner
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp $< $(DESTDIR)$(PREFIX)/bin/netrunner
mkdir -p $(DESTDIR)$(RESPREFIX)/netrunner
cp -R $(RES) $(DESTDIR)$(RESPREFIX)/netrunner/
.PHONY: uninstall
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/netrunner
rm -rf $(DESTDIR)$(RESPREFIX)/netrunner
6 years ago
include $(addsuffix .d,$(subst $(SRCDIR),$(DEPDIR),$(basename $(SOURCES))))