kusano 2b45e8
TOPDIR	= .
kusano 2b45e8
include ./Makefile.system
kusano 2b45e8
kusano 2b45e8
BLASDIRS = interface driver/level2 driver/level3 driver/others
kusano 2b45e8
kusano 2b45e8
ifndef DYNAMIC_ARCH
kusano 2b45e8
BLASDIRS += kernel 
kusano 2b45e8
endif
kusano 2b45e8
kusano 2b45e8
ifdef UTEST_CHECK
kusano 2b45e8
SANITY_CHECK = 1
kusano 2b45e8
endif
kusano 2b45e8
kusano 2b45e8
ifdef SANITY_CHECK
kusano 2b45e8
BLASDIRS += reference
kusano 2b45e8
endif
kusano 2b45e8
kusano 2b45e8
ifndef PREFIX
kusano 2b45e8
PREFIX = /opt/OpenBLAS
kusano 2b45e8
endif
kusano 2b45e8
kusano 2b45e8
SUBDIRS	= $(BLASDIRS)
kusano 2b45e8
ifneq ($(NO_LAPACK), 1)
kusano 2b45e8
SUBDIRS	+= lapack
kusano 2b45e8
endif
kusano 2b45e8
kusano 2b45e8
SUBDIRS_ALL = $(SUBDIRS) test ctest utest exports benchmark ../laswp ../bench
kusano 2b45e8
kusano 2b45e8
.PHONY : all libs netlib test ctest shared install
kusano 2b45e8
.NOTPARALLEL : all libs prof lapack-test install
kusano 2b45e8
kusano 2b45e8
all :: libs netlib tests shared
kusano 2b45e8
	@echo
kusano 2b45e8
	@echo " OpenBLAS build complete."
kusano 2b45e8
	@echo
kusano 2b45e8
	@echo "  OS               ... $(OSNAME)             "
kusano 2b45e8
	@echo "  Architecture     ... $(ARCH)               "
kusano 2b45e8
ifndef BINARY64
kusano 2b45e8
	@echo "  BINARY           ... 32bit                 "
kusano 2b45e8
else
kusano 2b45e8
	@echo "  BINARY           ... 64bit                 "
kusano 2b45e8
endif
kusano 2b45e8
ifdef INTERFACE64
kusano 2b45e8
	@echo "  Use 64 bits int    (equivalent to \"-i8\" in Fortran)      "
kusano 2b45e8
endif
kusano 2b45e8
	@echo "  C compiler       ... $(C_COMPILER)  (command line : $(CC))"
kusano 2b45e8
	@echo "  Fortran compiler ... $(F_COMPILER)  (command line : $(FC))"
kusano 2b45e8
ifneq ($(OSNAME), AIX)
kusano 2b45e8
	@echo -n "  Library Name     ... $(LIBNAME)"
kusano 2b45e8
else
kusano 2b45e8
	@echo "  Library Name     ... $(LIBNAME)"
kusano 2b45e8
endif
kusano 2b45e8
kusano 2b45e8
ifndef SMP
kusano 2b45e8
	@echo " (Single threaded)  "
kusano 2b45e8
else
kusano 2b45e8
	@echo " (Multi threaded; Max num-threads is $(NUM_THREADS))"
kusano 2b45e8
endif
kusano 2b45e8
kusano 2b45e8
ifeq ($(USE_OPENMP), 1)
kusano 2b45e8
	@echo
kusano 2b45e8
	@echo " Use OpenMP in the multithreading. Becasue of ignoring OPENBLAS_NUM_THREADS and GOTO_NUM_THREADS flags, "
kusano 2b45e8
	@echo " you should use OMP_NUM_THREADS environment variable to control the number of threads."
kusano 2b45e8
	@echo
kusano 2b45e8
endif
kusano 2b45e8
kusano 2b45e8
ifeq ($(OSNAME), Darwin)
kusano 2b45e8
	@echo "WARNING: If you plan to use the dynamic library $(LIBDYNNAME), you must run:"
kusano 2b45e8
	@echo
kusano 2b45e8
	@echo "\"make PREFIX=/your_installation_path/ install\"."
kusano 2b45e8
	@echo
kusano 2b45e8
	@echo "(or set PREFIX in Makefile.rule and run make install."
