lhapdf-config.in 3.11 KB
Newer Older
1
#! /usr/bin/env bash
2
## -*- sh -*-
Hannes Mildner's avatar
Hannes Mildner committed
3
## lhapdf-config for MadGraph use in Athena
4
## this custom config is required to find both the lhapdf installation dir and the actual pdf set data from LHAPDF_DATA_PATH
Hannes Mildner's avatar
Hannes Mildner committed
5
## in the default configuration the installation dir is hardcoded
6

Hannes Mildner's avatar
Hannes Mildner committed
7
8
prefix=
datapath=
9
10
# to find the prefix we searh LHAPATH before LHAPDF_DATA_PATH because the latter is more likely to change
for p in $(echo "${LHAPATH}:${LHAPDF_DATA_PATH}" | tr ":" "\n")
Hannes Mildner's avatar
Hannes Mildner committed
11
do
12
    # if LHAPDF libraries can be found from this dir and prefix is not yet defined
Hannes Mildner's avatar
Hannes Mildner committed
13
14
15
16
    if [[ -d "${p}/../../lib" ]] && [[ -z $prefix ]]
    then
	# we assume this is the lhapdf installation dir (and not the data dir)
	prefix=${p}/../..
17
18
19
20
21
22
23
24
    fi
done

# data is first searched in LHAPDF_DATA_PATH
for p in $(echo "${LHAPDF_DATA_PATH}:${LHAPATH}" | tr ":" "\n")
do
    # if this directory exists and datapath is not yet defined and its not the prefix dir
    if [[ -d ${p} ]] && [[ -z $datapath ]] && [[ ${p}/../.. != ${prefix} ]]
Hannes Mildner's avatar
Hannes Mildner committed
25
26
27
28
    then
	datapath=$p
    fi
done
29

30
31
32
33
34
35
# if no datapath is found we try the prefix path
if [[ -z $datapath ]] && [ -d $prefix/share/LHAPDF ]
then
    datapath=$prefix/share/LHAPDF
fi

Hannes Mildner's avatar
Hannes Mildner committed
36
37
if [ -z $prefix ]
then
38
    echo "WARNING: lhapdf-config could not get valid lhapdf prefix from LHAPDF_DATA_PATH"
Hannes Mildner's avatar
Hannes Mildner committed
39
fi
40

Hannes Mildner's avatar
Hannes Mildner committed
41
42
43
exec_prefix=${prefix}

version=$LHAPDFVER
44
if [ -z $version ]
Hannes Mildner's avatar
Hannes Mildner committed
45
46
47
then
    version=$(echo "$prefix" | awk '{split($1,a,"lhapdf/"); split(a[2],b,"/");print b[1];}')
fi
48

49
50
#find boost
boost=@Boost_INCLUDE_PATH@
51
52
53
54
if [ -z $boost ]
then
    echo "WARNING: lhapdf-config could not find boost headers"
fi
55
56
57
58
59
60

if [[ $# -eq 0 || -n $( echo $* | egrep -- "--help|-h" ) ]]; then
    echo "lhapdf-config: configuration tool for the LHAPDF"
    echo "               parton density function evolution library"
    echo "               http://projects.hepforge.org/lhapdf/"
    echo
61
    echo "Usage: lhapdf-config [options]"
62
    echo "Options:"
63
64
65
66
67
    echo "  --help | -h   : show this help message"
    echo "  --prefix      : show the installation prefix (cf. autoconf)"
    echo "  --incdir      : show the path to the LHAPDF C++ header directory"
    echo "  --libdir      : show the path to the LHAPDF library directory"
    echo "  --datadir     : show the path to the LHAPDF data directory"
68
    echo
69
70
    echo "  --cflags      : get compiler flags (aka --cppflags|--cxxflags)"
    echo "  --libs        : get linker flags (aka --ldflags)"
71
    echo
72
    echo "  --version     : return LHAPDF release version number"
73
74
75
76
77
fi

OUT=""

tmp=$( echo "$*" | egrep -- '--\<prefix\>')
78
test -n "$tmp" && OUT="$OUT $prefix"
79
80
81
82

tmp=$( echo "$*" | egrep -- '--\<incdir\>')
test -n "$tmp" && OUT="$OUT ${prefix}/include"

83
tmp=$( echo "$*" | egrep -- '--\<cflags|cppflags|cxxflags\>')
84
test -n "$tmp" && OUT="$OUT -I${prefix}/include -I$boost"
85
86
87
88

tmp=$( echo "$*" | egrep -- '--\<libdir\>')
test -n "$tmp" && OUT="$OUT ${exec_prefix}/lib"

89
tmp=$( echo "$*" | egrep -- '--\<libs|ldflags\>')
90
91
92
test -n "$tmp" && OUT="$OUT -L${exec_prefix}/lib -lLHAPDF"

tmp=$( echo "$*" | egrep -- '--\<datadir\>|--\<datarootdir\>')
93
test -n "$tmp" && OUT="$OUT $datapath"
94
95

tmp=$( echo "$*" | egrep -- '--\<version\>')
96
test -n "$tmp" && OUT="$OUT $version"
97
98

echo $OUT