aboutsummaryrefslogtreecommitdiffstats
path: root/configure
blob: 8a0115d5ee675c88d6e44ae9c469139284d84e72 (plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/sh
#
# configure, simulation of autoconf script, much simplified
#
# Copyright (c) 2008-2010 Wind River Systems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the Lesser GNU General Public License version 2.1 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the Lesser GNU General Public License for more details.
#
# You should have received a copy of the Lesser GNU General Public License
# version 2.1 along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
#
# not a real configure script...
opt_prefix=
opt_libdir=
opt_suffix=
opt_bits=
opt_sqlite=/usr
opt_rpath=

usage()
{
	echo >&2 "usage:"
	echo >&2 "  configure --prefix=..."
	echo >&2 " 	      [--libdir=...]"
	echo >&2 " 	      [--suffix=...]"
	echo >&2 "            [--with-sqlite=...]"
	echo >&2 "            [--enable-static-sqlite]"
	echo >&2 "            [--with-rpath=...|--without-rpath]"
	echo >&2 "            [--bits=32|64]"
	exit 1
}

sqlite_ldarg=-lsqlite3

maybe_rpath=
use_maybe_rpath=true

for arg
do
	case $arg in
	--)	shift; break ;;
	--prefix=*)
		opt_prefix=${arg#--prefix=}
		;;
	--libdir=*)
		opt_libdir=${arg#--libdir=}
		;;
	--enable-static-sqlite)
		sqlite_ldarg='$(SQLITE)/lib/libsqlite3.a'
		use_maybe_rpath=false
		;;
	--with-sqlite=*)
		opt_sqlite=${arg#--with-sqlite=}
		# assign new value if unset
		maybe_rpath='-Wl,-R$(SQLITE)/lib'
		;;
	--without-rpath)
		opt_rpath=''
		use_maybe_rpath=false
		;;
	--with-rpath=*)
	        rpath=${arg#--with-rpath=}
		opt_rpath=${rpath:+-Wl,-R$rpath}
		use_maybe_rpath=false
		;;
	--suffix=*)
		opt_suffix=${arg#--suffix=}
		;;
	--bits=*)
		opt_bits=${arg#--bits=}
		case $opt_bits in
		64)	opt_mark64=64;;
		32)	opt_mark64=;;
		*)	echo >&2 "Unknown bit size $opt_bits (only 32 and 64 known)."
			;;
		esac
		;;
	*)
		echo >&2 "warning: Unrecognized option '$arg'"
		;;
	esac
done

if $use_maybe_rpath && [ -n "$maybe_rpath" ]; then
	echo >&2 "Adding default RPATH for sqlite."
	opt_rpath="${opt_rpath+${opt_rpath} }${maybe_rpath}"
fi

if [ -z "$opt_prefix" ]; then
  usage
fi

if [ -z "$opt_libdir" ]; then
    opt_libdir=$opt_prefix/lib$opt_mark64
fi

# We need to find the libdir relative to the prefix, this is required
# by the code in pseudo-utils.c that handles relocation.
opt_lib=${opt_libdir#$opt_prefix/}
if [ "$opt_lib" = "$opt_libdir" ]; then
    echo >&2 "libdir must be relative to prefix."
    exit 1
fi

if [ ! -f "${opt_sqlite}/include/sqlite3.h" ]; then
    echo >&2 "SQLite3 headers not found in at ${opt_sqlite}/include/sqlite3.h. Please check that SQLite3 and SQLite3 headers are installed."
    exit 1
fi

read t1 t2 SQLITE3_VERSION << EOF
  `grep "#define SQLITE_VERSION_NUMBER " ${opt_sqlite}/include/sqlite3.h`
EOF

echo "SQLite header for version ${SQLITE3_VERSION} found in ${opt_sqlite}."

if [ "${SQLITE3_VERSION}" -lt "03006000" ]; then
    echo >&2 "Pseudo requires SQLite version 3, 3.6.x or later."
    exit 1
fi

sed -e '
  s,@PREFIX@,'"$opt_prefix"',g
  s,@LIBDIR@,'"$opt_libdir"',g
  s,@LIB@,'"$opt_lib"',g
  s,@SUFFIX@,'"$opt_suffix"',g
  s,@SQLITE@,'"$opt_sqlite"',g
  s,@SQLITE_LDARG@,'"$sqlite_ldarg"',g
  s!@RPATH@!'"$opt_rpath"'!g
  s,@MARK64@,'"$opt_mark64"',g
  s,@BITS@,'"$opt_bits"',g
' < Makefile.in > Makefile