Scripting some LFS steps?

Justin Yaple yaplej at
Tue Apr 14 21:41:00 PDT 2009

>No shebang.
Who did what?

>No comments.
Gentelmen never tell.

Ok enough of that.  No, I just was being lazy actually.  I was in a
hurry trying to make the thing work so I skipped the commenting n that
stuff.  Shame on me I know.

>How is this script executed?
I have a script for each section that I manually run at this point.  I
would like to eventually have a master script that fires each of the
other off in sequence.  As of now though I just manually run each of

>how is it logged?
It wasnt.  Again shame on me.

>In the future, showing the full output..
Ok here is the updated script.  With some additional help I was able
to identify the part that didnt work from the previous script due to
line continuation of the "echo".  It worked fine when manually typed,
but not in a script due to missing "\" or breaking it into multiple
"echo"s like I did.


#Begin GCC Installation Pass 2

#Change to sources directory.
cd $LFS/sources

#Extract GCC source code and change to that directory.
echo "Extracting GCC source code."
tar -jxf gcc-4.3.2.tar.bz2 && cd gcc-4.3.2

#Copy the Makefile.
echo "Going to fix the Makefile."
cp -v gcc/{,.orig} >> $LFS/sources/gcc2nd.log 2>&1

#Remove fixinclude script.
sed 's@\./fixinc\.sh at -c true@' gcc/ > gcc/
>> $LFS/sources/gcc2nd.log 2>&1

#Create temp Makefile.
cp -v gcc/{,.tmp} >> $LFS/sources/gcc2nd.log 2>&1

#Does something.
sed 's/^XCFLAGS =$/& -fomit-frame-pointer/' gcc/ >
gcc/ >> $LFS/sources/gcc2nd.log 2>&1

#Remove any fixed headers.
for file in $(find gcc/config -name linux64.h -o -name linux.h)
cp -uv $file{,.orig}
sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' -e 's@/usr@/tools at g'
$file.orig > $file
echo "#undef STANDARD_INCLUDE_DIR" >> $file
echo "#define STANDARD_INCLUDE_DIR 0" >> $file
touch $file.orig

#Extract mpfr and rename for GCC compile.
echo "Extract mpfr."
tar -jxf ../mpfr-2.3.2.tar.bz2 && mv mpfr-2.3.2 mpfr

#Extract gmp and rename for GCC compile.
echo "Extract gmp."
tar -jxf ../gmp-4.2.4.tar.bz2 && mv gmp-4.2.4 gmp

#Create build directory for GCC and change to that directory.
echo "Going to build directory."
mkdir -v ../gcc-build && cd ../gcc-build

#Confiure to make GCC.
echo "Configuring GCC."
../gcc-4.3.2/configure --prefix=/tools --with-local-prefix=/tools
--enable-clocale=gnu --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-languages=c,c++ --disable-libstdcxx-pch
--disable-bootstrap >> $LFS/sources/gcc2nd.log 2>&1

#Make GCC.
echo "Making GCC."
make >> $LFS/sources/gcc2nd.log 2>&1

#Check GCC.
echo "Checking GCC."
make -k check >> $LFS/sources/gcc2nd.log 2>&1

#Install GCC
echo "Installing GCC."
make install >> $LFS/sources/gcc2nd.log 2>&1

#Change to sources directory.
cd $LFS/sources

#Remove GCC source and build directories.
echo "Cleaning up."
rm gcc-4.3.2 -rf && rm gcc-build -rf

#End GCC Installation Pass 2

More information about the lfs-support mailing list