Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 369 lines (316 sloc) 9.11 kb
ef13427 initial import
mheily authored
1 #!/bin/sh
8e30416 port configure script to Nexenta
mheily authored
2 #
11215a9 Upgrade to makeconf r10.
mheily authored
3 # Copyright (c) 2009-2011 Mark Heily <mark@heily.com>
8e30416 port configure script to Nexenta
mheily authored
4 #
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
8 #
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 #
17
11215a9 Upgrade to makeconf r10.
mheily authored
18 makeconf_version="$Revision: 10 $"
ef13427 initial import
mheily authored
19
11215a9 Upgrade to makeconf r10.
mheily authored
20 c_exports="program version target api cflags"
bf60e74 major changes to internal build script
mheily authored
21
11215a9 Upgrade to makeconf r10.
mheily authored
22 make_exports="program version target api distfile \
23 prefix bindir sbindir libdir includedir mandir \
1aa0606 fix tests on linux
mheily authored
24 cflags ldflags ldadd libdepends \
7e83603 fix DEPS implementation
mheily authored
25 sources objs deps mans headers extra_dist subdirs \
8683334 changes for deb package
mheily authored
26 abi_major abi_minor abi_version \
35222ff Fix compilation issues on Solaris 10 with GCC 4.5
mheily authored
27 cc cpp ld ln ar install diff strip"
bf60e74 major changes to internal build script
mheily authored
28
29 required_headers=
30 optional_headers=
31
32 pre_configure_hook() {
33 return
34 }
35
36 post_configure_hook() {
37 return
38 }
39
40 export_to_make() {
41 for id in $*
42 do
5f3f14b * Use GCC instead of ld(1) for the linking stage. [Fixes problem re…
mheily authored
43
44 # Prepend $DESTDIR to installation directories
45 case "$id" in
11215a9 Upgrade to makeconf r10.
mheily authored
46 prefix)
5f3f14b * Use GCC instead of ld(1) for the linking stage. [Fixes problem re…
mheily authored
47 eval "$id=\"\\\$\\\$DESTDIR\$$id\""
48 esac
49
bcafd5e * Ported to Solaris 10. The port compiles but does not work yet.
mheily authored
50 uc_id=`echo $id | $tr '[:lower:]' '[:upper:]'`;
bf60e74 major changes to internal build script
mheily authored
51 eval "echo \"$uc_id=\"\$$id\"\" >> config.mk"
52 done
53 }
54
55 export_to_c() {
56 for id in $*
57 do
bcafd5e * Ported to Solaris 10. The port compiles but does not work yet.
mheily authored
58 uc_id=`echo $id | $tr '[:lower:]' '[:upper:]'`;
bf60e74 major changes to internal build script
mheily authored
59 eval "echo \"#define $uc_id \\\"\$$id\\\"\" >> config.h"
60 done
61 }
eb8a759 improved build system.
mheily authored
62
63 finalize() {
bcafd5e * Ported to Solaris 10. The port compiles but does not work yet.
mheily authored
64 uc_id=`echo \"$1\" | $tr '[:lower:]' '[:upper:]'`;
5adbd81 vnode fixes, build fixes.
mheily authored
65 eval "if [ \"\$$1\" = \"\" ] ; then $1=\"$2\" ; fi"
eb8a759 improved build system.
mheily authored
66 }
67
68 process_argv() {
69 for arg in $*
70 do
11215a9 Upgrade to makeconf r10.
mheily authored
71 if [ "$arg" = "--makeconf-version" ] ; then
72 echo $makeconf_version | sed 's/[^0-9.]//g'
73 exit 0
74 fi
eb8a759 improved build system.
mheily authored
75 id=`echo "$arg" | sed 's/=.*//; s/^--//;'`
76 val=`echo "$arg" | sed 's/^.*=//'`
77 if [ "$val" = "" ] ; then val=1 ; fi
bf60e74 major changes to internal build script
mheily authored
78 eval "$id=\"$val\""
eb8a759 improved build system.
mheily authored
79 done
80 }
81
bcafd5e * Ported to Solaris 10. The port compiles but does not work yet.
mheily authored
82 process_env() {
83 test -n "$CC" && cc="$CC"
84 test -n "$CPP" && cpp="$CPP"
85 test -n "$CPPFLAGS" && cppflags="$CPPFLAGS"
86 test -n "$CFLAGS" && cflags="$CFLAGS"
87 test -n "$LD" && ld="$LD"
8683334 changes for deb package
mheily authored
88 test -n "$LN" && ld="$LN"
bcafd5e * Ported to Solaris 10. The port compiles but does not work yet.
mheily authored
89 test -n "$LDFLAGS" && ldflags="$LDFLAGS"
90 test -n "$AR" && ar="$AR"
91 }
1aa0606 fix tests on linux
mheily authored
92
ef13427 initial import
mheily authored
93 check_header() {
bf60e74 major changes to internal build script
mheily authored
94 sym=`echo "have_$1" | sed 's,[./],_,g'`
bcafd5e * Ported to Solaris 10. The port compiles but does not work yet.
mheily authored
95 uc_sym=`echo "$sym" | $tr '[:lower:]' '[:upper:]'`;
eb8a759 improved build system.
mheily authored
96 path=$1
97
98 printf "checking for $path.. "
99 if [ -f "/usr/include/$path" ] ; then
100 echo "yes"
d8ab9a4 fix check_header()
mheily authored
101 echo "#define $uc_sym 1" >> config.h
bf60e74 major changes to internal build script
mheily authored
102 eval "$sym=yes"
ef13427 initial import
mheily authored
103 return 0
104 else
eb8a759 improved build system.
mheily authored
105 echo "no"
bf60e74 major changes to internal build script
mheily authored
106 echo "#undef $uc_sym" >> config.h
107 eval "$sym=no"
ef13427 initial import
mheily authored
108 return 1
109 fi
110 }
111
8e30416 port configure script to Nexenta
mheily authored
112 # Determine the path to an executable binary
113 check_binary() {
114 id=$1
115 shift
116
117 for path in $*
118 do
119 test -f $path
120 if [ $? = 0 ] ; then
121 eval "$id=\"$path\""
122 return
123 fi
124 done
125
126 echo "not found"
127 return
128 }
129
bf60e74 major changes to internal build script
mheily authored
130 check_headers() {
131 for header in $*
132 do
133 check_header "$header"
134 done
135 }
136
8574d9a add check_symbol to configure
mheily authored
137 check_symbol() {
138 header=$1
139 symbol=$2
140
bcafd5e * Ported to Solaris 10. The port compiles but does not work yet.
mheily authored
141 uc_symbol=`echo "HAVE_$symbol" | $tr '[:lower:]' '[:upper:]' | sed 's,[./],_,g'`
142 lc_symbol=`echo "have_$symbol" | $tr '[:upper:]' '[:lower:]' | sed 's,[./],_,g'`
1aa0606 fix tests on linux
mheily authored
143
144 if [ -f "$header" ] ; then
145 path="$header"
146 elif [ -f "/usr/include/$header" ] ; then
2d75d2d fix obsd breakage
mheily authored
147 path="/usr/include/$header"
1aa0606 fix tests on linux
mheily authored
148 else
149 echo "*** ERROR: Cannot find <$header>"
150 exit 1
151 fi
152
2d75d2d fix obsd breakage
mheily authored
153 printf "checking $header for $symbol.. "
1aa0606 fix tests on linux
mheily authored
154 if [ "`grep $symbol $path`" != "" ] ; then
8574d9a add check_symbol to configure
mheily authored
155 eval "$lc_symbol=yes"
c27cc2c fix check_symbol
mheily authored
156 echo "#define $uc_symbol 1" >> config.h
157 echo "yes"
8574d9a add check_symbol to configure
mheily authored
158 return 0
159 else
160 eval "$lc_symbol=no"
c27cc2c fix check_symbol
mheily authored
161 echo "no"
8574d9a add check_symbol to configure
mheily authored
162 echo "#undef $uc_symbol" >> config.h
163 return 1
164 fi
165 }
166
bf60e74 major changes to internal build script
mheily authored
167 check_install() {
168 printf "checking for a BSD-compatible install.. "
169 if [ "`uname -s`" = "SunOS" ] ; then
170 default_install=/usr/ucb/install
171 else
172 default_install=/usr/bin/install
173 fi
174 finalize install "$default_install"
175 echo "$install"
176 }
177
bcafd5e * Ported to Solaris 10. The port compiles but does not work yet.
mheily authored
178 check_target() {
179 printf "checking operating system type.. "
180 default_target=`uname -s | $tr '[:upper:]' '[:lower:]'`
11215a9 Upgrade to makeconf r10.
mheily authored
181 default_api="posix"
182 case "$default_target" in
183 sunos)
184 default_target="solaris"
185 ;;
186 "gnu/kfreebsd")
187 default_target="freebsd"
188 ;;
bc74af6 Fix various build issues on MinGW.
mheily authored
189 mingw*)
11215a9 Upgrade to makeconf r10.
mheily authored
190 default_target="windows"
191 default_api="windows"
192 ;;
193 esac
bcafd5e * Ported to Solaris 10. The port compiles but does not work yet.
mheily authored
194 finalize target "$default_target"
11215a9 Upgrade to makeconf r10.
mheily authored
195 finalize api "$default_api"
196 echo "$api-$target"
bcafd5e * Ported to Solaris 10. The port compiles but does not work yet.
mheily authored
197 }
198
199 check_compiler() {
200 printf "checking for a C compiler.. "
97d187c Honor CC environment variable as the first pick in the compiler list,…
jocke authored
201 check_binary default_cc "$cc" "`which $cc 2>/dev/null`" "/usr/bin/cc" "/usr/bin/gcc" "/usr/sfw/bin/gcc" "`which gcc 2>/dev/null`"
bcafd5e * Ported to Solaris 10. The port compiles but does not work yet.
mheily authored
202 finalize cc "$default_cc"
97d187c Honor CC environment variable as the first pick in the compiler list,…
jocke authored
203 # test -x "$cc" || err "Unable to locate a C compiler"
bcafd5e * Ported to Solaris 10. The port compiles but does not work yet.
mheily authored
204 echo "$cc"
205 }
206
207 check_linker() {
208 printf "checking for a suitable linker.. "
5f3f14b * Use GCC instead of ld(1) for the linking stage. [Fixes problem re…
mheily authored
209
210 # Workaround for "hidden symbol <foo> is referenced by DSO" linker error
211 # seen when compiling libdispatch.
212 # Appears to be a problem with GCC 4.0 and binutils
213 #
214 default_ld="$cc"
a289b23 backport "distfile" from pthwq
mheily authored
215 ldflags="-o $program.so.$abi_major.$abi_minor $ldflags"
ed9a21d solaris tweaks
mheily authored
216
55d3090 Handle ENOTSOCK properly
mheily authored
217 # FIXME: port to solaris
ed9a21d solaris tweaks
mheily authored
218 if [ "$target" = "linux" ] ; then
55d3090 Handle ENOTSOCK properly
mheily authored
219 ldflags="$ldflags -Wl,-export-dynamic -Wl,-soname,$program.so.$abi_major"
ed9a21d solaris tweaks
mheily authored
220 fi
5f3f14b * Use GCC instead of ld(1) for the linking stage. [Fixes problem re…
mheily authored
221
3676ec3 different ldflags for solaris (credit: Joakim Johansson)
mheily authored
222 if [ "$target" = "solaris" ] ; then
11215a9 Upgrade to makeconf r10.
mheily authored
223 ldflags="$ldflags"
3676ec3 different ldflags for solaris (credit: Joakim Johansson)
mheily authored
224 fi
225
bcafd5e * Ported to Solaris 10. The port compiles but does not work yet.
mheily authored
226 finalize ld "$default_ld"
227 echo "$ld"
228 }
229
230 check_archiver() {
231 printf "checking for a suitable archiver.. "
8e30416 port configure script to Nexenta
mheily authored
232 if [ "`uname -s`" = "SunOS" -a "`uname -v | grep Nexenta`" = "" ] ; then
bcafd5e * Ported to Solaris 10. The port compiles but does not work yet.
mheily authored
233 default_ar="/usr/sfw/bin/gar"
234 else
235 default_ar="/usr/bin/ar"
236 fi
237 finalize ar "$default_ar"
238 echo "$ar"
239 }
f5718b1 remove generated files in err()
mheily authored
240
bf60e74 major changes to internal build script
mheily authored
241 err() {
242 echo "*** ERROR *** $*"
f5718b1 remove generated files in err()
mheily authored
243 rm -f config.mk $program.pc config.h
bf60e74 major changes to internal build script
mheily authored
244 exit 1
245 }
246
fd9ad5b improved Diff target
mheily authored
247 check_diff() {
248 # TODO: Support non-GNU diff syntax
249 # TODO: Search for the command
250 printf "checking for a suitable diff(1) command.. "
251 finalize diff "diff -ruN -dEbwBp -x .svn -x .o -x config.h -x config.mk"
252 echo "found"
253 }
254
35222ff Fix compilation issues on Solaris 10 with GCC 4.5
mheily authored
255 check_strip() {
256 printf "checking for a suitable strip(1) command.. "
257 if [ "`uname -s`" = "SunOS" ] ; then
258 finalize strip "/usr/sfw/bin/gstrip --strip-unneeded"
259 else
260 finalize strip "/usr/bin/strip --strip-unneeded"
261 fi
262 echo "found"
263 }
264
db2b259 initial incomplete RPM implementation
mheily authored
265 subst_vars() {
266 outfile=$1
267
268 if [ ! -f "${outfile}.in" ] ; then
269 return
270 fi
271
272 echo "Creating $outfile"
273 rm -f $outfile
274 sed -e "
7a73c0b docfix
mheily authored
275 s,@@CWD@@,`pwd`,g;
db2b259 initial incomplete RPM implementation
mheily authored
276 s,@@PROGRAM@@,$program,g;
277 s,@@VERSION@@,$version,g;
278 s,@@PREFIX@@,$prefix,g;
279 s,@@LIBDIR@@,$libdir,g;
280 s,@@INCLUDEDIR@@,$includedir,g;
281 s,@@MANDIR@@,$mandir,g;
282 s,@@LIBDEPENDS@@,$libdepends,g;
283 s,@@PKG_SUMMARY@@,$pkg_summary,g;
e0421f2 create -devel RPM
mheily authored
284 s,@@RPM_DATE@@,`date +'%a %b %d %Y'`,g;
db2b259 initial incomplete RPM implementation
mheily authored
285 s,@@PKG_DESCRIPTION@@,$pkg_description,g;
286 s,@@LICENSE@@,$license,g;
287 s,@@AUTHOR@@,$author,g;
288 " < ${outfile}.in > $outfile
289 chmod 400 $outfile
290 }
291
eb8a759 improved build system.
mheily authored
292 #######################################################################
293 #
294 # MAIN()
295 #
296 #######################################################################
ef13427 initial import
mheily authored
297
bcafd5e * Ported to Solaris 10. The port compiles but does not work yet.
mheily authored
298 # Workaround for Solaris "Bad string" issue when LOCALE is undefined
299 tr="/usr/bin/tr"
300 test -f /usr/xpg4/bin/tr && tr="/usr/xpg4/bin/tr"
301
302 . ./config.inc
303
eb8a759 improved build system.
mheily authored
304 # Initialize the output files
305 #
11215a9 Upgrade to makeconf r10.
mheily authored
306 for output_file in config.mk
eb8a759 improved build system.
mheily authored
307 do
308 rm -f $output_file
309 echo "# AUTOMATICALLY GENERATED -- DO NOT EDIT" > $output_file
310 done
11215a9 Upgrade to makeconf r10.
mheily authored
311 if [ "$sources" != "" ] ; then
312 rm -f config.h
313 echo "/* AUTOMATICALLY GENERATED -- DO NOT EDIT */" > config.h
314 fi
eb8a759 improved build system.
mheily authored
315
bf60e74 major changes to internal build script
mheily authored
316 process_argv "$*"
bcafd5e * Ported to Solaris 10. The port compiles but does not work yet.
mheily authored
317 process_env
318
319 check_target
320 check_compiler
321 check_linker
322 check_archiver
323 check_install
fd9ad5b improved Diff target
mheily authored
324 check_diff
35222ff Fix compilation issues on Solaris 10 with GCC 4.5
mheily authored
325 check_strip
eb8a759 improved build system.
mheily authored
326
bf60e74 major changes to internal build script
mheily authored
327 finalize program "$program"
328 finalize version "$version"
8683334 changes for deb package
mheily authored
329 finalize abi_major "$abi_major"
330 finalize abi_minor "$abi_minor"
331 finalize abi_version "$abi_major.$abi_minor"
bf60e74 major changes to internal build script
mheily authored
332 finalize prefix "/usr/local"
11215a9 Upgrade to makeconf r10.
mheily authored
333 finalize bindir "\\\$(PREFIX)/bin"
334 finalize sbindir "\\\$(PREFIX)/sbin"
335 finalize libdir "\\\$(PREFIX)/lib"
336 finalize includedir "\\\$(PREFIX)/include"
337 finalize mandir "\\\$(PREFIX)/share/man"
bf60e74 major changes to internal build script
mheily authored
338 finalize cflags "$cflags"
339 finalize libdepends "$libdepends"
1aa0606 fix tests on linux
mheily authored
340 finalize ldadd ""
341 finalize ldflags ""
7e83603 fix DEPS implementation
mheily authored
342 finalize deps ""
8683334 changes for deb package
mheily authored
343 finalize ln "`which ln`"
a289b23 backport "distfile" from pthwq
mheily authored
344 finalize distfile "$program-$version.tar.gz"
bf60e74 major changes to internal build script
mheily authored
345
346 pre_configure_hook
347
348 for header in $required_headers
349 do
350 check_header "$header" || err "$header is required, but cannot be found."
351 done
352 check_headers $optional_headers
353
354 post_configure_hook
ef13427 initial import
mheily authored
355
4aa7182 add src/linux/proc.c
mheily authored
356 objs="`echo \"$sources\" | sed 's/\.c/\.o/g'`"
357
db2b259 initial incomplete RPM implementation
mheily authored
358 subst_vars "$program.pc"
5ee4e46 * Install libkqueue.la and libkqueue.a in LIBDIR
mheily authored
359 subst_vars "$program.la"
db2b259 initial incomplete RPM implementation
mheily authored
360 subst_vars "rpm.spec"
21051ab docfix
mheily authored
361
11215a9 Upgrade to makeconf r10.
mheily authored
362 if [ "$sources" != "" ] ; then
363 echo "Creating config.h"
364 export_to_c $c_exports
365 fi
bf60e74 major changes to internal build script
mheily authored
366
21051ab docfix
mheily authored
367 echo "Creating config.mk"
bf60e74 major changes to internal build script
mheily authored
368 export_to_make "$make_exports"
Something went wrong with that request. Please try again.