Skip to content

Commit

Permalink
Add make install
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yhchiang committed Sep 12, 2014
1 parent 0352a9f commit ebb5c65
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions Makefile
Expand Up @@ -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)

#-----------------------------------------------

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit ebb5c65

Please sign in to comment.