sysrepo_config 3.61 KB
Newer Older
Razvan Becheriu's avatar
Razvan Becheriu committed
1
#!/bin/sh
2

3
4
5
6
7
8
9
10
11
12
# Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# This is keactrl script responsible for starting up Kea processes.
# This script is used to run Kea from installation directory,
# as well as for running tests.

Andrei Pavel's avatar
Andrei Pavel committed
13
sysrepo_lib="libsysrepo"
14

Razvan Becheriu's avatar
Razvan Becheriu committed
15
if [ -z "${YANG_LIBRARY_PATH}" ]; then
Tomek Mrugalski's avatar
Tomek Mrugalski committed
16
    YANG_LIBRARY_PATH=/
17
18
fi

Tomek Mrugalski's avatar
Tomek Mrugalski committed
19
20
if [ "$(uname -s)" = "Darwin" ]; then
    DIR=$(stat -f %N "$0" | xargs dirname)
21
else
Tomek Mrugalski's avatar
Tomek Mrugalski committed
22
    DIR=$(readlink -f "$0" | xargs dirname)
23
24
fi

Tomek Mrugalski's avatar
Tomek Mrugalski committed
25
26
27
if ! [ -f "${DIR}/sysrepo_config_defines.sh" ] || ! [ -x "${DIR}/sysrepo_config_defines.sh" ]; then
    echo "missing path configuration file for Sysrepo (sysrepo_config_defines.sh)"
    exit 0
28
fi
29
30
31
32

# Shellcheck tries to follow this link and gets confused about not being able
# to find the file.
# shellcheck disable=SC1090
33
. "${DIR}/sysrepo_config_defines.sh"
34

Razvan Becheriu's avatar
Razvan Becheriu committed
35
36
37
if [ $# -ne 1 ] && [ $# -ne 2 ]; then
    echo "run: \`$0 --help\` for more help"
    exit 0
38
fi
Razvan Becheriu's avatar
Razvan Becheriu committed
39
<<<<<<< HEAD
40
if [ "$1" = "--help" ]
41
then
Razvan Becheriu's avatar
Razvan Becheriu committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
	echo "sysrepo_config 'option' ['library']"
	echo "options:"
	echo "--help"
	echo "    print this help message"
	echo "--cflags-only-other"
	echo "    get cpp compilation flags"
	echo "--cflags-only-I"
	echo "    get include path"
	echo "--libs"
	echo "    get lib path"
	echo "--modversion"
	echo "    get version"
	echo "--variable=SR_REPOSITORY_LOC"
	echo "    get repo path"
	echo "libraries:"
	echo "    libsysrepo"
	echo "    libSysrepo-cpp"
	exit 0
else if [ $# -ne 2 ]
	then
		echo "run: \`$0 --help\` for more help"
		exit 0
	else if [ $2 != "libsysrepo" ] && [ $2 != "libSysrepo-cpp" ]
		then
			echo "library $2 not supported"
			echo "run: \`$0 --help\` for more help"
			exit 0
		else
			sysrepo_lib=$2
		fi
	fi
Razvan Becheriu's avatar
Razvan Becheriu committed
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
=======

if [ "$1" = "--help" ]; then
    echo "sysrepo_config 'option' ['library']"
    echo "options:"
    echo "--help"
    echo "    print this help message"
    echo "--cflags-only-other"
    echo "    get cpp compilation flags"
    echo "--cflags-only-I"
    echo "    get include path"
    echo "--libs"
    echo "    get lib path"
    echo "--modversion"
    echo "    get version"
    echo "--variable=SR_REPOSITORY_LOC"
    echo "    get repo path"
    echo "libraries:"
    echo "    libsysrepo"
    echo "    libSysrepo-cpp"
    exit 0
>>>>>>> fixed script
95
fi
Tomek Mrugalski's avatar
Tomek Mrugalski committed
96
97
98

if [ $# -ne 2 ]; then
    echo "Incorrect number of parameters specified"
Razvan Becheriu's avatar
Razvan Becheriu committed
99
    echo "run: \`$0 --help\` for more help"
Tomek Mrugalski's avatar
Tomek Mrugalski committed
100
    exit 0
Razvan Becheriu's avatar
fixed    
Razvan Becheriu committed
101
elif [ "$2" != "libsysrepo" ] && [ "$2" != "libSysrepo-cpp" ]; then
Tomek Mrugalski's avatar
Tomek Mrugalski committed
102
103
104
105
106
    echo "library $2 not supported"
    echo "run: \`$0 --help\` for more help"
    exit 0
else
    sysrepo_lib=$2
107
fi
Razvan Becheriu's avatar
Razvan Becheriu committed
108
109
110
111
if [ $1 == "--cflags-only-I" ]
then
	echo "-I${SYSREPO_PATH}/include/"
	exit 0
112
fi
Razvan Becheriu's avatar
Razvan Becheriu committed
113
114
115
116
117
if [ $1 == "--libs" ]
then
# Earlier versions also required -lprotobuf, but it is no longer needed.
	echo "-L${SYSREPO_PATH}/lib/ -L${YANG_LIBRARY_PATH} -lsysrepo -lSysrepo-cpp -lyang -pthread -lpcre -lev -lavl -lprotobuf-c"
	exit 0
118
fi
Tomek Mrugalski's avatar
Tomek Mrugalski committed
119
120
121
122
123

if [ "$1" = "--libs" ]; then
    # Earlier versions also required -lprotobuf, but it is no longer needed.
    echo "-L${SYSREPO_PATH}/build/src -L${SYSREPO_PATH}/build/swig -L$YANG_LIBRARY_PATH -l:${sysrepo_lib}.a -lSysrepo-cpp -lyang -pthread -lpcre -lev -lavl -lprotobuf-c"
    exit 0
124
fi
Razvan Becheriu's avatar
Razvan Becheriu committed
125
126
127
128
129
130
131

if [ "$1" = "--modversion" ]; then
    MAJOR="1"
    MINOR="0"
    PATCH="0"
    echo "${MAJOR}.${MINOR}.${PATCH}"
    exit 0
132
fi
Tomek Mrugalski's avatar
Tomek Mrugalski committed
133

134
if [ "$1" = "--variable=SR_REPOSITORY_LOC" ]; then
Tomek Mrugalski's avatar
Tomek Mrugalski committed
135
136
137
    echo "${SYSREPO_PATH}/build/repository"
fi

138
139
echo "wrong parameter"
echo "run: \`$0 --help\` for more help"
Razvan Becheriu's avatar
Razvan Becheriu committed
140
141

exit 1