132 lines
3.5 KiB
Makefile
Executable File
132 lines
3.5 KiB
Makefile
Executable File
# SETTINGS
|
|
OBJECT_DIR = ../build
|
|
WEBOBJECT_DIR = ../web-build
|
|
EXEC = ../mps
|
|
WEBHTML = $(WEBOBJECT_DIR)/mps.html
|
|
# WEBEXEC = $(WEBOBJECT_DIR)/mps.js
|
|
WEBEXEC = ~/Projekte/web/html-quintern/src/script/mps/mps-wasm.js
|
|
|
|
# LOG_LEVEL = LOG_LEVEL_0
|
|
CXX = /usr/bin/g++
|
|
CXXFLAGS = -std=c++23 -MMD -MP -Wpedantic -Wall #-O3: optimierungsstufe 3, -MMD .d files, -MP leeres Target, Wextra alle Warnungen
|
|
CXXDEBUGFLAGS = -g -fsanitize=address -fno-omit-frame-pointer -O1
|
|
|
|
WEBCXX = em++
|
|
WEBCXXFLAGS = --cache "$(WEBOBJECT_DIR)/emscripten-cache" -Wno-c++11-narrowing -Wno-unused-main -DEMSCRIPTEN
|
|
WEBCXXDEBUGFLAGS = -gsource-map -g2 -O0
|
|
WEBLDFLAGS = -s EXPORTED_FUNCTIONS="['_free']" -s ASYNCIFY -s EXPORTED_RUNTIME_METHODS="['cwrap', 'getValue']" -lembind -s INITIAL_MEMORY=2GB -s ALLOW_MEMORY_GROWTH=1
|
|
# treated as error by em++
|
|
LDFLAGS = #-lgzutil
|
|
IFLAGS = -I../include/
|
|
|
|
SRCDIRS = $(wildcard */)
|
|
IFLAGS += $(foreach dir,$(SRCDIRS), -I$(dir))
|
|
IFLAGS += $(foreach dir,$(SRCDIRS), -I../$(dir))
|
|
IFLAGS += -I../ -I./
|
|
CXXFLAGS += $(IFLAGS)
|
|
|
|
|
|
# CXXFLAGS += -D $(LOG_LEVEL)
|
|
# CXXFLAGS += -fsanitize=address
|
|
# CXXFLAGS += -fconcepts-diagnostics-depth=2
|
|
|
|
SRC = $(wildcard *.cpp) $(wildcard */*.cpp)
|
|
# OBJECTS = $(SRC:%.cpp=$(OBJECT_DIR)/%.o)
|
|
OBJECTS = $($(notdir SRC):%.cpp=$(OBJECT_DIR)/%.o)
|
|
WEBOBJECTS = $($(notdir SRC):%.cpp=$(WEBOBJECT_DIR)/%.o)
|
|
OBJECT_DIRS = $(foreach dir,$(SRCDIRS), $(OBJECT_DIR)/$(dir))
|
|
WEBOBJECT_DIRS = $(foreach dir,$(SRCDIRS), $(WEBOBJECT_DIR)/$(dir))
|
|
DEPENDS = ${OBJECTS:.o=.d}
|
|
|
|
|
|
FMT_MESSAGE="\e[1;34m%s\e[0m %s %s %s\n"
|
|
default:
|
|
@printf $(FMT_MESSAGE) "CXXFLAGS = " "$(CXXFLAGS)"
|
|
@printf $(FMT_MESSAGE) "LDFLAGS = " "$(LDFLAGS)"
|
|
default: CXXFLAGS += -include pch.hpp
|
|
default: $(EXEC)
|
|
|
|
web: CXXFLAGS += $(WEBCXXFLAGS)
|
|
web: $(WEBEXEC)
|
|
|
|
webDebug: WEBLDFLAGS += -sASSERTIONS
|
|
webDebug: CXXFLAGS += $(WEBCXXDEBUGFLAGS)
|
|
webDebug: web
|
|
|
|
webO0: CXXFLAGS += $(WEBCXXFLAGS) -O0
|
|
webO0: web
|
|
webO1: CXXFLAGS += $(WEBCXXFLAGS) -O1
|
|
webO1: web
|
|
webO2: CXXFLAGS += $(WEBCXXFLAGS) -O2
|
|
webO2: web
|
|
webO3: CXXFLAGS += $(WEBCXXFLAGS) -O3
|
|
webO3: web
|
|
|
|
webrun: CXXFLAGS += $(WEBCXXFLAGS)
|
|
webrun: $(WEBHTML)
|
|
cd $(WEBOBJECT_DIR) && emrun $(WEBHTML)
|
|
|
|
.PHONY: release
|
|
release: CXXFLAGS += -O3
|
|
release: default
|
|
|
|
O0: CXXFLAGS += -O0
|
|
O0: default
|
|
O1: CXXFLAGS += -O1
|
|
O1: default
|
|
O2: CXXFLAGS += -O2
|
|
O2: default
|
|
O3: CXXFLAGS += -O3
|
|
O3: default
|
|
|
|
# rule for the executable
|
|
$(EXEC): $(OBJECT_DIRS) $(OBJECTS)
|
|
$(CXX) $(OBJECTS) -o $@ $(CXXFLAGS) $(LDFLAGS)
|
|
|
|
$(WEBHTML) $(WEBEXEC): $(WEBOBJECT_DIRS) $(WEBOBJECTS)
|
|
$(WEBCXX) $(WEBOBJECTS) -o $@ $(CXXFLAGS) $(LDFLAGS) $(WEBLDFLAGS)
|
|
# include the makefiles generated by the -M flag
|
|
-include $(DEPENDS)
|
|
|
|
# rule for all ../build/*.o files
|
|
$(OBJECT_DIR)/%.o: $(shell echo $<) %.cpp
|
|
@printf $(FMT_MESSAGE) "Building:" $< "->" $@
|
|
@$(CXX) -c $< -o $@ $(CXXFLAGS) $(LDFLAGS)
|
|
|
|
$(WEBOBJECT_DIR)/%.o: $(shell echo $<) %.cpp
|
|
@printf $(FMT_MESSAGE) "Building:" $< "->" $@
|
|
@$(WEBCXX) -c $< -o $@ $(CXXFLAGS) $(LDFLAGS)
|
|
|
|
$(OBJECT_DIRS) $(WEBOBJECT_DIRS):
|
|
mkdir -p $@
|
|
|
|
#
|
|
# Extras Options
|
|
#
|
|
# with debug flags
|
|
.PHONY += debug run gdb pch clean docs
|
|
|
|
debug: CXXFLAGS += $(CXXDEBUGFLAGS)
|
|
debug: default
|
|
|
|
# make with debug flags and run afterwards
|
|
run: CXXFLAGS += $(CXXDEBUGFLAGS)
|
|
run: default
|
|
-pwd; cd $(shell dirname $(EXEC)); pwd; ./$(shell basename $(EXEC))
|
|
|
|
# with debug flags and run gnu debugger
|
|
gdb: CXXFLAGS += -g
|
|
gdb: default
|
|
gdb $(EXEC) -ex "layout src"
|
|
|
|
# build pch
|
|
pch:
|
|
$(CXX) pch.hpp -std=c++23 -O3 -g $(IFLAGS)
|
|
|
|
# remove all object and dependecy files
|
|
clean:
|
|
-rm -r $(OBJECT_DIR)
|
|
-rm -r $(WEBOBJECT_DIR)
|
|
docs:
|
|
doxygen .doxygen_config
|