Merge pull request #366 from xantares/patch-1
[platform/upstream/openblas.git] / Makefile.install
1 TOPDIR  = .
2 export GOTOBLAS_MAKEFILE = 1
3 -include $(TOPDIR)/Makefile.conf_last
4 include ./Makefile.system
5
6 PREFIX ?= /opt/OpenBLAS
7
8 OPENBLAS_INCLUDE_DIR := $(PREFIX)/include
9 OPENBLAS_LIBRARY_DIR := $(PREFIX)/lib
10 OPENBLAS_BINARY_DIR := $(PREFIX)/bin
11 OPENBLAS_BUILD_DIR := $(CURDIR)
12
13 .PHONY : install
14 .NOTPARALLEL : install
15
16 lib.grd :
17         $(error OpenBLAS: Please run "make" firstly)
18
19 install :       lib.grd
20         @-mkdir -p $(DESTDIR)$(PREFIX)
21         @-mkdir -p $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)
22         @-mkdir -p $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
23         @echo Generating openblas_config.h in $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)
24 #for inc 
25         @echo \#ifndef OPENBLAS_CONFIG_H > $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/openblas_config.h
26         @echo \#define OPENBLAS_CONFIG_H >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/openblas_config.h
27         @awk 'NF {print $$1, "OPENBLAS_"$$2, $$3}' config_last.h >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/openblas_config.h
28         @echo \#define OPENBLAS_VERSION \" OpenBLAS $(VERSION) \" >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/openblas_config.h
29         @cat openblas_config_template.h >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/openblas_config.h
30         @echo \#endif  \/\* OPENBLAS_CONFIG_H \*\/ >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/openblas_config.h
31
32         @echo Generating f77blas.h in $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)
33         @echo \#ifndef OPENBLAS_F77BLAS_H > $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/f77blas.h
34         @echo \#define OPENBLAS_F77BLAS_H >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/f77blas.h
35         @echo \#include \"openblas_config.h\" >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/f77blas.h
36         @cat common_interface.h >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/f77blas.h
37         @echo \#endif >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/f77blas.h
38
39 ifndef NO_CBLAS
40         @echo Generating cblas.h in $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)
41         @sed 's/common/openblas_config/g' cblas.h > $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/cblas.h
42 endif
43
44 ifndef NO_LAPACKE
45         @echo Copying LAPACKE header files to $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
46         @-install -pDm644 $(NETLIB_LAPACK_DIR)/lapacke/include/lapacke.h $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/lapacke.h
47         @-install -pDm644 $(NETLIB_LAPACK_DIR)/lapacke/include/lapacke_config.h $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/lapacke_config.h
48         @-install -pDm644 $(NETLIB_LAPACK_DIR)/lapacke/include/lapacke_mangling_with_flags.h $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/lapacke_mangling.h
49         @-install -pDm644 $(NETLIB_LAPACK_DIR)/lapacke/include/lapacke_utils.h $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/lapacke_utils.h
50 endif
51
52 #for install static library 
53         @echo Copying the static library to $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
54         @install -pm644 $(LIBNAME) $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
55         @cd $(DESTDIR)$(OPENBLAS_LIBRARY_DIR) ; \
56         ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
57 #for install shared library 
58 ifndef NO_SHARED
59         @echo Copying the shared library to $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
60 ifeq ($(OSNAME), Linux)
61         @install -pm755 $(LIBSONAME) $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
62         @cd $(DESTDIR)$(OPENBLAS_LIBRARY_DIR) ; \
63         ln -fs $(LIBSONAME) $(LIBPREFIX).so ; \
64         ln -fs $(LIBSONAME) $(LIBPREFIX).so.$(MAJOR_VERSION)
65 endif
66 ifeq ($(OSNAME), FreeBSD)
67         @cp $(LIBSONAME) $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
68         @cd $(DESTDIR)$(OPENBLAS_LIBRARY_DIR) ; \
69         ln -fs $(LIBSONAME) $(LIBPREFIX).so
70 endif
71 ifeq ($(OSNAME), NetBSD)
72         @cp $(LIBSONAME) $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
73         @cd $(DESTDIR)$(OPENBLAS_LIBRARY_DIR) ; \
74         ln -fs $(LIBSONAME) $(LIBPREFIX).so
75 endif
76 ifeq ($(OSNAME), Darwin)     
77         @-cp $(LIBDYNNAME) $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
78         @-install_name_tool -id $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)/$(LIBDYNNAME) $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)/$(LIBDYNNAME)
79         @-ln -fs $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)/$(LIBDYNNAME) $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)/$(LIBPREFIX).dylib
80 endif
81 ifeq ($(OSNAME), WINNT)
82         @-cp $(LIBDLLNAME) $(OPENBLAS_BINARY_DIR)
83 endif
84 ifeq ($(OSNAME), CYGWIN_NT)
85         @-cp $(LIBDLLNAME) $(OPENBLAS_BINARY_DIR)
86 endif
87 endif
88
89         @echo Install OK!
90