[cfe-dev] Installing clang, braindead easy.
Paolo Bolzoni
bolzoni at cs.unipr.it
Tue Apr 29 10:25:32 PDT 2008
I made a script to allow installing clang on a Linux computer with extreme
easy.
In lab where I work it has been useful, I thought someone other may
find it useful.
Of course, on the other hand, if you feel I made a wrong choice about anything
or there is a bug in the script. Lemme know.
The script downloads the release 50422, adds the required paths to clang.cpp,
compile everything, makes a Makefile for installing and uninstalling.
make install will install in /usr/local and make uninstall will delete every
installed file and removes every added directory (if empty).
If you need updating uninstall, exec the script again, install.
pb
-- copy and paste --
#!/bin/sh
destver="50422"
startdir="$PWD"
svn co -r "$destver" http://llvm.org/svn/llvm-project/llvm/trunk llvm \
|| exit 1
cd "$startdir"/llvm/tools
svn co -r "$destver" http://llvm.org/svn/llvm-project/cfe/trunk clang \
|| exit 1
cd "$startdir"
[ -e src ] && find src -depth -name '.svn' -exec rm -rf "{}" \;
cp -ra llvm src || exit 1
cd src/tools
echo -ne 'e Makefile\n'\
'/bugpoint llvm-bcanalyzer llvm-stub llvmc2/\n'\
'c\n'\
'bugpoint llvm-bcanalyzer llvm-stub llvmc2 clang\n'\
'.\n'\
'w\n'\
'q\n' > p
cat p | ed || exit 1
rm p
cd "$startdir"/src/tools/clang/Driver
touch empty.c
echo -ne 'e clang.cpp\n'\
'/FIXME: temporary hack: hard-coded paths./\n'\
'/if (!nostdinc)/\n'\
'a\n'\
'/* C paths automatically added. START */\n'> addpaths
gcc -v empty.c -fsyntax-only &>/dev/stdout | \
sed -e '1,/#include <...> search starts here/ d' \
-e '/End of search list/,$ d' | \
sed -e 's_^ *__' \
-e 's_.*_ AddPath("&", System, true, false, false, Headers);_' \
-e 's_\n_ _' >> addpaths
echo -ne '/* C paths automatically added. END */\n'\
'.\n'\
'/if (Lang.CPlusPlus) {/\n'\
'a\n'\
'/* C++ paths automatically added. START */\n' >> addpaths
g++ -v empty.c -fsyntax-only &>/dev/stdout | \
sed -e '1,/#include <...> search starts here/ d' \
-e '/End of search list/,$ d' | \
sed -e 's_^ *__' -e 's_ *$__' \
-e 's_.*_ AddPath("&", System, true, false, false, Headers);_' \
-e 's_\n_ _' >> addpaths
echo -ne '/* C++ paths automatically added. END */\n'\
'.\n'\
'w\n'\
'q\n' >> addpaths
cat addpaths | ed || exit 1
rm empty.c
rm addpaths
cd "$startdir"/src
./configure -enable-optimized || exit 1
make || exit 1
cd "$startdir"
rm -rf dest
mkdir -p dest/include
cp -ra src/Release/bin dest
cp -ra src/Release/lib dest
cp -ra src/include/* dest/include
cp -ra src/tools/clang/include/* dest/include
find dest -depth -name '.*' -exec rm -rf "{}" \;
find dest -type d -exec chmod 755 "{}" \;
find dest -type f -exec chmod 644 "{}" \;
find dest/bin -type f -exec chmod 755 "{}" \;
find dest/lib -type f -name '*.so*' -exec chmod 755 "{}" \;
find dest/lib -type f -name '*.la' -exec chmod 755 "{}" \;
echo -ne '\ninstall:\n\tcp -r -d --preserve=mode dest/* /usr/local\n'\
'\nuninstall:\n' > Makefile
find dest -depth -not -type d | \
sed -e 's_dest_/usr/local_' -e 's_.*_\trm -f "&"_' >> Makefile
find dest -depth -mindepth 1 -type d | \
sed -e 's_dest_/usr/local_' \
-e 's_.*_\trmdir --ignore-fail-on-non-empty "&"_' >> Makefile
echo -ne '\n\n' >> Makefile
exit 0
-- copy and paste --
More information about the cfe-dev
mailing list