Skip to content

Commit ebb5c65

Browse files
committed
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
1 parent 0352a9f commit ebb5c65

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

Makefile

+28-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# found in the LICENSE file. See the AUTHORS file for names of contributors.
44

55
# Inherit some settings from environment variables, if available
6-
INSTALL_PATH ?= $(CURDIR)
76

87
#-----------------------------------------------
98

@@ -49,6 +48,33 @@ else
4948
PLATFORM_CCFLAGS += $(JEMALLOC_INCLUDE) -DHAVE_JEMALLOC
5049
endif
5150

51+
#-------------------------------------------------
52+
# make install related stuff
53+
INSTALL_PATH ?= /usr/local
54+
55+
uninstall:
56+
rm -rf $(INSTALL_PATH)/include/rocksdb
57+
if [ -a $(LIBRARY) ]; then \
58+
rm -rf $(INSTALL_PATH)/lib/$(LIBRARY); \
59+
fi
60+
if [ -a $(SHARED) ]; then \
61+
rm -rf $(INSTALL_PATH)/lib/$(SHARED); \
62+
fi
63+
64+
install:
65+
install -d $(INSTALL_PATH)/include/rocksdb
66+
install -d $(INSTALL_PATH)/lib
67+
for header in `find "include/rocksdb" -type f -name *.h`; do \
68+
install -C -m 644 -D $$header $(INSTALL_PATH)/$$header; \
69+
done
70+
if [ -a $(LIBRARY) ]; then \
71+
install -C -m 644 $(LIBRARY) $(INSTALL_PATH)/lib/.; \
72+
fi;
73+
if [ -a $(SHARED) ]; then \
74+
install -C -m 644 $(SHARED) $(INSTALL_PATH)/lib/.; \
75+
fi;
76+
#-------------------------------------------------
77+
5278
WARNING_FLAGS = -Wall -Werror -Wsign-compare
5379
CFLAGS += $(WARNING_FLAGS) -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
5480
CXXFLAGS += $(WARNING_FLAGS) -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT) -Woverloaded-virtual
@@ -178,7 +204,7 @@ endif # PLATFORM_SHARED_EXT
178204

179205
.PHONY: blackbox_crash_test check clean coverage crash_test ldb_tests \
180206
release tags valgrind_check whitebox_crash_test format static_lib shared_lib all \
181-
dbg
207+
dbg install uninstall
182208

183209
all: $(LIBRARY) $(PROGRAMS) $(TESTS)
184210

0 commit comments

Comments
 (0)