updated the recipes of geda-gaf, pcb and gerbv. Different server, the most current...
[minipack.git] / mpk
blob1d8acdd8ba538e7b14a28366889d8a33fe89fdba
1 #! /bin/sh
3 # mpk - top level, user visible script.
4 # Copyright (C) 2008 Cesar Strauss
6 # This file is part of Minipack - an automated build tool.
8 # Minipack is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # Minipack is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Minipack. If not, see <http://www.gnu.org/licenses/>.
21 bindir=$(dirname $0)
22 prog=$(basename $0)
23 case $bindir in
24 /*) ;;
25 *) bindir=$PWD/$bindir;;
26 esac
27 mpk=$bindir/$prog
28 prefix=$(cd $bindir && pwd)
29 tooldir=$prefix/tools
30 recipedir=$prefix/recipes
31 patchdir=$prefix/patches
33 MPK_VERSION=1.2
35 export PATH=$tooldir:$PATH
37 test -f ~/minipack.conf && . ~/minipack.conf
39 cwd=$PWD
40 topdir=$cwd
41 until [ "$topdir" = "/" ]; do
42 if [ -f $topdir/minipack.conf ]; then
43 break;
45 cd ..
46 topdir=$PWD
47 done
48 cd $cwd
50 if [ "$topdir" = "/" ]; then
51 echo Warning: no minipack.conf found.
52 topdir=$cwd
55 builddir=$topdir/build
56 resultdir=$topdir/result
57 sourcedir=$topdir/sources
58 local_tooldir=$resultdir/lib/mpk/tools
60 # Export resultdir in case we need to call our newly built tools.
61 export resultdir
63 test -f $topdir/minipack.conf && . $topdir/minipack.conf
65 # Setup environment variables
66 export PATH=$local_tooldir:$PATH
67 export ACLOCAL="aclocal -I $resultdir/share/aclocal"
68 export ACLOCAL_FLAGS="-I $resultdir/share/aclocal"
69 export PKG_CONFIG_LIBDIR=$resultdir/lib/pkgconfig
71 get_recipe_name()
73 name=$recipedir/$1.recipe
74 if [ ! -f $name ]; then
75 echo >&2 "Recipe for \"$1\" not found."
76 exit 1
78 echo $name
81 setup_configure_options()
83 pkg_configure_opt="$def_configure_opt $configure_opt"
84 pkg_configure_opt="$pkg_configure_opt --prefix=$resultdir"
86 if [ -n "$host" ]; then
87 pkg_configure_opt="$pkg_configure_opt --host=$host"
89 if [ -n "$build" ]; then
90 pkg_configure_opt="$pkg_configure_opt --build=$build"
93 # Local compiler/linker search path
94 CPPFLAGS="$CPPFLAGS -I$resultdir/include"
95 LDFLAGS="$LDFLAGS -L$resultdir/lib"
97 test -n "$configure_no_more_flags" && return
99 # Add search paths to the configure line.
100 pkg_configure_opt="$pkg_configure_opt CPPFLAGS=\"$CPPFLAGS\""
101 pkg_configure_opt="$pkg_configure_opt LDFLAGS=\"$LDFLAGS\""
103 # Add extra flags to the configure line, if present.
104 if [ -n "$CFLAGS" ]; then
105 pkg_configure_opt="$pkg_configure_opt CFLAGS=\"$CFLAGS\""
107 if [ -n "$CXXFLAGS" ]; then
108 pkg_configure_opt="$pkg_configure_opt CXXFLAGS=\"$CXXFLAGS\""
112 if [ -n "$1" ]; then
113 cmd=$1
114 shift
115 else
116 echo "$prog: missing argument."
117 cmd=help
120 case $cmd in
121 --version)
122 cmd=version ;;
123 --help)
124 cmd=help ;;
125 esac
126 tool=$tooldir/mpk-$cmd
127 if [ -f $tool ]; then
128 . $tool "$@"
129 else
130 echo $prog: Invalid command: $cmd