Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow GNU conventions for installation #453

Merged
merged 2 commits into from
Apr 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 17 additions & 58 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
CLANG_FORMAT ?= clang-format
CLANG_TIDY ?= clang-tidy
SHELL = /bin/bash

INSTALL = install
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL) -m 644

SRC_PATH = src
ifneq ($(BUILD_PATH),)
BIN_PATH = $(BUILD_PATH)
Expand Down Expand Up @@ -77,6 +82,13 @@ PREFIX ?= /usr/local
# default cryptographic engine
ENGINE ?= libressl

# default installation paths
prefix = $(PREFIX)
exec_prefix = $(prefix)
includedir = $(prefix)/include
libdir = $(exec_prefix)/lib
pkgconfigdir = $(libdir)/pkgconfig

#engine selection block
ifneq ($(ENGINE),)
ifeq ($(ENGINE),openssl)
Expand Down Expand Up @@ -282,6 +294,7 @@ include src/soter/soter.mk
include src/themis/themis.mk
ifndef CARGO
include src/wrappers/themis/jsthemis/jsthemis.mk
include src/wrappers/themis/themispp/themispp.mk
include jni/themis_jni.mk
endif
endif
Expand All @@ -298,8 +311,10 @@ all: err themis_static soter_static themis_shared soter_shared themis_pkgconfig

soter_static: $(BIN_PATH)/$(LIBSOTER_A)
soter_shared: $(BIN_PATH)/$(LIBSOTER_SO)
soter_pkgconfig: $(BIN_PATH)/libsoter.pc
themis_static: $(BIN_PATH)/$(LIBTHEMIS_A)
themis_shared: $(BIN_PATH)/$(LIBTHEMIS_SO)
themis_pkgconfig: $(BIN_PATH)/libthemis.pc
themis_jni: $(BIN_PATH)/$(LIBTHEMISJNI_SO)

#
Expand Down Expand Up @@ -336,11 +351,6 @@ $(OBJ_PATH)/%.fmt_check: %
@echo -n "check $< "
@$(BUILD_CMD_)

