From 6a29e7c484ed0ef22224e7b7b555fbc5b4045cc3 Mon Sep 17 00:00:00 2001 From: Shuai Kyle Zheng Date: Wed, 18 May 2016 11:10:13 +0100 Subject: [PATCH] revert back CMakeLists.txt and Makefile and Makefile.config.example --- CMakeLists.txt | 4 +- Makefile | 105 +++++++++------------------------------- Makefile.config.example | 19 -------- 3 files changed, 26 insertions(+), 102 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index da7142c9b3c..c5d99cef9dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,8 +10,8 @@ endif() project(Caffe C CXX) # ---[ Caffe version -set(CAFFE_TARGET_VERSION "1.0.0-rc3" CACHE STRING "Caffe logical version") -set(CAFFE_TARGET_SOVERSION "1.0.0-rc3" CACHE STRING "Caffe soname version") +set(CAFFE_TARGET_VERSION "1.0.0-rc3") +set(CAFFE_TARGET_SOVERSION "1.0.0-rc3") add_definitions(-DCAFFE_VERSION=${CAFFE_TARGET_VERSION}) # ---[ Using cmake scripts and modules diff --git a/Makefile b/Makefile index 403e00a38a1..80bc37375be 100644 --- a/Makefile +++ b/Makefile @@ -29,17 +29,9 @@ SRC_DIRS := $(shell find * -type d -exec bash -c "find {} -maxdepth 1 \ \( -name '*.cpp' -o -name '*.proto' \) | grep -q ." \; -print) # The target shared library name -LIBRARY_NAME := $(PROJECT) LIB_BUILD_DIR := $(BUILD_DIR)/lib -STATIC_NAME := $(LIB_BUILD_DIR)/lib$(LIBRARY_NAME).a -DYNAMIC_VERSION_MAJOR := 1 -DYNAMIC_VERSION_MINOR := 0 -DYNAMIC_VERSION_REVISION := 0-rc3 -DYNAMIC_NAME_SHORT := lib$(LIBRARY_NAME).so -#DYNAMIC_SONAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR) -DYNAMIC_VERSIONED_NAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION) -DYNAMIC_NAME := $(LIB_BUILD_DIR)/$(DYNAMIC_VERSIONED_NAME_SHORT) -COMMON_FLAGS += -DCAFFE_VERSION=$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION) +STATIC_NAME := $(LIB_BUILD_DIR)/lib$(PROJECT).a +DYNAMIC_NAME := $(LIB_BUILD_DIR)/lib$(PROJECT).so ############################## # Get all source files @@ -86,7 +78,7 @@ NONEMPTY_LINT_REPORT := $(BUILD_DIR)/$(LINT_EXT) # PY$(PROJECT)_SRC is the python wrapper for $(PROJECT) PY$(PROJECT)_SRC := python/$(PROJECT)/_$(PROJECT).cpp PY$(PROJECT)_SO := python/$(PROJECT)/_$(PROJECT).so -PY$(PROJECT)_HXX := include/$(PROJECT)/layers/python_layer.hpp +PY$(PROJECT)_HXX := include/$(PROJECT)/python_layer.hpp # MAT$(PROJECT)_SRC is the mex entrance point of matlab package for $(PROJECT) MAT$(PROJECT)_SRC := matlab/+$(PROJECT)/private/$(PROJECT)_.cpp ifneq ($(MATLAB_DIR),) @@ -177,29 +169,10 @@ ifneq ($(CPU_ONLY), 1) LIBRARY_DIRS += $(CUDA_LIB_DIR) LIBRARIES := cudart cublas curand endif - -LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5 - -# handle IO dependencies -USE_LEVELDB ?= 1 -USE_LMDB ?= 1 -USE_OPENCV ?= 1 - -ifeq ($(USE_LEVELDB), 1) - LIBRARIES += leveldb snappy -endif -ifeq ($(USE_LMDB), 1) - LIBRARIES += lmdb -endif -ifeq ($(USE_OPENCV), 1) - LIBRARIES += opencv_core opencv_highgui opencv_imgproc - - ifeq ($(OPENCV_VERSION), 3) - LIBRARIES += opencv_imgcodecs - endif - -endif -PYTHON_LIBRARIES ?= boost_python python2.7 +LIBRARIES += glog gflags protobuf leveldb snappy \ + lmdb boost_system hdf5_hl hdf5 m \ + opencv_core opencv_highgui opencv_imgproc +PYTHON_LIBRARIES := boost_python python2.7 WARNINGS := -Wall -Wno-sign-compare ############################## @@ -248,8 +221,6 @@ ifeq ($(UNAME), Linux) LINUX := 1 else ifeq ($(UNAME), Darwin) OSX := 1 - OSX_MAJOR_VERSION := $(shell sw_vers -productVersion | cut -f 1 -d .) - OSX_MINOR_VERSION := $(shell sw_vers -productVersion | cut -f 2 -d .) endif # Linux @@ -263,7 +234,6 @@ ifeq ($(LINUX), 1) # boost::thread is reasonably called boost_thread (compare OS X) # We will also explicitly add stdc++ to the link target. LIBRARIES += boost_thread stdc++ - VERSIONFLAGS += -Wl,-soname,$(DYNAMIC_VERSIONED_NAME_SHORT) -Wl,-rpath,$(ORIGIN)/../lib endif # OS X: @@ -272,29 +242,21 @@ endif ifeq ($(OSX), 1) CXX := /usr/bin/clang++ ifneq ($(CPU_ONLY), 1) - CUDA_VERSION := $(shell $(CUDA_DIR)/bin/nvcc -V | grep -o 'release [0-9.]*' | tr -d '[a-z ]') + CUDA_VERSION := $(shell $(CUDA_DIR)/bin/nvcc -V | grep -o 'release \d' | grep -o '\d') ifeq ($(shell echo | awk '{exit $(CUDA_VERSION) < 7.0;}'), 1) CXXFLAGS += -stdlib=libstdc++ LINKFLAGS += -stdlib=libstdc++ endif # clang throws this warning for cuda headers WARNINGS += -Wno-unneeded-internal-declaration - # 10.11 strips DYLD_* env vars so link CUDA (rpath is available on 10.5+) - OSX_10_OR_LATER := $(shell [ $(OSX_MAJOR_VERSION) -ge 10 ] && echo true) - OSX_10_5_OR_LATER := $(shell [ $(OSX_MINOR_VERSION) -ge 5 ] && echo true) - ifeq ($(OSX_10_OR_LATER),true) - ifeq ($(OSX_10_5_OR_LATER),true) - LDFLAGS += -Wl,-rpath,$(CUDA_LIB_DIR) - endif - endif endif # gtest needs to use its own tuple to not conflict with clang COMMON_FLAGS += -DGTEST_USE_OWN_TR1_TUPLE=1 # boost::thread is called boost_thread-mt to mark multithreading on OS X LIBRARIES += boost_thread-mt # we need to explicitly ask for the rpath to be obeyed + DYNAMIC_FLAGS := -install_name @rpath/libcaffe.so ORIGIN := @loader_path - VERSIONFLAGS += -Wl,-install_name,@rpath/$(DYNAMIC_VERSIONED_NAME_SHORT) -Wl,-rpath,$(ORIGIN)/../../build/lib else ORIGIN := \$$ORIGIN endif @@ -328,20 +290,6 @@ ifeq ($(USE_CUDNN), 1) COMMON_FLAGS += -DUSE_CUDNN endif -# configure IO libraries -ifeq ($(USE_OPENCV), 1) - COMMON_FLAGS += -DUSE_OPENCV -endif -ifeq ($(USE_LEVELDB), 1) - COMMON_FLAGS += -DUSE_LEVELDB -endif -ifeq ($(USE_LMDB), 1) - COMMON_FLAGS += -DUSE_LMDB -ifeq ($(ALLOW_LMDB_NOLOCK), 1) - COMMON_FLAGS += -DALLOW_LMDB_NOLOCK -endif -endif - # CPU-only configuration ifeq ($(CPU_ONLY), 1) OBJS := $(PROTO_OBJS) $(CXX_OBJS) @@ -364,9 +312,9 @@ ifeq ($(BLAS), mkl) # MKL LIBRARIES += mkl_rt COMMON_FLAGS += -DUSE_MKL - MKLROOT ?= /opt/intel/mkl - BLAS_INCLUDE ?= $(MKLROOT)/include - BLAS_LIB ?= $(MKLROOT)/lib $(MKLROOT)/lib/intel64 + MKL_DIR ?= /opt/intel/mkl + BLAS_INCLUDE ?= $(MKL_DIR)/include + BLAS_LIB ?= $(MKL_DIR)/lib $(MKL_DIR)/lib/intel64 else ifeq ($(BLAS), open) # OpenBLAS LIBRARIES += openblas @@ -381,9 +329,8 @@ else # OS X packages atlas as the vecLib framework LIBRARIES += cblas # 10.10 has accelerate while 10.9 has veclib - XCODE_CLT_VER := $(shell pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep 'version' | sed 's/[^0-9]*\([0-9]\).*/\1/') - XCODE_CLT_GEQ_6 := $(shell [ $(XCODE_CLT_VER) -gt 5 ] && echo 1) - ifeq ($(XCODE_CLT_GEQ_6), 1) + XCODE_CLT_VER := $(shell pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep -o 'version: 6') + ifneq (,$(findstring version: 6,$(XCODE_CLT_VER))) BLAS_INCLUDE ?= /System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/ LDFLAGS += -framework Accelerate else @@ -497,7 +444,7 @@ py: $(PY$(PROJECT)_SO) $(PROTO_GEN_PY) $(PY$(PROJECT)_SO): $(PY$(PROJECT)_SRC) $(PY$(PROJECT)_HXX) | $(DYNAMIC_NAME) @ echo CXX/LD -o $@ $< $(Q)$(CXX) -shared -o $@ $(PY$(PROJECT)_SRC) \ - -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(PYTHON_LDFLAGS) \ + -o $@ $(LINKFLAGS) -l$(PROJECT) $(PYTHON_LDFLAGS) \ -Wl,-rpath,$(ORIGIN)/../../build/lib mat$(PROJECT): mat @@ -525,7 +472,7 @@ runtest: $(TEST_ALL_BIN) pytest: py cd python; python -m unittest discover -s caffe/test - + mattest: mat cd matlab; $(MATLAB_DIR)/bin/matlab -nodisplay -r 'caffe.run_tests(), exit()' @@ -561,8 +508,7 @@ $(ALL_BUILD_DIRS): | $(BUILD_DIR_LINK) $(DYNAMIC_NAME): $(OBJS) | $(LIB_BUILD_DIR) @ echo LD -o $@ - $(Q)$(CXX) -shared -o $@ $(OBJS) $(VERSIONFLAGS) $(LINKFLAGS) $(LDFLAGS) - @ cd $(BUILD_DIR)/lib; rm -f $(DYNAMIC_NAME_SHORT); ln -s $(DYNAMIC_VERSIONED_NAME_SHORT) $(DYNAMIC_NAME_SHORT) + $(Q)$(CXX) -shared -o $@ $(OBJS) $(LINKFLAGS) $(LDFLAGS) $(DYNAMIC_FLAGS) $(STATIC_NAME): $(OBJS) | $(LIB_BUILD_DIR) @ echo AR -o $@ @@ -593,33 +539,33 @@ $(TEST_ALL_BIN): $(TEST_MAIN_SRC) $(TEST_OBJS) $(GTEST_OBJ) \ | $(DYNAMIC_NAME) $(TEST_BIN_DIR) @ echo CXX/LD -o $@ $< $(Q)$(CXX) $(TEST_MAIN_SRC) $(TEST_OBJS) $(GTEST_OBJ) \ - -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib + -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(PROJECT) -Wl,-rpath,$(ORIGIN)/../lib $(TEST_CU_BINS): $(TEST_BIN_DIR)/%.testbin: $(TEST_CU_BUILD_DIR)/%.o \ $(GTEST_OBJ) | $(DYNAMIC_NAME) $(TEST_BIN_DIR) @ echo LD $< $(Q)$(CXX) $(TEST_MAIN_SRC) $< $(GTEST_OBJ) \ - -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib + -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(PROJECT) -Wl,-rpath,$(ORIGIN)/../lib $(TEST_CXX_BINS): $(TEST_BIN_DIR)/%.testbin: $(TEST_CXX_BUILD_DIR)/%.o \ $(GTEST_OBJ) | $(DYNAMIC_NAME) $(TEST_BIN_DIR) @ echo LD $< $(Q)$(CXX) $(TEST_MAIN_SRC) $< $(GTEST_OBJ) \ - -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib + -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(PROJECT) -Wl,-rpath,$(ORIGIN)/../lib # Target for extension-less symlinks to tool binaries with extension '*.bin'. $(TOOL_BUILD_DIR)/%: $(TOOL_BUILD_DIR)/%.bin | $(TOOL_BUILD_DIR) @ $(RM) $@ - @ ln -s $(notdir $<) $@ + @ ln -s $(abspath $<) $@ $(TOOL_BINS): %.bin : %.o | $(DYNAMIC_NAME) @ echo CXX/LD -o $@ - $(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(LDFLAGS) \ + $(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(PROJECT) $(LDFLAGS) \ -Wl,-rpath,$(ORIGIN)/../lib $(EXAMPLE_BINS): %.bin : %.o | $(DYNAMIC_NAME) @ echo CXX/LD -o $@ - $(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(LDFLAGS) \ + $(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(PROJECT) $(LDFLAGS) \ -Wl,-rpath,$(ORIGIN)/../../lib proto: $(PROTO_GEN_CC) $(PROTO_GEN_HEADER) @@ -671,8 +617,6 @@ superclean: clean supercleanfiles $(DIST_ALIASES): $(DISTRIBUTE_DIR) $(DISTRIBUTE_DIR): all py | $(DISTRIBUTE_SUBDIRS) - # add proto - cp -r src/caffe/proto $(DISTRIBUTE_DIR)/ # add include cp -r include $(DISTRIBUTE_DIR)/ mkdir -p $(DISTRIBUTE_DIR)/include/caffe/proto @@ -682,8 +626,7 @@ $(DISTRIBUTE_DIR): all py | $(DISTRIBUTE_SUBDIRS) cp $(EXAMPLE_BINS) $(DISTRIBUTE_DIR)/bin # add libraries cp $(STATIC_NAME) $(DISTRIBUTE_DIR)/lib - install -m 644 $(DYNAMIC_NAME) $(DISTRIBUTE_DIR)/lib - cd $(DISTRIBUTE_DIR)/lib; rm -f $(DYNAMIC_NAME_SHORT); ln -s $(DYNAMIC_VERSIONED_NAME_SHORT) $(DYNAMIC_NAME_SHORT) + cp $(DYNAMIC_NAME) $(DISTRIBUTE_DIR)/lib # add python - it's not the standard way, indeed... cp -r python $(DISTRIBUTE_DIR)/python diff --git a/Makefile.config.example b/Makefile.config.example index 07bed63ae40..a873502559f 100644 --- a/Makefile.config.example +++ b/Makefile.config.example @@ -7,19 +7,6 @@ # CPU-only switch (uncomment to build without GPU support). # CPU_ONLY := 1 -# uncomment to disable IO dependencies and corresponding data layers -# USE_OPENCV := 0 -# USE_LEVELDB := 0 -# USE_LMDB := 0 - -# uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary) -# You should not set this flag if you will be reading LMDBs with any -# possibility of simultaneous read and write -# ALLOW_LMDB_NOLOCK := 1 - -# Uncomment if you're using OpenCV 3 -# OPENCV_VERSION := 3 - # To customize your choice of compiler, uncomment and set the following. # N.B. the default for Linux is g++ and the default for OSX is clang++ # CUSTOM_CXX := g++ @@ -70,11 +57,6 @@ PYTHON_INCLUDE := /usr/include/python2.7 \ # $(ANACONDA_HOME)/include/python2.7 \ # $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include \ -# Uncomment to use Python 3 (default is Python 2) -# PYTHON_LIBRARIES := boost_python3 python3.5m -# PYTHON_INCLUDE := /usr/include/python3.5m \ -# /usr/lib/python3.5/dist-packages/numpy/core/include - # We need to be able to find libpythonX.X.so or .dylib. PYTHON_LIB := /usr/lib # PYTHON_LIB := $(ANACONDA_HOME)/lib @@ -98,7 +80,6 @@ LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib # (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.) # USE_PKG_CONFIG := 1 -# N.B. both build and distribute dirs are cleared on `make clean` BUILD_DIR := build DISTRIBUTE_DIR := distribute