chiark / gitweb /
libllvm: add llvm-config helper script (#917)
authorVishal Biswas <vshlbiswas@ymail.com>
Sat, 1 Jul 2017 00:41:21 +0000 (06:11 +0530)
committerFredrik Fornwall <fredrik@fornwall.net>
Sat, 1 Jul 2017 00:41:21 +0000 (02:41 +0200)
* libllvm: add llvm-config helper script

* libllvm: add components to llvm-config wrapper

* libllvm: restructure llvm-config.in

* libllvm: remove unsupported gcc flags from llvm-config

* libllvm: use full libfile path for --libs

* libllvm: fix has_rtti in llvm-config

* libllvm: add cmake files path in llvm-config

packages/libllvm/build.sh
packages/libllvm/llvm-config.in [new file with mode: 0644]

index 656bd18b541b743e70563c798950b0b08965ed26..97ae0a81174facc44758668d563e066b0d636e30 100644 (file)
@@ -63,7 +63,8 @@ termux_step_host_build () {
 
 termux_step_pre_configure () {
        cd $TERMUX_PKG_BUILDDIR
 
 termux_step_pre_configure () {
        cd $TERMUX_PKG_BUILDDIR
-       local LLVM_DEFAULT_TARGET_TRIPLE=$TERMUX_HOST_PLATFORM
+       export LLVM_DEFAULT_TARGET_TRIPLE=$TERMUX_HOST_PLATFORM
+       export LLVM_TARGET_ARCH
        if [ $TERMUX_ARCH = "arm" ]; then
                LLVM_TARGET_ARCH=ARM
                # See https://github.com/termux/termux-packages/issues/282
        if [ $TERMUX_ARCH = "arm" ]; then
                LLVM_TARGET_ARCH=ARM
                # See https://github.com/termux/termux-packages/issues/282
@@ -89,3 +90,14 @@ termux_step_post_make_install () {
                ln -f -s clang-${_PKG_MAJOR_VERSION} $tool
        done
 }
                ln -f -s clang-${_PKG_MAJOR_VERSION} $tool
        done
 }
+
+termux_step_post_massage () {
+       sed $TERMUX_PKG_BUILDER_DIR/llvm-config.in \
+               -e "s|@_PKG_MAJOR_VERSION@|$_PKG_MAJOR_VERSION|g" \
+               -e "s|@TERMUX_PREFIX@|$TERMUX_PREFIX|g" \
+               -e "s|@TERMUX_PKG_SRCDIR@|$TERMUX_PKG_SRCDIR|g" \
+               -e "s|@LLVM_TARGET_ARCH@|$LLVM_TARGET_ARCH|g" \
+               -e "s|@LLVM_DEFAULT_TARGET_TRIPLE@|$LLVM_DEFAULT_TARGET_TRIPLE|g" \
+               -e "s|@TERMUX_ARCH@|$TERMUX_ARCH|g" > $TERMUX_PREFIX/bin/llvm-config
+       chmod 755 $TERMUX_PREFIX/bin/llvm-config
+}
diff --git a/packages/libllvm/llvm-config.in b/packages/libllvm/llvm-config.in
new file mode 100644 (file)
index 0000000..828a5ca
--- /dev/null
@@ -0,0 +1,105 @@
+#!/bin/sh
+show_help () {
+echo "usage: llvm-config <OPTION>... [<COMPONENT>...]
+
+Get various configuration information needed to compile programs which use
+LLVM.  Typically called from 'configure' scripts.  Examples:
+  llvm-config --cxxflags
+  llvm-config --ldflags
+  llvm-config --libs engine bcreader scalaropts
+
+Options:
+  --version         Print LLVM version.
+  --prefix          Print the installation prefix.
+  --src-root        Print the source root LLVM was built from.
+  --obj-root        Print the object root used to build LLVM.
+  --bindir          Directory containing LLVM executables.
+  --includedir      Directory containing LLVM headers.
+  --libdir          Directory containing LLVM libraries.
+  --cppflags        C preprocessor flags for files that include LLVM headers.
+  --cflags          C compiler flags for files that include LLVM headers.
+  --cxxflags        C++ compiler flags for files that include LLVM headers.
+  --ldflags         Print Linker flags.
+  --system-libs     System Libraries needed to link against LLVM components.
+  --libs            Libraries needed to link against LLVM components.
+  --libnames        Bare library names for in-tree builds.
+  --libfiles        Fully qualified library filenames for makefile depends.
+  --components      List of all possible components.
+  --targets-built   List of all targets currently built.
+  --host-target     Target triple used to configure LLVM.
+  --build-mode      Print build mode of LLVM tree (e.g. Debug or Release).
+  --assertion-mode  Print assertion mode of LLVM tree (ON or OFF).
+  --build-system    Print the build system used to build LLVM (always cmake).
+  --has-rtti        Print whether or not LLVM was built with rtti (YES or NO).
+  --has-global-isel Print whether or not LLVM was built with global-isel support (YES or NO).
+  --shared-mode     Print how the provided components can be collectively linked (\`shared\` or \`static\`).
+  --link-shared     Link the components as shared libraries.
+  --link-static     Link the component libraries statically.                                                                                                                                 
+Typical components:                                                                                                                                                                          
+  all               All LLVM libraries (default).                                                                                                                                            
+  engine            Either a native JIT or a bitcode interpreter."
+}
+
+arch=@TERMUX_ARCH@
+version=@_PKG_MAJOR_VERSION@
+prefix=@TERMUX_PREFIX@
+has_rtti=NO
+CPPFLAGS="-I${prefix}/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
+CFLAGS="${CPPFLAGS} -Os -fPIC -Wall -W -Wno-unused-parameter -Wwrite-strings -Wmissing-field-initializers"
+CFLAGS="${CFLAGS} -pedantic -Wno-long-long -Wdelete-non-virtual-dtor -Werror=date-time -ffunction-sections"
+CFLAGS="${CFLAGS} -fdata-sections -DNDEBUG"
+CXXFLAGS="${CFLAGS} -fvisibility-inlines-hidden -Wcast-qual -Wnon-virtual-dtor -std=c++11 -fno-exceptions"
+if [ "$has_rtti" != "YES" ]; then CXXFLAGS="$CXXFLAGS -fno-rtti"; fi
+LDFLAGS="-L${prefix}/lib"
+LIBFILE="${prefix}/lib/libLLVM-$version.so"
+
+show_components () {
+if [ "$arch" == "x86_64" -o "$arch" == "i686" ]; then arch="x86"; fi
+components="all all-targets analysis $arch ${arch}asmparser ${arch}asmprinter ${arch}codegen ${arch}desc"
+components="$components ${arch}disassembler ${arch}info asmparser asmprinter bitreader bitwriter codegen"
+components="$components core coroutines coverage debuginfocodeview debuginfodwarf debuginfomsf debuginfopdb"
+components="$components demangle engine executionengine globalisel instcombine instrumentation interpreter"
+components="$components ipo irreader libdriver lineeditor linker lto mc mcdisassembler mcjit mcparser"
+components="$components mirparser native nativecodegen objcarcopts object objectyaml option orcjit passes"
+components="$components profiledata runtimedyld scalaropts selectiondag support symbolize tablegen target"
+components="$components transformutils vectorize"
+if [ "$arch" != "arm" ]; then components="$components ${arch}utils"; fi
+echo "$components"
+}
+
+handle_args () {
+       case "${1##--}" in
+               version) echo "$version";;
+               prefix) echo "$prefix";;
+               src-root) echo "@TERMUX_PKG_SRCDIR@";;
+               obj-root) echo "$prefix";;
+               bindir) echo "$prefix/bin";;
+               includedir) echo "$prefix/include";;
+               libdir) echo "$prefix/lib";;
+               cppflags) echo "$CPPFLAGS";;
+               cflags) echo "$CFLAGS";;
+               cxxflags) echo "$CXXFLAGS";;
+               ldflags) echo "$LDFLAGS";;
+               system-libs) echo "-lc -ldl -lcurses -lz -lm";;
+               libs) echo "-l$LIBFILE";;
+               libnames) echo "libLLVM-$version.so";;
+               libfiles) echo "$LIBFILE";;
+               components) show_components;;
+               targets-built) echo "@LLVM_TARGET_ARCH@";;
+               host-target) echo "@LLVM_DEFAULT_TARGET_TRIPLE@";;
+               build-mode) echo "Release";;
+               assertion-mode) echo "OFF";;
+               build-system) echo "cmake";;
+               has-rtti) echo "$has_rtti";;
+               has-global-isel) echo "OFF";;
+               shared-mode) echo "shared";;
+               cmakedir) echo "$prefix/lib/cmake/llvm";;
+               # don't know what these do
+               link-shared) ;;
+               link-static) ;;
+               *) show_help >&2;;
+       esac
+}
+
+for arg in $@; do handle_args $arg; done
+