darshan-config.in 2.44 KB
Newer Older
Philip Carns's avatar
Philip Carns committed
1
2
3
#!/bin/sh

DARSHAN_LIB_PATH="@darshan_lib_path@"
4
DARSHAN_SHARE_PATH="@darshan_share_path@"
Philip Carns's avatar
Philip Carns committed
5
DARSHAN_LD_FLAGS="@LDFLAGS@"
6
7
DARSHAN_LOG_PATH="@__DARSHAN_LOG_PATH@"
DARSHAN_LOG_ENV="@__DARSHAN_LOG_ENV@"
Philip Carns's avatar
Philip Carns committed
8

9
# NOTE:
10
11
12
13
14
# - we deliberately list libdarshan twice in the link command when
#   statically linking.  The first sets symbol wrapping options early in the
#   link line. The final one is necessary to give the linker a change to
#   resolve indirect dependencies on PnetCDF and HDF5 symbols (if the
#   app used a library which in turn used one of those HLLs).
15

16
PRE_LD_FLAGS="-L$DARSHAN_LIB_PATH $DARSHAN_LD_FLAGS -ldarshan -lz -Wl,@$DARSHAN_SHARE_PATH/ld-opts/darshan-base-ld-opts"
17
POST_LD_FLAGS="-L$DARSHAN_LIB_PATH -ldarshan @DARSHAN_LUSTRE_LD_FLAGS@ -lz -lrt -lpthread"
Philip Carns's avatar
Philip Carns committed
18

19
20
21
22
# NOTE:
# - when dynamic linking there is no need for wrapping options, we simply
#   need to get the darshan symbol definitions early enough in the link
#   order.  We also set no-as-needed for linkers that may not identify
23
DYN_LD_FLAGS="-L$DARSHAN_LIB_PATH $DARSHAN_LD_FLAGS -Wl,-rpath=$DARSHAN_LIB_PATH -Wl,-no-as-needed -ldarshan @DARSHAN_LUSTRE_LD_FLAGS@ @DARSHAN_HDF5_LD_FLAGS@"
24

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# NOTE:
# - construct complete list of log path options, separated by commas.
#   LOG_ENV takes precedent over LOG_PATH, but both could be specified.  The
#   LOG_ENV may already be a comma saparated list, but we insert '$'
#   characters to denote that these are environment variables.
if [ "$DARSHAN_LOG_ENV" ]; then
    DARSHAN_LOG_ENV=`echo $DARSHAN_LOG_ENV | sed -e 's/^/\$/g'`
    DARSHAN_LOG_ENV=`echo $DARSHAN_LOG_ENV | sed -e 's/,/,\$/g'`
fi

# figure out if we need a comma separator to construct env and path list
if [ "$DARSHAN_LOG_ENV" -a "$DARSHAN_LOG_PATH" ]; then
    DARSHAN_LOG_ALL="$DARSHAN_LOG_ENV,$DARSHAN_LOG_PATH"
elif [ "$DARSHAN_LOG_ENV" ]; then
    DARSHAN_LOG_ALL=$DARSHAN_LOG_ENV
else
    DARSHAN_LOG_ALL=$DARSHAN_LOG_PATH
fi

Philip Carns's avatar
Philip Carns committed
44
usage="\
45
Usage: darshan-config [--pre-ld-flags] [--post-ld-flags] [--dyn-ld-flags] [--log-path]"
Philip Carns's avatar
Philip Carns committed
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

if test $# -eq 0; then
      echo "${usage}" 1>&2
      exit 1
fi

while test $# -gt 0; do
  case "$1" in
  -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
  *) optarg= ;;
  esac

  case $1 in
    --pre-ld-flags)
      echo $PRE_LD_FLAGS
      ;;
    --post-ld-flags)
      echo $POST_LD_FLAGS
      ;;
65
66
67
    --dyn-ld-flags)
      echo $DYN_LD_FLAGS
      ;;
68
69
70
    --log-path)
      echo $DARSHAN_LOG_ALL
      ;;
Philip Carns's avatar
Philip Carns committed
71
72
73
74
75
76
77
    *)
      echo "${usage}" 1>&2
      exit 1
      ;;
  esac
  shift
done