cross-compile.env: add oe_cmake
[opendreambox.git] / cross-compile.env
1 #!/bin/bash
2 #
3 # Copyright (c) 2016 Dream Property GmbH, Germany
4 #                    https://dreambox.de/
5 # Author:
6 #   Andreas Oberritter <obi@opendreambox.org>
7 #
8 # Permission is hereby granted, free of charge, to any person obtaining a copy
9 # of this software and associated documentation files (the "Software"), to deal
10 # in the Software without restriction, including without limitation the rights
11 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 # copies of the Software, and to permit persons to whom the Software is
13 # furnished to do so, subject to the following conditions:
14 #
15 # The above copyright notice and this permission notice shall be included in
16 # all copies or substantial portions of the Software.
17 #
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 # THE SOFTWARE.
25 #
26
27 oe_set_aliases()
28 {
29         local SCRIPT="${BASH_SOURCE[0]}"
30         if [ -z "${SCRIPT}" ]; then
31                 echo "Could not determine script location! Not using bash?"
32                 return
33         fi
34         while [ -h "${SCRIPT}" ]; do
35                 SCRIPT="$(readlink "${SCRIPT}")"
36         done
37
38         local SCRIPTDIR="$(cd -P `dirname "${SCRIPT}"` && pwd)"
39         local MACHINE="$1"
40         local MACHINE_ENV=".cross-compile-${MACHINE}.env"
41         local MAKE=${MAKE:-make}
42
43         ${MAKE} -C "${SCRIPTDIR}" -s MACHINE=${MACHINE} ${MACHINE_ENV} || echo "Trying to continue with possibly outdated environment."
44         . ${SCRIPTDIR}/${MACHINE_ENV} || return
45
46         PATH="${STAGING_BINDIR_NATIVE}/python-native:${PATH}"
47
48         local OE_ENV=" \
49                 BUILD_SYS=\"${BUILD_SYS}\" \
50                 HOST_SYS=\"${HOST_SYS}\" \
51                 STAGING_LIBDIR=\"${STAGING_LIBDIR}\" \
52                 STAGING_INCDIR=\"${STAGING_INCDIR}\" \
53                 PATH=\"${PATH}\" \
54                 CC=\"${CC}\" \
55                 CXX=\"${CXX}\" \
56                 F77=\"${F77}\" \
57                 CPP=\"${CPP}\" \
58                 LD=\"${LD}\" \
59                 CCLD=\"${CCLD}\" \
60                 AR=\"${AR}\" \
61                 AS=\"${AS}\" \
62                 RANLIB=\"${RANLIB}\" \
63                 STRIP=\"${STRIP}\" \
64                 OBJCOPY=\"${OBJCOPY}\" \
65                 OBJDUMP=\"${OBJDUMP}\" \
66                 NM=\"${NM}\" \
67                 PKG_CONFIG_DIR=\"${PKG_CONFIG_DIR}\" \
68                 PKG_CONFIG_PATH=\"${PKG_CONFIG_PATH}\" \
69                 PKG_CONFIG_LIBDIR=\"${PKG_CONFIG_LIBDIR}\" \
70                 PKG_CONFIG_SYSROOT_DIR=\"${PKG_CONFIG_SYSROOT_DIR}\" \
71                 PKG_CONFIG_DISABLE_UNINSTALLED=\"${PKG_CONFIG_DISABLE_UNINSTALLED}\" \
72         "
73
74         local OE_ENV_KERNEL=" \
75                 PATH=\"${PATH}\" \
76                 CROSS_COMPILE=\"${HOST_PREFIX}\" \
77                 KCFLAGS=--sysroot=${STAGING_DIR_HOST} \
78         "
79
80         echo "Creating shell command aliases:"
81         echo "* oe_autoreconf"
82         alias oe_autoreconf="${OE_ENV} autoreconf -Wcross --verbose --install --force --exclude=autopoint"
83
84         echo "* oe_runconf"
85         alias oe_runconf=" \
86                 ./configure \
87                         --build=${BUILD_SYS} \
88                         --host=${HOST_SYS} \
89                         --target=${TARGET_SYS} \
90                         --prefix=${prefix} \
91                         --exec_prefix=${exec_prefix} \
92                         --bindir=${bindir} \
93                         --sbindir=${sbindir} \
94                         --libexecdir=${libexecdir} \
95                         --datadir=${datadir} \
96                         --sysconfdir=${sysconfdir} \
97                         --sharedstatedir=${sharedstatedir} \
98                         --localstatedir=${localstatedir} \
99                         --libdir=${libdir} \
100                         --includedir=${includedir} \
101                         --oldincludedir=${oldincludedir} \
102                         --infodir=${infodir} \
103                         --mandir=${mandir} \
104                         --with-libtool-sysroot=${STAGING_DIR_HOST} \
105                         ${OE_ENV} \
106         "
107
108         echo "* oe_runmake"
109         alias oe_runmake="${OE_ENV} ${MAKE} ${PARALLEL_MAKE}"
110
111         echo "* oe_runmake_kernel"
112         alias oe_runmake_kernel="${OE_ENV_KERNEL} ${MAKE} ${PARALLEL_MAKE}"
113
114         echo "* oe_env"
115         alias oe_env="${OE_ENV}"
116
117         echo "* oe_env_kernel"
118         alias oe_env_kernel="${OE_ENV_KERNEL}"
119
120         echo "* oe_setenv"
121         alias oe_setenv="export ${OE_ENV}"
122
123         echo "* oe_setenv_kernel"
124         alias oe_setenv_kernel="export ${OE_ENV_KERNEL}"
125
126         echo "* oe_cmake"
127         alias oe_cmake=" \
128                 ${OE_ENV} cmake \
129                         -DCMAKE_FIND_ROOT_PATH:PATH=\"${STAGING_DIR_HOST};${STAGING_DIR_NATIVE}\" \
130                         -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE:STRING=ONLY \
131                         -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM:STRING=BOTH \
132                         -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY:STRING=ONLY \
133                         -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE:STRING=ONLY \
134                         -DCMAKE_INSTALL_PREFIX:PATH=${prefix} \
135                         -DCMAKE_INSTALL_BINDIR:PATH=${bindir} \
136                         -DCMAKE_INSTALL_SBINDIR:PATH=${sbindir} \
137                         -DCMAKE_INSTALL_LIBEXECDIR:PATH=${libexecdir} \
138                         -DCMAKE_INSTALL_SYSCONFDIR:PATH=${sysconfdir} \
139                         -DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=${sharedstatedir} \
140                         -DCMAKE_INSTALL_LOCALSTATEDIR:PATH=${localstatedir} \
141                         -DCMAKE_INSTALL_LIBDIR:PATH=${libdir} \
142                         -DCMAKE_INSTALL_INCLUDEDIR:PATH=${includedir} \
143                         -DCMAKE_INSTALL_DATAROOTDIR:PATH=${datadir} \
144                         -DCMAKE_INSTALL_SO_NO_EXE=0 \
145         "
146 }
147
148 if [ $# -ne 1 ]; then
149         echo "usage: . ${BASH_SOURCE[0]} \${MACHINE}"
150 else
151         oe_set_aliases $1
152 fi