fix makefile

This commit is contained in:
silverweed 2024-07-16 14:55:17 +02:00
parent 83ea4a0096
commit 9090d9d52d

View file

@ -1,13 +1,25 @@
CXX = clang++
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
ROOT = $(HOME)/root_build/debug
ROOTFLAGS = -std=c++17 -m64 -I$(ROOT)/include
ROOTLIBS = -L$(ROOT)/lib -lCore -lRIO -lROOTNTuple -lxxhash -Wl,-rpath,$(ROOT)/lib -pthread
LIBS = -lglfw
MOLD = mold -run
# ROOT_IFACE = build/libroot_iface.so
# ROOT_IFACE_DBG = build/libroot_iface_d.so
ROOTFLAGS = -std=c++17 -m64 -I$(ROOTINCDIR)
ROOTLIBS = -L$(ROOTLIBDIR) -lCore -lRIO -lROOTNTuple -lxxhash -pthread
ifeq ($(shell which mold),)
MOLD =
else
MOLD = mold -run
endif
ROOT_IFACE = build/RMicroFileReader.o
ROOT_IFACE_DBG = $(ROOT_IFACE)
@ -23,20 +35,17 @@ build/imgui.o: src/imgui_inc.cpp third_party/imgui/imgui.h
$(ROOT_IFACE): src/root/RMicroFileReader.cxx
$(CXX) -O3 -fPIC -c $(ROOTFLAGS) $< -o $@
# $(ROOT_IFACE): src/root/RMicroFileReader.cxx src/root/RMicroFileReader.hxx
# $(CXX) -O3 -fPIC -shared $(ROOTFLAGS) $< -o $@ $(ROOTLIBS)
# $(ROOT_IFACE_DBG): src/root/RMicroFileReader.cxx src/root/RMicroFileReader.hxx
# $(CXX) -g -O0 -fPIC -shared $(ROOTFLAGS) $< -o $@ $(ROOTLIBS)
# 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)
noasan: $(ROOT_IFACE_DBG) build/imgui.o
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)
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)