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

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