rntviewer/Makefile
2024-09-06 16:07:42 +02:00

71 lines
2.5 KiB
Makefile

ifeq ($(shell which root-config),)
ROOT = $(HOME)/root_build/debug
$(info Cannot find root-config: guessing the root is $(ROOT). Please source thisroot.sh)
ROOTINCDIR = $(ROOT)/include
ROOTLIBDIR = $(ROOT)/lib
else
ROOTINCDIR = $(shell root-config --incdir)
ROOTLIBDIR = $(shell root-config --libdir)
endif
CFLAGS = -Wall -Wextra -pedantic
INC = -Ithird_party -Ithird_party/imgui
LIBS = -lglfw
ROOTFLAGS = -std=c++17 -m64 -I$(ROOTINCDIR)
ROOTLIBS = -L$(ROOTLIBDIR) -lCore -lRIO -lROOTNTuple -lxxhash -pthread -Wl,-rpath,$(ROOTLIBDIR)
IMGUI_FLAGS = -Ithird_party -Ithird_party/imgui
ifeq ($(shell which mold),)
MOLD =
else
MOLD = mold -run
endif
ROOT_IFACE = build/RMicroFileReader.o
ROOT_IFACE_DBG = $(ROOT_IFACE).dbg
.PHONY: all clean
all: build/imgui.o $(ROOT_IFACE) ubsan
clean:
rm -f build/*.o rntviewer $(ROOT_IFACE) $(ROOT_IFACE_DBG)
build/imgui.o: src/imgui_inc.cpp
@mkdir -p $(@D)/build
$(CXX) -O3 -fPIC -c $(IMGUI_FLAGS) $< -o $@
$(ROOT_IFACE): src/root/RMicroFileReader.cxx
@mkdir -p $(@D)/build
$(CXX) -O3 -fPIC -c $(ROOTFLAGS) $< -o $@
$(ROOT_IFACE_DBG): src/root/RMicroFileReader.cxx
@mkdir -p $(@D)/build
$(CXX) -O0 -DDEBUG -g -fPIC -c $(ROOTFLAGS) $< -o $@
# debug build
d: $(ROOT_IFACE_DBG) build/imgui.o
$(MOLD) $(CXX) -DDEBUG -g -O0 -DENABLE_ASAN $(CFLAGS) $(INC) $(ROOTFLAGS) -o rntviewer src/rntviewer.cpp build/imgui.o -lasan $(ROOT_IFACE_DBG) $(LIBS) $(ROOTLIBS)
# release build
r: $(ROOT_IFACE) build/imgui.o
$(MOLD) $(CXX) -O2 -DNDEBUG $(CFLAGS) $(INC) $(ROOTFLAGS) -o rntviewer src/rntviewer.cpp build/imgui.o $(ROOT_IFACE) $(LIBS) $(ROOTLIBS)
# debug-release build
dr: $(ROOT_IFACE_DBG) build/imgui.o
$(MOLD) $(CXX) -g -O2 $(CFLAGS) $(INC) $(ROOTFLAGS) -o rntviewer src/rntviewer.cpp build/imgui.o $(ROOT_IFACE_DBG) $(LIBS) $(ROOTLIBS)
# sanitizers
asan: $(ROOT_IFACE_DBG) build/imgui.o
$(MOLD) $(CXX) -DDEBUG -g -O0 $(CFLAGS) -fsanitize=address $(INC) $(ROOTFLAGS) -o rntviewer src/rntviewer.cpp build/imgui.o $(ROOT_IFACE_DBG) $(LIBS) $(ROOTLIBS)
ubsan: $(ROOT_IFACE_DBG) build/imgui.o
$(MOLD) $(CXX) -DDEBUG -g -O0 $(CFLAGS) -fsanitize=undefined $(INC) $(ROOTFLAGS) -o rntviewer src/rntviewer.cpp build/imgui.o $(ROOT_IFACE_DBG) $(LIBS) $(ROOTLIBS)
# no gfx debug build
nogfx_d: $(ROOT_IFACE_DBG)
$(MOLD) $(CXX) -DDEBUG -g -O0 -DRNT_NO_GFX -DENABLE_ASAN $(CFLAGS) $(INC) $(ROOTFLAGS) -o rntviewer src/rntviewer.cpp -lasan $(ROOT_IFACE_DBG) $(ROOTLIBS)
# no gfx release build
nogfx_r: $(ROOT_IFACE)
$(MOLD) $(CXX) -O2 -DRNT_NO_GFX -DNDEBUG $(CFLAGS) $(INC) $(ROOTFLAGS) -o rntviewer src/rntviewer.cpp $(ROOT_IFACE) $(ROOTLIBS)