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.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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 UTEST_CHECK
  8. SANITY_CHECK = 1
  9. endif
  10. ifdef SANITY_CHECK
  11. BLASDIRS += reference
  12. endif
  13. ifndef PREFIX
  14. PREFIX = /opt/OpenBLAS
  15. endif
  16. SUBDIRS = $(BLASDIRS)
  17. ifneq ($(NO_LAPACK), 1)
  18. SUBDIRS += lapack
  19. endif
  20. SUBDIRS_ALL = $(SUBDIRS) test ctest utest exports benchmark ../laswp ../bench
  21. .PHONY : all libs netlib test ctest shared install
  22. .NOTPARALLEL : all libs prof lapack-test install
  23. all :: libs netlib tests shared
  24. @echo
  25. @echo " OpenBLAS build complete."
  26. @echo
  27. @echo " OS ... $(OSNAME) "
  28. @echo " Architecture ... $(ARCH) "
  29. ifndef BINARY64
  30. @echo " BINARY ... 32bit "
  31. else
  32. @echo " BINARY ... 64bit "
  33. endif
  34. ifdef INTERFACE64
  35. @echo " Use 64 bits int (equivalent to \"-i8\" in Fortran) "
  36. endif
  37. @echo " C compiler ... $(C_COMPILER) (command line : $(CC))"
  38. @echo " Fortran compiler ... $(F_COMPILER) (command line : $(FC))"
  39. ifneq ($(OSNAME), AIX)
  40. @echo -n " Library Name ... $(LIBNAME)"
  41. else
  42. @echo " Library Name ... $(LIBNAME)"
  43. endif
  44. ifndef SMP
  45. @echo " (Single threaded) "
  46. else
  47. @echo " (Multi threaded; Max num-threads is $(NUM_THREADS))"
  48. endif
  49. ifeq ($(USE_OPENMP), 1)
  50. @echo
  51. @echo " Use OpenMP in the multithreading. Becasue of ignoring OPENBLAS_NUM_THREADS and GOTO_NUM_THREADS flags, "
  52. @echo " you should use OMP_NUM_THREADS environment variable to control the number of threads."
  53. @echo
  54. endif
  55. ifeq ($(OSNAME), Darwin)
  56. @echo "WARNING: If you plan to use the dynamic library $(LIBDYNNAME), you must run:"
  57. @echo
  58. @echo "\"make PREFIX=/your_installation_path/ install\"."
  59. @echo
  60. @echo "(or set PREFIX in Makefile.rule and run make install."
  61. @echo "If you want to move the .dylib to a new location later, make sure you change"
  62. @echo "the internal name of the dylib with:"
  63. @echo
  64. @echo "install_name_tool -id /new/absolute/path/to/$(LIBDYNNAME) $(LIBDYNNAME)"
  65. endif
  66. @echo
  67. @echo "To install the library, you can run \"make PREFIX=/path/to/your/installation install\"."
  68. @echo
  69. shared :
  70. ifndef NO_SHARED
  71. ifeq ($(OSNAME), Linux)
  72. $(MAKE) -C exports so
  73. -ln -fs $(LIBSONAME) $(LIBPREFIX).so
  74. -ln -fs $(LIBSONAME) $(LIBPREFIX).so.$(MAJOR_VERSION)
  75. endif
  76. ifeq ($(OSNAME), FreeBSD)
  77. $(MAKE) -C exports so
  78. -ln -fs $(LIBSONAME) $(LIBPREFIX).so
  79. endif
  80. ifeq ($(OSNAME), NetBSD)
  81. $(MAKE) -C exports so
  82. -ln -fs $(LIBSONAME) $(LIBPREFIX).so
  83. endif
  84. ifeq ($(OSNAME), Darwin)
  85. $(MAKE) -C exports dyn
  86. -ln -fs $(LIBDYNNAME) $(LIBPREFIX).dylib
  87. endif
  88. ifeq ($(OSNAME), WINNT)
  89. $(MAKE) -C exports dll
  90. endif
  91. ifeq ($(OSNAME), CYGWIN_NT)
  92. $(MAKE) -C exports dll
  93. endif
  94. endif
  95. tests :
  96. ifndef NOFORTRAN
  97. ifndef TARGET
  98. ifndef CROSS
  99. touch $(LIBNAME)
  100. ifndef NO_FBLAS
  101. $(MAKE) -C test all
  102. ifdef UTEST_CHECK
  103. $(MAKE) -C utest all
  104. endif
  105. endif
  106. ifndef NO_CBLAS
  107. $(MAKE) -C ctest all
  108. endif
  109. endif
  110. endif
  111. endif
  112. libs :
  113. ifeq ($(CORE), UNKOWN)
  114. $(error OpenBLAS: Detecting CPU failed. Please set TARGET explicitly, e.g. make TARGET=your_cpu_target. Please read README for the detail.)
  115. endif
  116. ifeq ($(NOFORTRAN), 1)
  117. $(error OpenBLAS: Detecting fortran compiler failed. Please install fortran compiler, e.g. gfortran, ifort, openf90.)
  118. endif
  119. -ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
  120. for d in $(SUBDIRS) ; \
  121. do if test -d $$d; then \
  122. $(MAKE) -C $$d $(@F) || exit 1 ; \
  123. fi; \
  124. done
  125. #Save the config files for installation
  126. cp Makefile.conf Makefile.conf_last
  127. cp config.h config_last.h
  128. ifdef QUAD_PRECISION
  129. echo "#define QUAD_PRECISION">> config_last.h
  130. endif
  131. ifeq ($(EXPRECISION), 1)
  132. echo "#define EXPRECISION">> config_last.h
  133. endif
  134. ##
  135. ifeq ($(DYNAMIC_ARCH), 1)
  136. $(MAKE) -C kernel commonlibs || exit 1
  137. for d in $(DYNAMIC_CORE) ; \
  138. do $(MAKE) GOTOBLAS_MAKEFILE= -C kernel TARGET_CORE=$$d kernel || exit 1 ;\
  139. done
  140. echo DYNAMIC_ARCH=1 >> Makefile.conf_last
  141. endif
  142. touch lib.grd
  143. prof : prof_blas prof_lapack
  144. prof_blas :
  145. ln -fs $(LIBNAME_P) $(LIBPREFIX)_p.$(LIBSUFFIX)
  146. for d in $(SUBDIRS) ; \
  147. do if test -d $$d; then \
  148. $(MAKE) -C $$d prof || exit 1 ; \
  149. fi; \
  150. done
  151. ifeq ($(DYNAMIC_ARCH), 1)
  152. $(MAKE) -C kernel commonprof || exit 1
  153. endif
  154. blas :
  155. ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
  156. for d in $(BLASDIRS) ; \
  157. do if test -d $$d; then \
  158. $(MAKE) -C $$d libs || exit 1 ; \
  159. fi; \
  160. done
  161. hpl :
  162. ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
  163. for d in $(BLASDIRS) ../laswp exports ; \
  164. do if test -d $$d; then \
  165. $(MAKE) -C $$d $(@F) || exit 1 ; \
  166. fi; \
  167. done
  168. ifeq ($(DYNAMIC_ARCH), 1)
  169. $(MAKE) -C kernel commonlibs || exit 1
  170. for d in $(DYNAMIC_CORE) ; \
  171. do $(MAKE) GOTOBLAS_MAKEFILE= -C kernel TARGET_CORE=$$d kernel || exit 1 ;\
  172. done
  173. endif
  174. hpl_p :
  175. ln -fs $(LIBNAME_P) $(LIBPREFIX)_p.$(LIBSUFFIX)
  176. for d in $(SUBDIRS) ../laswp exports ; \
  177. do if test -d $$d; then \
  178. $(MAKE) -C $$d $(@F) || exit 1 ; \
  179. fi; \
  180. done
  181. ifeq ($(NO_LAPACK), 1)
  182. netlib :
  183. else
  184. netlib : lapack-3.4.2 patch.for_lapack-3.4.2 $(NETLIB_LAPACK_DIR)/make.inc
  185. ifndef NOFORTRAN
  186. -@$(MAKE) -C $(NETLIB_LAPACK_DIR) lapacklib
  187. endif
  188. ifndef NO_LAPACKE
  189. -@$(MAKE) -C $(NETLIB_LAPACK_DIR) lapackelib
  190. endif
  191. endif
  192. prof_lapack : lapack-3.4.2 $(NETLIB_LAPACK_DIR)/make.inc
  193. -@$(MAKE) -C $(NETLIB_LAPACK_DIR) lapack_prof
  194. $(NETLIB_LAPACK_DIR)/make.inc :
  195. ifndef NOFORTRAN
  196. -@echo "FORTRAN = $(FC)" > $(NETLIB_LAPACK_DIR)/make.inc
  197. -@echo "OPTS = $(FFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
  198. -@echo "POPTS = $(FPFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
  199. -@echo "NOOPT = $(FFLAGS) -O0" >> $(NETLIB_LAPACK_DIR)/make.inc
  200. -@echo "PNOOPT = $(FPFLAGS) -O0" >> $(NETLIB_LAPACK_DIR)/make.inc
  201. -@echo "LOADOPTS = $(FFLAGS) $(EXTRALIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
  202. -@echo "CC = $(CC)" >> $(NETLIB_LAPACK_DIR)/make.inc
  203. ifdef INTERFACE64
  204. -@echo "CFLAGS = $(CFLAGS) -DHAVE_LAPACK_CONFIG_H -DLAPACK_ILP64" >> $(NETLIB_LAPACK_DIR)/make.inc
  205. else
  206. -@echo "CFLAGS = $(CFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
  207. endif
  208. -@echo "ARCH = $(AR)" >> $(NETLIB_LAPACK_DIR)/make.inc
  209. -@echo "ARCHFLAGS = -ru" >> $(NETLIB_LAPACK_DIR)/make.inc
  210. -@echo "RANLIB = $(RANLIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
  211. -@echo "LAPACKLIB = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
  212. -@echo "LAPACKELIB = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
  213. -@echo "LAPACKLIB_P = ../$(LIBNAME_P)" >> $(NETLIB_LAPACK_DIR)/make.inc
  214. -@echo "SUFFIX = $(SUFFIX)" >> $(NETLIB_LAPACK_DIR)/make.inc
  215. -@echo "PSUFFIX = $(PSUFFIX)" >> $(NETLIB_LAPACK_DIR)/make.inc
  216. -@echo "CEXTRALIB = $(EXTRALIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
  217. -@cat make.inc >> $(NETLIB_LAPACK_DIR)/make.inc
  218. endif
  219. lapack-3.4.2 : lapack-3.4.2.tgz
  220. ifndef NOFORTRAN
  221. ifndef NO_LAPACK
  222. @if test `$(MD5SUM) lapack-3.4.2.tgz | $(AWK) '{print $$1}'` = 61bf1a8a4469d4bdb7604f5897179478; then \
  223. echo $(TAR) zxf $< ;\
  224. $(TAR) zxf $< && (cd $(NETLIB_LAPACK_DIR); $(PATCH) -p1 < ../patch.for_lapack-3.4.2) ;\
  225. rm -f $(NETLIB_LAPACK_DIR)/lapacke/make.inc ;\
  226. else \
  227. rm -rf $(NETLIB_LAPACK_DIR) ;\
  228. echo " Cannot download lapack-3.4.2.tgz or the MD5 check sum is wrong (Please use orignal)."; \
  229. exit 1; \
  230. fi
  231. endif
  232. endif
  233. LAPACK_URL=http://www.netlib.org/lapack/lapack-3.4.2.tgz
  234. lapack-3.4.2.tgz :
  235. ifndef NOFORTRAN
  236. #http://stackoverflow.com/questions/7656425/makefile-ifeq-logical-or
  237. ifeq ($(OSNAME), $(filter $(OSNAME),Darwin NetBSD))
  238. curl -O $(LAPACK_URL)
  239. else
  240. ifeq ($(OSNAME), FreeBSD)
  241. fetch $(LAPACK_URL)
  242. else
  243. wget $(LAPACK_URL)
  244. endif
  245. endif
  246. endif
  247. large.tgz :
  248. ifndef NOFORTRAN
  249. -wget http://www.netlib.org/lapack/timing/large.tgz
  250. endif
  251. timing.tgz :
  252. ifndef NOFORTRAN
  253. -wget http://www.netlib.org/lapack/timing/timing.tgz
  254. endif
  255. lapack-timing : lapack-3.4.2 large.tgz timing.tgz
  256. ifndef NOFORTRAN
  257. (cd $(NETLIB_LAPACK_DIR); $(TAR) zxf ../timing.tgz TIMING)
  258. (cd $(NETLIB_LAPACK_DIR)/TIMING; $(TAR) zxf ../../large.tgz )
  259. make -C $(NETLIB_LAPACK_DIR) tmglib
  260. make -C $(NETLIB_LAPACK_DIR)/TIMING
  261. endif
  262. lapack-test :
  263. $(MAKE) -C $(NETLIB_LAPACK_DIR) tmglib
  264. $(MAKE) -C $(NETLIB_LAPACK_DIR)/TESTING xeigtstc xeigtstd xeigtsts xeigtstz xlintstc xlintstd xlintstds xlintsts xlintstz xlintstzc
  265. @rm -f $(NETLIB_LAPACK_DIR)/TESTING/*.out
  266. $(MAKE) -j 1 -C $(NETLIB_LAPACK_DIR)/TESTING
  267. $(GREP) failed $(NETLIB_LAPACK_DIR)/TESTING/*.out
  268. dummy :
  269. install :
  270. $(MAKE) -f Makefile.install install
  271. clean ::
  272. @for d in $(SUBDIRS_ALL) ; \
  273. do if test -d $$d; then \
  274. $(MAKE) -C $$d $(@F) || exit 1 ; \
  275. fi; \
  276. done
  277. #ifdef DYNAMIC_ARCH
  278. @$(MAKE) -C kernel clean
  279. #endif
  280. @$(MAKE) -C reference clean
  281. @rm -f *.$(LIBSUFFIX) *.so *~ *.exe getarch getarch_2nd *.dll *.lib *.$(SUFFIX) *.dwf $(LIBPREFIX).$(LIBSUFFIX) $(LIBPREFIX)_p.$(LIBSUFFIX) $(LIBPREFIX).so.$(MAJOR_VERSION) *.lnk myconfig.h
  282. @rm -f Makefile.conf config.h cblas_noconst.h Makefile_kernel.conf config_kernel.h st* *.dylib
  283. @if test -d $(NETLIB_LAPACK_DIR); then \
  284. echo deleting $(NETLIB_LAPACK_DIR); \
  285. rm -rf $(NETLIB_LAPACK_DIR) ;\
  286. fi
  287. @rm -f *.grd Makefile.conf_last config_last.h
  288. @echo Done.