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
12 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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. endif
  140. ifdef USE_THREAD
  141. @echo USE_THREAD=$(USE_THREAD) >> Makefile.conf_last
  142. endif
  143. @touch lib.grd
  144. prof : prof_blas prof_lapack
  145. prof_blas :
  146. ln -fs $(LIBNAME_P) $(LIBPREFIX)_p.$(LIBSUFFIX)
  147. for d in $(SUBDIRS) ; \
  148. do if test -d $$d; then \
  149. $(MAKE) -C $$d prof || exit 1 ; \
  150. fi; \
  151. done
  152. ifeq ($(DYNAMIC_ARCH), 1)
  153. $(MAKE) -C kernel commonprof || exit 1
  154. endif
  155. blas :
  156. ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
  157. for d in $(BLASDIRS) ; \
  158. do if test -d $$d; then \
  159. $(MAKE) -C $$d libs || exit 1 ; \
  160. fi; \
  161. done
  162. hpl :
  163. ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
  164. for d in $(BLASDIRS) ../laswp exports ; \
  165. do if test -d $$d; then \
  166. $(MAKE) -C $$d $(@F) || exit 1 ; \
  167. fi; \
  168. done
  169. ifeq ($(DYNAMIC_ARCH), 1)
  170. $(MAKE) -C kernel commonlibs || exit 1
  171. for d in $(DYNAMIC_CORE) ; \
  172. do $(MAKE) GOTOBLAS_MAKEFILE= -C kernel TARGET_CORE=$$d kernel || exit 1 ;\
  173. done
  174. endif
  175. hpl_p :
  176. ln -fs $(LIBNAME_P) $(LIBPREFIX)_p.$(LIBSUFFIX)
  177. for d in $(SUBDIRS) ../laswp exports ; \
  178. do if test -d $$d; then \
  179. $(MAKE) -C $$d $(@F) || exit 1 ; \
  180. fi; \
  181. done
  182. ifeq ($(NO_LAPACK), 1)
  183. netlib :
  184. else
  185. netlib : lapack_prebuild
  186. ifndef NOFORTRAN
  187. @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapacklib
  188. @$(MAKE) -C $(NETLIB_LAPACK_DIR) tmglib
  189. endif
  190. ifndef NO_LAPACKE
  191. @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapackelib
  192. endif
  193. endif
  194. ifeq ($(NO_LAPACK), 1)
  195. re_lapack :
  196. else
  197. re_lapack :
  198. @$(MAKE) -C relapack
  199. endif
  200. prof_lapack : lapack_prebuild
  201. @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapack_prof
  202. lapack_prebuild :
  203. ifndef NOFORTRAN
  204. -@echo "FORTRAN = $(FC)" > $(NETLIB_LAPACK_DIR)/make.inc
  205. -@echo "OPTS = $(LAPACK_FFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
  206. -@echo "POPTS = $(LAPACK_FPFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
  207. -@echo "NOOPT = -O0 $(LAPACK_NOOPT)" >> $(NETLIB_LAPACK_DIR)/make.inc
  208. -@echo "PNOOPT = $(LAPACK_FPFLAGS) -O0" >> $(NETLIB_LAPACK_DIR)/make.inc
  209. -@echo "LOADOPTS = $(FFLAGS) $(EXTRALIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
  210. -@echo "CC = $(CC)" >> $(NETLIB_LAPACK_DIR)/make.inc
  211. -@echo "override CFLAGS = $(LAPACK_CFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
  212. -@echo "ARCH = $(AR)" >> $(NETLIB_LAPACK_DIR)/make.inc
  213. -@echo "ARCHFLAGS = $(ARFLAGS) -ru" >> $(NETLIB_LAPACK_DIR)/make.inc
  214. -@echo "RANLIB = $(RANLIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
  215. -@echo "LAPACKLIB = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
  216. -@echo "TMGLIB = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
  217. -@echo "BLASLIB = ../../../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
  218. -@echo "LAPACKELIB = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
  219. -@echo "LAPACKLIB_P = ../$(LIBNAME_P)" >> $(NETLIB_LAPACK_DIR)/make.inc
  220. -@echo "SUFFIX = $(SUFFIX)" >> $(NETLIB_LAPACK_DIR)/make.inc
  221. -@echo "PSUFFIX = $(PSUFFIX)" >> $(NETLIB_LAPACK_DIR)/make.inc
  222. -@echo "CEXTRALIB = $(EXTRALIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
  223. ifeq ($(F_COMPILER), GFORTRAN)
  224. -@echo "TIMER = INT_ETIME" >> $(NETLIB_LAPACK_DIR)/make.inc
  225. ifdef SMP
  226. ifeq ($(OSNAME), WINNT)
  227. -@echo "LOADER = $(FC)" >> $(NETLIB_LAPACK_DIR)/make.inc
  228. else
  229. -@echo "LOADER = $(FC) -pthread" >> $(NETLIB_LAPACK_DIR)/make.inc
  230. endif
  231. else
  232. -@echo "LOADER = $(FC)" >> $(NETLIB_LAPACK_DIR)/make.inc
  233. endif
  234. else
  235. -@echo "TIMER = NONE" >> $(NETLIB_LAPACK_DIR)/make.inc
  236. -@echo "LOADER = $(FC)" >> $(NETLIB_LAPACK_DIR)/make.inc
  237. endif
  238. ifeq ($(BUILD_LAPACK_DEPRECATED), 1)
  239. -@echo "BUILD_DEPRECATED = 1" >> $(NETLIB_LAPACK_DIR)/make.inc
  240. endif
  241. -@echo "LAPACKE_WITH_TMG = 1" >> $(NETLIB_LAPACK_DIR)/make.inc
  242. -@cat make.inc >> $(NETLIB_LAPACK_DIR)/make.inc
  243. endif
  244. large.tgz :
  245. ifndef NOFORTRAN
  246. if [ ! -a $< ]; then
  247. -wget http://www.netlib.org/lapack/timing/large.tgz;
  248. fi
  249. endif
  250. timing.tgz :
  251. ifndef NOFORTRAN
  252. if [ ! -a $< ]; then
  253. -wget http://www.netlib.org/lapack/timing/timing.tgz;
  254. fi
  255. endif
  256. lapack-timing : large.tgz timing.tgz
  257. ifndef NOFORTRAN
  258. (cd $(NETLIB_LAPACK_DIR); $(TAR) zxf ../timing.tgz TIMING)
  259. (cd $(NETLIB_LAPACK_DIR)/TIMING; $(TAR) zxf ../../large.tgz )
  260. $(MAKE) -C $(NETLIB_LAPACK_DIR)/TIMING
  261. endif
  262. lapack-test :
  263. (cd $(NETLIB_LAPACK_DIR)/TESTING && rm -f x* *.out)
  264. $(MAKE) -j 1 -C $(NETLIB_LAPACK_DIR)/TESTING xeigtstc xeigtstd xeigtsts xeigtstz xlintstc xlintstd xlintstds xlintstrfd xlintstrfz xlintsts xlintstz xlintstzc xlintstrfs xlintstrfc
  265. ifneq ($(CROSS), 1)
  266. ( cd $(NETLIB_LAPACK_DIR)/INSTALL; ./testlsame; ./testslamch; ./testdlamch; \
  267. ./testsecond; ./testdsecnd; ./testieee; ./testversion )
  268. (cd $(NETLIB_LAPACK_DIR); ./lapack_testing.py -r )
  269. endif
  270. lapack-runtest:
  271. ( cd $(NETLIB_LAPACK_DIR)/INSTALL; ./testlsame; ./testslamch; ./testdlamch; \
  272. ./testsecond; ./testdsecnd; ./testieee; ./testversion )
  273. (cd $(NETLIB_LAPACK_DIR); ./lapack_testing.py -r )
  274. blas-test:
  275. (cd $(NETLIB_LAPACK_DIR)/BLAS && rm -f x* *.out)
  276. $(MAKE) -j 1 -C $(NETLIB_LAPACK_DIR) blas_testing
  277. (cd $(NETLIB_LAPACK_DIR)/BLAS && cat *.out)
  278. dummy :
  279. install :
  280. $(MAKE) -f Makefile.install install
  281. clean ::
  282. @for d in $(SUBDIRS_ALL) ; \
  283. do if test -d $$d; then \
  284. $(MAKE) -C $$d $(@F) || exit 1 ; \
  285. fi; \
  286. done
  287. #ifdef DYNAMIC_ARCH
  288. @$(MAKE) -C kernel clean
  289. #endif
  290. @$(MAKE) -C reference clean
  291. @rm -f *.$(LIBSUFFIX) *.so *~ *.exe getarch getarch_2nd *.dll *.lib *.$(SUFFIX) *.dwf $(LIBPREFIX).$(LIBSUFFIX) $(LIBPREFIX)_p.$(LIBSUFFIX) $(LIBPREFIX).so.$(MAJOR_VERSION) *.lnk myconfig.h
  292. ifeq ($(OSNAME), Darwin)
  293. @rm -rf getarch.dSYM getarch_2nd.dSYM
  294. endif
  295. @rm -f Makefile.conf config.h Makefile_kernel.conf config_kernel.h st* *.dylib
  296. @touch $(NETLIB_LAPACK_DIR)/make.inc
  297. @$(MAKE) -C $(NETLIB_LAPACK_DIR) clean
  298. @rm -f $(NETLIB_LAPACK_DIR)/make.inc $(NETLIB_LAPACK_DIR)/lapacke/include/lapacke_mangling.h
  299. @$(MAKE) -C relapack clean
  300. @rm -f *.grd Makefile.conf_last config_last.h
  301. @(cd $(NETLIB_LAPACK_DIR)/TESTING && rm -f x* *.out testing_results.txt)
  302. @echo Done.