Remove dependency on xml-light, replace with libxml2
[virt-top.git] / ocaml-link.sh.in
1 #!/bin/bash -
2 # Script used to link OCaml programs.
3 # @configure_input@
4 # (C) Copyright 2015-2020 Red Hat Inc.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20 # See guestfs-hacking(1) section "HOW OCAML PROGRAMS ARE COMPILED AND LINKED"
21
22 # Hack automake to link OCaml-based binaries properly.
23 # There is no other way to add the -cclib parameter to the end of
24 # the command line.
25
26 # Usage:
27 #   ./ocaml-link.sh -cclib '...' -- ARGS
28 # Pass the cclib argument separately, and the rest as separated
29 # arguments.
30
31 TEMP=`getopt -a -o '' --long 'cclib:' \
32   -n "$(basename $0)" -- "$@"`
33 if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
34 eval set -- "$TEMP"
35
36 cclib=
37
38 while true ; do
39   case "$1" in
40     -cclib|--cclib) cclib="$2" ; shift 2 ;;
41     --) shift ; break ;;
42     *) echo "Internal error!" ; exit 1 ;;
43   esac
44 done
45
46 # Integration with silent rules of automake: print the full command
47 # line option in verbose mode.
48 if [ x"${V:-@AM_DEFAULT_VERBOSITY@}" = x1 ]; then
49   echo "$@" \
50      @OCAML_RUNTIME_VARIANT_PIC_OPTION@ \
51      -linkpkg \
52      -cclib "'@LDFLAGS@ $cclib'"
53 fi
54 # NB -cclib must come last.
55 exec "$@" \
56      @OCAML_RUNTIME_VARIANT_PIC_OPTION@ \
57      -linkpkg \
58      -cclib "@LDFLAGS@ $cclib"