diff --git a/.gitignore b/.gitignore index 66abf2f..60ab6f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *~ build/ test* +obj/ diff --git a/Makefile b/Makefile index 470e90c..f927adb 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,26 @@ -SRC:=src/*.cpp -INCLUDE:=include/ -BUILD:=build -FEATURES?=-DFIXED_ROW_SIZE=24 -CXXFLAGS+= $(FEATURES) -Wall -pedantic -O3 -march=native --std=gnu++20 -fgraphite -flto -LDFLAGS+=-O3 -flto -lfmt -bindir?=/usr/local/bin +SRC=$(wildcard src/*.cpp) +INCLUDE =include +CXXFLAGS = -Wall -pedantic --std=gnu++20 $(addprefix -I,$(INCLUDE)) +CXXFLAGS+= -flto -felide-constructors -fgraphite -O3 +LDFLAGS = -lfmt -O3 -flto -hexview: - g++ $(SRC) $(CXXFLAGS) -I$(INCLUDE) -o $(BUILD)/$@ $(LDFLAGS) - strip $(BUILD)/$@ +PROJ = hexview -clean: - rm -f $(BUILD)/* +OBJ = $(addprefix obj/,$(SRC:.cpp=.o)) + +.PHONY: all +all: dirs $(PROJ) + +dirs: + @mkdir -p obj/src -install: - cp -f $(BUILD)/hexview $(DESTDIR)$(bindir)/hexview +obj/%.o: %.cpp + $(CXX) -c $< $(CXXFLAGS) -o $@ $(LDFLAGS) + +$(PROJ): $(OBJ) + $(CXX) $^ $(CXXFLAGS) -o $@ $(LDFLAGS) + strip $@ + +clean: + rm -f $(PROJ) + rm -rf obj