Use special CFLAGS for binaries
[qi-bootmenu-system/guyou.git] / sources / include.sh
blob3a211f82e0f0bb22c0de6099bef69f42df63838a
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 # flags for executables
38 CFLAGS_EXE="$CFLAGS -ffunction-sections -fdata-sections"
40 LDFLAGS=""
42 LDFLAGS_EXE="$LDFLAGS -Wl,--gc-section"
44 # Make sure that pkg-config uses the right paths and doesn't pull
45 # in depencies from the host system.
46 export PKG_CONFIG_PATH="${STAGING_DIR}/usr/lib/pkgconfig"
47 export PKG_CONFIG_LIBDIR="${STAGING_DIR}/usr/lib/pkgconfig"
48 export PKG_CONFIG_SYSROOT_DIR="${STAGING_DIR}"
50 # check if we are building natively or if we are cross compiling
52 if [[ ! $(uname -m) == arm* ]]
53 then
54 STAGE_NAME="cross"
55 CROSS_CONFIGURE_FLAGS="--build=`$SCRIPTS/config.guess` \
56 --target=armv4tl-unknown-linux-gnueabi \
57 --host=armv4tl-unknown-linux-gnueabi"
58 # cross compiler prefix used by kernel, uclibc and busybox
59 # build system
60 [ -z "$CROSS" ] && CROSS="armv4tl-"
63 STRIP="${CROSS}strip"
64 [ -z "$CC" ] && export CC="${CROSS}gcc"
66 # tell the compiler wrapper to link against the libc from
67 # $STAGING_DIR and not against the one from the toolchain
69 export CCWRAP_TOPDIR="$STAGING_DIR/usr"
71 umask 022
73 # Tell bash not to cache the $PATH because we modify it. Without
74 # this, bash won't find new executables added after startup.
75 set +h
77 [ -e config ] && source config
78 source sources/functions-fwl.sh
79 source sources/functions.sh
81 # How many processors should make -j use?
83 if [ -z "$CPUS" ]
84 then
85 export CPUS=$(echo /sys/devices/system/cpu/cpu[0-9]* | wc -w)
86 [ "$CPUS" -lt 1 ] && CPUS=1
89 export MAKEFLAGS="-j $CPUS"
91 # This is an if instead of && so the exit code of include.sh is reliably 0
92 if [ ! -z "$BUILD_VERBOSE" ]
93 then
94 VERBOSITY="V=1"