rntviewer/Makefile
2024-07-23 10:41:55 +02:00

55 lines
1.9 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)
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 build/*.o rntviewer $(ROOT_IFACE)
build/imgui.o: src/imgui_inc.cpp
@mkdir -p $(@D)/build
$(CXX) -O3 -fPIC -c -Ithird_party/imgui $< -o $@
$(ROOT_IFACE): src/root/RMicroFileReader.cxx
$(CXX) -O3 -fPIC -c $(ROOTFLAGS) $< -o $@
$(ROOT_IFACE_DBG): src/root/RMicroFileReader.cxx
$(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)
# 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)