]>
Commit | Line | Data |
---|---|---|
1ded22cc MT |
1 | #!/bin/bash |
2 | ############################################################################### | |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2008 Michael Tremer & Christian Schmidt # | |
6 | # # | |
7 | # This program is free software: you can redistribute it and/or modify # | |
8 | # it under the terms of the GNU General Public License as published by # | |
9 | # the Free Software Foundation, either version 3 of the License, or # | |
10 | # (at your option) any later version. # | |
11 | # # | |
12 | # This program is distributed in the hope that it will be useful, # | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
15 | # GNU General Public License for more details. # | |
16 | # # | |
17 | # You should have received a copy of the GNU General Public License # | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
19 | # # | |
20 | ############################################################################### | |
27b9c375 MT |
21 | ############################################################################### |
22 | # | |
23 | # Define default vars | |
24 | # | |
25 | ############################################################################### | |
1ded22cc MT |
26 | |
27 | # Default target | |
7a566507 | 28 | TARGET=${TARGET-i686} |
80fa5639 | 29 | POSSIBLE_TARGETS="i686 i586 i486 via-c7 via-c3 geodelx atom330 core2duo" |
1ded22cc MT |
30 | |
31 | # Configuration rootdir | |
32 | CONFIG_ROOT=/etc/$SNAME | |
33 | ||
34 | # Nice level | |
35 | NICE=10 | |
36 | ||
37 | # Read in kernel version | |
8985a698 | 38 | KVER=$(grep --max-count=1 PKG_VER lfs/linux | awk '{ print $3 }' | tr -d '\n'; grep --max-count=1 LOCALVERSION lfs/linux | awk '{ print $3 }' | tail -1) |
1ded22cc MT |
39 | |
40 | # Read in machine type | |
41 | MACHINE_REAL=$(uname -m) | |
42 | ||
12b17e35 MT |
43 | # Read in information from git |
44 | GIT_REV=$(git rev-list HEAD | head -n 1) | |
45 | GIT_TAG=$(git tag 2>/dev/null | tail -n 1) | |
1ded22cc | 46 | |
1ded22cc MT |
47 | # Embedded build |
48 | EMB=0 | |
49 | ||
50 | # Default building options | |
51 | BUILD_EXTRAS=1 | |
52 | BUILD_DEBUG=0 | |
53 | ||
54 | # Default parallelism options | |
55 | PARALLELISMFLAGS=-j$(( $(grep processor < /proc/cpuinfo | wc -l) * 2 + 1 )) | |
56 | ||
57 | # Default distcc options | |
1ded22cc | 58 | DISTCC_PORT=3632 |
e3e4d196 | 59 | DISTCC_JOBS=4 |
1ded22cc MT |
60 | |
61 | # Default hostname | |
1aac9908 | 62 | HOSTNAME=$(hostname -f || hostname) |
1ded22cc | 63 | |
27b9c375 MT |
64 | ############################################################################### |
65 | # | |
66 | # Read the local configuration to override the environment variables | |
67 | # | |
68 | ############################################################################### | |
69 | ||
70 | if ! [ -e .config ]; then | |
71 | sed -e "s/@UUID@/$(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid)/" \ | |
72 | -e "s/^#UUID=/UUID=/" < $BASEDIR/.config-default > $BASEDIR/.config | |
73 | fi | |
74 | ||
75 | . $BASEDIR/.config | |
76 | ||
77 | ############################################################################### | |
78 | # | |
79 | # Variables that are not modifyable by .config | |
80 | # | |
81 | ############################################################################### | |
82 | ||
83 | if [ 'i686' = $MACHINE_REAL \ | |
84 | -o 'i586' = $MACHINE_REAL \ | |
85 | -o 'i486' = $MACHINE_REAL \ | |
86 | -o 'x86_64' = $MACHINE_REAL ]; then | |
87 | IFS_HOST="$(echo $MACHTYPE | sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")" | |
88 | else | |
89 | beautify message FAIL | |
90 | echo "Can't determine your architecture - $MACHINE_REAL" | |
91 | exit 1 | |
92 | fi | |
93 | ||
11f0ec61 | 94 | LINKER=/lib/ld-linux.so.2 |
27b9c375 MT |
95 | if [ 'i686' = $TARGET -o 'i586' = $TARGET \ |
96 | -o 'i486' = $TARGET ]; then | |
97 | MACHINE=${TARGET} | |
27b9c375 | 98 | IFS_TARGET="${MACHINE}-pc-linux-gnu" |
11f0ec61 | 99 | CFLAGS="-O2 -march=${MACHINE} -pipe -fomit-frame-pointer" |
27b9c375 | 100 | CXXFLAGS="${CFLAGS}" |
d964d562 MT |
101 | elif [ 'atom330' = $TARGET ]; then |
102 | MACHINE=i686 | |
d964d562 | 103 | IFS_TARGET="${MACHINE}-atom-linux-gnu" |
11f0ec61 | 104 | CFLAGS="-O2 -march=${MACHINE} -mmmx -msse -msse2 -msse3 -mssse3 -pipe -fomit-frame-pointer" |
d964d562 | 105 | CXXFLAGS="${CFLAGS}" |
ba60acd3 MT |
106 | elif [ 'core2duo' = $TARGET ]; then |
107 | MACHINE=i686 | |
108 | IFS_TARGET="${MACHINE}-c2d-linux-gnu" | |
109 | CFLAGS="-O2 -march=pentium-m -msse2 -pipe" | |
110 | CXXFLAGS="${CFLAGS}" | |
27b9c375 MT |
111 | elif [ 'via-c7' = $TARGET ]; then |
112 | MACHINE=i686 | |
88068980 | 113 | IFS_TARGET="${MACHINE}-via-linux-gnu" |
11f0ec61 | 114 | CFLAGS="-O2 -march=${MACHINE} -mmmx -msse -msse2 -msse3 -pipe" |
27b9c375 MT |
115 | CXXFLAGS="${CFLAGS}" |
116 | elif [ 'via-c3' = $TARGET ]; then | |
117 | MACHINE=i586 | |
88068980 | 118 | IFS_TARGET="${MACHINE}-via-linux-gnu" |
11f0ec61 | 119 | CFLAGS="-O2 -march=c3 -m3dnow -pipe -fomit-frame-pointer" |
27b9c375 MT |
120 | CXXFLAGS="${CFLAGS}" |
121 | elif [ 'geodelx' = $TARGET ]; then | |
122 | MACHINE=i586 | |
88068980 | 123 | IFS_TARGET="${MACHINE}-geode-linux-gnu" |
11f0ec61 | 124 | CFLAGS="-Os -march=geode -pipe -fomit-frame-pointer" |
27b9c375 MT |
125 | CXXFLAGS="${CFLAGS}" |
126 | else | |
127 | beautify message FAIL | |
128 | echo "Not a valid target arch (i686|i586|i486|via-c7|via-c3|geodelx) - $TARGET" | |
129 | exit 1 | |
130 | fi | |
131 | ||
132 | # Make debugging symbols | |
133 | if [ "$BUILD_DEBUG" == "1" ]; then | |
134 | CFLAGS=$(sed -e "s/-O[123s]/-O/g" <<< $CFLAGS) | |
135 | CFLAGS="$CFLAGS -g" | |
136 | CXXFLAGS=$(sed -e "s/-O[123s]/-O/g" <<< $CXXFLAGS) | |
137 | CXXFLAGS="$CXXFLAGS -g" | |
138 | fi | |
139 | ||
0ad657e2 MT |
140 | # Define IMAGENAME |
141 | IMAGENAME=${SNAME}-${VERSION}.${TARGET} | |
142 | ||
143 | if [ "$BUILD_DEBUG" == "1" ]; then | |
144 | # On debug build, append -debug | |
145 | IMAGENAME=${IMAGENAME}-debug | |
146 | fi | |
147 | ||
148 | # Define TOOLCHAINNAME | |
7418ecd8 | 149 | TOOLCHAINNAME=$SNAME-$TOOLCHAINVERSION-toolchain-${TARGET} |
27b9c375 | 150 | |
1ded22cc | 151 | # Set up what used to be /tools |
11f0ec61 | 152 | TOOLS_DIR=/tools_${TARGET} |
1ded22cc MT |
153 | |
154 | # Set up /installer | |
155 | INSTALLER_DIR=/pomona | |
156 | ||
157 | # A place to build the iso | |
158 | CDROM_DIR=/cdrom | |
159 | ||
160 | # A place to keep the images | |
161 | IMAGES_DIR=/images | |
162 | ||
163 | # Files that indicates that we are running or failed | |
164 | RUNNING=$BASEDIR/.running | |
165 | FAILED=$BASEDIR/.failed |