[616f5dd3] | 1 | #!/bin/bash
|
---|
| 2 | #
|
---|
[140e21a] | 3 | # Copyright (c) 2020 Jiri Svoboda
|
---|
[616f5dd3] | 4 | # All rights reserved.
|
---|
| 5 | #
|
---|
| 6 | # Redistribution and use in source and binary forms, with or without
|
---|
| 7 | # modification, are permitted provided that the following conditions
|
---|
| 8 | # are met:
|
---|
| 9 | #
|
---|
| 10 | # - Redistributions of source code must retain the above copyright
|
---|
| 11 | # notice, this list of conditions and the following disclaimer.
|
---|
| 12 | # - Redistributions in binary form must reproduce the above copyright
|
---|
| 13 | # notice, this list of conditions and the following disclaimer in the
|
---|
| 14 | # documentation and/or other materials provided with the distribution.
|
---|
| 15 | # - The name of the author may not be used to endorse or promote products
|
---|
| 16 | # derived from this software without specific prior written permission.
|
---|
| 17 | #
|
---|
| 18 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 19 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 20 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 21 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 22 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 23 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 27 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 28 | #
|
---|
| 29 | # pkg-config-like tool for HelenOS libraries
|
---|
| 30 | # HelenOS Cross Compiler Wrapper (XCW)
|
---|
| 31 | # Facilitate cross-compiling external software to HelenOS
|
---|
| 32 | #
|
---|
| 33 |
|
---|
| 34 | XCW="$(dirname "$0")"
|
---|
[b78300f] | 35 | BUILD_ROOT="$(dirname "$(dirname "$(dirname "$XCW")")")"
|
---|
[b501de7] | 36 | if [ -z "$EXPORT_DIR" ]; then
|
---|
[b78300f] | 37 | EXPORT_DIR="$BUILD_ROOT/export"
|
---|
[b501de7] | 38 | fi
|
---|
[b78300f] | 39 |
|
---|
[b501de7] | 40 | INCLUDE_DIR="$EXPORT_DIR/include"
|
---|
| 41 | LIB_DIR="$EXPORT_DIR/lib"
|
---|
[616f5dd3] | 42 |
|
---|
[b501de7] | 43 | libmath_cflags="-I$INCLUDE_DIR/libmath"
|
---|
| 44 | libmath_libs="$LIB_DIR/libmath.a"
|
---|
[616f5dd3] | 45 |
|
---|
[140e21a] | 46 | libui_cflags="-I$INCLUDE_DIR/libui -I$INCLUDE_DIR/libdisplay -I$INCLUDE_DIR/libgfx -I$INCLUDE_DIR/libipcgfx"
|
---|
| 47 | libui_libs="$LIB_DIR/libui.a $LIB_DIR/libdisplay.a $LIB_DIR/libipcgfx.a $LIB_DIR/libgfx.a"
|
---|
[616f5dd3] | 48 |
|
---|
[140e21a] | 49 | libgfximage_cflags="-I$INCLUDE_DIR/libgfximage"
|
---|
| 50 | libgfximage_libs="$LIB_DIR/libgfximage.a $LIB_DIR/libpixconv.a"
|
---|
[616f5dd3] | 51 |
|
---|
[b501de7] | 52 | libhound_cflags="-I$INCLUDE_DIR/libhound"
|
---|
| 53 | libhound_libs="$LIB_DIR/libhound.a"
|
---|
[f98434b8] | 54 |
|
---|
[b501de7] | 55 | libpcm_cflags="-I$INCLUDE_DIR/libpcm"
|
---|
| 56 | libpcm_libs="$LIB_DIR/libpcm.a"
|
---|
[f98434b8] | 57 |
|
---|
[ecb7828] | 58 | libgfx_cflags="-I$INCLUDE_DIR/libgfx"
|
---|
| 59 | libgfx_libs="$LIB_DIR/libgfx.a"
|
---|
| 60 |
|
---|
| 61 | libipcgfx_cflags="-I$INCLUDE_DIR/libipcgfx"
|
---|
| 62 | libipcgfx_libs="$LIB_DIR/libipcgfx.a"
|
---|
| 63 |
|
---|
| 64 | libdisplay_cflags="-I$INCLUDE_DIR/libdisplay"
|
---|
| 65 | libdisplay_libs="$LIB_DIR/libdisplay.a"
|
---|
| 66 |
|
---|
[616f5dd3] | 67 | action=none
|
---|
| 68 | pkg=
|
---|
| 69 |
|
---|
| 70 | while [ ".$1" != . ] ; do
|
---|
| 71 | case ".$1" in
|
---|
| 72 | (.--cflags) action=cflags;;
|
---|
| 73 | (.--libs) action=libs;;
|
---|
| 74 | (.-*) echo "Uknwown option $1" >&2; exit 1;;
|
---|
| 75 | (.*)
|
---|
| 76 | case "$1" in
|
---|
[140e21a] | 77 | (libui) ;;
|
---|
| 78 | (libgfximage) ;;
|
---|
[616f5dd3] | 79 | (libmath) ;;
|
---|
[f98434b8] | 80 | (libhound) ;;
|
---|
| 81 | (libpcm) ;;
|
---|
[ecb7828] | 82 | (libgfx) ;;
|
---|
| 83 | (libipcgfx) ;;
|
---|
| 84 | (libdisplay) ;;
|
---|
[616f5dd3] | 85 | (*) echo "Unknown package $1" >&2; exit 1;;
|
---|
| 86 | esac
|
---|
| 87 |
|
---|
| 88 | echo "$pkg" | grep -w "$1" >/dev/null 2>&1
|
---|
| 89 | if [ $? -ne 0 ] ; then
|
---|
| 90 | pkg="$pkg $1"
|
---|
| 91 | fi;;
|
---|
| 92 | esac
|
---|
| 93 | shift 1
|
---|
| 94 | done
|
---|
| 95 |
|
---|
| 96 | if [ ."$pkg" = . ]; then
|
---|
| 97 | echo "Package name(s) required." >&2
|
---|
| 98 | exit 1
|
---|
| 99 | fi
|
---|
| 100 |
|
---|
| 101 | for p in $pkg ; do
|
---|
| 102 | case "$action" in
|
---|
| 103 | (cflags) eval "printf ' %s' \$${p}_cflags";;
|
---|
| 104 | (libs) eval "printf ' %s' \$${p}_libs";;
|
---|
| 105 | esac
|
---|
| 106 | done
|
---|
| 107 |
|
---|
| 108 | echo
|
---|