1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#!/bin/sh
##
## Copyright (C) by Argonne National Laboratory
## See COPYRIGHT in top-level directory
##
# Wrapper to create .lo objects with non-standard compilers, e.g. NVCC.
# This is hack assuming
# 1. option "-Xcompiler -fPIC" to create PIC object.
# 2. the format will remain compatible with libtool.
#
set -e
verbose=
if test "$1" = "--verbose" ; then
verbose=1
shift
fi
LO_FILEPATH="$1"
O_FILEPATH="${LO_FILEPATH%%.lo}.o"
shift # handle the rest of the arguments together with ${@}
LO_DIR=$(dirname $O_FILEPATH)
O_FILENAME=$(basename $O_FILEPATH)
LOCAL_PIC_DIR=".libs/"
LOCAL_NPIC_DIR=""
PIC_DIR="$LO_DIR/$LOCAL_PIC_DIR"
NPIC_DIR="$LO_DIR/$LOCAL_NPIC_DIR"
PIC_FILEPATH="$PIC_DIR/$O_FILENAME"
NPIC_FILEPATH="$NPIC_DIR/$O_FILENAME"
LOCAL_PIC_FILEPATH="$LOCAL_PIC_DIR$O_FILENAME"
LOCAL_NPIC_FILEPATH="$LOCAL_NPIC_DIR$O_FILENAME"
if test ! -d "$PIC_DIR" ; then
mkdir -p "$PIC_DIR"
fi
CMD="${@} -Xcompiler -fPIC -o $PIC_FILEPATH"
if test "$verbose" ; then echo "$CMD" ; fi
eval "$CMD"
CMD="${@} -o $NPIC_FILEPATH"
if test "$verbose" ; then echo "$CMD" ; fi
eval "$CMD"
cat > $LO_FILEPATH <<EOF
# $LO_FILEPATH - a libtool object file
# Generated by libtool (GNU libtool) 2.4.5
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# Name of the PIC object.
pic_object="$LOCAL_PIC_FILEPATH"
# Name of the non-PIC object.
non_pic_object="$LOCAL_NPIC_FILEPATH"
EOF
|