Set $CC in common code (sources/include.sh)
[qi-bootmenu-system/guyou.git] / sources / include.sh
blobc8ab1aaddcf0bff448a0d47ceb95ec0720d65e86
1 #!/bin/bash
3 # Architecture
5 ARCH=armv4tl
6 KARCH=arm
7 ARCH_NAME="$ARCH"
8 STAGE_NAME="native"
10 # Directory layout
11 TOP=`pwd`
12 export SOURCES="${TOP}/sources"
13 export SCRIPTS="${SOURCES}/scripts"
14 export SRCDIR="${TOP}/packages"
15 export ROOT_DIR="${TOP}/rootfs"
16 export ROOT_OVERLAY="${TOP}/rootfs-overlay"
17 export BUILD="${TOP}/build"
18 export CONFIG_DIR="${TOP}/sources/configs"
19 export WORK="${BUILD}/temp-${ARCH}"
20 export STAGING_DIR="${TOP}/staging-dir"
22 # Default flags to point the compiler to the right libraries and
23 # include files. In the case of cross compiling this assumes that
24 # the compiler doesn't add system directories to it's search paths.
25 # This is taken care of by a gcc wrapper script which passes things
26 # like -nostdinc -nostdlibs -nodefaultlibs to gcc.
28 CFLAGS_HEADERS="-I$STAGING_DIR/usr/include"
30 if [ -z "$DEBUG" ]; then
31 CFLAGS="$CFLAGS_HEADERS -Os -pipe -march=armv4t -mtune=arm920t"
32 else
33 CFLAGS="$CFLAGS_HEADERS -O0 -g -ggdb -pipe -march=armv4t -mtune=arm920t"
36 LDFLAGS_LIBS="-L$STAGING_DIR/usr/lib"
37 LDFLAGS="$LDFLAGS_LIBS"
39 # Make sure that pkg-config uses the right paths and doesn't pull
40 # in depencies from the host system.
41 export PKG_CONFIG_PATH="${STAGING_DIR}/usr/lib/pkgconfig"
42 export PKG_CONFIG_LIBDIR="${STAGING_DIR}/usr/lib/pkgconfig"
43 export PKG_CONFIG_SYSROOT_DIR="${STAGING_DIR}"
45 # check if we are building natively or if we are cross compiling
47 if [[ ! $(uname -m) == arm* ]]
48 then
49 STAGE_NAME="cross"
50 CROSS_LDFLAGS=
51 CROSS_CFLAGS=
52 CROSS_CONFIGURE_FLAGS="--build=`$SCRIPTS/config.guess` \
53 --target=armv4tl-unknown-linux-gnueabi \
54 --host=armv4tl-unknown-linux-gnueabi"
55 # cross compiler prefix used by kernel, uclibc and busybox
56 # build system
57 [ -z "$CROSS" ] && CROSS="armv4tl-"
60 STRIP="${CROSS}strip"
61 [ -z "$CC" ] && export CC="${CROSS}gcc"
63 umask 022
65 # Tell bash not to cache the $PATH because we modify it. Without
66 # this, bash won't find new executables added after startup.
67 set +h
69 [ -e config ] && source config
70 source sources/functions-fwl.sh
71 source sources/functions.sh
73 # How many processors should make -j use?
75 if [ -z "$CPUS" ]
76 then
77 export CPUS=$(echo /sys/devices/system/cpu/cpu[0-9]* | wc -w)
78 [ "$CPUS" -lt 1 ] && CPUS=1
81 export MAKEFLAGS="-j $CPUS"
83 # This is an if instead of && so the exit code of include.sh is reliably 0
84 if [ ! -z "$BUILD_VERBOSE" ]
85 then
86 VERBOSITY="V=1"