Merge pull request #399 from TimothyGu/upstr
[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         @-mkdir -p $(DESTDIR)$(OPENBLAS_BINARY_DIR)
24         @echo Generating openblas_config.h in $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)
25 #for inc 
26         @echo \#ifndef OPENBLAS_CONFIG_H > $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/openblas_config.h
27         @echo \#define OPENBLAS_CONFIG_H >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/openblas_config.h
28         @awk 'NF {print $$1, "OPENBLAS_"$$2, $$3}' config_last.h >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/openblas_config.h
29         @echo \#define OPENBLAS_VERSION \" OpenBLAS $(VERSION) \" >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/openblas_config.h
30         @cat openblas_config_template.h >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/openblas_config.h
31         @echo \#endif  \/\* OPENBLAS_CONFIG_H \*\/ >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/openblas_config.h
32
33         @echo Generating f77blas.h in $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)
34         @echo \#ifndef OPENBLAS_F77BLAS_H > $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/f77blas.h
35         @echo \#define OPENBLAS_F77BLAS_H >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/f77blas.h
36         @echo \#include \"openblas_config.h\" >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/f77blas.h
37         @cat common_interface.h >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/f77blas.h
38         @echo \#endif >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/f77blas.h
39
40 ifndef NO_CBLAS
41         @echo Generating cblas.h in $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)
42         @sed 's/common/openblas_config/g' cblas.h > $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/cblas.h
43 endif
44
45 ifndef NO_LAPACKE
46         @echo Copying LAPACKE header files to $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
47         @-install -pDm644 $(NETLIB_LAPACK_DIR)/lapacke/include/lapacke.h $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/lapacke.h
48         @-install -pDm644 $(NETLIB_LAPACK_DIR)/lapacke/include/lapacke_config.h $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/lapacke_config.h
49         @-install -pDm644 $(NETLIB_LAPACK_DIR)/lapacke/include/lapacke_mangling_with_flags.h $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/lapacke_mangling.h
50         @-install -pDm644 $(NETLIB_LAPACK_DIR)/lapacke/include/lapacke_utils.h $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/lapacke_utils.h
51 endif
52
53 #for install static library 
54 ifndef NO_STATIC
55         @echo Copying the static library to $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
56         @install -pm644 $(LIBNAME) $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
57         @cd $(DESTDIR)$(OPENBLAS_LIBRARY_DIR) ; \
58         ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
59 endif
60 #for install shared library 
61 ifndef NO_SHARED
62         @echo Copying the shared library to $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
63 ifeq ($(OSNAME), Linux)
64         @install -pm755 $(LIBSONAME) $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
65         @cd $(DESTDIR)$(OPENBLAS_LIBRARY_DIR) ; \
66         ln -fs $(LIBSONAME) $(LIBPREFIX).so ; \
67         ln -fs $(LIBSONAME) $(LIBPREFIX).so.$(MAJOR_VERSION)
68 endif
69 ifeq ($(OSNAME), FreeBSD)
70         @cp $(LIBSONAME) $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
71         @cd $(DESTDIR)$(OPENBLAS_LIBRARY_DIR) ; \
72         ln -fs $(LIBSONAME) $(LIBPREFIX).so
73 endif
74 ifeq ($(OSNAME), NetBSD)
75         @cp $(LIBSONAME) $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
76         @cd $(DESTDIR)$(OPENBLAS_LIBRARY_DIR) ; \
77         ln -fs $(LIBSONAME) $(LIBPREFIX).so
78 endif
79 ifeq ($(OSNAME), Darwin)     
80         @-cp $(LIBDYNNAME) $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
81         @-install_name_tool -id $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)/$(LIBDYNNAME) $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)/$(LIBDYNNAME)
82         @-ln -fs $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)/$(LIBDYNNAME) $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)/$(LIBPREFIX).dylib
83 endif
84 ifeq ($(OSNAME), WINNT)
85         @-cp $(LIBDLLNAME) $(OPENBLAS_BINARY_DIR)
86         @-cp $(LIBDLLNAME).a $(OPENBLAS_LIBRARY_DIR)
87 endif
88 ifeq ($(OSNAME), CYGWIN_NT)
89         @-cp $(LIBDLLNAME) $(OPENBLAS_BINARY_DIR)
90 endif
91 endif
92
93         @echo Install OK!
94