You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 11 kB

7 years ago
11 years ago
7 years ago
13 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. TOPDIR = .
  2. include ./Makefile.system
  3. BLASDIRS = interface driver/level2 driver/level3 driver/others
  4. ifneq ($(DYNAMIC_ARCH), 1)
  5. BLASDIRS += kernel
  6. endif
  7. ifdef SANITY_CHECK
  8. BLASDIRS += reference
  9. endif
  10. SUBDIRS = $(BLASDIRS)
  11. ifneq ($(NO_LAPACK), 1)
  12. SUBDIRS += lapack
  13. endif
  14. RELA =
  15. ifeq ($(BUILD_RELAPACK), 1)
  16. RELA = re_lapack
  17. endif
  18. ifeq ($(NO_FORTRAN), 1)
  19. define NOFORTRAN
  20. 1
  21. endef
  22. define NO_LAPACK
  23. 1
  24. endef
  25. export NOFORTRAN
  26. export NO_LAPACK
  27. endif
  28. LAPACK_NOOPT := $(filter-out -O0 -O1 -O2 -O3 -Ofast,$(LAPACK_FFLAGS))
  29. SUBDIRS_ALL = $(SUBDIRS) test ctest utest exports benchmark ../laswp ../bench cpp_thread_test
  30. .PHONY : all libs netlib $(RELA) test ctest shared install
  31. .NOTPARALLEL : all libs $(RELA) prof lapack-test install blas-test
  32. all :: libs netlib $(RELA) tests shared
  33. @echo
  34. @echo " OpenBLAS build complete. ($(LIB_COMPONENTS))"
  35. @echo
  36. @echo " OS ... $(OSNAME) "
  37. @echo " Architecture ... $(ARCH) "
  38. ifndef BINARY64
  39. @echo " BINARY ... 32bit "
  40. else
  41. @echo " BINARY ... 64bit "
  42. endif
  43. ifdef INTERFACE64
  44. ifneq ($(INTERFACE64), 0)
  45. @echo " Use 64 bits int (equivalent to \"-i8\" in Fortran) "
  46. endif
  47. endif
  48. @echo " C compiler ... $(C_COMPILER) (command line : $(CC))"
  49. ifeq ($(NOFORTRAN), $(filter 0,$(NOFORTRAN)))
  50. @echo " Fortran compiler ... $(F_COMPILER) (command line : $(FC))"
  51. endif
  52. ifneq ($(OSNAME), AIX)
  53. @echo -n " Library Name ... $(LIBNAME)"
  54. else
  55. @echo " Library Name ... $(LIBNAME)"
  56. endif
  57. ifndef SMP
  58. @echo " (Single threaded) "
  59. else
  60. @echo " (Multi threaded; Max num-threads is $(NUM_THREADS))"
  61. endif
  62. ifeq ($(USE_OPENMP), 1)
  63. @echo
  64. @echo " Use OpenMP in the multithreading. Because of ignoring OPENBLAS_NUM_THREADS and GOTO_NUM_THREADS flags, "
  65. @echo " you should use OMP_NUM_THREADS environment variable to control the number of threads."
  66. @echo
  67. endif
  68. ifeq ($(OSNAME), Darwin)
  69. @echo "WARNING: If you plan to use the dynamic library $(LIBDYNNAME), you must run:"
  70. @echo
  71. @echo "\"make PREFIX=/your_installation_path/ install\"."
  72. @echo
  73. @echo "(or set PREFIX in Makefile.rule and run make install."
  74. @echo "If you want to move the .dylib to a new location later, make sure you change"
  75. @echo "the internal name of the dylib with:"
  76. @echo
  77. @echo "install_name_tool -id /new/absolute/path/to/$(LIBDYNNAME) $(LIBDYNNAME)"
  78. endif
  79. @echo
  80. @echo "To install the library, you can run \"make PREFIX=/path/to/your/installation install\"."
  81. @echo
  82. shared :
  83. ifneq ($(NO_SHARED), 1)
  84. ifeq ($(OSNAME), $(filter $(OSNAME),Linux SunOS Android Haiku))
  85. @$(MAKE) -C exports so
  86. @ln -fs $(LIBSONAME) $(LIBPREFIX).so
  87. @ln -fs $(LIBSONAME) $(LIBPREFIX).so.$(MAJOR_VERSION)
  88. endif
  89. ifeq ($(OSNAME), $(filter $(OSNAME),FreeBSD OpenBSD NetBSD DragonFly))
  90. @$(MAKE) -C exports so
  91. @ln -fs $(LIBSONAME) $(LIBPREFIX).so
  92. endif
  93. ifeq ($(OSNAME), Darwin)
  94. @$(MAKE) -C exports dyn
  95. @ln -fs $(LIBDYNNAME) $(LIBPREFIX).dylib
  96. endif
  97. ifeq ($(OSNAME), WINNT)
  98. @$(MAKE) -C exports dll
  99. endif
  100. ifeq ($(OSNAME), CYGWIN_NT)
  101. @$(MAKE) -C exports dll
  102. endif
  103. endif
  104. tests :
  105. ifeq ($(NOFORTRAN), $(filter 0,$(NOFORTRAN)))
  106. touch $(LIBNAME)
  107. ifndef NO_FBLAS
  108. $(MAKE) -C test all
  109. endif
  110. $(MAKE) -C utest all
  111. ifndef NO_CBLAS
  112. $(MAKE) -C ctest all
  113. ifeq ($(CPP_THREAD_SAFETY_TEST), 1)
  114. $(MAKE) -C cpp_thread_test all
  115. endif
  116. endif
  117. endif
  118. libs :
  119. ifeq ($(CORE), UNKNOWN)
  120. $(error OpenBLAS: Detecting CPU failed. Please set TARGET explicitly, e.g. make TARGET=your_cpu_target. Please read README for the detail.)
  121. endif
  122. ifeq ($(NOFORTRAN), 1)
  123. $(info OpenBLAS: Detecting fortran compiler failed. Cannot compile LAPACK. Only compile BLAS.)
  124. endif
  125. ifeq ($(NO_STATIC), 1)
  126. ifeq ($(NO_SHARED), 1)
  127. $(error OpenBLAS: neither static nor shared are enabled.)
  128. endif
  129. endif
  130. @-ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
  131. @for d in $(SUBDIRS) ; \
  132. do if test -d $$d; then \
  133. $(MAKE) -C $$d $(@F) || exit 1 ; \
  134. fi; \
  135. done
  136. #Save the config files for installation
  137. @cp Makefile.conf Makefile.conf_last
  138. @cp config.h config_last.h
  139. ifdef QUAD_PRECISION
  140. @echo "#define QUAD_PRECISION">> config_last.h
  141. endif
  142. ifeq ($(EXPRECISION), 1)
  143. @echo "#define EXPRECISION">> config_last.h
  144. endif
  145. ##
  146. ifeq ($(DYNAMIC_ARCH), 1)
  147. @$(MAKE) -C kernel commonlibs || exit 1
  148. @for d in $(DYNAMIC_CORE) ; \
  149. do $(MAKE) GOTOBLAS_MAKEFILE= -C kernel TARGET_CORE=$$d kernel || exit 1 ;\
  150. done
  151. @echo DYNAMIC_ARCH=1 >> Makefile.conf_last
  152. ifeq ($(DYNAMIC_OLDER), 1)
  153. @echo DYNAMIC_OLDER=1 >> Makefile.conf_last
  154. endif
  155. endif
  156. ifdef USE_THREAD
  157. @echo USE_THREAD=$(USE_THREAD) >> Makefile.conf_last
  158. endif
  159. @touch lib.grd
  160. prof : prof_blas prof_lapack
  161. prof_blas :
  162. ln -fs $(LIBNAME_P) $(LIBPREFIX)_p.$(LIBSUFFIX)
  163. for d in $(SUBDIRS) ; \
  164. do if test -d $$d; then \
  165. $(MAKE) -C $$d prof || exit 1 ; \
  166. fi; \
  167. done
  168. ifeq ($(DYNAMIC_ARCH), 1)
  169. $(MAKE) -C kernel commonprof || exit 1
  170. endif
  171. blas :
  172. ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
  173. for d in $(BLASDIRS) ; \
  174. do if test -d $$d; then \
  175. $(MAKE) -C $$d libs || exit 1 ; \
  176. fi; \
  177. done
  178. hpl :
  179. ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
  180. for d in $(BLASDIRS) ../laswp exports ; \
  181. do if test -d $$d; then \
  182. $(MAKE) -C $$d $(@F) || exit 1 ; \
  183. fi; \
  184. done
  185. ifeq ($(DYNAMIC_ARCH), 1)
  186. $(MAKE) -C kernel commonlibs || exit 1
  187. for d in $(DYNAMIC_CORE) ; \
  188. do $(MAKE) GOTOBLAS_MAKEFILE= -C kernel TARGET_CORE=$$d kernel || exit 1 ;\
  189. done
  190. endif
  191. hpl_p :
  192. ln -fs $(LIBNAME_P) $(LIBPREFIX)_p.$(LIBSUFFIX)
  193. for d in $(SUBDIRS) ../laswp exports ; \
  194. do if test -d $$d; then \
  195. $(MAKE) -C $$d $(@F) || exit 1 ; \
  196. fi; \
  197. done
  198. ifeq ($(NO_LAPACK), 1)
  199. netlib :
  200. else
  201. netlib : lapack_prebuild
  202. ifeq ($(NOFORTRAN), $(filter 0,$(NOFORTRAN)))
  203. @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapacklib
  204. @$(MAKE) -C $(NETLIB_LAPACK_DIR) tmglib
  205. endif
  206. ifndef NO_LAPACKE
  207. @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapackelib
  208. endif
  209. endif
  210. ifeq ($(NO_LAPACK), 1)
  211. re_lapack :
  212. else
  213. re_lapack :
  214. @$(MAKE) -C relapack
  215. endif
  216. prof_lapack : lapack_prebuild
  217. @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapack_prof
  218. lapack_prebuild :
  219. ifeq ($(NOFORTRAN), $(filter 0,$(NOFORTRAN)))
  220. -@echo "FORTRAN = $(FC)" > $(NETLIB_LAPACK_DIR)/make.inc
  221. -@echo "OPTS = $(LAPACK_FFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
  222. -@echo "POPTS = $(LAPACK_FPFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
  223. -@echo "NOOPT = -O0 $(LAPACK_NOOPT)" >> $(NETLIB_LAPACK_DIR)/make.inc
  224. -@echo "PNOOPT = $(LAPACK_FPFLAGS) -O0" >> $(NETLIB_LAPACK_DIR)/make.inc
  225. -@echo "LOADOPTS = $(FFLAGS) $(EXTRALIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
  226. -@echo "CC = $(CC)" >> $(NETLIB_LAPACK_DIR)/make.inc
  227. -@echo "override CFLAGS = $(LAPACK_CFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
  228. -@echo "override ARCH = $(AR)" >> $(NETLIB_LAPACK_DIR)/make.inc
  229. -@echo "ARCHFLAGS = $(ARFLAGS) -ru" >> $(NETLIB_LAPACK_DIR)/make.inc
  230. -@echo "RANLIB = $(RANLIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
  231. -@echo "LAPACKLIB = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
  232. -@echo "TMGLIB = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
  233. -@echo "BLASLIB = ../../../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
  234. -@echo "LAPACKELIB = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
  235. -@echo "LAPACKLIB_P = ../$(LIBNAME_P)" >> $(NETLIB_LAPACK_DIR)/make.inc
  236. -@echo "SUFFIX = $(SUFFIX)" >> $(NETLIB_LAPACK_DIR)/make.inc
  237. -@echo "PSUFFIX = $(PSUFFIX)" >> $(NETLIB_LAPACK_DIR)/make.inc
  238. -@echo "CEXTRALIB = $(EXTRALIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
  239. ifeq ($(F_COMPILER), GFORTRAN)
  240. -@echo "TIMER = INT_ETIME" >> $(NETLIB_LAPACK_DIR)/make.inc
  241. ifdef SMP
  242. ifeq ($(OSNAME), WINNT)
  243. -@echo "LOADER = $(FC)" >> $(NETLIB_LAPACK_DIR)/make.inc
  244. else ifeq ($(OSNAME), Haiku)
  245. -@echo "LOADER = $(FC)" >> $(NETLIB_LAPACK_DIR)/make.inc
  246. else
  247. -@echo "LOADER = $(FC) -pthread" >> $(NETLIB_LAPACK_DIR)/make.inc
  248. endif
  249. else
  250. -@echo "LOADER = $(FC)" >> $(NETLIB_LAPACK_DIR)/make.inc
  251. endif
  252. else
  253. -@echo "TIMER = NONE" >> $(NETLIB_LAPACK_DIR)/make.inc
  254. -@echo "LOADER = $(FC)" >> $(NETLIB_LAPACK_DIR)/make.inc
  255. endif
  256. ifeq ($(BUILD_LAPACK_DEPRECATED), 1)
  257. -@echo "BUILD_DEPRECATED = 1" >> $(NETLIB_LAPACK_DIR)/make.inc
  258. endif
  259. -@echo "LAPACKE_WITH_TMG = 1" >> $(NETLIB_LAPACK_DIR)/make.inc
  260. -@cat make.inc >> $(NETLIB_LAPACK_DIR)/make.inc
  261. endif
  262. large.tgz :
  263. ifeq ($(NOFORTRAN), $(filter 0,$(NOFORTRAN)))
  264. if [ ! -a $< ]; then
  265. -wget http://www.netlib.org/lapack/timing/large.tgz;
  266. fi
  267. endif
  268. timing.tgz :
  269. ifeq ($(NOFORTRAN), $(filter 0,$(NOFORTRAN)))
  270. if [ ! -a $< ]; then
  271. -wget http://www.netlib.org/lapack/timing/timing.tgz;
  272. fi
  273. endif
  274. lapack-timing : large.tgz timing.tgz
  275. ifeq ($(NOFORTRAN), $(filter 0,$(NOFORTRAN)))
  276. (cd $(NETLIB_LAPACK_DIR); $(TAR) zxf ../timing.tgz TIMING)
  277. (cd $(NETLIB_LAPACK_DIR)/TIMING; $(TAR) zxf ../../large.tgz )
  278. $(MAKE) -C $(NETLIB_LAPACK_DIR)/TIMING
  279. endif
  280. lapack-test :
  281. (cd $(NETLIB_LAPACK_DIR)/TESTING && rm -f x* *.out)
  282. $(MAKE) -j 1 -C $(NETLIB_LAPACK_DIR)/TESTING/EIG xeigtstc xeigtstd xeigtsts xeigtstz
  283. $(MAKE) -j 1 -C $(NETLIB_LAPACK_DIR)/TESTING/LIN xlintstc xlintstd xlintstds xlintstrfd xlintstrfz xlintsts xlintstz xlintstzc xlintstrfs xlintstrfc
  284. ifneq ($(CROSS), 1)
  285. ( cd $(NETLIB_LAPACK_DIR)/INSTALL; make all; ./testlsame; ./testslamch; ./testdlamch; \
  286. ./testsecond; ./testdsecnd; ./testieee; ./testversion )
  287. (cd $(NETLIB_LAPACK_DIR); ./lapack_testing.py -r )
  288. endif
  289. lapack-runtest:
  290. ( cd $(NETLIB_LAPACK_DIR)/INSTALL; ./testlsame; ./testslamch; ./testdlamch; \
  291. ./testsecond; ./testdsecnd; ./testieee; ./testversion )
  292. (cd $(NETLIB_LAPACK_DIR); ./lapack_testing.py -r )
  293. blas-test:
  294. (cd $(NETLIB_LAPACK_DIR)/BLAS/TESTING && rm -f x* *.out)
  295. $(MAKE) -j 1 -C $(NETLIB_LAPACK_DIR) blas_testing
  296. (cd $(NETLIB_LAPACK_DIR)/BLAS/TESTING && cat *.out)
  297. dummy :
  298. install :
  299. $(MAKE) -f Makefile.install install
  300. clean ::
  301. @for d in $(SUBDIRS_ALL) ; \
  302. do if test -d $$d; then \
  303. $(MAKE) -C $$d $(@F) || exit 1 ; \
  304. fi; \
  305. done
  306. #ifdef DYNAMIC_ARCH
  307. @$(MAKE) -C kernel clean
  308. #endif
  309. @$(MAKE) -C reference clean
  310. @rm -f *.$(LIBSUFFIX) *.so *~ *.exe getarch getarch_2nd *.dll *.lib *.$(SUFFIX) *.dwf $(LIBPREFIX).$(LIBSUFFIX) $(LIBPREFIX)_p.$(LIBSUFFIX) $(LIBPREFIX).so.$(MAJOR_VERSION) *.lnk myconfig.h
  311. ifeq ($(OSNAME), Darwin)
  312. @rm -rf getarch.dSYM getarch_2nd.dSYM
  313. endif
  314. @rm -f Makefile.conf config.h Makefile_kernel.conf config_kernel.h st* *.dylib
  315. @touch $(NETLIB_LAPACK_DIR)/make.inc
  316. @$(MAKE) -C $(NETLIB_LAPACK_DIR) clean
  317. @rm -f $(NETLIB_LAPACK_DIR)/make.inc $(NETLIB_LAPACK_DIR)/lapacke/include/lapacke_mangling.h
  318. @$(MAKE) -C relapack clean
  319. @rm -f *.grd Makefile.conf_last config_last.h
  320. @(cd $(NETLIB_LAPACK_DIR)/TESTING && rm -f x* *.out testing_results.txt)
  321. @echo Done.