Add make install

Summary:
Add make install.  If INSTALL_PATH is not set, then rocksdb will be
installed under "/usr/local" directory (/usr/local/include for headers
and /usr/local/lib for library file(s).)

Test Plan:
Develop a simple rocksdb app, called test.cc, and do the followings.

make clean
make static_lib -j32
sudo make install
g++ -std=c++11 test.cc -lrocksdb -lbz2 -lz -o test
./test

sudo make uninstall
make clean
make shared_lib -j32
sudo make install
g++ -std=c++11 test.cc -lrocksdb -lbz2 -lz -o test
./test

make INSTALL_PATH=/tmp/path install
make INSTALL_PATH=/tmp/path uninstall
and make sure things are installed / uninstalled in the specified path.

Reviewers: ljin, sdong, igor

Reviewed By: igor

Subscribers: leveldb

Differential Revision: https://reviews.facebook.net/D23211
This commit is contained in:
Yueh-Hsuan Chiang 2014-09-11 20:41:02 -07:00
parent 0352a9fa91
commit ebb5c65e60

View File

@ -3,7 +3,6 @@
# found in the LICENSE file. See the AUTHORS file for names of contributors.
# Inherit some settings from environment variables, if available
INSTALL_PATH ?= $(CURDIR)
#-----------------------------------------------
@ -49,6 +48,33 @@ else
PLATFORM_CCFLAGS += $(JEMALLOC_INCLUDE) -DHAVE_JEMALLOC
endif
#-------------------------------------------------
# make install related stuff
INSTALL_PATH ?= /usr/local
uninstall:
rm -rf $(INSTALL_PATH)/include/rocksdb
if [ -a $(LIBRARY) ]; then \
rm -rf $(INSTALL_PATH)/lib/$(LIBRARY); \
fi
if [ -a $(SHARED) ]; then \
rm -rf $(INSTALL_PATH)/lib/$(SHARED); \
fi
install:
install -d $(INSTALL_PATH)/include/rocksdb
install -d $(INSTALL_PATH)/lib
for header in `find "include/rocksdb" -type f -name *.h`; do \
install -C -m 644 -D $$header $(INSTALL_PATH)/$$header; \
done
if [ -a $(LIBRARY) ]; then \
install -C -m 644 $(LIBRARY) $(INSTALL_PATH)/lib/.; \
fi;
if [ -a $(SHARED) ]; then \
install -C -m 644 $(SHARED) $(INSTALL_PATH)/lib/.; \
fi;
#-------------------------------------------------
WARNING_FLAGS = -Wall -Werror -Wsign-compare
CFLAGS += $(WARNING_FLAGS) -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
CXXFLAGS += $(WARNING_FLAGS) -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT) -Woverloaded-virtual
@ -178,7 +204,7 @@ endif # PLATFORM_SHARED_EXT
.PHONY: blackbox_crash_test check clean coverage crash_test ldb_tests \
release tags valgrind_check whitebox_crash_test format static_lib shared_lib all \
dbg
dbg install uninstall
all: $(LIBRARY) $(PROGRAMS) $(TESTS)