2 include ./Makefile.system
4 BLASDIRS = interface driver/level2 driver/level3 driver/others
6 ifneq ($(DYNAMIC_ARCH), 1)
19 PREFIX = /opt/OpenBLAS
23 ifneq ($(NO_LAPACK), 1)
27 SUBDIRS_ALL = $(SUBDIRS) test ctest utest exports benchmark ../laswp ../bench
29 .PHONY : all libs netlib test ctest shared install
30 .NOTPARALLEL : all libs prof lapack-test install
32 all :: libs netlib tests shared
34 @echo " OpenBLAS build complete. ($(LIB_COMPONENTS))"
36 @echo " OS ... $(OSNAME) "
37 @echo " Architecture ... $(ARCH) "
39 @echo " BINARY ... 32bit "
41 @echo " BINARY ... 64bit "
44 @echo " Use 64 bits int (equivalent to \"-i8\" in Fortran) "
46 @echo " C compiler ... $(C_COMPILER) (command line : $(CC))"
48 @echo " Fortran compiler ... $(F_COMPILER) (command line : $(FC))"
50 ifneq ($(OSNAME), AIX)
51 @echo -n " Library Name ... $(LIBNAME)"
53 @echo " Library Name ... $(LIBNAME)"
57 @echo " (Single threaded) "
59 @echo " (Multi threaded; Max num-threads is $(NUM_THREADS))"
62 ifeq ($(USE_OPENMP), 1)
64 @echo " Use OpenMP in the multithreading. Becasue of ignoring OPENBLAS_NUM_THREADS and GOTO_NUM_THREADS flags, "
65 @echo " you should use OMP_NUM_THREADS environment variable to control the number of threads."
69 ifeq ($(OSNAME), Darwin)
70 @echo "WARNING: If you plan to use the dynamic library $(LIBDYNNAME), you must run:"
72 @echo "\"make PREFIX=/your_installation_path/ install\"."
74 @echo "(or set PREFIX in Makefile.rule and run make install."
75 @echo "If you want to move the .dylib to a new location later, make sure you change"
76 @echo "the internal name of the dylib with:"
78 @echo "install_name_tool -id /new/absolute/path/to/$(LIBDYNNAME) $(LIBDYNNAME)"
81 @echo "To install the library, you can run \"make PREFIX=/path/to/your/installation install\"."
86 ifeq ($(OSNAME), Linux)
87 @$(MAKE) -C exports so
88 @-ln -fs $(LIBSONAME) $(LIBPREFIX).so
89 @-ln -fs $(LIBSONAME) $(LIBPREFIX).so.$(MAJOR_VERSION)
91 ifeq ($(OSNAME), FreeBSD)
92 @$(MAKE) -C exports so
93 @-ln -fs $(LIBSONAME) $(LIBPREFIX).so
95 ifeq ($(OSNAME), NetBSD)
96 @$(MAKE) -C exports so
97 @-ln -fs $(LIBSONAME) $(LIBPREFIX).so
99 ifeq ($(OSNAME), Darwin)
100 @$(MAKE) -C exports dyn
101 @-ln -fs $(LIBDYNNAME) $(LIBPREFIX).dylib
103 ifeq ($(OSNAME), WINNT)
104 @$(MAKE) -C exports dll
106 ifeq ($(OSNAME), CYGWIN_NT)
107 @$(MAKE) -C exports dll
130 ifeq ($(CORE), UNKOWN)
131 $(error OpenBLAS: Detecting CPU failed. Please set TARGET explicitly, e.g. make TARGET=your_cpu_target. Please read README for the detail.)
133 ifeq ($(NOFORTRAN), 1)
134 $(error OpenBLAS: Detecting fortran compiler failed. Please install fortran compiler, e.g. gfortran, ifort, openf90.)
136 @-ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
137 @for d in $(SUBDIRS) ; \
138 do if test -d $$d; then \
139 $(MAKE) -C $$d $(@F) || exit 1 ; \
142 #Save the config files for installation
143 @cp Makefile.conf Makefile.conf_last
144 @cp config.h config_last.h
146 @echo "#define QUAD_PRECISION">> config_last.h
148 ifeq ($(EXPRECISION), 1)
149 @echo "#define EXPRECISION">> config_last.h
152 ifeq ($(DYNAMIC_ARCH), 1)
153 @$(MAKE) -C kernel commonlibs || exit 1
154 @for d in $(DYNAMIC_CORE) ; \
155 do $(MAKE) GOTOBLAS_MAKEFILE= -C kernel TARGET_CORE=$$d kernel || exit 1 ;\
157 @echo DYNAMIC_ARCH=1 >> Makefile.conf_last
160 @echo USE_THREAD=$(USE_THREAD) >> Makefile.conf_last
164 prof : prof_blas prof_lapack
167 ln -fs $(LIBNAME_P) $(LIBPREFIX)_p.$(LIBSUFFIX)
168 for d in $(SUBDIRS) ; \
169 do if test -d $$d; then \
170 $(MAKE) -C $$d prof || exit 1 ; \
173 ifeq ($(DYNAMIC_ARCH), 1)
174 $(MAKE) -C kernel commonprof || exit 1
178 ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
179 for d in $(BLASDIRS) ; \
180 do if test -d $$d; then \
181 $(MAKE) -C $$d libs || exit 1 ; \
186 ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
187 for d in $(BLASDIRS) ../laswp exports ; \
188 do if test -d $$d; then \
189 $(MAKE) -C $$d $(@F) || exit 1 ; \
192 ifeq ($(DYNAMIC_ARCH), 1)
193 $(MAKE) -C kernel commonlibs || exit 1
194 for d in $(DYNAMIC_CORE) ; \
195 do $(MAKE) GOTOBLAS_MAKEFILE= -C kernel TARGET_CORE=$$d kernel || exit 1 ;\
200 ln -fs $(LIBNAME_P) $(LIBPREFIX)_p.$(LIBSUFFIX)
201 for d in $(SUBDIRS) ../laswp exports ; \
202 do if test -d $$d; then \
203 $(MAKE) -C $$d $(@F) || exit 1 ; \
207 ifeq ($(NO_LAPACK), 1)
211 netlib : lapack_prebuild
213 @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapacklib
216 @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapackelib
220 prof_lapack : lapack_prebuild
221 @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapack_prof
225 -@echo "FORTRAN = $(FC)" > $(NETLIB_LAPACK_DIR)/make.inc
226 -@echo "OPTS = $(FFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
227 -@echo "POPTS = $(FPFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
228 -@echo "NOOPT = $(FFLAGS) -O0" >> $(NETLIB_LAPACK_DIR)/make.inc
229 -@echo "PNOOPT = $(FPFLAGS) -O0" >> $(NETLIB_LAPACK_DIR)/make.inc
230 -@echo "LOADOPTS = $(FFLAGS) $(EXTRALIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
231 -@echo "CC = $(CC)" >> $(NETLIB_LAPACK_DIR)/make.inc
232 -@echo "override CFLAGS = $(LAPACK_CFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
233 -@echo "ARCH = $(AR)" >> $(NETLIB_LAPACK_DIR)/make.inc
234 -@echo "ARCHFLAGS = -ru" >> $(NETLIB_LAPACK_DIR)/make.inc
235 -@echo "RANLIB = $(RANLIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
236 -@echo "LAPACKLIB = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
237 -@echo "LAPACKELIB = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
238 -@echo "LAPACKLIB_P = ../$(LIBNAME_P)" >> $(NETLIB_LAPACK_DIR)/make.inc
239 -@echo "SUFFIX = $(SUFFIX)" >> $(NETLIB_LAPACK_DIR)/make.inc
240 -@echo "PSUFFIX = $(PSUFFIX)" >> $(NETLIB_LAPACK_DIR)/make.inc
241 -@echo "CEXTRALIB = $(EXTRALIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
242 -@cat make.inc >> $(NETLIB_LAPACK_DIR)/make.inc
245 lapack-3.4.2 : lapack-3.4.2.tgz
248 @if test `$(MD5SUM) $< | $(AWK) '{print $$1}'` = 61bf1a8a4469d4bdb7604f5897179478; then \
249 echo $(TAR) zxf $< ;\
250 $(TAR) zxf $< && (cd $(NETLIB_LAPACK_DIR); $(PATCH) -p1 < ../patch.for_lapack-3.4.2) ;\
251 rm -f $(NETLIB_LAPACK_DIR)/lapacke/make.inc ;\
253 rm -rf $(NETLIB_LAPACK_DIR) ;\
254 echo " Cannot download lapack-3.4.2.tgz or the MD5 check sum is wrong (Please use orignal)."; \
260 LAPACK_URL=http://www.netlib.org/lapack/lapack-3.4.2.tgz
264 #http://stackoverflow.com/questions/7656425/makefile-ifeq-logical-or
265 ifeq ($(OSNAME), $(filter $(OSNAME),Darwin NetBSD))
266 curl -O $(LAPACK_URL);
268 ifeq ($(OSNAME), FreeBSD)
271 wget -O $@ $(LAPACK_URL);
279 -wget http://www.netlib.org/lapack/timing/large.tgz;
286 -wget http://www.netlib.org/lapack/timing/timing.tgz;
290 lapack-timing : large.tgz timing.tgz
292 (cd $(NETLIB_LAPACK_DIR); $(TAR) zxf ../timing.tgz TIMING)
293 (cd $(NETLIB_LAPACK_DIR)/TIMING; $(TAR) zxf ../../large.tgz )
294 make -C $(NETLIB_LAPACK_DIR) tmglib
295 make -C $(NETLIB_LAPACK_DIR)/TIMING
300 $(MAKE) -C $(NETLIB_LAPACK_DIR) tmglib
301 $(MAKE) -C $(NETLIB_LAPACK_DIR)/TESTING xeigtstc xeigtstd xeigtsts xeigtstz xlintstc xlintstd xlintstds xlintsts xlintstz xlintstzc
302 @rm -f $(NETLIB_LAPACK_DIR)/TESTING/*.out
303 $(MAKE) -j 1 -C $(NETLIB_LAPACK_DIR)/TESTING
304 $(GREP) failed $(NETLIB_LAPACK_DIR)/TESTING/*.out
309 $(MAKE) -f Makefile.install install
312 @for d in $(SUBDIRS_ALL) ; \
313 do if test -d $$d; then \
314 $(MAKE) -C $$d $(@F) || exit 1 ; \
318 @$(MAKE) -C kernel clean
320 @$(MAKE) -C reference clean
321 @rm -f *.$(LIBSUFFIX) *.so *~ *.exe getarch getarch_2nd *.dll *.lib *.$(SUFFIX) *.dwf $(LIBPREFIX).$(LIBSUFFIX) $(LIBPREFIX)_p.$(LIBSUFFIX) $(LIBPREFIX).so.$(MAJOR_VERSION) *.lnk myconfig.h
322 ifeq ($(OSNAME), Darwin)
323 @rm -rf getarch.dSYM getarch_2nd.dSYM
325 @rm -f Makefile.conf config.h Makefile_kernel.conf config_kernel.h st* *.dylib
326 @touch $(NETLIB_LAPACK_DIR)/make.inc
327 @$(MAKE) -C $(NETLIB_LAPACK_DIR) clean
328 @rm -f $(NETLIB_LAPACK_DIR)/make.inc $(NETLIB_LAPACK_DIR)/lapacke/include/lapacke_mangling.h
329 @rm -f *.grd Makefile.conf_last config_last.h