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
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), FreeBSD)
  80. @$(MAKE) -C exports so
  81. @ln -fs $(LIBSONAME) $(LIBPREFIX).so
  82. endif
  83. ifeq ($(OSNAME), NetBSD)
  84. @$(MAKE) -C exports so
  85. @ln -fs $(LIBSONAME) $(LIBPREFIX).so
  86. endif
  87. ifeq ($(OSNAME), Darwin)
  88. @$(MAKE) -C exports dyn
  89. @ln -fs $(LIBDYNNAME) $(LIBPREFIX).dylib
  90. endif
  91. ifeq ($(OSNAME), WINNT)
  92. @$(MAKE) -C exports dll
  93. endif
  94. ifeq ($(OSNAME), CYGWIN_NT)
  95. @$(MAKE) -C exports dll
  96. endif
  97. endif
  98. tests :
  99. ifndef NOFORTRAN
  100. touch $(LIBNAME)
  101. ifndef NO_FBLAS
  102. $(MAKE) -C test all
  103. $(MAKE) -C utest all
  104. endif
  105. ifndef NO_CBLAS
  106. $(MAKE) -C ctest all
  107. endif
  108. endif
  109. libs :
  110. ifeq ($(CORE), UNKOWN)
  111. $(error OpenBLAS: Detecting CPU failed. Please set TARGET explicitly, e.g. make TARGET=your_cpu_target. Please read README for the detail.)
  112. endif
  113. ifeq ($(NOFORTRAN), 1)
  114. $(info OpenBLAS: Detecting fortran compiler failed. Cannot compile LAPACK. Only compile BLAS.)
  115. endif
  116. ifeq ($(NO_STATIC), 1)
  117. ifeq ($(NO_SHARED), 1)
  118. $(error OpenBLAS: neither static nor shared are enabled.)
  119. endif
  120. endif
  121. @-ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
  122. @for d in $(SUBDIRS) ; \
  123. do if test -d $$d; then \
  124. $(MAKE) -C $$d $(@F) || exit 1 ; \
  125. fi; \
  126. done
  127. #Save the config files for installation
  128. @cp Makefile.conf Makefile.conf_last
  129. @cp config.h config_last.h
  130. ifdef QUAD_PRECISION
  131. @echo "#define QUAD_PRECISION">> config_last.h
  132. endif
  133. ifeq ($(EXPRECISION), 1)
  134. @echo "#define EXPRECISION">> config_last.h
  135. endif
  136. ##
  137. ifeq ($(DYNAMIC_ARCH), 1)
  138. @$(MAKE) -C kernel commonlibs || exit 1
  139. @for d in $(DYNAMIC_CORE) ; \
  140. do $(MAKE) GOTOBLAS_MAKEFILE= -C kernel TARGET_CORE=$$d kernel || exit 1 ;\
  141. done
  142. @echo DYNAMIC_ARCH=1 >> Makefile.conf_last
  143. endif
  144. ifdef USE_THREAD
  145. @echo USE_THREAD=$(USE_THREAD) >> Makefile.conf_last
  146. endif
  147. @touch lib.grd
  148. prof : prof_blas prof_lapack
  149. prof_blas :
  150. ln -fs $(LIBNAME_P) $(LIBPREFIX)_p.$(LIBSUFFIX)
  151. for d in $(SUBDIRS) ; \
  152. do if test -d $$d; then \
  153. $(MAKE) -C $$d prof || exit 1 ; \
  154. fi; \
  155. done
  156. ifeq ($(DYNAMIC_ARCH), 1)
  157. $(MAKE) -C kernel commonprof || exit 1
  158. endif
  159. blas :
  160. ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
  161. for d in $(BLASDIRS) ; \
  162. do if test -d $$d; then \
  163. $(MAKE) -C $$d libs || exit 1 ; \
  164. fi; \
  165. done
  166. hpl :
  167. ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
  168. for d in $(BLASDIRS) ../laswp exports ; \
  169. do if test -d $$d; then \
  170. $(MAKE) -C $$d $(@F) || exit 1 ; \
  171. fi; \
  172. done
  173. ifeq ($(DYNAMIC_ARCH), 1)
  174. $(MAKE) -C kernel commonlibs || exit 1
  175. for d in $(DYNAMIC_CORE) ; \
  176. do $(MAKE) GOTOBLAS_MAKEFILE= -C kernel TARGET_CORE=$$d kernel || exit 1 ;\
  177. done
  178. endif
  179. hpl_p :
  180. ln -fs $(LIBNAME_P) $(LIBPREFIX)_p.$(LIBSUFFIX)
  181. for d in $(SUBDIRS) ../laswp exports ; \
  182. do if test -d $$d; then \
  183. $(MAKE) -C $$d $(@F) || exit 1 ; \
  184. fi; \
  185. done
  186. ifeq ($(NO_LAPACK), 1)
  187. netlib :
  188. else
  189. netlib : lapack_prebuild
  190. ifndef NOFORTRAN
  191. @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapacklib
  192. @$(MAKE) -C $(NETLIB_LAPACK_DIR) tmglib
  193. endif
  194. ifndef NO_LAPACKE
  195. @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapackelib
  196. endif
  197. endif
  198. ifeq ($(NO_LAPACK), 1)
  199. re_lapack :
  200. else
  201. re_lapack :
  202. @$(MAKE) -C relapack
  203. endif
  204. prof_lapack : lapack_prebuild
  205. @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapack_prof
  206. lapack_prebuild :
  207. ifndef NOFORTRAN
  208. -@echo "FORTRAN = $(FC)" > $(NETLIB_LAPACK_DIR)/make.inc
  209. -@echo "OPTS = $(LAPACK_FFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
  210. -@echo "POPTS = $(LAPACK_FPFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
  211. -@echo "NOOPT = -O0 $(LAPACK_NOOPT)" >> $(NETLIB_LAPACK_DIR)/make.inc
  212. -@echo "PNOOPT = $(LAPACK_FPFLAGS) -O0" >> $(NETLIB_LAPACK_DIR)/make.inc
  213. -@echo "LOADOPTS = $(FFLAGS) $(EXTRALIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
  214. -@echo "CC = $(CC)" >> $(NETLIB_LAPACK_DIR)/make.inc
  215. -@echo "override CFLAGS = $(LAPACK_CFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
  216. -@echo "ARCH = $(AR)" >> $(NETLIB_LAPACK_DIR)/make.inc
  217. -@echo "ARCHFLAGS = $(ARFLAGS) -ru" >> $(NETLIB_LAPACK_DIR)/make.inc
  218. -@echo "RANLIB = $(RANLIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
  219. -@echo "LAPACKLIB = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
  220. -@echo "TMGLIB = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
  221. -@echo "BLASLIB = ../../../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
  222. -@echo "LAPACKELIB = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
  223. -@echo "LAPACKLIB_P = ../$(LIBNAME_P)" >> $(NETLIB_LAPACK_DIR)/make.inc
  224. -@echo "SUFFIX = $(SUFFIX)" >> $(NETLIB_LAPACK_DIR)/make.inc
  225. -@echo "PSUFFIX = $(PSUFFIX)" >> $(NETLIB_LAPACK_DIR)/make.inc
  226. -@echo "CEXTRALIB = $(EXTRALIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
  227. ifeq ($(F_COMPILER), GFORTRAN)
  228. -@echo "TIMER = INT_ETIME" >> $(NETLIB_LAPACK_DIR)/make.inc
  229. ifdef SMP
  230. ifeq ($(OSNAME), WINNT)
  231. -@echo "LOADER = $(FC)" >> $(NETLIB_LAPACK_DIR)/make.inc
  232. else
  233. -@echo "LOADER = $(FC) -pthread" >> $(NETLIB_LAPACK_DIR)/make.inc
  234. endif
  235. else
  236. -@echo "LOADER = $(FC)" >> $(NETLIB_LAPACK_DIR)/make.inc
  237. endif
  238. else
  239. -@echo "TIMER = NONE" >> $(NETLIB_LAPACK_DIR)/make.inc
  240. -@echo "LOADER = $(FC)" >> $(NETLIB_LAPACK_DIR)/make.inc
  241. endif
  242. ifeq ($(BUILD_LAPACK_DEPRECATED), 1)
  243. -@echo "BUILD_DEPRECATED = 1" >> $(NETLIB_LAPACK_DIR)/make.inc
  244. endif
  245. -@echo "LAPACKE_WITH_TMG = 1" >> $(NETLIB_LAPACK_DIR)/make.inc
  246. -@cat make.inc >> $(NETLIB_LAPACK_DIR)/make.inc
  247. endif
  248. large.tgz :
  249. ifndef NOFORTRAN
  250. if [ ! -a $< ]; then
  251. -wget http://www.netlib.org/lapack/timing/large.tgz;
  252. fi
  253. endif
  254. timing.tgz :
  255. ifndef NOFORTRAN
  256. if [ ! -a $< ]; then
  257. -wget http://www.netlib.org/lapack/timing/timing.tgz;
  258. fi
  259. endif
  260. lapack-timing : large.tgz timing.tgz
  261. ifndef NOFORTRAN
  262. (cd $(NETLIB_LAPACK_DIR); $(TAR) zxf ../timing.tgz TIMING)
  263. (cd $(NETLIB_LAPACK_DIR)/TIMING; $(TAR) zxf ../../large.tgz )
  264. $(MAKE) -C $(NETLIB_LAPACK_DIR)/TIMING
  265. endif
  266. lapack-test :
  267. (cd $(NETLIB_LAPACK_DIR)/TESTING && rm -f x* *.out)
  268. $(MAKE) -j 1 -C $(NETLIB_LAPACK_DIR)/TESTING xeigtstc xeigtstd xeigtsts xeigtstz xlintstc xlintstd xlintstds xlintstrfd xlintstrfz xlintsts xlintstz xlintstzc xlintstrfs xlintstrfc
  269. ifneq ($(CROSS), 1)
  270. ( cd $(NETLIB_LAPACK_DIR)/INSTALL; ./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 && rm -f x* *.out)
  280. $(MAKE) -j 1 -C $(NETLIB_LAPACK_DIR) blas_testing
  281. (cd $(NETLIB_LAPACK_DIR)/BLAS && 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.