-
Notifications
You must be signed in to change notification settings - Fork 0
/
setupFBCAccess.sh
executable file
·66 lines (58 loc) · 2.11 KB
/
setupFBCAccess.sh
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
64
65
66
#! /bin/bash
OS=$(uname)
IFS=':' read -ra FRONTBASE_DIRS <<< "/Library/FrontBase:/Library:/usr/local/FrontBase:/usr/local:/usr:/opt:/var"
for DIRECTORY in "${FRONTBASE_DIRS[@]}"; do
if [[ -d "$DIRECTORY" ]]; then
IFS='\0' read -ra DIRECTORIES <<< "$(find "$DIRECTORY" -name libFBCAccess.a -print0 2> /dev/null)"
if [[ -n $DIRECTORIES ]]; then
FRONTBASE_DIRECTORY="$(dirname "$(dirname "$DIRECTORIES")")"
break
fi
fi
done
if [[ -n "$FRONTBASE_DIRECTORY" ]]; then
LIBRARY_DIRECTORY="$(dirname "$DIRECTORIES")"
IFS='\0' read -ra HEADER_FILES <<< "$(find "$(dirname "$FRONTBASE_DIRECTORY")" -name FBCAccess.h -print0 2> /dev/null)"
if [[ -n "$HEADER_FILES" ]]; then
INCLUDE_DIRECTORY="$(dirname "$(dirname "$HEADER_FILES")")"
fi
fi
if [[ -z "$LIBRARY_DIRECTORY" ]] || [[ -z "$INCLUDE_DIRECTORY" ]]; then
echo "Could not find any FrontBase installed in either of ${FRONTBASE_DIRS[*]}"
exit 1
else
echo "Found FrontBase installation in $FRONTBASE_DIRECTORY"
fi
IFS=':' read -ra CONFIG_DIRS <<< "$(pkg-config --variable pc_path pkg-config)"
for DIRECTORY in "${CONFIG_DIRS[@]}"; do
if [[ -f "$DIRECTORY/FBCAccess.pc" ]]; then
PKG_CONFIG_PATH="$DIRECTORY/FBCAccess.pc"
break
fi
done
if [[ -z "$PKG_CONFIG_PATH" ]]; then
echo "No pkgConfig file found for FCBAccess"
for DIRECTORY in "${CONFIG_DIRS[@]}"; do
if [[ -d "$DIRECTORY" ]]; then
echo "Will create file at $DIRECTORY/FBCAccess.pc"
echo "Will sudo"
sudo tee "$DIRECTORY/FBCAccess.pc" > /dev/null <<END
Description: Frontbase client library
Version: 1.0
Cflags: -I${INCLUDE_DIRECTORY}
Libs: -L${LIBRARY_DIRECTORY} -lFBCAccess
END
break
fi
done
else
echo "Found pkgConfig file at $PKG_CONFIG_PATH"
fi
if [[ $OS == "Linux" ]]; then
if [[ ! -f "/etc/ld.so.conf.d/FrontBase.conf" ]]; then
echo "Will create file at /etc/ld.so.conf.d/FrontBase.conf"
echo "Will sudo"
echo "$LIBRARY_DIRECTORY" | sudo tee "/etc/ld.so.conf.d/FrontBase.conf" > /dev/null
sudo ldconfig
fi
fi