2010-08-12 01:18:31 +08:00
#
# Chakra Packages for Chakra, part of chakra-project.org
#
2013-01-23 12:04:28 +08:00
# maintainer Daniele Cocca <jmc@chakra-project.org>
2012-01-05 23:37:41 +08:00
2012-11-21 09:36:57 +08:00
pkgbase = "llvm"
2010-08-12 01:18:31 +08:00
pkgname = ( 'llvm' 'llvm-ocaml' 'clang' 'clang-analyzer' )
2012-12-22 00:38:23 +08:00
pkgver = 3.2
2012-11-21 09:36:57 +08:00
_gcc_ver = 4.7.2
2013-02-27 10:24:50 +08:00
pkgrel = 2
2012-11-21 09:36:57 +08:00
arch = ( 'x86_64' )
2011-05-11 03:25:54 +08:00
url = "http://llvm.org/"
2010-06-07 21:12:50 +08:00
license = ( 'custom:University of Illinois/NCSA Open Source License' )
2012-01-05 23:37:41 +08:00
makedepends = ( 'gcc-libs' 'libffi' 'python2' 'ocaml' " gcc= ${ _gcc_ver } " 'groff' )
2012-11-21 09:36:57 +08:00
source = ( " http://llvm.org/releases/ ${ pkgver } / ${ pkgbase } - ${ pkgver } .src.tar.gz "
2012-07-17 09:05:37 +08:00
" http://llvm.org/releases/ ${ pkgver } /clang- ${ pkgver } .src.tar.gz " )
2012-12-22 00:38:23 +08:00
md5sums = ( '71610289bbc819e3e15fdd562809a2d7'
'3896ef4334df08563b05d0848ba80582' )
2010-06-07 21:12:50 +08:00
build( ) {
2012-11-21 09:36:57 +08:00
cd " ${ srcdir } / ${ pkgbase } - ${ pkgver } .src "
2010-06-07 21:12:50 +08:00
# At the present, clang must reside inside the LLVM source code tree to build
# See http://llvm.org/bugs/show_bug.cgi?id=4840
2010-08-12 01:18:31 +08:00
rm -rf tools/clang
2012-01-05 23:37:41 +08:00
cp -r " ${ srcdir } /clang- ${ pkgver } .src " tools/clang
2010-06-07 21:12:50 +08:00
# Fix symbolic links from OCaml bindings to LLVM libraries
2012-07-17 09:05:37 +08:00
sed -e 's:\$(PROJ_libdir):/usr/lib/llvm:' \
-i bindings/ocaml/Makefile.ocaml
2010-06-07 21:12:50 +08:00
# Fix installation directories, ./configure doesn't seem to set them right
2012-07-17 09:05:37 +08:00
sed -e 's:\$(PROJ_prefix)/etc/llvm:/etc/llvm:' \
-e 's:\$(PROJ_prefix)/lib:$(PROJ_prefix)/lib/llvm:' \
-e 's:\$(PROJ_prefix)/docs/llvm:$(PROJ_prefix)/share/doc/llvm:' \
-i Makefile.config.in
2010-06-07 21:12:50 +08:00
2012-07-20 10:11:46 +08:00
sed -e '/ActiveLibDir = ActivePrefix/s:lib:lib/llvm:' \
-i tools/llvm-config/llvm-config.cpp
sed -e 's:LLVM_LIBDIR="${prefix}/lib":LLVM_LIBDIR="${prefix}/lib/llvm":' \
-i autoconf/configure.ac \
-i configure
2010-06-07 21:12:50 +08:00
# Fix insecure rpath (http://bugs.archlinux.org/task/14017)
2012-07-17 09:05:37 +08:00
sed -e 's:$(RPATH) -Wl,$(\(ToolDir\|LibDir\|ExmplDir\))::g' \
-i Makefile.rules
2010-06-07 21:12:50 +08:00
# Apply strip option to configure
2011-05-11 03:25:54 +08:00
_optimized_switch = "enable"
2012-01-05 23:37:41 +08:00
[ " $( check_option strip) " = = 'n' ] && _optimized_switch = "disable"
2010-06-07 21:12:50 +08:00
# Include location of libffi headers in CPPFLAGS
2012-01-05 23:37:41 +08:00
export CPPFLAGS = " ${ CPPFLAGS } $( pkg-config --cflags libffi) "
2010-06-07 21:12:50 +08:00
2012-01-05 23:37:41 +08:00
_cxx_headers = " /usr/include/c++/ ${ _gcc_ver } "
if [ ! -d " ${ _cxx_headers } " ] ; then
error "Couldn't find the C++ headers, PKGBUILD needs fixing!"
return 1
fi
2011-11-20 02:37:53 +08:00
_32bit_headers = ""
2012-01-05 23:37:41 +08:00
if [ " ${ CARCH } " = = 'x86_64' ] ; then
2011-11-20 02:37:53 +08:00
# Important for multilib
_32bit_headers = "32"
2011-05-11 03:25:54 +08:00
fi
2012-01-05 23:37:41 +08:00
./configure --prefix= /usr \
--libdir= /usr/lib/llvm \
--sysconfdir= /etc \
--enable-shared \
--enable-libffi \
--enable-targets= all \
--disable-expensive-checks \
--disable-debug-runtime \
--disable-assertions \
--with-binutils-include= /usr/include \
--with-cxx-include-root= " ${ _cxx_headers } " \
--with-cxx-include-arch= " ${ CHOST } " \
--with-cxx-include-32bit-dir= " ${ _32bit_headers } " \
2012-07-17 09:05:37 +08:00
" -- ${ _optimized_switch } -optimized "
2011-05-11 03:25:54 +08:00
make REQUIRES_RTTI = 1
2010-06-07 21:12:50 +08:00
}
package_llvm( ) {
2012-11-21 09:36:57 +08:00
pkgdesc = "The LLVM Core libraries provide a modern source- and target-independent optimizer, along with code generation support for many popular CPUs."
2012-07-17 09:05:37 +08:00
depends = ( 'perl' 'libffi' )
2010-06-07 21:12:50 +08:00
2012-11-21 09:36:57 +08:00
cd " ${ srcdir } / ${ pkgbase } - ${ pkgver } .src "
2012-01-05 23:37:41 +08:00
# The OCaml binding installation is currently broken, let's fix it
# see https://github.com/mxcl/homebrew/issues/8947#issuecomment-3256464
2012-07-17 09:05:37 +08:00
sed -e 's:\$(ObjDir)/META.llvm:\$(OcamlDir)/META.llvm:' \
-i bindings/ocaml/llvm/Makefile
2010-06-07 21:12:50 +08:00
# We move the clang directory out of the tree so it won't get installed and
# then we bring it back in for the clang package
2012-01-05 23:37:41 +08:00
mv tools/clang " ${ srcdir } "
2010-06-07 21:12:50 +08:00
# -j1 is due to race conditions during the installation of the OCaml bindings
2012-01-05 23:37:41 +08:00
make -j1 DESTDIR = " ${ pkgdir } " install
mv " ${ srcdir } /clang " tools
2010-06-07 21:12:50 +08:00
# OCaml bindings go to a separate package
2012-01-05 23:37:41 +08:00
rm -rf " ${ srcdir } " /{ ocaml,ocamldoc}
mv " ${ pkgdir } " /usr/{ lib/ocaml,share/doc/llvm/ocamldoc} " ${ srcdir } "
2010-06-07 21:12:50 +08:00
# Remove duplicate files installed by the OCaml bindings
2012-01-05 23:37:41 +08:00
rm " ${ pkgdir } " /usr/{ lib/llvm/libllvm*,share/doc/llvm/ocamldoc.tar.gz}
2010-06-07 21:12:50 +08:00
# Fix permissions of static libs
2012-01-05 23:37:41 +08:00
chmod -x " ${ pkgdir } " /usr/lib/llvm/*.a
2010-06-07 21:12:50 +08:00
# Fix libdir in llvm-config (http://bugs.archlinux.org/task/14487)
2012-07-17 09:05:37 +08:00
sed -e 's:\(ABS_RUN_DIR/lib\):\1/llvm:' \
-i " ${ pkgdir } /usr/bin/llvm-config "
2010-06-07 21:12:50 +08:00
# Get rid of example Hello transformation
2012-01-05 23:37:41 +08:00
rm " ${ pkgdir } " /usr/lib/llvm/*LLVMHello.*
2010-06-07 21:12:50 +08:00
2011-05-11 03:25:54 +08:00
# Symlink the gold plugin where clang expects it
2012-01-05 23:37:41 +08:00
ln -s llvm/LLVMgold.so " ${ pkgdir } /usr/lib/LLVMgold.so "
2011-05-11 03:25:54 +08:00
2010-06-07 21:12:50 +08:00
# Add ld.so.conf.d entry
2012-01-05 23:37:41 +08:00
install -d " ${ pkgdir } /etc/ld.so.conf.d "
echo /usr/lib/llvm >" ${ pkgdir } /etc/ld.so.conf.d/llvm.conf "
2010-06-07 21:12:50 +08:00
2012-07-17 09:05:37 +08:00
install -D -m644 LICENSE.TXT " ${ pkgdir } /usr/share/licenses/ ${ pkgname } /LICENSE "
2010-06-07 21:12:50 +08:00
}
package_llvm-ocaml( ) {
2012-11-21 09:36:57 +08:00
pkgdesc = "OCaml bindings for LLVM."
2012-07-17 09:05:37 +08:00
depends = ( " llvm= ${ pkgver } - ${ pkgrel } " 'ocaml' )
2010-06-07 21:12:50 +08:00
2012-11-21 09:36:57 +08:00
cd " ${ srcdir } / ${ pkgbase } - ${ pkgver } .src "
2010-06-07 21:12:50 +08:00
2012-01-05 23:37:41 +08:00
install -d " ${ pkgdir } " /{ usr/lib,usr/share/doc/llvm}
cp -r " ${ srcdir } /ocaml " " ${ pkgdir } /usr/lib "
cp -r " ${ srcdir } /ocamldoc " " ${ pkgdir } /usr/share/doc/llvm "
2010-06-07 21:12:50 +08:00
# Remove execute bit from static libraries
2012-01-05 23:37:41 +08:00
chmod -x " ${ pkgdir } " /usr/lib/ocaml/libllvm*.a
2010-06-07 21:12:50 +08:00
2012-11-21 09:36:57 +08:00
install -D -m644 LICENSE.TXT " ${ pkgdir } /usr/share/licenses/ ${ pkgname } /LICENSE "
2010-06-07 21:12:50 +08:00
}
package_clang( ) {
2012-11-21 09:36:57 +08:00
pkgdesc = "Clang is an \"LLVM native\" C/C++/Objective-C compiler, which aims to deliver amazingly fast compiles, extremely useful error and warning messages and to provide a platform for building great source level tools."
2012-07-17 09:05:37 +08:00
url = "http://clang.llvm.org/"
# It looks like clang still needs GCC to assemble and link object files
# See http://old.nabble.com/%22clang--v%22-shows-a-GCC-call-td28378453.html
depends = ( " llvm= ${ pkgver } - ${ pkgrel } " " gcc= ${ _gcc_ver } " )
2010-06-07 21:12:50 +08:00
# Fix installation path for clang docs
2012-07-17 09:05:37 +08:00
sed -e 's:$(PROJ_prefix)/share/doc/llvm:$(PROJ_prefix)/share/doc/clang:' \
2012-11-21 09:36:57 +08:00
-i " ${ srcdir } / ${ pkgbase } - ${ pkgver } .src/Makefile.config "
2010-06-07 21:12:50 +08:00
2012-11-21 09:36:57 +08:00
cd " ${ srcdir } / ${ pkgbase } - ${ pkgver } .src/tools/clang "
2012-01-05 23:37:41 +08:00
make DESTDIR = " ${ pkgdir } " install
2010-06-07 21:12:50 +08:00
# Fix permissions of static libs
2012-01-05 23:37:41 +08:00
chmod -x " ${ pkgdir } " /usr/lib/llvm/*.a
2010-06-07 21:12:50 +08:00
# Revert the path change in case we want to do a repackage later
2012-07-17 09:05:37 +08:00
sed -e 's:$(PROJ_prefix)/share/doc/clang:$(PROJ_prefix)/share/doc/llvm:' \
2012-11-21 09:36:57 +08:00
-i " ${ srcdir } / ${ pkgbase } - ${ pkgver } .src/Makefile.config "
2010-06-07 21:12:50 +08:00
2011-11-20 02:37:53 +08:00
# Install old libstdc++ headers. Contains combined headers from
# gcc 4.5.2-6-i686 and gcc-multilib-4.5.2-6-x86_64
2012-01-05 23:37:41 +08:00
# install -d "${pkgdir}/usr/include/c++"
# cp -rd "${srcdir}/gcc-headers-${_gcc_ver}" "${pkgdir}/usr/include/c++/clang-${pkgver}"
2011-11-20 02:37:53 +08:00
2012-11-21 09:36:57 +08:00
install -D -m644 LICENSE.TXT " ${ pkgdir } /usr/share/licenses/ ${ pkgname } /LICENSE "
2010-06-07 21:12:50 +08:00
}
package_clang-analyzer( ) {
2012-11-21 09:36:57 +08:00
pkgdesc = "The Clang Static Analyzer is a tool that automatically finds bugs in your code, and is a great example of the sort of tool that can be built using the Clang frontend as a library to parse C/C++ code."
2012-07-17 09:05:37 +08:00
url = "http://clang-analyzer.llvm.org/"
depends = ( " clang= ${ pkgver } - ${ pkgrel } " 'python2' )
2010-06-07 21:12:50 +08:00
2012-11-21 09:36:57 +08:00
cd " ${ srcdir } / ${ pkgbase } - ${ pkgver } .src/tools/clang "
2010-06-07 21:12:50 +08:00
2012-01-05 23:37:41 +08:00
install -d " ${ pkgdir } " /usr/{ bin,lib/clang-analyzer}
2011-05-11 03:25:54 +08:00
for _tool in scan-{ build,view} ; do
2012-01-05 23:37:41 +08:00
cp -r " tools/ ${ _tool } " " ${ pkgdir } /usr/lib/clang-analyzer "
ln -s " /usr/lib/clang-analyzer/ ${ _tool } / ${ _tool } " " ${ pkgdir } /usr/bin "
2010-06-07 21:12:50 +08:00
done
2011-05-11 03:25:54 +08:00
# Use Python 2
2012-07-17 09:05:37 +08:00
sed -e 's/env python$/&2/' \
-i " ${ pkgdir } /usr/lib/clang-analyzer/scan-view/scan-view " \
-i " ${ pkgdir } /usr/lib/clang-analyzer/scan-build/set-xcode-analyzer "
2011-05-11 03:25:54 +08:00
2010-06-07 21:12:50 +08:00
# Compile Python scripts
2012-01-05 23:37:41 +08:00
python2 -m compileall " ${ pkgdir } /usr/lib/clang-analyzer "
python2 -O -m compileall " ${ pkgdir } /usr/lib/clang-analyzer "
2010-06-07 21:12:50 +08:00
2012-11-21 09:36:57 +08:00
install -D -m644 LICENSE.TXT " ${ pkgdir } /usr/share/licenses/ ${ pkgname } /LICENSE "
2011-11-20 02:37:53 +08:00
}
2012-01-05 23:37:41 +08:00
# vim:set ts=2 sw=2 et: