comparison host-tools.sh @ 608:ab76d4cdd392

Jean Wolter pointed out that running RECORD_COMMANDS=1 twice could create circular symlinks. Hopefully fixed now, and some related cleanups/clarifications.
author Rob Landley <rob@landley.net>
date Tue, 03 Feb 2009 01:42:29 -0600
parents 7fc1f4695c29
children 3c30ce98c273
comparison
equal deleted inserted replaced
607:c1659b564005 608:ab76d4cdd392
17 mkdir -p "${HOSTTOOLS}" || dienow 17 mkdir -p "${HOSTTOOLS}" || dienow
18 18
19 # If we want to record the host command lines, so we know exactly what commands 19 # If we want to record the host command lines, so we know exactly what commands
20 # the build uses. 20 # the build uses.
21 21
22 if [ ! -z "$RECORD_COMMANDS" ] && [ ! -f "$BUILD/wrapdir/wrappy" ] 22 if [ ! -z "$RECORD_COMMANDS" ]
23 then 23 then
24 echo setup wrapdir 24 if [ ! -f "$BUILD/wrapdir/wrappy" ]
25 then
26 echo setup wrapdir
25 27
26 # Build the wrapper and install it into build/wrapdir/wrappy 28 # Build the wrapper and install it into build/wrapdir/wrappy
27 rm -rf "$BUILD/wrapdir" 29 rm -rf "$BUILD/wrapdir"
28 mkdir "$BUILD/wrapdir" && 30 mkdir "$BUILD/wrapdir" &&
29 $CC -Os "$SOURCES/toys/wrappy.c" -o "$BUILD/wrapdir/wrappy" || dienow 31 $CC -Os "$SOURCES/toys/wrappy.c" -o "$BUILD/wrapdir/wrappy" || dienow
30 32
31 # Loop through each $PATH element and create a symlink to the wrapper with 33 # Loop through each $PATH element and create a symlink to the wrapper with
32 # that name. 34 # that name.
33 35
34 for i in $(echo $PATH | sed 's/:/ /g') 36 for i in $(echo $PATH | sed 's/:/ /g')
35 do
36 for j in $(ls $i)
37 do 37 do
38 [ -f "$BUILD/wrapdir/$j" ] || ln -s wrappy "$BUILD/wrapdir/$j" 38 for j in $(ls $i)
39 do
40 [ -f "$BUILD/wrapdir/$j" ] || ln -s wrappy "$BUILD/wrapdir/$j"
41 done
39 done 42 done
40 done
41 43
42 # Adjust things to use wrapper directory 44 # Adjust things to use wrapper directory
43 45
44 export WRAPPY_REALPATH="$PATH" 46 export WRAPPY_REALPATH="$PATH"
45 PATH="$BUILD/wrapdir" 47 PATH="$BUILD/wrapdir"
48 fi
46 49
47 # If we're not recording the host command lines, then populate a directory 50 # If we're not recording the host command lines, then populate a directory
48 # with host versions of all the command line utilities we're going to install 51 # with host versions of all the command line utilities we're going to install
49 # into mini-native. When we're done, PATH can be set to include just this 52 # into mini-native. When we're done, PATH can be set to include just this
50 # directory and nothing else. 53 # directory and nothing else.
71 # compiler for the target, but we don't build a host toolchain. We use the 74 # compiler for the target, but we don't build a host toolchain. We use the
72 # one that's already there. 75 # one that's already there.
73 76
74 for i in ar as nm cc gcc make ld 77 for i in ar as nm cc gcc make ld
75 do 78 do
76 [ ! -f "${HOSTTOOLS}/$i" ] && (ln -s `which $i` "${HOSTTOOLS}/$i" || dienow) 79 [ ! -e "${HOSTTOOLS}/$i" ] && (ln -s `which $i` "${HOSTTOOLS}/$i" || dienow)
77 done 80 done
78 81
79 # Build toybox 82 # Build toybox
80 83
81 if [ ! -f "${HOSTTOOLS}/toybox" ] 84 if [ ! -f "${HOSTTOOLS}/toybox" ]
173 if [ ! -z "$RECORD_COMMANDS" ] 176 if [ ! -z "$RECORD_COMMANDS" ]
174 then 177 then
175 # Make sure the host tools we just built are also in wrapdir 178 # Make sure the host tools we just built are also in wrapdir
176 for j in $(ls "$HOSTTOOLS") 179 for j in $(ls "$HOSTTOOLS")
177 do 180 do
178 [ -f "$BUILD/wrapdir/$j" ] || ln -s wrappy "$BUILD/wrapdir/$j" 181 [ -e "$BUILD/wrapdir/$j" ] || ln -s wrappy "$BUILD/wrapdir/$j"
179 done 182 done
180 fi 183 fi
181 184
182 echo -e "\e[32mHost tools build complete.\e[0m" 185 echo -e "\e[32mHost tools build complete.\e[0m"