kusano 2b45e8
	@echo "If you want to move the .dylib to a new location later, make sure you change"
kusano 2b45e8
	@echo "the internal name of the dylib with:"
kusano 2b45e8
	@echo
kusano 2b45e8
	@echo "install_name_tool -id /new/absolute/path/to/$(LIBDYNNAME) $(LIBDYNNAME)"
kusano 2b45e8
endif
kusano 2b45e8
	@echo
kusano 2b45e8
	@echo "To install the library, you can run \"make PREFIX=/path/to/your/installation install\"."
kusano 2b45e8
	@echo
kusano 2b45e8
kusano 2b45e8
shared :
kusano 2b45e8
ifeq ($(OSNAME), Linux)
kusano 2b45e8
	$(MAKE) -C exports so
kusano 2b45e8
	-ln -fs $(LIBSONAME) $(LIBPREFIX).so
kusano 2b45e8
	-ln -fs $(LIBSONAME) $(LIBPREFIX).so.$(MAJOR_VERSION)
kusano 2b45e8
endif
kusano 2b45e8
ifeq ($(OSNAME), FreeBSD)
kusano 2b45e8
	$(MAKE) -C exports so
kusano 2b45e8
	-ln -fs $(LIBSONAME) $(LIBPREFIX).so
kusano 2b45e8
endif
kusano 2b45e8
ifeq ($(OSNAME), NetBSD)
kusano 2b45e8
	$(MAKE) -C exports so
kusano 2b45e8
	-ln -fs $(LIBSONAME) $(LIBPREFIX).so
kusano 2b45e8
endif
kusano 2b45e8
ifeq ($(OSNAME), Darwin)
kusano 2b45e8
	$(MAKE) -C exports dyn
kusano 2b45e8
	-ln -fs $(LIBDYNNAME) $(LIBPREFIX).dylib
kusano 2b45e8
endif
kusano 2b45e8
ifeq ($(OSNAME), WINNT)
kusano 2b45e8
	$(MAKE) -C exports dll
kusano 2b45e8
	-ln -fs $(LIBDLLNAME) $(LIBPREFIX).dll
kusano 2b45e8
endif
kusano 2b45e8
ifeq ($(OSNAME), CYGWIN_NT)
kusano 2b45e8
	$(MAKE) -C exports dll
kusano 2b45e8
	-ln -fs $(LIBDLLNAME) $(LIBPREFIX).dll
kusano 2b45e8
endif
kusano 2b45e8
kusano 2b45e8
tests :
kusano 2b45e8
ifndef NOFORTRAN
kusano 2b45e8
ifndef TARGET
kusano 2b45e8
ifndef CROSS
kusano 2b45e8
	touch $(LIBNAME)
kusano 2b45e8
ifndef NO_FBLAS
kusano 2b45e8
	$(MAKE) -C test all
kusano 2b45e8
ifdef UTEST_CHECK
kusano 2b45e8
	$(MAKE) -C utest all
kusano 2b45e8
endif
kusano 2b45e8
endif
kusano 2b45e8
ifndef NO_CBLAS
kusano 2b45e8
	$(MAKE) -C ctest all
kusano 2b45e8
endif
kusano 2b45e8
endif
kusano 2b45e8
endif
kusano 2b45e8
endif
kusano 2b45e8
kusano 2b45e8
libs :
kusano 2b45e8
ifeq ($(CORE), UNKOWN)
kusano 2b45e8
	$(error OpenBLAS: Detecting CPU failed. Please set TARGET explicitly, e.g. make TARGET=your_cpu_target. Please read README for the detail.)
kusano 2b45e8
endif
kusano 2b45e8
ifeq ($(NOFORTRAN), 1)
kusano 2b45e8
	$(error OpenBLAS: Detecting fortran compiler failed. Please install fortran compiler, e.g. gfortran, ifort, openf90.)
kusano 2b45e8
endif
kusano 2b45e8
	-ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
kusano 2b45e8
	for d in $(SUBDIRS) ; \
kusano 2b45e8
	do if test -d $$d; then \
kusano 2b45e8
	  $(MAKE) -C $$d $(@F) || exit 1 ; \
kusano 2b45e8
	fi; \
kusano 2b45e8
	done
kusano 2b45e8
#Save the config files for installation
kusano 2b45e8
	cp Makefile.conf Makefile.conf_last
