[Make] refactor build script to use config file
This commit is contained in:
parent
7e6f00ee11
commit
084f5f4715
2
.gitignore
vendored
2
.gitignore
vendored
@ -69,4 +69,4 @@ nb-configuration*
|
|||||||
.pydevproject
|
.pydevproject
|
||||||
.settings/
|
.settings/
|
||||||
build
|
build
|
||||||
|
config.mk
|
||||||
|
|||||||
89
Makefile
89
Makefile
@ -1,39 +1,11 @@
|
|||||||
ifndef CC
|
ifndef config
|
||||||
export CC = $(if $(shell which gcc-5),gcc-5,gcc)
|
ifneq ("$(wildcard ./config.mk)","")
|
||||||
endif
|
config = config.mk
|
||||||
ifndef CXX
|
|
||||||
export CXX = $(if $(shell which g++-5),g++-5,g++)
|
|
||||||
endif
|
|
||||||
|
|
||||||
export LDFLAGS= -pthread -lm
|
|
||||||
export CFLAGS= -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -fPIC -Iinclude
|
|
||||||
|
|
||||||
ifndef LINT_LANG
|
|
||||||
LINT_LANG= "all"
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(OS), Windows_NT)
|
|
||||||
export CXX = g++ -m64
|
|
||||||
export CC = gcc -m64
|
|
||||||
endif
|
|
||||||
|
|
||||||
UNAME= $(shell uname)
|
|
||||||
|
|
||||||
ifeq ($(UNAME), Linux)
|
|
||||||
LDFLAGS += -lrt
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(no_omp),1)
|
|
||||||
CFLAGS += -DDISABLE_OPENMP
|
|
||||||
else
|
else
|
||||||
ifeq ($(omp_mac_static),1)
|
config = make/config.mk
|
||||||
CFLAGS += -static-libgcc -static-libstdc++ -L. -fopenmp
|
|
||||||
else
|
|
||||||
CFLAGS += -fopenmp
|
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
ifndef DMLC_CORE
|
ifndef DMLC_CORE
|
||||||
DMLC_CORE = dmlc-core
|
DMLC_CORE = dmlc-core
|
||||||
endif
|
endif
|
||||||
@ -42,21 +14,60 @@ ifndef RABIT
|
|||||||
RABIT = rabit
|
RABIT = rabit
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ROOTDIR = $(CURDIR)
|
||||||
|
UNAME= $(shell uname)
|
||||||
|
|
||||||
|
include $(config)
|
||||||
|
ifeq ($(USE_OPENMP), 0)
|
||||||
|
export NO_OPENMP = 1
|
||||||
|
endif
|
||||||
|
include $(DMLC_CORE)/make/dmlc.mk
|
||||||
|
|
||||||
|
# use customized config file
|
||||||
|
ifndef CC
|
||||||
|
export CC = $(if $(shell which gcc-5),gcc-5,gcc)
|
||||||
|
endif
|
||||||
|
ifndef CXX
|
||||||
|
export CXX = $(if $(shell which g++-5),g++-5,g++)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(OS), Windows_NT)
|
||||||
|
export CXX = g++ -m64
|
||||||
|
export CC = gcc -m64
|
||||||
|
endif
|
||||||
|
|
||||||
|
export LDFLAGS= -pthread -lm $(ADD_LDFLAGS) $(DMLC_LDFLAGS)
|
||||||
|
export CFLAGS= -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -fPIC -Iinclude $(ADD_CFLAGS)
|
||||||
|
CFLAGS += -I$(DMLC_CORE)/include -I$(RABIT)/include
|
||||||
|
|
||||||
|
ifndef LINT_LANG
|
||||||
|
LINT_LANG= "all"
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(UNAME), Linux)
|
||||||
|
LDFLAGS += -lrt
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(USE_OPENMP), 1)
|
||||||
|
CFLAGS += -fopenmp
|
||||||
|
else
|
||||||
|
CFLAGS += -DDISABLE_OPENMP
|
||||||
|
endif
|
||||||
|
|
||||||
# specify tensor path
|
# specify tensor path
|
||||||
.PHONY: clean all lint
|
.PHONY: clean all lint clean_all
|
||||||
|
|
||||||
all: lib/libxgboost.a lib/libxgboost.so
|
all: lib/libxgboost.a lib/libxgboost.so
|
||||||
|
|
||||||
$(DMLC_CORE)/libdmlc.a:
|
$(DMLC_CORE)/libdmlc.a:
|
||||||
+ cd $(DMLC_CORE); make libdmlc.a; cd $(ROOTDIR)
|
+ cd $(DMLC_CORE); make libdmlc.a config=$(ROOTDIR)/$(config); cd $(ROOTDIR)
|
||||||
|
|
||||||
$(RABIT)/lib/librabit.a:
|
$(RABIT)/lib/$(LIB_RABIT):
|
||||||
+ cd $(RABIT); make lib/librabit.a; cd $(ROOTDIR)
|
+ cd $(RABIT); make lib/$(LIB_RABIT); cd $(ROOTDIR)
|
||||||
|
|
||||||
CFLAGS += -I$(DMLC_CORE)/include -I$(RABIT)/include
|
|
||||||
SRC = $(wildcard src/*.cc src/*/*.cc)
|
SRC = $(wildcard src/*.cc src/*/*.cc)
|
||||||
OBJ = $(patsubst src/%.cc, build/%.o, $(SRC))
|
OBJ = $(patsubst src/%.cc, build/%.o, $(SRC))
|
||||||
LIB_DEP = $(DMLC_CORE)/libdmlc.a $(RABIT)/lib/librabit.a
|
LIB_DEP = $(DMLC_CORE)/libdmlc.a $(RABIT)/lib/$(LIB_RABIT)
|
||||||
ALL_DEP = $(OBJ) $(LIB_DEP)
|
ALL_DEP = $(OBJ) $(LIB_DEP)
|
||||||
|
|
||||||
build/%.o: src/%.cc
|
build/%.o: src/%.cc
|
||||||
@ -78,7 +89,7 @@ lint:
|
|||||||
clean:
|
clean:
|
||||||
$(RM) -r build lib bin *~ */*~ */*/*~ */*/*/*~
|
$(RM) -r build lib bin *~ */*~ */*/*~ */*/*/*~
|
||||||
|
|
||||||
clean_all: clean
|
clean: clean_all
|
||||||
cd $(DMLC_CORE); make clean; cd -
|
cd $(DMLC_CORE); make clean; cd -
|
||||||
cd $(RABIT); make clean; cd -
|
cd $(RABIT); make clean; cd -
|
||||||
|
|
||||||
|
|||||||
17
build.sh
17
build.sh
@ -6,27 +6,14 @@
|
|||||||
|
|
||||||
# See additional instruction in doc/build.md
|
# See additional instruction in doc/build.md
|
||||||
|
|
||||||
#for building static OpenMP lib in MAC for easier installation in MAC
|
|
||||||
#doesn't work with XCode clang/LLVM since Apple doesn't support,
|
|
||||||
#needs brew install gcc 4.9+ with OpenMP. By default the static link is OFF
|
|
||||||
static_omp=0
|
|
||||||
if ((${static_omp}==1)); then
|
|
||||||
rm libgomp.a
|
|
||||||
ln -s `g++ -print-file-name=libgomp.a`
|
|
||||||
make clean
|
|
||||||
make omp_mac_static=1
|
|
||||||
echo "Successfully build multi-thread static link xgboost"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if make; then
|
if make; then
|
||||||
echo "Successfully build multi-thread xgboost"
|
echo "Successfully build multi-thread xgboost"
|
||||||
else
|
else
|
||||||
echo "-----------------------------"
|
echo "-----------------------------"
|
||||||
echo "Building multi-thread xgboost failed"
|
echo "Building multi-thread xgboost failed"
|
||||||
echo "Start to build single-thread xgboost"
|
echo "Start to build single-thread xgboost"
|
||||||
make clean
|
make clean_all
|
||||||
make no_omp=1
|
make config=config/mininum.mk
|
||||||
echo "Successfully build single-thread xgboost"
|
echo "Successfully build single-thread xgboost"
|
||||||
echo "If you want multi-threaded version"
|
echo "If you want multi-threaded version"
|
||||||
echo "See additional instructions in doc/build.md"
|
echo "See additional instructions in doc/build.md"
|
||||||
|
|||||||
48
make/config.mk
Normal file
48
make/config.mk
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#-----------------------------------------------------
|
||||||
|
# xgboost: the configuration compile script
|
||||||
|
#
|
||||||
|
# If you want to change the configuration, please use the following
|
||||||
|
# steps. Assume you are on the root directory of xgboost.
|
||||||
|
# First copy the this file so that any local changes will be ignored by git
|
||||||
|
#
|
||||||
|
# $ cp make/config.mk .
|
||||||
|
#
|
||||||
|
# Next modify the according entries, and then compile by
|
||||||
|
#
|
||||||
|
# $ make
|
||||||
|
#
|
||||||
|
# or build in parallel with 8 threads
|
||||||
|
#
|
||||||
|
# $ make -j8
|
||||||
|
#----------------------------------------------------
|
||||||
|
|
||||||
|
# choice of compiler, by default use system preference.
|
||||||
|
# export CC = gcc
|
||||||
|
# export CXX = g++
|
||||||
|
# export MPICXX = mpicxx
|
||||||
|
|
||||||
|
# the additional link flags you want to add
|
||||||
|
ADD_LDFLAGS =
|
||||||
|
|
||||||
|
# the additional compile flags you want to add
|
||||||
|
ADD_CFLAGS =
|
||||||
|
|
||||||
|
# Whether enable openmp support, needed for multi-threading.
|
||||||
|
USE_OPENMP = 1
|
||||||
|
|
||||||
|
# whether use HDFS support during compile
|
||||||
|
USE_HDFS = 0
|
||||||
|
|
||||||
|
# whether use AWS S3 support during compile
|
||||||
|
USE_S3 = 0
|
||||||
|
|
||||||
|
# whether use Azure blob support during compile
|
||||||
|
USE_AZURE = 0
|
||||||
|
|
||||||
|
# Rabit library version,
|
||||||
|
# - librabit.a Normal distributed version.
|
||||||
|
# - librabit_empty.a Non distributed mock version,
|
||||||
|
LIB_RABIT = librabit.a
|
||||||
|
|
||||||
|
# path to libjvm.so
|
||||||
|
LIBJVM=$(JAVA_HOME)/jre/lib/amd64/server
|
||||||
22
make/minimum.mk
Normal file
22
make/minimum.mk
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#-----------------------------------------------------
|
||||||
|
# xgboost: minumum dependency configuration,
|
||||||
|
# see config.mk for template.
|
||||||
|
#----------------------------------------------------
|
||||||
|
|
||||||
|
# Whether enable openmp support, needed for multi-threading.
|
||||||
|
USE_OPENMP = 0
|
||||||
|
|
||||||
|
# whether use HDFS support during compile
|
||||||
|
USE_HDFS = 0
|
||||||
|
|
||||||
|
# whether use AWS S3 support during compile
|
||||||
|
USE_S3 = 0
|
||||||
|
|
||||||
|
# whether use Azure blob support during compile
|
||||||
|
USE_AZURE = 0
|
||||||
|
|
||||||
|
# Rabit library version,
|
||||||
|
# - librabit.a Normal distributed version.
|
||||||
|
# - librabit_empty.a Non distributed mock version,
|
||||||
|
LIB_RABIT = librabit_empty.a
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user