diff --git a/Makefile b/Makefile index e2ff249..b6283ae 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,10 @@ OBJECTS += $(BUILD_DIR)/miniz.o DSO_PATH := $(BUILD_DIR)/$(DSO_NAME) DSO := $(DSO_PATH).so.$(DSO_MAJOR).$(DSO_MINOR) +ifndef DONT_STRIP + INSTALL_STRIP := -s --strip-program=$(STRIP) +endif + $(DSO): $(OBJECTS) $(LINK_DSO) ln -sf $(DSO_NAME).so.$(DSO_MAJOR).$(DSO_MINOR) $(DSO_PATH).so.$(DSO_MINOR) @@ -37,6 +41,11 @@ $(BENCH_DIR)/zrle-bench: $(OBJECTS) $(BUILD_DIR)/pngfb.o \ $(BENCH_DIR)/zrle-bench.o $(LINK_EXE) $(shell pkg-config --libs libpng) +.PHONY: install +install: $(DSO) + install $(INSTALL_STRIP) -Dt $(DESTDIR)$(PREFIX)/lib $(BUILD_DIR)/*.so* + install -Dt $(DESTDIR)$(PREFIX)/include inc/neatvnc.h + .PHONY: bench bench: $(BENCH_DIR)/zrle-bench ./$(BENCH_DIR)/zrle-bench diff --git a/common.mk b/common.mk index 10c7ec5..e611cb7 100644 --- a/common.mk +++ b/common.mk @@ -2,6 +2,8 @@ MACHINE := $(shell $(CC) -dumpmachine) ARCH := $(firstword $(subst -, ,$(MACHINE))) BUILD_DIR ?= build-$(MACHINE) +PREFIX ?= /usr/local + ifeq ($(ARCH),x86_64) ARCH_CFLAGS := -mavx else @@ -10,6 +12,12 @@ ifeq ($(ARCH),arm) endif # end arm block endif # end x86_64 block +ifeq (, $(shell which $(MACHINE)-strip 2>/dev/null)) + STRIP := strip +else + STRIP := $(MACHINE)-strip +endif + CFLAGS ?= -g -O3 $(ARCH_CFLAGS) -flto -DNDEBUG LDFLAGS ?= -flto