1ifndef DMLC_CORE 2 DMLC_CORE = dmlc-core 3endif 4 5ifndef RABIT 6 RABIT = rabit 7endif 8 9ROOTDIR = $(CURDIR) 10 11# workarounds for some buggy old make & msys2 versions seen in windows 12ifeq (NA, $(shell test ! -d "$(ROOTDIR)" && echo NA )) 13 $(warning Attempting to fix non-existing ROOTDIR [$(ROOTDIR)]) 14 ROOTDIR := $(shell pwd) 15 $(warning New ROOTDIR [$(ROOTDIR)] $(shell test -d "$(ROOTDIR)" && echo " is OK" )) 16endif 17MAKE_OK := $(shell "$(MAKE)" -v 2> /dev/null) 18ifndef MAKE_OK 19 $(warning Attempting to recover non-functional MAKE [$(MAKE)]) 20 MAKE := $(shell which make 2> /dev/null) 21 MAKE_OK := $(shell "$(MAKE)" -v 2> /dev/null) 22endif 23$(warning MAKE [$(MAKE)] - $(if $(MAKE_OK),checked OK,PROBLEM)) 24 25include $(DMLC_CORE)/make/dmlc.mk 26 27# set compiler defaults for OSX versus *nix 28# let people override either 29OS := $(shell uname) 30ifeq ($(OS), Darwin) 31ifndef CC 32export CC = $(if $(shell which clang), clang, gcc) 33endif 34ifndef CXX 35export CXX = $(if $(shell which clang++), clang++, g++) 36endif 37else 38# linux defaults 39ifndef CC 40export CC = gcc 41endif 42ifndef CXX 43export CXX = g++ 44endif 45endif 46 47export CFLAGS= -DDMLC_LOG_CUSTOMIZE=1 -std=c++14 -Wall -Wno-unknown-pragmas -Iinclude $(ADD_CFLAGS) 48CFLAGS += -I$(DMLC_CORE)/include -I$(RABIT)/include -I$(GTEST_PATH)/include 49 50ifeq ($(TEST_COVER), 1) 51 CFLAGS += -g -O0 -fprofile-arcs -ftest-coverage 52else 53 CFLAGS += -O3 -funroll-loops 54endif 55 56ifndef LINT_LANG 57 LINT_LANG= "all" 58endif 59 60# specify tensor path 61.PHONY: clean all lint clean_all doxygen rcpplint pypack Rpack Rbuild Rcheck 62 63build/%.o: src/%.cc 64 @mkdir -p $(@D) 65 $(CXX) $(CFLAGS) -MM -MT build/$*.o $< >build/$*.d 66 $(CXX) -c $(CFLAGS) $< -o $@ 67 68# The should be equivalent to $(ALL_OBJ) except for build/cli_main.o 69amalgamation/xgboost-all0.o: amalgamation/xgboost-all0.cc 70 $(CXX) -c $(CFLAGS) $< -o $@ 71 72rcpplint: 73 python3 dmlc-core/scripts/lint.py xgboost ${LINT_LANG} R-package/src 74 75lint: rcpplint 76 python3 dmlc-core/scripts/lint.py --exclude_path python-package/xgboost/dmlc-core \ 77 python-package/xgboost/include python-package/xgboost/lib \ 78 python-package/xgboost/make python-package/xgboost/rabit \ 79 python-package/xgboost/src --pylint-rc ${PWD}/python-package/.pylintrc xgboost \ 80 ${LINT_LANG} include src python-package 81 82ifeq ($(TEST_COVER), 1) 83cover: check 84 @- $(foreach COV_OBJ, $(COVER_OBJ), \ 85 gcov -pbcul -o $(shell dirname $(COV_OBJ)) $(COV_OBJ) > gcov.log || cat gcov.log; \ 86 ) 87endif 88 89 90# dask is required to pass, others are not 91# If any of the dask tests failed, contributor won't see the other error. 92mypy: 93 cd python-package; \ 94 mypy ./xgboost/dask.py && \ 95 mypy ./xgboost/rabit.py && \ 96 mypy ../demo/guide-python/external_memory.py && \ 97 mypy ../tests/python-gpu/test_gpu_with_dask.py && \ 98 mypy ../tests/python/test_data_iterator.py && \ 99 mypy ../tests/python-gpu/test_gpu_data_iterator.py && \ 100 mypy ./xgboost/sklearn.py || exit 1; \ 101 mypy . || true ; 102 103clean: 104 $(RM) -rf build lib bin *~ */*~ */*/*~ */*/*/*~ */*.o */*/*.o */*/*/*.o #xgboost 105 $(RM) -rf build_tests *.gcov tests/cpp/xgboost_test 106 if [ -d "R-package/src" ]; then \ 107 cd R-package/src; \ 108 $(RM) -rf rabit src include dmlc-core amalgamation *.so *.dll; \ 109 cd $(ROOTDIR); \ 110 fi 111 112clean_all: clean 113 cd $(DMLC_CORE); "$(MAKE)" clean; cd $(ROOTDIR) 114 cd $(RABIT); "$(MAKE)" clean; cd $(ROOTDIR) 115 116# create pip source dist (sdist) pack for PyPI 117pippack: clean_all 118 cd python-package; python setup.py sdist; mv dist/*.tar.gz ..; cd .. 119 120# Script to make a clean installable R package. 121Rpack: clean_all 122 rm -rf xgboost xgboost*.tar.gz 123 cp -r R-package xgboost 124 rm -rf xgboost/src/*.o xgboost/src/*.so xgboost/src/*.dll 125 rm -rf xgboost/src/*/*.o 126 rm -rf xgboost/demo/*.model xgboost/demo/*.buffer xgboost/demo/*.txt 127 rm -rf xgboost/demo/runall.R 128 cp -r src xgboost/src/src 129 cp -r include xgboost/src/include 130 cp -r amalgamation xgboost/src/amalgamation 131 mkdir -p xgboost/src/rabit 132 cp -r rabit/include xgboost/src/rabit/include 133 cp -r rabit/src xgboost/src/rabit/src 134 rm -rf xgboost/src/rabit/src/*.o 135 mkdir -p xgboost/src/dmlc-core 136 cp -r dmlc-core/include xgboost/src/dmlc-core/include 137 cp -r dmlc-core/src xgboost/src/dmlc-core/src 138 cp ./LICENSE xgboost 139# Modify PKGROOT in Makevars.in 140 cat R-package/src/Makevars.in|sed '2s/.*/PKGROOT=./' > xgboost/src/Makevars.in 141# Configure Makevars.win (Windows-specific Makevars, likely using MinGW) 142 cp xgboost/src/Makevars.in xgboost/src/Makevars.win 143 cat xgboost/src/Makevars.in| sed '3s/.*/ENABLE_STD_THREAD=0/' > xgboost/src/Makevars.win 144 sed -i -e 's/@OPENMP_CXXFLAGS@/$$\(SHLIB_OPENMP_CXXFLAGS\)/g' xgboost/src/Makevars.win 145 sed -i -e 's/-pthread/$$\(SHLIB_PTHREAD_FLAGS\)/g' xgboost/src/Makevars.win 146 sed -i -e 's/@ENDIAN_FLAG@/-DDMLC_CMAKE_LITTLE_ENDIAN=1/g' xgboost/src/Makevars.win 147 sed -i -e 's/@BACKTRACE_LIB@//g' xgboost/src/Makevars.win 148 sed -i -e 's/@OPENMP_LIB@//g' xgboost/src/Makevars.win 149 rm -f xgboost/src/Makevars.win-e # OSX sed create this extra file; remove it 150 bash R-package/remove_warning_suppression_pragma.sh 151 bash xgboost/remove_warning_suppression_pragma.sh 152 rm xgboost/remove_warning_suppression_pragma.sh 153 rm -rfv xgboost/tests/helper_scripts/ 154 155R ?= R 156 157Rbuild: Rpack 158 $(R) CMD build xgboost 159 rm -rf xgboost 160 161Rcheck: Rbuild 162 $(R) CMD check --as-cran xgboost*.tar.gz 163 164-include build/*.d 165-include build/*/*.d 166