THEMISPP_HEADERS = $(wildcard $(SRC_PATH)/wrappers/themis/themispp/*.hpp)

FMT_FIXUP += $(patsubst %,$(OBJ_PATH)/%.fmt_fixup, $(THEMISPP_HEADERS))
FMT_CHECK += $(patsubst %,$(OBJ_PATH)/%.fmt_check, $(THEMISPP_HEADERS))

#$(AUD_PATH)/%: CMD = $(CC) $(CFLAGS) -E -dI -dD $< -o $@
$(AUD_PATH)/%: CMD = ./scripts/pp.sh $< $@

Expand Down Expand Up @@ -370,43 +380,7 @@ ifdef RUST_VERSION
@rm -f tools/rust/*.rust
endif

make_install_dirs: CMD = mkdir -p $(PREFIX)/include/themis $(PREFIX)/include/soter $(PREFIX)/lib $(PREFIX)/lib/pkgconfig

make_install_dirs:
@echo -n "making dirs for install "
@$(BUILD_CMD_)

install_soter_headers: CMD = install $(SRC_PATH)/soter/*.h $(PREFIX)/include/soter

install_soter_headers: err all make_install_dirs
@echo -n "install soter headers "
@$(BUILD_CMD_)

install_themis_headers: CMD = install $(SRC_PATH)/themis/*.h $(PREFIX)/include/themis

install_themis_headers: err all make_install_dirs
@echo -n "install themis headers "
@$(BUILD_CMD_)

install_static_libs: CMD = install $(BIN_PATH)/*.a $(PREFIX)/lib

install_static_libs: err all make_install_dirs
@echo -n "install static libraries "
@$(BUILD_CMD_)

install_shared_libs: CMD = install $(BIN_PATH)/*.$(SHARED_EXT) $(PREFIX)/lib

install_shared_libs: err all make_install_dirs
@echo -n "install shared libraries "
@$(BUILD_CMD_)

install_pkgconfig: CMD = install $(BIN_PATH)/*.pc $(PREFIX)/lib/pkgconfig

install_pkgconfig: err all make_install_dirs
@echo -n "install pkg-config files "
@$(BUILD_CMD_)

install: install_soter_headers install_themis_headers install_static_libs install_shared_libs install_pkgconfig
install: all install_soter install_themis
@echo -n "Themis installed to $(PREFIX)"
@$(PRINT_OK_)
ifdef IS_LINUX
Expand Down Expand Up @@ -486,9 +460,7 @@ ifdef NPM_VERSION
@$(BUILD_CMD_)
endif

uninstall: CMD = rm -rf $(PREFIX)/include/themis && rm -rf $(PREFIX)/include/soter && rm -f $(PREFIX)/lib/libsoter.a && rm -f $(PREFIX)/lib/libthemis.a && rm -f $(PREFIX)/lib/libsoter.$(SHARED_EXT) && rm -f $(PREFIX)/lib/libthemis.$(SHARED_EXT) && rm -f $(PREFIX)/lib/pkgconfig/libsoter.pc && rm -f $(PREFIX)/lib/pkgconfig/libthemis.pc

uninstall: phpthemis_uninstall rbthemis_uninstall themispp_uninstall jsthemis_uninstall
uninstall: phpthemis_uninstall rbthemis_uninstall themispp_uninstall jsthemis_uninstall uninstall_themis uninstall_soter
@echo -n "Themis uninstalled from $(PREFIX) "
@$(BUILD_CMD_)

Expand Down Expand Up @@ -545,19 +517,6 @@ endif
@echo -n "pythemis install "
@$(BUILD_CMD_)


themispp_install: CMD = install $(SRC_PATH)/wrappers/themis/themispp/*.hpp $(PREFIX)/include/themispp

themispp_install:
@mkdir -p $(PREFIX)/include/themispp
@$(BUILD_CMD)

themispp_uninstall: CMD = rm -rf $(PREFIX)/include/themispp

themispp_uninstall:
@echo -n "themispp uninstall "
@$(BUILD_CMD_)

soter_collect_headers:
@mkdir -p $(BIN_PATH)/include/soter
@cd src/soter && find . -name \*.h -exec cp --parents {} ../../$(BIN_PATH)/include/soter/ \; && cd - > /dev/null
Expand Down
21 changes: 20 additions & 1 deletion src/soter/soter.mk
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,28 @@ ifdef IS_MACOS
@install_name_tool -change "$(BIN_PATH)/$(notdir $@)" "$(PREFIX)/lib/$(notdir $@)" $(BIN_PATH)/$(notdir $@)
endif

soter_pkgconfig:
$(BIN_PATH)/libsoter.pc:
@mkdir -p $(BIN_PATH)
@sed -e "s!%prefix%!$(PREFIX)!" \
-e "s!%version%!$(VERSION)!" \
-e "s!%crypto-libs%!$(CRYPTO_ENGINE_LDFLAGS)!" \
$(SRC_PATH)/soter/libsoter.pc.in > $(BIN_PATH)/libsoter.pc

install_soter: err $(BIN_PATH)/$(LIBSOTER_A) $(BIN_PATH)/$(LIBSOTER_SO) $(BIN_PATH)/libsoter.pc
@echo -n "install Soter "
@mkdir -p $(DESTDIR)/$(includedir)/soter
@mkdir -p $(DESTDIR)/$(pkgconfigdir)
@mkdir -p $(DESTDIR)/$(libdir)
@$(INSTALL_DATA) $(SRC_PATH)/soter/*.h $(DESTDIR)/$(includedir)/soter
@$(INSTALL_DATA) $(BIN_PATH)/libsoter.pc $(DESTDIR)/$(pkgconfigdir)
@$(INSTALL_DATA) $(BIN_PATH)/$(LIBSOTER_A) $(DESTDIR)/$(libdir)
@$(INSTALL_PROGRAM) $(BIN_PATH)/$(LIBSOTER_SO) $(DESTDIR)/$(libdir)
@$(PRINT_OK_)

uninstall_soter:
@echo -n "uninstall Soter "
@rm -rf $(DESTDIR)/$(includedir)/soter
@rm -f $(DESTDIR)/$(pkgconfigdir)/libsoter.pc
@rm -f $(DESTDIR)/$(libdir)/$(LIBSOTER_A)
@rm -f $(DESTDIR)/$(libdir)/$(LIBSOTER_SO)
@$(PRINT_OK_)
21 changes: 20 additions & 1 deletion src/themis/themis.mk
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,27 @@ ifdef IS_MACOS
@install_name_tool -change "$(BIN_PATH)/$(notdir $@)" "$(PREFIX)/lib/$(notdir $@)" $(BIN_PATH)/$(notdir $@)
endif

themis_pkgconfig:
$(BIN_PATH)/libthemis.pc:
@mkdir -p $(BIN_PATH)
@sed -e "s!%prefix%!$(PREFIX)!" \
-e "s!%version%!$(VERSION)!" \
$(SRC_PATH)/themis/libthemis.pc.in > $(BIN_PATH)/libthemis.pc

install_themis: err $(BIN_PATH)/$(LIBTHEMIS_A) $(BIN_PATH)/$(LIBTHEMIS_SO) $(BIN_PATH)/libthemis.pc
@echo -n "install Themis "
@mkdir -p $(DESTDIR)/$(includedir)/themis
@mkdir -p $(DESTDIR)/$(pkgconfigdir)
@mkdir -p $(DESTDIR)/$(libdir)
@$(INSTALL_DATA) $(SRC_PATH)/themis/*.h $(DESTDIR)/$(includedir)/themis
@$(INSTALL_DATA) $(BIN_PATH)/libthemis.pc $(DESTDIR)/$(pkgconfigdir)
@$(INSTALL_DATA) $(BIN_PATH)/$(LIBTHEMIS_A) $(DESTDIR)/$(libdir)
@$(INSTALL_PROGRAM) $(BIN_PATH)/$(LIBTHEMIS_SO) $(DESTDIR)/$(libdir)
@$(PRINT_OK_)

uninstall_themis:
@echo -n "uninstall Themis "
@rm -rf $(DESTDIR)/$(includedir)/themis
@rm -f $(DESTDIR)/$(pkgconfigdir)/libthemis.pc
@rm -f $(DESTDIR)/$(libdir)/$(LIBTHEMIS_A)
@rm -f $(DESTDIR)/$(libdir)/$(LIBTHEMIS_SO)
@$(PRINT_OK_)
31 changes: 31 additions & 0 deletions src/wrappers/themis/themispp/themispp.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# Copyright (c) 2019 Cossack Labs Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

THEMISPP_HEADERS = $(wildcard $(SRC_PATH)/wrappers/themis/themispp/*.hpp)

FMT_FIXUP += $(patsubst %,$(OBJ_PATH)/%.fmt_fixup, $(THEMISPP_HEADERS))
FMT_CHECK += $(patsubst %,$(OBJ_PATH)/%.fmt_check, $(THEMISPP_HEADERS))

themispp_install:
@echo -n "install ThemisPP "
@mkdir -p $(DESTDIR)/$(includedir)/themispp
@$(INSTALL_DATA) $(SRC_PATH)/wrappers/themis/themispp/*.hpp $(DESTDIR)/$(includedir)/themispp
@$(PRINT_OK_)

themispp_uninstall:
@echo -n "uninstall ThemisPP "
@rm -rf $(DESTDIR)/$(includedir)/themispp
@$(PRINT_OK_)