]> git.ipfire.org Git - ipfire-3.x.git/blob - tools/make-constants
Added new package: dosfstools.
[ipfire-3.x.git] / tools / make-constants
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 ###############################################################################
21 ###############################################################################
22 #
23 # Define default vars
24 #
25 ###############################################################################
26
27 # Default target
28 TARGET=${TARGET-i686}
29 POSSIBLE_TARGETS="i686 i586 i486 via-c7 via-c3 geodelx atom330 core2duo"
30
31 # Configuration rootdir
32 CONFIG_ROOT=/etc/$SNAME
33
34 # Nice level
35 NICE=10
36
37 # Read in kernel version
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)
39
40 # Read in machine type
41 MACHINE_REAL=$(uname -m)
42
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)
46
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
58 DISTCC_PORT=3632
59 DISTCC_JOBS=4
60
61 # Default hostname
62 HOSTNAME=$(hostname -f || hostname)
63
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
94 LINKER=/lib/ld-linux.so.2
95 if [ 'i686' = $TARGET -o 'i586' = $TARGET \
96 -o 'i486' = $TARGET ]; then
97 MACHINE=${TARGET}
98 IFS_TARGET="${MACHINE}-pc-linux-gnu"
99 CFLAGS="-O2 -march=${MACHINE} -pipe -fomit-frame-pointer"
100 CXXFLAGS="${CFLAGS}"
101 elif [ 'atom330' = $TARGET ]; then
102 MACHINE=i686
103 IFS_TARGET="${MACHINE}-atom-linux-gnu"
104 CFLAGS="-O2 -march=${MACHINE} -mmmx -msse -msse2 -msse3 -mssse3 -pipe -fomit-frame-pointer"
105 CXXFLAGS="${CFLAGS}"
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}"
111 elif [ 'via-c7' = $TARGET ]; then
112 MACHINE=i686
113 IFS_TARGET="${MACHINE}-via-linux-gnu"
114 CFLAGS="-O2 -march=${MACHINE} -mmmx -msse -msse2 -msse3 -pipe"
115 CXXFLAGS="${CFLAGS}"
116 elif [ 'via-c3' = $TARGET ]; then
117 MACHINE=i586
118 IFS_TARGET="${MACHINE}-via-linux-gnu"
119 CFLAGS="-O2 -march=c3 -m3dnow -pipe -fomit-frame-pointer"
120 CXXFLAGS="${CFLAGS}"
121 elif [ 'geodelx' = $TARGET ]; then
122 MACHINE=i586
123 IFS_TARGET="${MACHINE}-geode-linux-gnu"
124 CFLAGS="-Os -march=geode -pipe -fomit-frame-pointer"
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
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
149 TOOLCHAINNAME=$SNAME-$TOOLCHAINVERSION-toolchain-${TARGET}
150
151 # Set up what used to be /tools
152 TOOLS_DIR=/tools_${TARGET}
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