kusano 2b45e8
	cp config.h config_last.h
kusano 2b45e8
ifdef QUAD_PRECISION
kusano 2b45e8
	echo "#define QUAD_PRECISION">> config_last.h
kusano 2b45e8
endif
kusano 2b45e8
ifeq ($(EXPRECISION), 1)
kusano 2b45e8
	echo "#define EXPRECISION">> config_last.h
kusano 2b45e8
endif
kusano 2b45e8
## 
kusano 2b45e8
ifdef DYNAMIC_ARCH
kusano 2b45e8
	  $(MAKE) -C kernel commonlibs || exit 1
kusano 2b45e8
	for d in $(DYNAMIC_CORE) ; \
kusano 2b45e8
	do  $(MAKE) GOTOBLAS_MAKEFILE= -C kernel TARGET_CORE=$$d kernel || exit 1 ;\
kusano 2b45e8
	done
kusano 2b45e8
	echo DYNAMIC_ARCH=1 >> Makefile.conf_last
kusano 2b45e8
endif
kusano 2b45e8
	touch lib.grd
kusano 2b45e8
kusano 2b45e8
prof : prof_blas prof_lapack
kusano 2b45e8
kusano 2b45e8
prof_blas :
kusano 2b45e8
	ln -fs $(LIBNAME_P) $(LIBPREFIX)_p.$(LIBSUFFIX)
kusano 2b45e8
	for d in $(SUBDIRS) ; \
kusano 2b45e8
	do if test -d $$d; then \
kusano 2b45e8
	  $(MAKE) -C $$d prof || exit 1 ; \
kusano 2b45e8
	fi; \
kusano 2b45e8
	done
kusano 2b45e8
ifdef DYNAMIC_ARCH
kusano 2b45e8
	  $(MAKE) -C kernel commonprof || exit 1
kusano 2b45e8
endif
kusano 2b45e8
kusano 2b45e8
blas :
kusano 2b45e8
	ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
kusano 2b45e8
	for d in $(BLASDIRS) ; \
kusano 2b45e8
	do if test -d $$d; then \
kusano 2b45e8
	  $(MAKE) -C $$d libs || exit 1 ; \
kusano 2b45e8
	fi; \
kusano 2b45e8
	done
kusano 2b45e8
kusano 2b45e8
hpl : 
kusano 2b45e8
	ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
kusano 2b45e8
	for d in $(BLASDIRS) ../laswp exports ; \
kusano 2b45e8
	do if test -d $$d; then \
kusano 2b45e8
	  $(MAKE) -C $$d $(@F) || exit 1 ; \
kusano 2b45e8
	fi; \
kusano 2b45e8
	done
kusano 2b45e8
ifdef DYNAMIC_ARCH
kusano 2b45e8
	  $(MAKE) -C kernel commonlibs || exit 1
kusano 2b45e8
	for d in $(DYNAMIC_CORE) ; \
kusano 2b45e8
	do  $(MAKE) GOTOBLAS_MAKEFILE= -C kernel TARGET_CORE=$$d kernel || exit 1 ;\
kusano 2b45e8
	done
kusano 2b45e8
endif
kusano 2b45e8
kusano 2b45e8
hpl_p :
kusano 2b45e8
	ln -fs $(LIBNAME_P) $(LIBPREFIX)_p.$(LIBSUFFIX)
kusano 2b45e8
	for d in $(SUBDIRS) ../laswp exports ; \
kusano 2b45e8
	do if test -d $$d; then \
kusano 2b45e8
	  $(MAKE) -C $$d $(@F) || exit 1 ; \
kusano 2b45e8
	fi; \
kusano 2b45e8
	done
kusano 2b45e8
kusano 2b45e8
ifeq ($(NO_LAPACK), 1)
kusano 2b45e8
netlib : 
kusano 2b45e8
kusano 2b45e8
else
kusano 2b45e8
netlib : lapack-3.4.1 patch.for_lapack-3.4.1 $(NETLIB_LAPACK_DIR)/make.inc
kusano 2b45e8
ifndef NOFORTRAN
kusano 2b45e8
	-@$(MAKE) -C $(NETLIB_LAPACK_DIR) lapacklib
