2 # Script used to link OCaml programs.
4 # (C) Copyright 2015-2020 Red Hat Inc.
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.
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.
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.
20 # See guestfs-hacking(1) section "HOW OCAML PROGRAMS ARE COMPILED AND LINKED"
22 # Hack automake to link OCaml-based binaries properly.
23 # There is no other way to add the -cclib parameter to the end of
27 # ./ocaml-link.sh -cclib '...' -- ARGS
28 # Pass the cclib argument separately, and the rest as separated
31 TEMP=`getopt -a -o '' --long 'cclib:' \
32 -n "$(basename $0)" -- "$@"`
33 if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
40 -cclib|--cclib) cclib="$2" ; shift 2 ;;
42 *) echo "Internal error!" ; exit 1 ;;
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
50 @OCAML_RUNTIME_VARIANT_PIC_OPTION@ \
52 -cclib "'@LDFLAGS@ $cclib'"
54 # NB -cclib must come last.
56 @OCAML_RUNTIME_VARIANT_PIC_OPTION@ \
58 -cclib "@LDFLAGS@ $cclib"