Use standard variables for installing/uninstalling with make (#7187)

Summary:
Fixes https://github.com/facebook/rocksdb/issues/7185.

Standard for GNU and FreeBSD. See
https://www.freebsd.org/doc/en/books/porters-handbook/porting-prefix.html
https://www.gnu.org/prep/standards/html_node/DESTDIR.html#DESTDIR
https://www.gnu.org/prep/standards/html_node/Directory-Variables.html

Pull Request resolved: https://github.com/facebook/rocksdb/pull/7187

Reviewed By: cheng-chang

Differential Revision: D23333233

Pulled By: ajkr

fbshipit-source-id: f704d23852c4516cf5fa00df73ff57687b2ddffb
main
Jonny Heggheim 4 years ago committed by Facebook GitHub Bot
parent c2485f2d81
commit 1e59800718
  1. 44
      Makefile
  2. 21
      build_tools/make_package.sh

@ -1830,36 +1830,40 @@ prefetch_test: $(OBJ_DIR)/file/prefetch_test.o $(TEST_LIBRARY) $(LIBRARY)
#------------------------------------------------- #-------------------------------------------------
# make install related stuff # make install related stuff
INSTALL_PATH ?= /usr/local PREFIX ?= /usr/local
LIBDIR ?= $(PREFIX)/lib
INSTALL_LIBDIR = $(DESTDIR)$(LIBDIR)
uninstall: uninstall:
rm -rf $(INSTALL_PATH)/include/rocksdb \ rm -rf $(DESTDIR)$(PREFIX)/include/rocksdb \
$(INSTALL_PATH)/lib/$(LIBRARY) \ $(INSTALL_LIBDIR)/$(LIBRARY) \
$(INSTALL_PATH)/lib/$(SHARED4) \ $(INSTALL_LIBDIR)/$(SHARED4) \
$(INSTALL_PATH)/lib/$(SHARED3) \ $(INSTALL_LIBDIR)/$(SHARED3) \
$(INSTALL_PATH)/lib/$(SHARED2) \ $(INSTALL_LIBDIR)/$(SHARED2) \
$(INSTALL_PATH)/lib/$(SHARED1) \ $(INSTALL_LIBDIR)/$(SHARED1) \
$(INSTALL_PATH)/lib/pkgconfig/rocksdb.pc $(INSTALL_LIBDIR)/pkgconfig/rocksdb.pc
install-headers: gen-pc install-headers: gen-pc
install -d $(INSTALL_PATH)/lib install -d $(INSTALL_LIBDIR)
install -d $(INSTALL_PATH)/lib/pkgconfig install -d $(INSTALL_LIBDIR)/pkgconfig
for header_dir in `$(FIND) "include/rocksdb" -type d`; do \ for header_dir in `$(FIND) "include/rocksdb" -type d`; do \
install -d $(INSTALL_PATH)/$$header_dir; \ install -d $(DESTDIR)/$(PREFIX)/$$header_dir; \
done done
for header in `$(FIND) "include/rocksdb" -type f -name *.h`; do \ for header in `$(FIND) "include/rocksdb" -type f -name *.h`; do \
install -C -m 644 $$header $(INSTALL_PATH)/$$header; \ install -C -m 644 $$header $(DESTDIR)/$(PREFIX)/$$header; \
done done
install -C -m 644 rocksdb.pc $(INSTALL_PATH)/lib/pkgconfig/rocksdb.pc install -C -m 644 rocksdb.pc $(INSTALL_LIBDIR)/pkgconfig/rocksdb.pc
install-static: install-headers $(LIBRARY) install-static: install-headers $(LIBRARY)
install -C -m 755 $(LIBRARY) $(INSTALL_PATH)/lib install -d $(INSTALL_LIBDIR)
install -C -m 755 $(LIBRARY) $(INSTALL_LIBDIR)
install-shared: install-headers $(SHARED4) install-shared: install-headers $(SHARED4)
install -C -m 755 $(SHARED4) $(INSTALL_PATH)/lib && \ install -d $(INSTALL_LIBDIR)
ln -fs $(SHARED4) $(INSTALL_PATH)/lib/$(SHARED3) && \ install -C -m 755 $(SHARED4) $(INSTALL_LIBDIR)
ln -fs $(SHARED4) $(INSTALL_PATH)/lib/$(SHARED2) && \ ln -fs $(SHARED4) $(INSTALL_LIBDIR)/$(SHARED3)
ln -fs $(SHARED4) $(INSTALL_PATH)/lib/$(SHARED1) ln -fs $(SHARED4) $(INSTALL_LIBDIR)/$(SHARED2)
ln -fs $(SHARED4) $(INSTALL_LIBDIR)/$(SHARED1)
# install static by default + install shared if it exists # install static by default + install shared if it exists
install: install-static install: install-static
@ -1867,10 +1871,10 @@ install: install-static
# Generate the pkg-config file # Generate the pkg-config file
gen-pc: gen-pc:
-echo 'prefix=$(INSTALL_PATH)' > rocksdb.pc -echo 'prefix=$(PREFIX)' > rocksdb.pc
-echo 'exec_prefix=$${prefix}' >> rocksdb.pc -echo 'exec_prefix=$${prefix}' >> rocksdb.pc
-echo 'includedir=$${prefix}/include' >> rocksdb.pc -echo 'includedir=$${prefix}/include' >> rocksdb.pc
-echo 'libdir=$${exec_prefix}/lib' >> rocksdb.pc -echo 'libdir=$(LIBDIR)' >> rocksdb.pc
-echo '' >> rocksdb.pc -echo '' >> rocksdb.pc
-echo 'Name: rocksdb' >> rocksdb.pc -echo 'Name: rocksdb' >> rocksdb.pc
-echo 'Description: An embeddable persistent key-value store for fast storage' >> rocksdb.pc -echo 'Description: An embeddable persistent key-value store for fast storage' >> rocksdb.pc

@ -103,31 +103,26 @@ function main() {
gem_install fpm gem_install fpm
make static_lib make static_lib
make install INSTALL_PATH=package LIBDIR=/usr/lib
if [[ $FPM_OUTPUT = "rpm" ]]; then
cd package LIBDIR=$(rpm --eval '%_libdir')
LIB_DIR=lib
if [[ -z "$ARCH" ]]; then
ARCH=$(getconf LONG_BIT)
fi
if [[ ("$FPM_OUTPUT" = "rpm") && ($ARCH -eq 64) ]]; then
mv lib lib64
LIB_DIR=lib64
fi fi
rm -rf package
make install DESTDIR=package PREFIX=/usr LIBDIR=$LIBDIR
fpm \ fpm \
-s dir \ -s dir \
-t $FPM_OUTPUT \ -t $FPM_OUTPUT \
-C package \
-n rocksdb \ -n rocksdb \
-v $1 \ -v $1 \
--prefix /usr \
--url http://rocksdb.org/ \ --url http://rocksdb.org/ \
-m rocksdb@fb.com \ -m rocksdb@fb.com \
--license BSD \ --license BSD \
--vendor Facebook \ --vendor Facebook \
--description "RocksDB is an embeddable persistent key-value store for fast storage." \ --description "RocksDB is an embeddable persistent key-value store for fast storage." \
include $LIB_DIR usr
} }
# shellcheck disable=SC2068 # shellcheck disable=SC2068

Loading…
Cancel
Save