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

13 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. TOPDIR = ..
  2. include ../Makefile.system
  3. ifndef EXPRECISION
  4. EXPRECISION = 0
  5. endif
  6. ifndef NO_CBLAS
  7. NO_CBLAS = 0
  8. endif
  9. ifndef NO_LAPACK
  10. NO_LAPACK = 0
  11. endif
  12. ifndef NO_LAPACKE
  13. NO_LAPACKE = 0
  14. endif
  15. ifndef NEED2UNDERSCORES
  16. NEED2UNDERSCORES=0
  17. endif
  18. ifndef ONLY_CBLAS
  19. ONLY_CBLAS = 0
  20. endif
  21. ifndef BUILD_LAPACK_DEPRECATED
  22. BUILD_LAPACK_DEPRECATED = 0
  23. endif
  24. ifeq ($(OSNAME), WINNT)
  25. ifeq ($(F_COMPILER), GFORTRAN)
  26. ifndef ONLY_CBLAS
  27. EXTRALIB += -lgfortran
  28. endif
  29. endif
  30. ifeq ($(USE_OPENMP), 1)
  31. ifeq ($(C_COMPILER), GCC)
  32. EXTRALIB += -lgomp
  33. endif
  34. endif
  35. endif
  36. ifeq ($(OSNAME), CYGWIN_NT)
  37. ifeq ($(F_COMPILER), GFORTRAN)
  38. ifndef ONLY_CBLAS
  39. EXTRALIB += -lgfortran
  40. endif
  41. endif
  42. endif
  43. ifneq (,$(filter 1 2,$(NOFORTRAN)))
  44. FEXTRALIB =
  45. endif
  46. all::
  47. libs::
  48. prof::
  49. hpl:: libgoto_hpl.$(LIBSUFFIX)
  50. hpl_p:: libgoto_hpl_p.$(LIBSUFFIX)
  51. libgoto_hpl.$(LIBSUFFIX) : ../$(LIBNAME)
  52. rm -f $(@F)
  53. $(LD) -r $(LDFLAGS) -o goto.$(SUFFIX) --whole-archive $< --no-whole-archive
  54. $(AR) cq $(@F) goto.$(SUFFIX)
  55. $(RANLIB) libgoto_hpl.$(LIBSUFFIX)
  56. libgoto_hpl_p.$(LIBSUFFIX) : ../$(LIBNAME_P)
  57. rm -f $(@F)
  58. $(LD) -r $(LDFLAGS) -o goto.$(PSUFFIX) --whole-archive $< --no-whole-archive
  59. $(AR) cq $(@F) goto.$(PSUFFIX)
  60. $(RANLIB) libgoto_hpl_p.$(LIBSUFFIX)
  61. libgoto_hpl.dll : libgoto_hpl.$(LIBSUFFIX) dllinit.$(SUFFIX) libgoto_hpl.def
  62. $(DLLWRAP) -o $(@F) --def libgoto_hpl.def --entry _dllinit -s dllinit.$(SUFFIX) --dllname libgoto_hpl.dll libgoto_hpl.$(LIBSUFFIX)
  63. lib /machine:X64 /def:libgoto_hpl.def
  64. dyn : $(LIBDYNNAME)
  65. zip : dll
  66. zip $(LIBZIPNAME) $(LIBDLLNAME) $(LIBNAME)
  67. dll : ../$(LIBDLLNAME)
  68. # On Windows, we only generate a DLL without a version suffix. This is because
  69. # applications which link against the dynamic library reference a fixed DLL name
  70. # in their import table. By instead using a stable name it is possible to
  71. # upgrade between library versions, without needing to re-link an application.
  72. # For more details see: https://github.com/xianyi/OpenBLAS/issues/127.
  73. ../$(LIBDLLNAME) : ../$(LIBNAME) $(LIBPREFIX).def dllinit.$(SUFFIX)
  74. $(RANLIB) ../$(LIBNAME)
  75. $(CC) $(CFLAGS) $(LDFLAGS) $(LIBPREFIX).def dllinit.$(SUFFIX) \
  76. -shared -o ../$(LIBDLLNAME) -Wl,--out-implib,../$(IMPLIBNAME) \
  77. -Wl,--whole-archive ../$(LIBNAME) -Wl,--no-whole-archive $(FEXTRALIB) $(EXTRALIB)
  78. $(LIBPREFIX).def : gensymbol
  79. perl ./gensymbol win2k $(ARCH) dummy $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" $(BUILD_LAPACK_DEPRECATED) > $(@F)
  80. libgoto_hpl.def : gensymbol
  81. perl ./gensymbol win2khpl $(ARCH) dummy $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" $(BUILD_LAPACK_DEPRECATED) > $(@F)
  82. ifeq (, $(SYMBOLPREFIX)$(SYMBOLSUFFIX))
  83. $(LIBDYNNAME) : ../$(LIBNAME) osx.def
  84. else
  85. ../$(LIBNAME).osx.renamed : ../$(LIBNAME) objconv.def
  86. $(OBJCONV) @objconv.def ../$(LIBNAME) ../$(LIBNAME).osx.renamed
  87. $(LIBDYNNAME) : ../$(LIBNAME).osx.renamed osx.def
  88. endif
  89. ifneq (,$(filter 1 2,$(NOFORTRAN)))
  90. #only build without Fortran
  91. $(CC) $(CFLAGS) $(LDFLAGS) -all_load -headerpad_max_install_names -install_name "$(CURDIR)/../$(LIBDYNNAME)" -dynamiclib -o ../$(LIBDYNNAME) $< -Wl,-exported_symbols_list,osx.def $(FEXTRALIB)
  92. else
  93. $(FC) $(FFLAGS) $(LDFLAGS) -all_load -headerpad_max_install_names -install_name "$(CURDIR)/../$(LIBDYNNAME)" -dynamiclib -o ../$(LIBDYNNAME) $< -Wl,-exported_symbols_list,osx.def $(FEXTRALIB)
  94. endif
  95. dllinit.$(SUFFIX) : dllinit.c
  96. $(CC) $(CFLAGS) -c -o $(@F) -s $<
  97. ifeq ($(OSNAME), $(filter $(OSNAME),Linux SunOS Android Haiku))
  98. so : ../$(LIBSONAME)
  99. ifeq ($(OSNAME), Android)
  100. INTERNALNAME = $(LIBPREFIX).so
  101. FEXTRALIB += -lm
  102. EXTRALIB += -lm
  103. else
  104. INTERNALNAME = $(LIBPREFIX).so.$(MAJOR_VERSION)
  105. endif
  106. ifeq (, $(SYMBOLPREFIX)$(SYMBOLSUFFIX))
  107. ../$(LIBSONAME) : ../$(LIBNAME) linktest.c
  108. else
  109. ../$(LIBNAME).renamed : ../$(LIBNAME) objcopy.def
  110. $(OBJCOPY) --redefine-syms objcopy.def ../$(LIBNAME) ../$(LIBNAME).renamed
  111. ../$(LIBSONAME) : ../$(LIBNAME).renamed linktest.c
  112. endif
  113. ifneq ($(C_COMPILER), LSB)
  114. $(CC) $(CFLAGS) $(LDFLAGS) -shared -o ../$(LIBSONAME) \
  115. -Wl,--whole-archive $< -Wl,--no-whole-archive \
  116. -Wl,-soname,$(INTERNALNAME) $(EXTRALIB)
  117. $(CC) $(CFLAGS) $(LDFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) $(FEXTRALIB) && echo OK.
  118. else
  119. #for LSB
  120. env LSBCC_SHAREDLIBS=gfortran $(CC) $(CFLAGS) $(LDFLAGS) -shared -o ../$(LIBSONAME) \
  121. -Wl,--whole-archive $< -Wl,--no-whole-archive \
  122. -Wl,-soname,$(INTERNALNAME) $(EXTRALIB)
  123. $(FC) $(CFLAGS) $(LDFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) $(FEXTRALIB) && echo OK.
  124. endif
  125. rm -f linktest
  126. endif
  127. #http://stackoverflow.com/questions/7656425/makefile-ifeq-logical-or
  128. ifeq ($(OSNAME), $(filter $(OSNAME),FreeBSD OpenBSD NetBSD DragonFly))
  129. so : ../$(LIBSONAME)
  130. ifeq (, $(SYMBOLPREFIX)$(SYMBOLSUFFIX))
  131. ../$(LIBSONAME) : ../$(LIBNAME) linktest.c
  132. else
  133. ../$(LIBNAME).renamed : ../$(LIBNAME) objcopy.def
  134. $(OBJCOPY) --redefine-syms objcopy.def ../$(LIBNAME) ../$(LIBNAME).renamed
  135. ../$(LIBSONAME) : ../$(LIBNAME).renamed linktest.c
  136. endif
  137. $(CC) $(CFLAGS) $(LDFLAGS) -shared -o ../$(LIBSONAME) \
  138. -Wl,--whole-archive $< -Wl,--no-whole-archive \
  139. $(FEXTRALIB) $(EXTRALIB)
  140. $(CC) $(CFLAGS) $(LDFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) $(FEXTRALIB) && echo OK.
  141. rm -f linktest
  142. endif
  143. ifeq ($(OSNAME), OSF1)
  144. so : ../$(LIBSONAME)
  145. ../$(LIBSONAME) :
  146. $(CC) $(CFLAGS) $(LDFLAGS) -shared -o ../$(LIBSONAME) ../$(LIBNAME)
  147. endif
  148. ifeq ($(OSNAME), SunOS)
  149. so : ../$(LIBSONAME)
  150. $(CC) $(CFLAGS) $(LDFLAGS) -shared -o ../$(LIBSONAME) \
  151. -Wl,--whole-archive ../$(LIBNAME) -Wl,--no-whole-archive $(EXTRALIB)
  152. $(CC) $(CFLAGS) $(LDFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) $(FEXTRALIB) && echo OK.
  153. rm -f linktest
  154. endif
  155. ifeq ($(OSNAME), AIX)
  156. ifeq ($(COMPILER_F77), xlf)
  157. goto32.$(SUFFIX) : ../$(LIBNAME) aix.def
  158. ld -o $(@F) ../$(LIBNAME) -bE:aix.def -bM:SRE -bnoexpall -bnoentry -L$(HOME)/misc/lib -lxlf90 -lc -lm -lpthread
  159. goto64.$(SUFFIX) : ../$(LIBNAME) aix.def
  160. ld -b64 -o $(@F) ../$(LIBNAME) -bE:aix.def -bM:SRE -bnoexpall -bnoentry -L$(HOME)/misc/lib/ppc64 -lxlf90 -lc -lm -lpthread
  161. else
  162. goto32.$(SUFFIX) : ../$(LIBNAME) aix.def
  163. ld -o $(@F) ../$(LIBNAME) -bE:aix.def -bM:SRE -bnoexpall -bnoentry -L$(HOME)/misc/lib -lg2c -lc -lm
  164. goto64.$(SUFFIX) : ../$(LIBNAME) aix.def
  165. ld -b64 -o $(@F) ../$(LIBNAME) -bE:aix.def -bM:SRE -bnoexpall -bnoentry -L$(HOME)/misc/lib/ppc64 -lg2c -lc -lm
  166. endif
  167. endif
  168. static : ../$(LIBNAME)
  169. $(LD) $(LDFLAGS) -r -o goto.$(SUFFIX) \
  170. --whole-archive ../$(LIBNAME) --no-whole-archive
  171. rm -f ../$(LIBNAME)
  172. $(AR) -cq ../$(LIBNAME) goto.$(SUFFIX)
  173. rm -f goto.$(SUFFIX)
  174. osx.def : gensymbol ../Makefile.system ../getarch.c
  175. perl ./gensymbol osx $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" $(BUILD_LAPACK_DEPRECATED) > $(@F)
  176. aix.def : gensymbol ../Makefile.system ../getarch.c
  177. perl ./gensymbol aix $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" $(BUILD_LAPACK_DEPRECATED) > $(@F)
  178. objcopy.def : gensymbol ../Makefile.system ../getarch.c
  179. perl ./gensymbol objcopy $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" $(BUILD_LAPACK_DEPRECATED) > $(@F)
  180. objconv.def : gensymbol ../Makefile.system ../getarch.c
  181. perl ./gensymbol objconv $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" $(BUILD_LAPACK_DEPRECATED) > $(@F)
  182. test : linktest.c
  183. $(CC) $(CFLAGS) $(LDFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) -lm && echo OK.
  184. rm -f linktest
  185. linktest.c : gensymbol ../Makefile.system ../getarch.c
  186. perl ./gensymbol linktest $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" $(BUILD_LAPACK_DEPRECATED) > linktest.c
  187. clean ::
  188. @rm -f *.def *.dylib __.SYMDEF* *.renamed
  189. include ../Makefile.tail