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 10 kB

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