kusano 2b45e8
endif
kusano 2b45e8
ifndef NO_LAPACKE
kusano 2b45e8
	-@$(MAKE) -C $(NETLIB_LAPACK_DIR) lapackelib
kusano 2b45e8
endif
kusano 2b45e8
endif
kusano 2b45e8
kusano 2b45e8
prof_lapack : lapack-3.4.1 $(NETLIB_LAPACK_DIR)/make.inc
kusano 2b45e8
	-@$(MAKE) -C $(NETLIB_LAPACK_DIR) lapack_prof
kusano 2b45e8
kusano 2b45e8
$(NETLIB_LAPACK_DIR)/make.inc :
kusano 2b45e8
ifndef NOFORTRAN
kusano 2b45e8
	-@echo "FORTRAN     = $(FC)" > $(NETLIB_LAPACK_DIR)/make.inc
kusano 2b45e8
	-@echo "OPTS        = $(FFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
kusano 2b45e8
	-@echo "POPTS       = $(FPFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
kusano 2b45e8
	-@echo "NOOPT       = $(FFLAGS) -O0" >> $(NETLIB_LAPACK_DIR)/make.inc
kusano 2b45e8
	-@echo "PNOOPT      = $(FPFLAGS) -O0" >> $(NETLIB_LAPACK_DIR)/make.inc
kusano 2b45e8
	-@echo "LOADOPTS    = $(FFLAGS) $(EXTRALIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
kusano 2b45e8
	-@echo "CC          = $(CC)" >> $(NETLIB_LAPACK_DIR)/make.inc
kusano 2b45e8
	-@echo "CFLAGS      = $(CFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
kusano 2b45e8
	-@echo "ARCH        = $(AR)" >> $(NETLIB_LAPACK_DIR)/make.inc
kusano 2b45e8
	-@echo "ARCHFLAGS   = -ru" >> $(NETLIB_LAPACK_DIR)/make.inc
kusano 2b45e8
	-@echo "RANLIB      = $(RANLIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
kusano 2b45e8
	-@echo "LAPACKLIB   = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
kusano 2b45e8
	-@echo "LAPACKELIB  = ../$(LIBNAME)" >> $(NETLIB_LAPACK_DIR)/make.inc
kusano 2b45e8
	-@echo "LAPACKLIB_P = ../$(LIBNAME_P)" >> $(NETLIB_LAPACK_DIR)/make.inc
kusano 2b45e8
	-@echo "SUFFIX      = $(SUFFIX)" >> $(NETLIB_LAPACK_DIR)/make.inc
kusano 2b45e8
	-@echo "PSUFFIX     = $(PSUFFIX)" >> $(NETLIB_LAPACK_DIR)/make.inc
kusano 2b45e8
#	-@echo "CEXTRALIB   = $(CEXTRALIB)" >> $(NETLIB_LAPACK_DIR)/make.inc
kusano 2b45e8
	-@cat  make.inc >> $(NETLIB_LAPACK_DIR)/make.inc
kusano 2b45e8
endif
kusano 2b45e8
kusano 2b45e8
lapack-3.4.1 : lapack-3.4.1.tgz
kusano 2b45e8
ifndef NOFORTRAN
kusano 2b45e8
ifndef NO_LAPACK
kusano 2b45e8
	@if test `$(MD5SUM) lapack-3.4.1.tgz | $(AWK) '{print $$1}'` = 44c3869c38c8335c2b9c2a8bb276eb55; then \
kusano 2b45e8
		echo $(TAR) zxf $< ;\
kusano 2b45e8
		$(TAR) zxf $< && (cd $(NETLIB_LAPACK_DIR); $(PATCH) -p1 < ../patch.for_lapack-3.4.1) ;\
kusano 2b45e8
		rm -f $(NETLIB_LAPACK_DIR)/lapacke/make.inc ;\
kusano 2b45e8
	else \
kusano 2b45e8
		rm -rf $(NETLIB_LAPACK_DIR) ;\
kusano 2b45e8
		echo "	Cannot download lapack-3.4.1.tgz or the MD5 check sum is wrong (Please use orignal)."; \
kusano 2b45e8
		exit 1; \
kusano 2b45e8
	fi
