fix build error
[platform/upstream/openblas.git] / Makefile
1 TOPDIR  = .
2 include ./Makefile.system
3
4 BLASDIRS = interface driver/level2 driver/level3 driver/others
5
6 ifneq ($(DYNAMIC_ARCH), 1)
7 BLASDIRS += kernel
8 endif
9
10 ifdef SANITY_CHECK
11 BLASDIRS += reference
12 endif
13
14 SUBDIRS = $(BLASDIRS)
15 ifneq ($(NO_LAPACK), 1)
16 SUBDIRS += lapack
17 endif
18
19 RELA =
20 ifeq ($(BUILD_RELAPACK), 1)
21 RELA = re_lapack
22 endif
23
24 LAPACK_NOOPT := $(filter-out -O0 -O1 -O2 -O3 -Ofast,$(LAPACK_FFLAGS))
25
26 SUBDIRS_ALL = $(SUBDIRS) test ctest utest exports benchmark ../laswp ../bench
27
28 .PHONY : all libs netlib $(RELA) test ctest shared install
29 .NOTPARALLEL : all libs $(RELA) prof lapack-test install blas-test
30
31 all :: libs netlib $(RELA) tests shared
32         @echo
33         @echo " OpenBLAS build complete. ($(LIB_COMPONENTS))"
34         @echo
35         @echo "  OS               ... $(OSNAME)             "
36         @echo "  Architecture     ... $(ARCH)               "
37 ifndef BINARY64
38         @echo "  BINARY           ... 32bit                 "
39 else
40         @echo "  BINARY           ... 64bit                 "
41 endif
42
43 ifdef INTERFACE64
44 ifneq ($(INTERFACE64), 0)
45         @echo "  Use 64 bits int    (equivalent to \"-i8\" in Fortran)      "
46 endif
47 endif
48
49         @echo "  C compiler       ... $(C_COMPILER)  (command line : $(CC))"
50 ifndef NOFORTRAN
51         @echo "  Fortran compiler ... $(F_COMPILER)  (command line : $(FC))"
52 endif
53 ifneq ($(OSNAME), AIX)
54         @echo -n "  Library Name     ... $(LIBNAME)"
55 else
56         @echo "  Library Name     ... $(LIBNAME)"
57 endif
58
59 ifndef SMP
60         @echo " (Single threaded)  "
61 else
62         @echo " (Multi threaded; Max num-threads is $(NUM_THREADS))"
63 endif
64
65 ifeq ($(USE_OPENMP), 1)
66         @echo
67         @echo " Use OpenMP in the multithreading. Because of ignoring OPENBLAS_NUM_THREADS and GOTO_NUM_THREADS flags, "
68         @echo " you should use OMP_NUM_THREADS environment variable to control the number of threads."
69         @echo
70 endif
71
72 ifeq ($(OSNAME), Darwin)
73         @echo "WARNING: If you plan to use the dynamic library $(LIBDYNNAME), you must run:"
74         @echo
75         @echo "\"make PREFIX=/your_installation_path/ install\"."
76         @echo
77         @echo "(or set PREFIX in Makefile.rule and run make install."
78         @echo "If you want to move the .dylib to a new location later, make sure you change"
79         @echo "the internal name of the dylib with:"
80         @echo
81         @echo "install_name_tool -id /new/absolute/path/to/$(LIBDYNNAME) $(LIBDYNNAME)"
82 endif
83         @echo
84         @echo "To install the library, you can run \"make PREFIX=/path/to/your/installation install\"."
85         @echo
86
87 shared :
88 ifndef NO_SHARED
89 ifeq ($(OSNAME), $(filter $(OSNAME),Linux SunOS Android))
90         @$(MAKE) -C exports so
91         @ln -fs $(LIBSONAME) $(LIBPREFIX).so
92         @ln -fs $(LIBSONAME) $(LIBPREFIX).so.$(MAJOR_VERSION)
93 endif
94 ifeq ($(OSNAME), FreeBSD)
95         @$(MAKE) -C exports so
96         @ln -fs $(LIBSONAME) $(LIBPREFIX).so
97 endif
98 ifeq ($(OSNAME), NetBSD)
99         @$(MAKE) -C exports so
100         @ln -fs $(LIBSONAME) $(LIBPREFIX).so
101 endif
102 ifeq ($(OSNAME), Darwin)
103         @$(MAKE) -C exports dyn
104         @ln -fs $(LIBDYNNAME) $(LIBPREFIX).dylib
105 endif
106 ifeq ($(OSNAME), WINNT)
107         @$(MAKE) -C exports dll
108 endif
109 ifeq ($(OSNAME), CYGWIN_NT)
110         @$(MAKE) -C exports dll
111 endif
112 endif
113
114 tests :
115 ifndef NOFORTRAN
116         touch $(LIBNAME)
117 ifndef NO_FBLAS
118         $(MAKE) -C test all
119         $(MAKE) -C utest all
120 endif
121 ifndef NO_CBLAS
122         $(MAKE) -C ctest all
123 endif
124 endif
125
126 libs :
127 ifeq ($(CORE), UNKOWN)
128         $(error OpenBLAS: Detecting CPU failed. Please set TARGET explicitly, e.g. make TARGET=your_cpu_target. Please read README for the detail.)
129 endif
130 ifeq ($(NOFORTRAN), 1)
131         $(info OpenBLAS: Detecting fortran compiler failed. Cannot compile LAPACK. Only compile BLAS.)
132 endif
133 ifeq ($(NO_STATIC), 1)
134 ifeq ($(NO_SHARED), 1)
135         $(error OpenBLAS: neither static nor shared are enabled.)
136 endif
137 endif
138         @-ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
139         @for d in $(SUBDIRS) ; \
140         do if test -d $$d; then \
141           $(MAKE) -C $$d $(@F) || exit 1 ; \
142         fi; \
143         done
144 #Save the config files for installation
145         @cp Makefile.conf Makefile.conf_last
146         @cp config.h config_last.h
147 ifdef QUAD_PRECISION
148         @echo "#define QUAD_PRECISION">> config_last.h
149 endif
150 ifeq ($(EXPRECISION), 1)
151         @echo "#define EXPRECISION">> config_last.h
152 endif
153 ##
154 ifeq ($(DYNAMIC_ARCH), 1)
155         @$(MAKE) -C kernel commonlibs || exit 1
156         @for d in $(DYNAMIC_CORE) ; \
157         do  $(MAKE) GOTOBLAS_MAKEFILE= -C kernel TARGET_CORE=$$d kernel || exit 1 ;\
158         done
159         @echo DYNAMIC_ARCH=1 >> Makefile.conf_last
160 endif
161 ifdef USE_THREAD
162         @echo USE_THREAD=$(USE_THREAD) >>  Makefile.conf_last
163 endif
164         @touch lib.grd
165
166 prof : prof_blas prof_lapack
167
168 prof_blas :
169         ln -fs $(LIBNAME_P) $(LIBPREFIX)_p.$(LIBSUFFIX)
170         for d in $(SUBDIRS) ; \
171         do if test -d $$d; then \
172           $(MAKE) -C $$d prof || exit 1 ; \
173         fi; \
174         done
175 ifeq ($(DYNAMIC_ARCH), 1)
176           $(MAKE) -C kernel commonprof || exit 1
177 endif
178
179 blas :
180         ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
181         for d in $(BLASDIRS) ; \
182         do if test -d $$d; then \
183           $(MAKE) -C $$d libs || exit 1 ; \
184         fi; \
185         done
186
187 hpl :
188         ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
189         for d in $(BLASDIRS) ../laswp exports ; \
190         do if test -d $$d; then \
191           $(MAKE) -C $$d $(@F) || exit 1 ; \
192         fi; \
193         done
194 ifeq ($(DYNAMIC_ARCH), 1)
195           $(MAKE) -C kernel commonlibs || exit 1
196         for d in $(DYNAMIC_CORE) ; \
197         do  $(MAKE) GOTOBLAS_MAKEFILE= -C kernel TARGET_CORE=$$d kernel || exit 1 ;\
198         done
199 endif
200
201 hpl_p :
202         ln -fs $(LIBNAME_P) $(LIBPREFIX)_p.$(LIBSUFFIX)
203         for d in $(SUBDIRS) ../laswp exports ; \
204         do if test -d $$d; then \
205           $(MAKE) -C $$d $(@F) || exit 1 ; \
206         fi; \
207         done
208
209 ifeq ($(NO_LAPACK), 1)
210 netlib :
211
212 else
213 netlib : lapack_prebuild
214 ifndef NOFORTRAN
215         @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapacklib
216         @$(MAKE) -C $(NETLIB_LAPACK_DIR) tmglib
217 endif
218 ifndef NO_LAPACKE
219         @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapackelib
220 endif
221 endif
222
223 ifeq ($(NO_LAPACK), 1)
224 re_lapack :
225
226 else
227 re_lapack :
228         @$(MAKE) -C relapack
229 endif
230
231 prof_lapack : lapack_prebuild
232         @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapack_prof
233
234 lapack_prebuild :
235 ifndef NOFORTRAN
236         -@echo "FORTRAN     = $(FC)" > $(NETLIB_LAPACK_DIR)/make.inc
237         -@echo "OPTS        = $(LAPACK_FFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
238         -@echo "POPTS       = $(LAPACK_FPFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
239         -@echo "NOOPT       = -O0 $(LAPACK_NOOPT)" >> $(NETLIB_LAPACK_DIR)/make.inc
240         -@echo "PNOOPT      = $(LAPACK_FPFLAGS) -O0" >> $(NETLIB_LAPACK_DIR)/make.inc
241         -@echo "LOADOPTS    = $(FFLAGS) $(EXTRALIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
242         -@echo "CC          = $(CC)" >> $(NETLIB_LAPACK_DIR)/make.inc
243         -@echo "override CFLAGS      = $(LAPACK_CFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
244         -@echo "ARCH        = $(AR)" >> $(NETLIB_LAPACK_DIR)/make.inc
245         -@echo "ARCHFLAGS   = -ru" >> $(NETLIB_LAPACK_DIR)/make.inc
246         -@echo "RANLIB      = $(RANLIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
247         -@echo "LAPACKLIB   = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
248         -@echo "TMGLIB      = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
249         -@echo "BLASLIB     = ../../../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
250         -@echo "LAPACKELIB  = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
251         -@echo "LAPACKLIB_P = ../$(LIBNAME_P)" >> $(NETLIB_LAPACK_DIR)/make.inc
252         -@echo "SUFFIX      = $(SUFFIX)" >> $(NETLIB_LAPACK_DIR)/make.inc
253         -@echo "PSUFFIX     = $(PSUFFIX)" >> $(NETLIB_LAPACK_DIR)/make.inc
254         -@echo "CEXTRALIB   = $(EXTRALIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
255 ifeq ($(F_COMPILER), GFORTRAN)
256         -@echo "TIMER       = INT_ETIME" >> $(NETLIB_LAPACK_DIR)/make.inc
257 ifdef SMP
258 ifeq ($(OSNAME), WINNT)
259         -@echo "LOADER      = $(FC)" >> $(NETLIB_LAPACK_DIR)/make.inc
260 else
261         -@echo "LOADER      = $(FC) -pthread" >> $(NETLIB_LAPACK_DIR)/make.inc
262 endif
263 else
264         -@echo "LOADER      = $(FC)" >> $(NETLIB_LAPACK_DIR)/make.inc
265 endif
266 else
267         -@echo "TIMER       = NONE" >> $(NETLIB_LAPACK_DIR)/make.inc
268         -@echo "LOADER      = $(FC)" >> $(NETLIB_LAPACK_DIR)/make.inc
269 endif
270 ifeq ($(BUILD_LAPACK_DEPRECATED), 1)
271         -@echo "BUILD_DEPRECATED      = 1" >> $(NETLIB_LAPACK_DIR)/make.inc
272 endif
273         -@cat  make.inc >> $(NETLIB_LAPACK_DIR)/make.inc
274 endif
275
276 large.tgz :
277 ifndef NOFORTRAN
278         if [ ! -a $< ]; then
279         -wget http://www.netlib.org/lapack/timing/large.tgz;
280         fi
281 endif
282
283 timing.tgz :
284 ifndef NOFORTRAN
285         if [ ! -a $< ]; then
286         -wget http://www.netlib.org/lapack/timing/timing.tgz;
287         fi
288 endif
289
290 lapack-timing : large.tgz timing.tgz
291 ifndef NOFORTRAN
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)/TIMING
295 endif
296
297
298 lapack-test :
299         (cd $(NETLIB_LAPACK_DIR)/TESTING && rm -f x* *.out)
300         $(MAKE) -j 1 -C $(NETLIB_LAPACK_DIR)/TESTING xeigtstc  xeigtstd  xeigtsts  xeigtstz  xlintstc  xlintstd  xlintstds  xlintstrfd  xlintstrfz  xlintsts  xlintstz  xlintstzc xlintstrfs xlintstrfc
301 ifneq ($(CROSS), 1)
302         ( cd $(NETLIB_LAPACK_DIR)/INSTALL; ./testlsame; ./testslamch; ./testdlamch; \
303         ./testsecond; ./testdsecnd; ./testieee; ./testversion )
304         (cd $(NETLIB_LAPACK_DIR); ./lapack_testing.py -r )
305 endif
306
307 lapack-runtest:
308         ( cd $(NETLIB_LAPACK_DIR)/INSTALL; ./testlsame; ./testslamch; ./testdlamch; \
309         ./testsecond; ./testdsecnd; ./testieee; ./testversion )
310         (cd $(NETLIB_LAPACK_DIR); ./lapack_testing.py -r )
311
312
313 blas-test:
314         (cd $(NETLIB_LAPACK_DIR)/BLAS && rm -f x* *.out)
315         $(MAKE) -j 1 -C $(NETLIB_LAPACK_DIR) blas_testing
316         (cd $(NETLIB_LAPACK_DIR)/BLAS && cat *.out)
317
318
319 dummy :
320
321 install :
322         $(MAKE) -f Makefile.install install
323
324 clean ::
325         @for d in $(SUBDIRS_ALL) ; \
326         do if test -d $$d; then \
327           $(MAKE) -C $$d $(@F) || exit 1 ; \
328         fi; \
329         done
330 #ifdef DYNAMIC_ARCH
331         @$(MAKE) -C kernel clean
332 #endif
333         @$(MAKE) -C reference clean
334         @rm -f *.$(LIBSUFFIX) *.so *~ *.exe getarch getarch_2nd *.dll *.lib *.$(SUFFIX) *.dwf $(LIBPREFIX).$(LIBSUFFIX) $(LIBPREFIX)_p.$(LIBSUFFIX) $(LIBPREFIX).so.$(MAJOR_VERSION) *.lnk myconfig.h
335 ifeq ($(OSNAME), Darwin)
336         @rm -rf getarch.dSYM getarch_2nd.dSYM
337 endif
338         @rm -f Makefile.conf config.h Makefile_kernel.conf config_kernel.h st* *.dylib
339         @touch $(NETLIB_LAPACK_DIR)/make.inc
340         @$(MAKE) -C $(NETLIB_LAPACK_DIR) clean
341         @rm -f $(NETLIB_LAPACK_DIR)/make.inc $(NETLIB_LAPACK_DIR)/lapacke/include/lapacke_mangling.h
342         @$(MAKE) -C relapack clean
343         @rm -f *.grd Makefile.conf_last config_last.h
344         @(cd $(NETLIB_LAPACK_DIR)/TESTING && rm -f x* *.out testing_results.txt)
345         @echo Done.