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

11 years ago
13 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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. 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. prof_lapack : lapack_prebuild
  195. @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapack_prof
  196. lapack_prebuild :
  197. ifndef NOFORTRAN
  198. -@echo "FORTRAN = $(FC)" > $(NETLIB_LAPACK_DIR)/make.inc
  199. -@echo "OPTS = $(LAPACK_FFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
  200. -@echo "POPTS = $(LAPACK_FPFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
  201. -@echo "NOOPT = -O0 $(LAPACK_NOOPT)" >> $(NETLIB_LAPACK_DIR)/make.inc
  202. -@echo "PNOOPT = $(LAPACK_FPFLAGS) -O0" >> $(NETLIB_LAPACK_DIR)/make.inc
  203. -@echo "LOADOPTS = $(FFLAGS) $(EXTRALIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
  204. -@echo "CC = $(CC)" >> $(NETLIB_LAPACK_DIR)/make.inc
  205. -@echo "override CFLAGS = $(LAPACK_CFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
  206. -@echo "ARCH = $(AR)" >> $(NETLIB_LAPACK_DIR)/make.inc
  207. -@echo "ARCHFLAGS = -ru" >> $(NETLIB_LAPACK_DIR)/make.inc
  208. -@echo "RANLIB = $(RANLIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
  209. -@echo "LAPACKLIB = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
  210. -@echo "TMGLIB = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
  211. -@echo "BLASLIB = ../../../$(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. ifeq ($(F_COMPILER), GFORTRAN)
  218. -@echo "TIMER = INT_ETIME" >> $(NETLIB_LAPACK_DIR)/make.inc
  219. ifdef SMP
  220. ifeq ($(OSNAME), WINNT)
  221. -@echo "LOADER = $(FC)" >> $(NETLIB_LAPACK_DIR)/make.inc
  222. else
  223. -@echo "LOADER = $(FC) -pthread" >> $(NETLIB_LAPACK_DIR)/make.inc
  224. endif
  225. else
  226. -@echo "LOADER = $(FC)" >> $(NETLIB_LAPACK_DIR)/make.inc
  227. endif
  228. else
  229. -@echo "TIMER = NONE" >> $(NETLIB_LAPACK_DIR)/make.inc
  230. -@echo "LOADER = $(FC)" >> $(NETLIB_LAPACK_DIR)/make.inc
  231. endif
  232. ifeq ($(BUILD_LAPACK_DEPRECATED), 1)
  233. -@echo "BUILD_DEPRECATED = 1" >> $(NETLIB_LAPACK_DIR)/make.inc
  234. endif
  235. -@cat make.inc >> $(NETLIB_LAPACK_DIR)/make.inc
  236. endif
  237. large.tgz :
  238. ifndef NOFORTRAN
  239. if [ ! -a $< ]; then
  240. -wget http://www.netlib.org/lapack/timing/large.tgz;
  241. fi
  242. endif
  243. timing.tgz :
  244. ifndef NOFORTRAN
  245. if [ ! -a $< ]; then
  246. -wget http://www.netlib.org/lapack/timing/timing.tgz;
  247. fi
  248. endif
  249. lapack-timing : large.tgz timing.tgz
  250. ifndef NOFORTRAN
  251. (cd $(NETLIB_LAPACK_DIR); $(TAR) zxf ../timing.tgz TIMING)
  252. (cd $(NETLIB_LAPACK_DIR)/TIMING; $(TAR) zxf ../../large.tgz )
  253. make -C $(NETLIB_LAPACK_DIR)/TIMING
  254. endif
  255. lapack-test :
  256. (cd $(NETLIB_LAPACK_DIR)/TESTING && rm -f x* *.out)
  257. make -j 1 -C $(NETLIB_LAPACK_DIR)/TESTING xeigtstc xeigtstd xeigtsts xeigtstz xlintstc xlintstd xlintstds xlintstrfd xlintstrfz xlintsts xlintstz xlintstzc xlintstrfs xlintstrfc
  258. ifneq ($(CROSS), 1)
  259. ( cd $(NETLIB_LAPACK_DIR)/INSTALL; ./testlsame; ./testslamch; ./testdlamch; \
  260. ./testsecond; ./testdsecnd; ./testieee; ./testversion )
  261. (cd $(NETLIB_LAPACK_DIR); ./lapack_testing.py -r )
  262. endif
  263. lapack-runtest:
  264. ( cd $(NETLIB_LAPACK_DIR)/INSTALL; ./testlsame; ./testslamch; ./testdlamch; \
  265. ./testsecond; ./testdsecnd; ./testieee; ./testversion )
  266. (cd $(NETLIB_LAPACK_DIR); ./lapack_testing.py -r )
  267. blas-test:
  268. (cd $(NETLIB_LAPACK_DIR)/BLAS && rm -f x* *.out)
  269. make -j 1 -C $(NETLIB_LAPACK_DIR) blas_testing
  270. (cd $(NETLIB_LAPACK_DIR)/BLAS && cat *.out)
  271. dummy :
  272. install :
  273. $(MAKE) -f Makefile.install install
  274. clean ::
  275. @for d in $(SUBDIRS_ALL) ; \
  276. do if test -d $$d; then \
  277. $(MAKE) -C $$d $(@F) || exit 1 ; \
  278. fi; \
  279. done
  280. #ifdef DYNAMIC_ARCH
  281. @$(MAKE) -C kernel clean
  282. #endif
  283. @$(MAKE) -C reference clean
  284. @rm -f *.$(LIBSUFFIX) *.so *~ *.exe getarch getarch_2nd *.dll *.lib *.$(SUFFIX) *.dwf $(LIBPREFIX).$(LIBSUFFIX) $(LIBPREFIX)_p.$(LIBSUFFIX) $(LIBPREFIX).so.$(MAJOR_VERSION) *.lnk myconfig.h
  285. ifeq ($(OSNAME), Darwin)
  286. @rm -rf getarch.dSYM getarch_2nd.dSYM
  287. endif
  288. @rm -f Makefile.conf config.h Makefile_kernel.conf config_kernel.h st* *.dylib
  289. @touch $(NETLIB_LAPACK_DIR)/make.inc
  290. @$(MAKE) -C $(NETLIB_LAPACK_DIR) clean
  291. @rm -f $(NETLIB_LAPACK_DIR)/make.inc $(NETLIB_LAPACK_DIR)/lapacke/include/lapacke_mangling.h
  292. @rm -f *.grd Makefile.conf_last config_last.h
  293. @(cd $(NETLIB_LAPACK_DIR)/TESTING && rm -f x* *.out testing_results.txt)
  294. @echo Done.