kusano 2b45e8
endif
kusano 2b45e8
endif
kusano 2b45e8
kusano 2b45e8
LAPACK_URL=http://www.netlib.org/lapack/lapack-3.4.1.tgz
kusano 2b45e8
kusano 2b45e8
lapack-3.4.1.tgz :
kusano 2b45e8
ifndef NOFORTRAN
kusano 2b45e8
ifeq ($(OSNAME), Darwin)
kusano 2b45e8
	curl -O $(LAPACK_URL)
kusano 2b45e8
else
kusano 2b45e8
	wget $(LAPACK_URL)
kusano 2b45e8
endif
kusano 2b45e8
endif
kusano 2b45e8
kusano 2b45e8
large.tgz : 
kusano 2b45e8
ifndef NOFORTRAN
kusano 2b45e8
	-wget http://www.netlib.org/lapack/timing/large.tgz
kusano 2b45e8
endif
kusano 2b45e8
kusano 2b45e8
timing.tgz :
kusano 2b45e8
ifndef NOFORTRAN
kusano 2b45e8
	-wget http://www.netlib.org/lapack/timing/timing.tgz
kusano 2b45e8
endif
kusano 2b45e8
kusano 2b45e8
lapack-timing : lapack-3.4.1 large.tgz timing.tgz
kusano 2b45e8
ifndef NOFORTRAN
kusano 2b45e8
	(cd $(NETLIB_LAPACK_DIR); $(TAR) zxf ../timing.tgz TIMING)
kusano 2b45e8
	(cd $(NETLIB_LAPACK_DIR)/TIMING; $(TAR) zxf ../../large.tgz )
kusano 2b45e8
	make -C $(NETLIB_LAPACK_DIR) tmglib
kusano 2b45e8
	make -C $(NETLIB_LAPACK_DIR)/TIMING
kusano 2b45e8
endif
kusano 2b45e8
kusano 2b45e8
kusano 2b45e8
lapack-test :
kusano 2b45e8
	$(MAKE) -C $(NETLIB_LAPACK_DIR) tmglib
kusano 2b45e8
	$(MAKE) -C $(NETLIB_LAPACK_DIR)/TESTING xeigtstc xeigtstd xeigtsts xeigtstz xlintstc xlintstd xlintstds xlintsts xlintstz xlintstzc
kusano 2b45e8
	@rm	-f $(NETLIB_LAPACK_DIR)/TESTING/*.out
kusano 2b45e8
	$(MAKE) -j 1 -C $(NETLIB_LAPACK_DIR)/TESTING
kusano 2b45e8
	$(GREP) failed $(NETLIB_LAPACK_DIR)/TESTING/*.out
kusano 2b45e8
kusano 2b45e8
dummy :
kusano 2b45e8
kusano 2b45e8
install :
kusano 2b45e8
	$(MAKE) -f Makefile.install install
kusano 2b45e8
kusano 2b45e8
clean ::
kusano 2b45e8
	@for d in $(SUBDIRS_ALL) ; \
kusano 2b45e8
	do if test -d $$d; then \
kusano 2b45e8
	  $(MAKE) -C $$d $(@F) || exit 1 ; \
kusano 2b45e8
	fi; \
kusano 2b45e8
	done
kusano 2b45e8
#ifdef DYNAMIC_ARCH
kusano 2b45e8
	@$(MAKE) -C kernel clean
kusano 2b45e8
#endif
kusano 2b45e8
	@$(MAKE) -C reference clean
kusano 2b45e8
	@rm -f *.$(LIBSUFFIX) *.so *~ *.exe getarch getarch_2nd *.dll *.lib *.$(SUFFIX) *.dwf $(LIBPREFIX).$(LIBSUFFIX) $(LIBPREFIX)_p.$(LIBSUFFIX) $(LIBPREFIX).so.$(MAJOR_VERSION) *.lnk myconfig.h
kusano 2b45e8
	@rm -f Makefile.conf config.h Makefile_kernel.conf config_kernel.h st* *.dylib
kusano 2b45e8
	@if test -d $(NETLIB_LAPACK_DIR); then \
kusano 2b45e8
	echo deleting $(NETLIB_LAPACK_DIR); \
kusano 2b45e8
	rm -rf $(NETLIB_LAPACK_DIR) ;\
kusano 2b45e8
	fi
kusano 2b45e8
	@rm -f *.grd Makefile.conf_last config_last.h
kusano 2b45e8
	@echo Done.