gz-cpp-util/src/Makefile

64 lines
1.4 KiB
Makefile
Raw Normal View History

2022-09-04 23:09:54 +02:00
CXX = /usr/bin/g++
CXXFLAGS = -std=c++20 -MMD -MP -O3
SRCDIRS = $(wildcard */)
IFLAGS = $(foreach dir,$(SRCDIRS), -I$(dir))
IFLAGS += $(foreach dir,$(SRCDIRS), -I../$(dir))
OBJECT_DIR = ../build
LIB = ../libgzutil.a
HEADER = $(wildcard *.hpp) $(wildcard */*.hpp)
HEADER_INST = $($(notdir HEADER):%.hpp=$(OBJECT_DIR)/%.stamp)
SRC = $(wildcard *.cpp) $(wildcard */*.cpp)
# OBJECTS = $(SRC:%.cpp=$(OBJECT_DIR)/%.o)
OBJECTS = $($(notdir SRC):%.cpp=$(OBJECT_DIR)/%.o)
OBJECT_DIRS = $(OBJECT_DIR) $(foreach dir,$(SRCDIRS), $(OBJECT_DIR)/$(dir))
DEPENDS = ${OBJECTS:.o=.d}
CXXFLAGS += $(IFLAGS)
.PHONY: install debug run clean docs
#
# BUILDING
#
default: $(LIB)
echo $(OBJECTS)
# with debug flags
debug: CXXFLAGS += -g +Wextra # -DDEBUG
debug: default
$(LIB): $(OBJECT_DIRS) $(OBJECTS)
ar -cq $(LIB) $(OBJECTS)
# include the makefiles generated by the -M flag
-include $(DEPENDS)
# rule for all ../build/*.o files
$(OBJECT_DIR)/%.o: %.cpp
$(CXX) -c $< -o $@ $(CXXFLAGS) $(LDFLAGS) $(LDLIBS)
$(OBJECT_DIRS):
mkdir -p $@
#
# INSTALLATION
#
install: $(LIB) $(HEADER_INST)
2022-09-05 00:32:37 +02:00
install -D -m 755 $< $(DESTDIR)/usr/lib/$(subst ../,,$<)
2022-09-05 03:10:40 +02:00
install -D -m 755 ../gen_enum_str.py $(DESTDIR)/usr/bin/gz-enum-str
2022-09-04 23:09:54 +02:00
$(OBJECT_DIR)/%.stamp: %.hpp $(OBJECT_DIR)
install -D -m 644 $< $(DESTDIR)/usr/include/gz-util/$<
touch $@
#
# EXTRAS
#
# remove all object and dependecy files
clean:
-rm -r $(OBJECT_DIR)
-rm $(LIB)
docs:
doxygen .doxygen_config