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

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