Skip to content

Commit

Permalink
Use "/usr/local" as default prefix for "make install" (#448)
Browse files Browse the repository at this point in the history
* Use "/usr/local" as default prefix for "make install"

Convential filesystem standards imply that "/usr" prefix should be
used only by system package managers. Custom installations should go
to /usr/local by default.

However, we *should* keep "/usr" prefix for packaging, therefore
override the default for "deb" and "rpm" targets.

* Print out installation paths

It's better for our users to know where do we install files to and
where do we remove them from during uninstallation. Let's print the
PREFIX value for "make install" and "make uninstall" targets.

* Warning about multiple Themis installations

Changing default installation path from /usr to /usr/local is more or
less safe on Linux as the compilers and linker-loaders *usually* check
/usr/local before /usr. Therefore after "sudo make install" the software
will (probably) be using the new version of Themis. However, the old
installation may still remain there in "/usr" and this may cause issues
with non-standard configurations.

Check if there are multiple installations of Themis and print a warning
for the users, suggesting to keep only one installation in their system.
  • Loading branch information
ilammy authored Apr 10, 2019
1 parent bedd0b1 commit c266872
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,11 @@ define themisecho
@tput sgr0
endef

ifeq ($(ENGINE),)
ENGINE=libressl
endif

#default engine
ifeq ($(PREFIX),)
PREFIX = /usr
# default installation prefix
PREFIX ?= /usr/local

# MacOS
ifdef IS_MACOS
PREFIX = /usr/local
endif

endif
# default cryptographic engine
ENGINE ?= libressl

#engine selection block
ifneq ($(ENGINE),)
Expand Down Expand Up @@ -419,9 +410,29 @@ install_pkgconfig: err all make_install_dirs
@$(BUILD_CMD_)

install: install_soter_headers install_themis_headers install_static_libs install_shared_libs install_pkgconfig
@echo -n "Themis installed to $(PREFIX)"
@$(PRINT_OK_)
ifdef IS_LINUX
@ldconfig || (status=$$?; if [ $$(id -u) = "0" ]; then exit $$status; else exit 0; fi)
endif
@if [ -e /usr/include/themis/themis.h ] && [ -e /usr/local/include/themis/themis.h ]; then \
echo ""; \
echo "Multiple Themis installations detected in standard system paths:"; \
echo ""; \
echo " - /usr"; \
echo " - /usr/local"; \
echo ""; \
echo "This may lead to surprising behaviour when building and using software"; \
echo "which depends on Themis."; \
echo ""; \
echo "If you previously had Themis installed from source to \"/usr\","; \
echo "consider uninstalling the old version with"; \
echo ""; \
echo " sudo $(MAKE) uninstall PREFIX=/usr"; \
echo ""; \
echo "and keep the new version in \"/usr/local\"."; \
echo ""; \
fi

get_version:
@echo $(VERSION)
Expand Down Expand Up @@ -481,7 +492,7 @@ 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
@echo -n "themis uninstall "
@echo -n "Themis uninstalled from $(PREFIX) "
@$(BUILD_CMD_)

ifeq ($(PHP_VERSION),5)
Expand Down Expand Up @@ -644,6 +655,8 @@ symlink_realname_to_soname:
strip:
@find . -name \*.$(SHARED_EXT)\.* -exec strip -o {} {} \;

deb: PREFIX = /usr

deb: soter_static themis_static soter_shared themis_shared soter_pkgconfig themis_pkgconfig collect_headers install_shell_scripts strip symlink_realname_to_soname
@mkdir -p $(BIN_PATH)/deb

Expand Down Expand Up @@ -686,6 +699,7 @@ deb: soter_static themis_static soter_shared themis_shared soter_pkgconfig themi
# it's just for printing .deb files
@find $(BIN_PATH) -name \*.deb

rpm: PREFIX = /usr

rpm: themis_static themis_shared themis_pkgconfig soter_static soter_shared soter_pkgconfig collect_headers install_shell_scripts strip symlink_realname_to_soname
@mkdir -p $(BIN_PATH)/rpm
Expand Down

0 comments on commit c266872

Please sign in to comment.