1 # Copyright (c) 2011 The Native Client Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that be
3 # found in the LICENSE file.
9 # scripts that source this file must be run from within packages tree
10 readonly SAVE_PWD
=$
(pwd)
12 # Pick platform directory for compiler.
13 readonly OS_NAME
=$
(uname
-s)
14 if [ $OS_NAME = "Darwin" ]; then
15 readonly OS_SUBDIR
="mac"
16 readonly OS_SUBDIR_SHORT
="mac"
17 elif [ $OS_NAME = "Linux" ]; then
18 readonly OS_SUBDIR
="linux"
19 readonly OS_SUBDIR_SHORT
="linux"
21 readonly OS_SUBDIR
="windows"
22 readonly OS_SUBDIR_SHORT
="win"
25 readonly MACHINE
=$
(uname
-m)
26 if [ $MACHINE = "x86_64" ]; then
27 readonly TARGET_BITSIZE
=${TARGET_BITSIZE:-"64"}
28 readonly HOST_BITSIZE
=${HOST_BITSIZE:-"64"}
30 # uname -m reports i686 on Linux and i386 on Mac
31 readonly TARGET_BITSIZE
=${TARGET_BITSIZE:-"32"}
32 readonly HOST_BITSIZE
=${HOST_BITSIZE:-"32"}
35 if [ $TARGET_BITSIZE == "64" ]; then
36 readonly TARGET_BIT_PREFIX
="64"
37 readonly CROSS_ID
=x86_64
39 readonly TARGET_BIT_PREFIX
=""
40 readonly CROSS_ID
=i686
42 # we might want to override the detected host platform (e.g. on OSX 10.6)
43 if [ $HOST_BITSIZE == "64" ]; then
44 readonly HOST_BIT_PREFIX
="64"
46 readonly HOST_BIT_PREFIX
=""
49 export NACL_CROSS_PREFIX
=${CROSS_ID}-nacl
50 export NACL_CROSS_PREFIX_DASH
=${NACL_CROSS_PREFIX}-
52 readonly NACL_NEWLIB
=${NACL_NEWLIB:-"0"}
54 if [ $NACL_NEWLIB = "1" ]; then
55 readonly NACL_SDK_BASE
=${NACL_SDK_ROOT}/toolchain
/${OS_SUBDIR_SHORT}_x86_newlib
57 case "${NACL_SDK_ROOT}" in
58 *pepper_15
* |
*pepper_16
* |
*pepper_17
*)
59 readonly NACL_SDK_BASE
=${NACL_SDK_ROOT}/toolchain
/${OS_SUBDIR_SHORT}_x86
62 readonly NACL_SDK_BASE
=${NACL_SDK_ROOT}/toolchain
/${OS_SUBDIR_SHORT}_x86_glibc
67 readonly NACL_BIN_PATH
=${NACL_SDK_BASE}/bin
68 export NACLCC
=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}gcc
69 export NACLCXX
=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}g
++
70 export NACLAR
=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}ar
71 export NACLRANLIB
=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}ranlib
72 export NACLLD
=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}ld
73 export NACLAS
=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}as
75 # NACL_SDK_GCC_SPECS_PATH is where nacl-gcc 'specs' file will be installed
76 readonly NACL_SDK_GCC_SPECS_PATH
=${NACL_SDK_BASE}/lib
/gcc
/x86_64-nacl
/4.4.3
78 # NACL_SDK_USR is where the headers, libraries, etc. will be installed
79 readonly NACL_SDK_USR
=${NACL_SDK_BASE}/${NACL_CROSS_PREFIX}/usr
80 readonly NACL_SDK_USR_INCLUDE
=${NACL_SDK_USR}/include
81 readonly NACL_SDK_USR_LIB
=${NACL_SDK_USR}/lib
84 ######################################################################
86 ######################################################################
89 echo "######################################################################"
91 echo "######################################################################"
96 # make sure path isn't all slashes (possibly from an unset variable)
99 if [ ${#TRIM} -ne 0 ]; then
109 if VerifyPath
${NAME}; then
112 echo "ChangeDir called with bad path."
120 if VerifyPath
${NAME}; then
123 echo "Remove called with bad path."
131 if VerifyPath
${NAME}; then
134 echo "MakeDir called with bad path."
141 # fix up spaces so gcc sees entire path
142 local SED_SAFE_SPACES_USR_INCLUDE
=${NACL_SDK_USR_INCLUDE/ /\ /}
143 local SED_SAFE_SPACES_USR_LIB
=${NACL_SDK_USR_LIB/ /\ /}
144 # have nacl-gcc dump specs file & add include & lib search paths
145 ${NACL_SDK_BASE}/bin
/x86_64-nacl-gcc
-dumpspecs |\
148 s|$| -I${SED_SAFE_SPACES_USR_INCLUDE}|
150 sed "/*link_libgcc:/{
152 s|$| -L${SED_SAFE_SPACES_USR_LIB}|
153 }" >${NACL_SDK_GCC_SPECS_PATH}/specs
157 DefaultConfigureStep
() {
158 Banner
"Configuring ${PACKAGE_NAME}"
159 # export the nacl tools
161 export CXX
=${NACLCXX}
163 export RANLIB
=${NACLRANLIB}
164 export PKG_CONFIG_PATH
=${NACL_SDK_USR_LIB}/pkgconfig
165 export PKG_CONFIG_LIBDIR
=${NACL_SDK_USR_LIB}
166 export PATH
=${NACL_BIN_PATH}:${PATH};
167 ChangeDir
${NACL_PACKAGES_REPOSITORY}/${PACKAGE_NAME}
168 Remove
${PACKAGE_NAME}-build
169 MakeDir
${PACKAGE_NAME}-build
170 cd ${PACKAGE_NAME}-build
174 --prefix=${NACL_SDK_USR} \
175 --exec-prefix=${NACL_SDK_USR} \
176 --libdir=${NACL_SDK_USR_LIB} \
177 --oldincludedir=${NACL_SDK_USR_INCLUDE} \
186 # assumes pwd has makefile
188 if [ $TARGET_BITSIZE == "64" ]; then
196 DefaultInstallStep
() {
197 # assumes pwd has makefile
202 DefaultCleanUpStep
() {
204 ChangeDir
${SAVE_PWD}
208 DefaultPackageInstall
() {
209 DefaultPreInstallStep