$NetBSD: patch-Makefile,v 1.1 2019/05/04 16:15:25 bacon Exp $ # Add destdir support, install-strip, and respect LDFLAGS --- Makefile.orig 2019-04-17 03:23:22.000000000 +0000 +++ Makefile @@ -3,9 +3,11 @@ DIR_SRC := ./src DIR_OBJ := ./obj PREFIX ?= /usr/local +DESTDIR ?= BINDIR ?= $(PREFIX)/bin INCLUDE_DIRS ?= LIBRARY_DIRS ?= +STRIP ?= strip SRC := $(wildcard ${DIR_SRC}/*.cpp) OBJ := $(patsubst %.cpp,${DIR_OBJ}/%.o,$(notdir ${SRC})) @@ -15,13 +17,14 @@ TARGET := fastp BIN_TARGET := ${TARGET} CXX ?= g++ -CXXFLAGS := -std=c++11 -g -O3 -I${DIR_INC} $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir)) ${CXXFLAGS} -LIBS := -lz -lpthread -LD_FLAGS := $(foreach librarydir,$(LIBRARY_DIRS),-L$(librarydir)) $(LIBS) $(LD_FLAGS) +CXXFLAGS ?= -g -O3 +CXXFLAGS += -std=c++11 -I${DIR_INC} $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir)) +LIBS := -lz +LDFLAGS += $(foreach librarydir,$(LIBRARY_DIRS),-L$(librarydir)) $(LIBS) ${BIN_TARGET}:${OBJ} - $(CXX) $(OBJ) -o $@ $(LD_FLAGS) + $(CXX) $(OBJ) -o $@ $(LDFLAGS) ${DIR_OBJ}/%.o:${DIR_SRC}/%.cpp make_obj_dir $(CXX) -c $< -o $@ $(CXXFLAGS) @@ -38,5 +41,9 @@ make_obj_dir: fi install: - install $(TARGET) $(BINDIR)/$(TARGET) + install -d $(DESTDIR)$(BINDIR) + install $(TARGET) $(DESTDIR)$(BINDIR)/$(TARGET) @echo "Installed." + +install-strip: install + $(STRIP) $(DESTDIR)$(BINDIR)/$(TARGET)