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

12 years ago
13 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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. LAPACK_NOOPT := $(filter-out -O0 -O1 -O2 -O3 -Ofast,$(LAPACK_FFLAGS))
  15. SUBDIRS_ALL = $(SUBDIRS) test ctest utest exports benchmark ../laswp ../bench
  16. .PHONY : all libs netlib test ctest shared install
  17. .NOTPARALLEL : all libs prof lapack-test install blas-test
  18. all :: libs netlib tests shared
  19. @echo
  20. @echo " OpenBLAS build complete. ($(LIB_COMPONENTS))"
  21. @echo
  22. @echo " OS ... $(OSNAME) "
  23. @echo " Architecture ... $(ARCH) "
  24. ifndef BINARY64
  25. @echo " BINARY ... 32bit "
  26. else
  27. @echo " BINARY ... 64bit "
  28. endif
  29. ifdef INTERFACE64
  30. ifneq ($(INTERFACE64), 0)
  31. @echo " Use 64 bits int (equivalent to \"-i8\" in Fortran) "
  32. endif
  33. endif
  34. @echo " C compiler ... $(C_COMPILER) (command line : $(CC))"
  35. ifndef NOFORTRAN
  36. @echo " Fortran compiler ... $(F_COMPILER) (command line : $(FC))"
  37. endif
  38. ifneq ($(OSNAME), AIX)
  39. @echo -n " Library Name ... $(LIBNAME)"
  40. else
  41. @echo " Library Name ... $(LIBNAME)"
  42. endif
  43. ifndef SMP
  44. @echo " (Single threaded) "
  45. else
  46. @echo " (Multi threaded; Max num-threads is $(NUM_THREADS))"
  47. endif
  48. ifeq ($(USE_OPENMP), 1)
  49. @echo
  50. @echo " Use OpenMP in the multithreading. Because of ignoring OPENBLAS_NUM_THREADS and GOTO_NUM_THREADS flags, "
  51. @echo " you should use OMP_NUM_THREADS environment variable to control the number of threads."
  52. @echo
  53. endif
  54. ifeq ($(OSNAME), Darwin)
  55. @echo "WARNING: If you plan to use the dynamic library $(LIBDYNNAME), you must run:"
  56. @echo
  57. @echo "\"make PREFIX=/your_installation_path/ install\"."
  58. @echo
  59. @echo "(or set PREFIX in Makefile.rule and run make install."
  60. @echo "If you want to move the .dylib to a new location later, make sure you change"
  61. @echo "the internal name of the dylib with:"
  62. @echo
  63. @echo "install_name_tool -id /new/absolute/path/to/$(LIBDYNNAME) $(LIBDYNNAME)"
  64. endif
  65. @echo
  66. @echo "To install the library, you can run \"make PREFIX=/path/to/your/installation install\"."
  67. @echo
  68. shared :
  69. ifndef NO_SHARED
  70. ifeq ($(OSNAME), $(filter $(OSNAME),Linux SunOS))
  71. @$(MAKE) -C exports so
  72. @ln -fs $(LIBSONAME) $(LIBPREFIX).so
  73. @ln -fs $(LIBSONAME) $(LIBPREFIX).so.$(MAJOR_VERSION)
  74. endif
  75. ifeq ($(OSNAME), FreeBSD)
  76. @$(MAKE) -C exports so
  77. @ln -fs $(LIBSONAME) $(LIBPREFIX).so
  78. endif
  79. ifeq ($(OSNAME), NetBSD)
  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. ifndef TARGET
  97. ifndef CROSS
  98. touch $(LIBNAME)
  99. ifndef NO_FBLAS
  100. $(MAKE) -C test all
  101. $(MAKE) -C utest all
  102. endif
  103. ifndef NO_CBLAS
  104. $(MAKE) -C ctest all
  105. endif
  106. endif
  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. prof_lapack : lapack_prebuild
  199. @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapack_prof
  200. lapack_prebuild :
  201. ifndef NOFORTRAN
  202. -@echo "FORTRAN = $(FC)" > $(NETLIB_LAPACK_DIR)/make.inc
  203. -@echo "OPTS = $(LAPACK_FFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
  204. -@echo "POPTS = $(LAPACK_FPFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
  205. -@echo "NOOPT = -O0 $(LAPACK_NOOPT)" >> $(NETLIB_LAPACK_DIR)/make.inc
  206. -@echo "PNOOPT = $(LAPACK_FPFLAGS) -O0" >> $(NETLIB_LAPACK_DIR)/make.inc
  207. -@echo "LOADOPTS = $(FFLAGS) $(EXTRALIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
  208. -@echo "CC = $(CC)" >> $(NETLIB_LAPACK_DIR)/make.inc
  209. -@echo "override CFLAGS = $(LAPACK_CFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
  210. -@echo "ARCH = $(AR)" >> $(NETLIB_LAPACK_DIR)/make.inc
  211. -@echo "ARCHFLAGS = -ru" >> $(NETLIB_LAPACK_DIR)/make.inc
  212. -@echo "RANLIB = $(RANLIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
  213. -@echo "LAPACKLIB = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
  214. -@echo "TMGLIB = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
  215. -@echo "BLASLIB = ../../../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
  216. -@echo "LAPACKELIB = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
  217. -@echo "LAPACKLIB_P = ../$(LIBNAME_P)" >> $(NETLIB_LAPACK_DIR)/make.inc
  218. -@echo "SUFFIX = $(SUFFIX)" >> $(NETLIB_LAPACK_DIR)/make.inc
  219. -@echo "PSUFFIX = $(PSUFFIX)" >> $(NETLIB_LAPACK_DIR)/make.inc
  220. -@echo "CEXTRALIB = $(EXTRALIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
  221. ifeq ($(F_COMPILER), GFORTRAN)
  222. -@echo "TIMER = INT_ETIME" >> $(NETLIB_LAPACK_DIR)/make.inc
  223. ifdef SMP
  224. ifeq ($(OSNAME), WINNT)
  225. -@echo "LOADER = $(FC)" >> $(NETLIB_LAPACK_DIR)/make.inc
  226. else
  227. -@echo "LOADER = $(FC) -pthread" >> $(NETLIB_LAPACK_DIR)/make.inc
  228. endif
  229. else
  230. -@echo "LOADER = $(FC)" >> $(NETLIB_LAPACK_DIR)/make.inc
  231. endif
  232. else
  233. -@echo "TIMER = NONE" >> $(NETLIB_LAPACK_DIR)/make.inc
  234. -@echo "LOADER = $(FC)" >> $(NETLIB_LAPACK_DIR)/make.inc
  235. endif
  236. ifeq ($(BUILD_LAPACK_DEPRECATED), 1)
  237. -@echo "BUILD_DEPRECATED = 1" >> $(NETLIB_LAPACK_DIR)/make.inc
  238. endif
  239. -@cat make.inc >> $(NETLIB_LAPACK_DIR)/make.inc
  240. endif
  241. large.tgz :
  242. ifndef NOFORTRAN
  243. if [ ! -a $< ]; then
  244. -wget http://www.netlib.org/lapack/timing/large.tgz;
  245. fi
  246. endif
  247. timing.tgz :
  248. ifndef NOFORTRAN
  249. if [ ! -a $< ]; then
  250. -wget http://www.netlib.org/lapack/timing/timing.tgz;
  251. fi
  252. endif
  253. lapack-timing : large.tgz timing.tgz
  254. ifndef NOFORTRAN
  255. (cd $(NETLIB_LAPACK_DIR); $(TAR) zxf ../timing.tgz TIMING)
  256. (cd $(NETLIB_LAPACK_DIR)/TIMING; $(TAR) zxf ../../large.tgz )
  257. make -C $(NETLIB_LAPACK_DIR)/TIMING
  258. endif
  259. lapack-test :
  260. (cd $(NETLIB_LAPACK_DIR)/TESTING && rm -f x* *.out)
  261. make -j 1 -C $(NETLIB_LAPACK_DIR)/TESTING xeigtstc xeigtstd xeigtsts xeigtstz xlintstc xlintstd xlintstds xlintstrfd xlintstrfz xlintsts xlintstz xlintstzc xlintstrfs xlintstrfc
  262. ifneq ($(CROSS), 1)
  263. ( cd $(NETLIB_LAPACK_DIR)/INSTALL; ./testlsame; ./testslamch; ./testdlamch; \
  264. ./testsecond; ./testdsecnd; ./testieee; ./testversion )
  265. (cd $(NETLIB_LAPACK_DIR); ./lapack_testing.py -r )
  266. endif
  267. lapack-runtest:
  268. ( cd $(NETLIB_LAPACK_DIR)/INSTALL; ./testlsame; ./testslamch; ./testdlamch; \
  269. ./testsecond; ./testdsecnd; ./testieee; ./testversion )
  270. (cd $(NETLIB_LAPACK_DIR); ./lapack_testing.py -r )
  271. blas-test:
  272. (cd $(NETLIB_LAPACK_DIR)/BLAS && rm -f x* *.out)
  273. make -j 1 -C $(NETLIB_LAPACK_DIR) blas_testing
  274. (cd $(NETLIB_LAPACK_DIR)/BLAS && cat *.out)
  275. dummy :
  276. install :
  277. $(MAKE) -f Makefile.install install
  278. clean ::
  279. @for d in $(SUBDIRS_ALL) ; \
  280. do if test -d $$d; then \
  281. $(MAKE) -C $$d $(@F) || exit 1 ; \
  282. fi; \
  283. done
  284. #ifdef DYNAMIC_ARCH
  285. @$(MAKE) -C kernel clean
  286. #endif
  287. @$(MAKE) -C reference clean
  288. @rm -f *.$(LIBSUFFIX) *.so *~ *.exe getarch getarch_2nd *.dll *.lib *.$(SUFFIX) *.dwf $(LIBPREFIX).$(LIBSUFFIX) $(LIBPREFIX)_p.$(LIBSUFFIX) $(LIBPREFIX).so.$(MAJOR_VERSION) *.lnk myconfig.h
  289. ifeq ($(OSNAME), Darwin)
  290. @rm -rf getarch.dSYM getarch_2nd.dSYM
  291. endif
  292. @rm -f Makefile.conf config.h Makefile_kernel.conf config_kernel.h st* *.dylib
  293. @touch $(NETLIB_LAPACK_DIR)/make.inc
  294. @$(MAKE) -C $(NETLIB_LAPACK_DIR) clean
  295. @rm -f $(NETLIB_LAPACK_DIR)/make.inc $(NETLIB_LAPACK_DIR)/lapacke/include/lapacke_mangling.h
  296. @rm -f *.grd Makefile.conf_last config_last.h
  297. @(cd $(NETLIB_LAPACK_DIR)/TESTING && rm -f x* *.out testing_results.txt)
  298. @echo Done.