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."
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))"
47 @echo " Fortran compiler ... $(F_COMPILER) (command line : $(FC))"
48 ifneq ($(OSNAME), AIX)
49 @echo -n " Library Name ... $(LIBNAME)"
51 @echo " Library Name ... $(LIBNAME)"
55 @echo " (Single threaded) "
57 @echo " (Multi threaded; Max num-threads is $(NUM_THREADS))"
60 ifeq ($(USE_OPENMP), 1)
62 @echo " Use OpenMP in the multithreading. Becasue of ignoring OPENBLAS_NUM_THREADS and GOTO_NUM_THREADS flags, "
63 @echo " you should use OMP_NUM_THREADS environment variable to control the number of threads."
67 ifeq ($(OSNAME), Darwin)
68 @echo "WARNING: If you plan to use the dynamic library $(LIBDYNNAME), you must run:"
70 @echo "\"make PREFIX=/your_installation_path/ install\"."
72 @echo "(or set PREFIX in Makefile.rule and run make install."
73 @echo "If you want to move the .dylib to a new location later, make sure you change"
74 @echo "the internal name of the dylib with:"
76 @echo "install_name_tool -id /new/absolute/path/to/$(LIBDYNNAME) $(LIBDYNNAME)"
79 @echo "To install the library, you can run \"make PREFIX=/path/to/your/installation install\"."
84 ifeq ($(OSNAME), Linux)
85 @$(MAKE) -C exports so
86 @-ln -fs $(LIBSONAME) $(LIBPREFIX).so
87 @-ln -fs $(LIBSONAME) $(LIBPREFIX).so.$(MAJOR_VERSION)
89 ifeq ($(OSNAME), FreeBSD)
90 @$(MAKE) -C exports so
91 @-ln -fs $(LIBSONAME) $(LIBPREFIX).so
93 ifeq ($(OSNAME), NetBSD)
94 @$(MAKE) -C exports so
95 @-ln -fs $(LIBSONAME) $(LIBPREFIX).so
97 ifeq ($(OSNAME), Darwin)
98 @$(MAKE) -C exports dyn
99 @-ln -fs $(LIBDYNNAME) $(LIBPREFIX).dylib
101 ifeq ($(OSNAME), WINNT)
102 @$(MAKE) -C exports dll
104 ifeq ($(OSNAME), CYGWIN_NT)
105 @$(MAKE) -C exports dll
128 ifeq ($(CORE), UNKOWN)
129 $(error OpenBLAS: Detecting CPU failed. Please set TARGET explicitly, e.g. make TARGET=your_cpu_target. Please read README for the detail.)
131 ifeq ($(NOFORTRAN), 1)
132 $(error OpenBLAS: Detecting fortran compiler failed. Please install fortran compiler, e.g. gfortran, ifort, openf90.)
134 @-ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
135 @for d in $(SUBDIRS) ; \
136 do if test -d $$d; then \
137 $(MAKE) -C $$d $(@F) || exit 1 ; \
140 #Save the config files for installation
141 @cp Makefile.conf Makefile.conf_last
142 @cp config.h config_last.h
144 @echo "#define QUAD_PRECISION">> config_last.h
146 ifeq ($(EXPRECISION), 1)
147 @echo "#define EXPRECISION">> config_last.h
150 ifeq ($(DYNAMIC_ARCH), 1)
151 @$(MAKE) -C kernel commonlibs || exit 1
152 @for d in $(DYNAMIC_CORE) ; \
153 do $(MAKE) GOTOBLAS_MAKEFILE= -C kernel TARGET_CORE=$$d kernel || exit 1 ;\
155 @echo DYNAMIC_ARCH=1 >> Makefile.conf_last
158 @echo USE_THREAD=$(USE_THREAD) >> Makefile.conf_last
162 prof : prof_blas prof_lapack
165 ln -fs $(LIBNAME_P) $(LIBPREFIX)_p.$(LIBSUFFIX)
166 for d in $(SUBDIRS) ; \
167 do if test -d $$d; then \
168 $(MAKE) -C $$d prof || exit 1 ; \
171 ifeq ($(DYNAMIC_ARCH), 1)
172 $(MAKE) -C kernel commonprof || exit 1
176 ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
177 for d in $(BLASDIRS) ; \
178 do if test -d $$d; then \
179 $(MAKE) -C $$d libs || exit 1 ; \
184 ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
185 for d in $(BLASDIRS) ../laswp exports ; \
186 do if test -d $$d; then \
187 $(MAKE) -C $$d $(@F) || exit 1 ; \
190 ifeq ($(DYNAMIC_ARCH), 1)
191 $(MAKE) -C kernel commonlibs || exit 1
192 for d in $(DYNAMIC_CORE) ; \
193 do $(MAKE) GOTOBLAS_MAKEFILE= -C kernel TARGET_CORE=$$d kernel || exit 1 ;\
198 ln -fs $(LIBNAME_P) $(LIBPREFIX)_p.$(LIBSUFFIX)
199 for d in $(SUBDIRS) ../laswp exports ; \
200 do if test -d $$d; then \
201 $(MAKE) -C $$d $(@F) || exit 1 ; \
205 ifeq ($(NO_LAPACK), 1)
209 netlib : lapack_prebuild
211 @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapacklib
214 @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapackelib
218 prof_lapack : lapack_prebuild
219 @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapack_prof
223 -@echo "FORTRAN = $(FC)" > $(NETLIB_LAPACK_DIR)/make.inc
224 -@echo "OPTS = $(FFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
225 -@echo "POPTS = $(FPFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
226 -@echo "NOOPT = $(FFLAGS) -O0" >> $(NETLIB_LAPACK_DIR)/make.inc
227 -@echo "PNOOPT = $(FPFLAGS) -O0" >> $(NETLIB_LAPACK_DIR)/make.inc
228 -@echo "LOADOPTS = $(FFLAGS) $(EXTRALIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
229 -@echo "CC = $(CC)" >> $(NETLIB_LAPACK_DIR)/make.inc
230 -@echo "override CFLAGS = $(LAPACK_CFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
231 -@echo "ARCH = $(AR)" >> $(NETLIB_LAPACK_DIR)/make.inc
232 -@echo "ARCHFLAGS = -ru" >> $(NETLIB_LAPACK_DIR)/make.inc
233 -@echo "RANLIB = $(RANLIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
234 -@echo "LAPACKLIB = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
235 -@echo "LAPACKELIB = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
236 -@echo "LAPACKLIB_P = ../$(LIBNAME_P)" >> $(NETLIB_LAPACK_DIR)/make.inc
237 -@echo "SUFFIX = $(SUFFIX)" >> $(NETLIB_LAPACK_DIR)/make.inc
238 -@echo "PSUFFIX = $(PSUFFIX)" >> $(NETLIB_LAPACK_DIR)/make.inc
239 -@echo "CEXTRALIB = $(EXTRALIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
240 -@cat make.inc >> $(NETLIB_LAPACK_DIR)/make.inc
243 lapack-3.4.2 : lapack-3.4.2.tgz
246 @if test `$(MD5SUM) $< | $(AWK) '{print $$1}'` = 61bf1a8a4469d4bdb7604f5897179478; then \
247 echo $(TAR) zxf $< ;\
248 $(TAR) zxf $< && (cd $(NETLIB_LAPACK_DIR); $(PATCH) -p1 < ../patch.for_lapack-3.4.2) ;\
249 rm -f $(NETLIB_LAPACK_DIR)/lapacke/make.inc ;\
251 rm -rf $(NETLIB_LAPACK_DIR) ;\
252 echo " Cannot download lapack-3.4.2.tgz or the MD5 check sum is wrong (Please use orignal)."; \
258 LAPACK_URL=http://www.netlib.org/lapack/lapack-3.4.2.tgz
262 #http://stackoverflow.com/questions/7656425/makefile-ifeq-logical-or
263 ifeq ($(OSNAME), $(filter $(OSNAME),Darwin NetBSD))
264 curl -O $(LAPACK_URL);
266 ifeq ($(OSNAME), FreeBSD)
269 wget -O $@ $(LAPACK_URL);
277 -wget http://www.netlib.org/lapack/timing/large.tgz;
284 -wget http://www.netlib.org/lapack/timing/timing.tgz;
288 lapack-timing : large.tgz timing.tgz
290 (cd $(NETLIB_LAPACK_DIR); $(TAR) zxf ../timing.tgz TIMING)
291 (cd $(NETLIB_LAPACK_DIR)/TIMING; $(TAR) zxf ../../large.tgz )
292 make -C $(NETLIB_LAPACK_DIR) tmglib
293 make -C $(NETLIB_LAPACK_DIR)/TIMING
298 $(MAKE) -C $(NETLIB_LAPACK_DIR) tmglib
299 $(MAKE) -C $(NETLIB_LAPACK_DIR)/TESTING xeigtstc xeigtstd xeigtsts xeigtstz xlintstc xlintstd xlintstds xlintsts xlintstz xlintstzc
300 @rm -f $(NETLIB_LAPACK_DIR)/TESTING/*.out
301 $(MAKE) -j 1 -C $(NETLIB_LAPACK_DIR)/TESTING
302 $(GREP) failed $(NETLIB_LAPACK_DIR)/TESTING/*.out
307 $(MAKE) -f Makefile.install install
310 @for d in $(SUBDIRS_ALL) ; \
311 do if test -d $$d; then \
312 $(MAKE) -C $$d $(@F) || exit 1 ; \
316 @$(MAKE) -C kernel clean
318 @$(MAKE) -C reference clean
319 @rm -f *.$(LIBSUFFIX) *.so *~ *.exe getarch getarch_2nd *.dll *.lib *.$(SUFFIX) *.dwf $(LIBPREFIX).$(LIBSUFFIX) $(LIBPREFIX)_p.$(LIBSUFFIX) $(LIBPREFIX).so.$(MAJOR_VERSION) *.lnk myconfig.h
320 ifeq ($(OSNAME), Darwin)
321 @rm -rf getarch.dSYM getarch_2nd.dSYM
323 @rm -f Makefile.conf config.h cblas_noconst.h Makefile_kernel.conf config_kernel.h st* *.dylib
324 @touch $(NETLIB_LAPACK_DIR)/make.inc
325 @$(MAKE) -C $(NETLIB_LAPACK_DIR) clean
326 @rm -f $(NETLIB_LAPACK_DIR)/make.inc $(NETLIB_LAPACK_DIR)/lapacke/include/lapacke_mangling.h
327 @rm -f *.grd Makefile.conf_last config_last.h