]>
Commit | Line | Data |
---|---|---|
1 | dnl --------------------------------------------------------------------------- | |
2 | dnl Support macros for makefiles generated by BAKEFILE. | |
3 | dnl --------------------------------------------------------------------------- | |
4 | ||
5 | dnl Lots of compiler & linker detection code contained here was taken from | |
6 | dnl wxWindows configure.in script (see http://www.wxwindows.org) | |
7 | ||
8 | ||
9 | ||
10 | dnl --------------------------------------------------------------------------- | |
11 | dnl AC_BAKEFILE_GNUMAKE | |
12 | dnl | |
13 | dnl Detects GNU make | |
14 | dnl --------------------------------------------------------------------------- | |
15 | ||
16 | AC_DEFUN([AC_BAKEFILE_GNUMAKE], | |
17 | [ | |
18 | dnl does make support "-include" (only GNU make does AFAIK)? | |
19 | AC_CACHE_CHECK([if make is GNU make], bakefile_cv_prog_makeisgnu, | |
20 | [ | |
21 | if ( ${SHELL-sh} -c "${MAKE-make} --version" 2> /dev/null | | |
22 | egrep -s GNU > /dev/null); then | |
23 | bakefile_cv_prog_makeisgnu="yes" | |
24 | else | |
25 | bakefile_cv_prog_makeisgnu="no" | |
26 | fi | |
27 | ]) | |
28 | ||
29 | if test "x$bakefile_cv_prog_makeisgnu" = "xyes"; then | |
30 | IF_GNU_MAKE="" | |
31 | else | |
32 | IF_GNU_MAKE="#" | |
33 | fi | |
34 | AC_SUBST(IF_GNU_MAKE) | |
35 | ]) | |
36 | ||
37 | dnl --------------------------------------------------------------------------- | |
38 | dnl AC_BAKEFILE_PLATFORM | |
39 | dnl | |
40 | dnl Detects platform and sets PLATFORM_XXX variables accordingly | |
41 | dnl --------------------------------------------------------------------------- | |
42 | ||
43 | AC_DEFUN([AC_BAKEFILE_PLATFORM], | |
44 | [ | |
45 | PLATFORM_UNIX=0 | |
46 | PLATFORM_WIN32=0 | |
47 | PLATFORM_MSDOS=0 | |
48 | PLATFORM_MAC=0 | |
49 | PLATFORM_MACOS=0 | |
50 | PLATFORM_MACOSX=0 | |
51 | PLATFORM_OS2=0 | |
52 | PLATFORM_BEOS=0 | |
53 | ||
54 | if test "x$BAKEFILE_FORCE_PLATFORM" = "x"; then | |
55 | case "${BAKEFILE_HOST}" in | |
56 | *-*-mingw32* ) | |
57 | PLATFORM_WIN32=1 | |
58 | ;; | |
59 | *-pc-msdosdjgpp ) | |
60 | PLATFORM_MSDOS=1 | |
61 | ;; | |
62 | *-pc-os2_emx | *-pc-os2-emx ) | |
63 | PLATFORM_OS2=1 | |
64 | ;; | |
65 | *-*-darwin* ) | |
66 | PLATFORM_MAC=1 | |
67 | PLATFORM_MACOSX=1 | |
68 | ;; | |
69 | *-*-beos* ) | |
70 | PLATFORM_BEOS=1 | |
71 | ;; | |
72 | powerpc-apple-macos* ) | |
73 | PLATFORM_MAC=1 | |
74 | PLATFORM_MACOS=1 | |
75 | ;; | |
76 | * ) | |
77 | PLATFORM_UNIX=1 | |
78 | ;; | |
79 | esac | |
80 | else | |
81 | case "$BAKEFILE_FORCE_PLATFORM" in | |
82 | win32 ) | |
83 | PLATFORM_WIN32=1 | |
84 | ;; | |
85 | msdos ) | |
86 | PLATFORM_MSDOS=1 | |
87 | ;; | |
88 | os2 ) | |
89 | PLATFORM_OS2=1 | |
90 | ;; | |
91 | darwin ) | |
92 | PLATFORM_MAC=1 | |
93 | PLATFORM_MACOSX=1 | |
94 | ;; | |
95 | unix ) | |
96 | PLATFORM_UNIX=1 | |
97 | ;; | |
98 | beos ) | |
99 | PLATFORM_BEOS=1 | |
100 | ;; | |
101 | * ) | |
102 | AC_MSG_ERROR([Unknown platform: $BAKEFILE_FORCE_PLATFORM]) | |
103 | ;; | |
104 | esac | |
105 | fi | |
106 | ||
107 | AC_SUBST(PLATFORM_UNIX) | |
108 | AC_SUBST(PLATFORM_WIN32) | |
109 | AC_SUBST(PLATFORM_MSDOS) | |
110 | AC_SUBST(PLATFORM_MAC) | |
111 | AC_SUBST(PLATFORM_MACOS) | |
112 | AC_SUBST(PLATFORM_MACOSX) | |
113 | AC_SUBST(PLATFORM_OS2) | |
114 | AC_SUBST(PLATFORM_BEOS) | |
115 | ]) | |
116 | ||
117 | ||
118 | dnl --------------------------------------------------------------------------- | |
119 | dnl AC_BAKEFILE_PLATFORM_SPECIFICS | |
120 | dnl | |
121 | dnl Sets misc platform-specific settings | |
122 | dnl --------------------------------------------------------------------------- | |
123 | ||
124 | AC_DEFUN([AC_BAKEFILE_PLATFORM_SPECIFICS], | |
125 | [ | |
126 | AC_ARG_ENABLE([omf], AS_HELP_STRING([--enable-omf], | |
127 | [use OMF object format (OS/2)]), | |
128 | [bk_os2_use_omf="$enableval"]) | |
129 | ||
130 | case "${BAKEFILE_HOST}" in | |
131 | *-*-darwin* ) | |
132 | dnl For Unix to MacOS X porting instructions, see: | |
133 | dnl http://fink.sourceforge.net/doc/porting/porting.html | |
134 | if test "x$GCC" = "xyes"; then | |
135 | CFLAGS="$CFLAGS -fno-common" | |
136 | CXXFLAGS="$CXXFLAGS -fno-common" | |
137 | fi | |
138 | if test "x$XLCC" = "xyes"; then | |
139 | CFLAGS="$CFLAGS -qnocommon" | |
140 | CXXFLAGS="$CXXFLAGS -qnocommon" | |
141 | fi | |
142 | ;; | |
143 | ||
144 | *-pc-os2_emx | *-pc-os2-emx ) | |
145 | if test "x$bk_os2_use_omf" = "xyes" ; then | |
146 | AR=emxomfar | |
147 | RANLIB=: | |
148 | LDFLAGS="-Zomf $LDFLAGS" | |
149 | CFLAGS="-Zomf $CFLAGS" | |
150 | CXXFLAGS="-Zomf $CXXFLAGS" | |
151 | OS2_LIBEXT="lib" | |
152 | else | |
153 | OS2_LIBEXT="a" | |
154 | fi | |
155 | ;; | |
156 | ||
157 | i*86-*-beos* ) | |
158 | LDFLAGS="-L/boot/develop/lib/x86 $LDFLAGS" | |
159 | ;; | |
160 | esac | |
161 | ]) | |
162 | ||
163 | dnl --------------------------------------------------------------------------- | |
164 | dnl AC_BAKEFILE_SUFFIXES | |
165 | dnl | |
166 | dnl Detects shared various suffixes for shared libraries, libraries, programs, | |
167 | dnl plugins etc. | |
168 | dnl --------------------------------------------------------------------------- | |
169 | ||
170 | AC_DEFUN([AC_BAKEFILE_SUFFIXES], | |
171 | [ | |
172 | SO_SUFFIX="so" | |
173 | SO_SUFFIX_MODULE="so" | |
174 | EXEEXT="" | |
175 | LIBPREFIX="lib" | |
176 | LIBEXT=".a" | |
177 | DLLPREFIX="lib" | |
178 | DLLPREFIX_MODULE="" | |
179 | DLLIMP_SUFFIX="" | |
180 | dlldir="$libdir" | |
181 | ||
182 | case "${BAKEFILE_HOST}" in | |
183 | *-hp-hpux* ) | |
184 | SO_SUFFIX="sl" | |
185 | SO_SUFFIX_MODULE="sl" | |
186 | ;; | |
187 | *-*-aix* ) | |
188 | dnl quoting from | |
189 | dnl http://www-1.ibm.com/servers/esdd/articles/gnu.html: | |
190 | dnl Both archive libraries and shared libraries on AIX have an | |
191 | dnl .a extension. This will explain why you can't link with an | |
192 | dnl .so and why it works with the name changed to .a. | |
193 | SO_SUFFIX="a" | |
194 | SO_SUFFIX_MODULE="a" | |
195 | ;; | |
196 | *-*-cygwin* ) | |
197 | SO_SUFFIX="dll" | |
198 | SO_SUFFIX_MODULE="dll" | |
199 | DLLIMP_SUFFIX="dll.a" | |
200 | EXEEXT=".exe" | |
201 | DLLPREFIX="cyg" | |
202 | dlldir="$bindir" | |
203 | ;; | |
204 | *-*-mingw32* ) | |
205 | SO_SUFFIX="dll" | |
206 | SO_SUFFIX_MODULE="dll" | |
207 | DLLIMP_SUFFIX="dll.a" | |
208 | EXEEXT=".exe" | |
209 | DLLPREFIX="" | |
210 | dlldir="$bindir" | |
211 | ;; | |
212 | *-pc-msdosdjgpp ) | |
213 | EXEEXT=".exe" | |
214 | DLLPREFIX="" | |
215 | dlldir="$bindir" | |
216 | ;; | |
217 | *-pc-os2_emx | *-pc-os2-emx ) | |
218 | SO_SUFFIX="dll" | |
219 | SO_SUFFIX_MODULE="dll" | |
220 | DLLIMP_SUFFIX=$OS2_LIBEXT | |
221 | EXEEXT=".exe" | |
222 | DLLPREFIX="" | |
223 | LIBPREFIX="" | |
224 | LIBEXT=".$OS2_LIBEXT" | |
225 | dlldir="$bindir" | |
226 | ;; | |
227 | *-*-darwin* ) | |
228 | SO_SUFFIX="dylib" | |
229 | SO_SUFFIX_MODULE="bundle" | |
230 | ;; | |
231 | esac | |
232 | ||
233 | if test "x$DLLIMP_SUFFIX" = "x" ; then | |
234 | DLLIMP_SUFFIX="$SO_SUFFIX" | |
235 | fi | |
236 | ||
237 | AC_SUBST(SO_SUFFIX) | |
238 | AC_SUBST(SO_SUFFIX_MODULE) | |
239 | AC_SUBST(DLLIMP_SUFFIX) | |
240 | AC_SUBST(EXEEXT) | |
241 | AC_SUBST(LIBPREFIX) | |
242 | AC_SUBST(LIBEXT) | |
243 | AC_SUBST(DLLPREFIX) | |
244 | AC_SUBST(DLLPREFIX_MODULE) | |
245 | AC_SUBST(dlldir) | |
246 | ]) | |
247 | ||
248 | ||
249 | dnl --------------------------------------------------------------------------- | |
250 | dnl AC_BAKEFILE_SHARED_LD | |
251 | dnl | |
252 | dnl Detects command for making shared libraries, substitutes SHARED_LD_CC | |
253 | dnl and SHARED_LD_CXX. | |
254 | dnl --------------------------------------------------------------------------- | |
255 | ||
256 | AC_DEFUN([AC_BAKEFILE_SHARED_LD], | |
257 | [ | |
258 | dnl the extra compiler flags needed for compilation of shared library | |
259 | PIC_FLAG="" | |
260 | if test "x$GCC" = "xyes"; then | |
261 | dnl the switch for gcc is the same under all platforms | |
262 | PIC_FLAG="-fPIC" | |
263 | fi | |
264 | ||
265 | dnl Defaults for GCC and ELF .so shared libs: | |
266 | SHARED_LD_CC="\$(CC) -shared ${PIC_FLAG} -o" | |
267 | SHARED_LD_CXX="\$(CXX) -shared ${PIC_FLAG} -o" | |
268 | WINDOWS_IMPLIB=0 | |
269 | ||
270 | case "${BAKEFILE_HOST}" in | |
271 | *-hp-hpux* ) | |
272 | dnl default settings are good for gcc but not for the native HP-UX | |
273 | if test "x$GCC" != "xyes"; then | |
274 | dnl no idea why it wants it, but it does | |
275 | LDFLAGS="$LDFLAGS -L/usr/lib" | |
276 | ||
277 | SHARED_LD_CC="${CC} -b -o" | |
278 | SHARED_LD_CXX="${CXX} -b -o" | |
279 | PIC_FLAG="+Z" | |
280 | fi | |
281 | ;; | |
282 | ||
283 | *-*-linux* ) | |
284 | if test "x$GCC" != "xyes"; then | |
285 | AC_CACHE_CHECK([for Intel compiler], bakefile_cv_prog_icc, | |
286 | [ | |
287 | AC_TRY_COMPILE([], | |
288 | [ | |
289 | #ifndef __INTEL_COMPILER | |
290 | This is not ICC | |
291 | #endif | |
292 | ], | |
293 | bakefile_cv_prog_icc=yes, | |
294 | bakefile_cv_prog_icc=no | |
295 | ) | |
296 | ]) | |
297 | if test "$bakefile_cv_prog_icc" = "yes"; then | |
298 | PIC_FLAG="-KPIC" | |
299 | fi | |
300 | fi | |
301 | ;; | |
302 | ||
303 | *-*-solaris2* ) | |
304 | if test "x$GCC" != xyes ; then | |
305 | SHARED_LD_CC="${CC} -G -o" | |
306 | SHARED_LD_CXX="${CXX} -G -o" | |
307 | PIC_FLAG="-KPIC" | |
308 | fi | |
309 | ;; | |
310 | ||
311 | *-*-darwin* ) | |
312 | AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH | |
313 | chmod +x shared-ld-sh | |
314 | ||
315 | SHARED_LD_MODULE_CC="`pwd`/shared-ld-sh -bundle -headerpad_max_install_names -o" | |
316 | SHARED_LD_MODULE_CXX="$SHARED_LD_MODULE_CC" | |
317 | ||
318 | dnl Most apps benefit from being fully binded (its faster and static | |
319 | dnl variables initialized at startup work). | |
320 | dnl This can be done either with the exe linker flag -Wl,-bind_at_load | |
321 | dnl or with a double stage link in order to create a single module | |
322 | dnl "-init _wxWindowsDylibInit" not useful with lazy linking solved | |
323 | ||
324 | dnl If using newer dev tools then there is a -single_module flag that | |
325 | dnl we can use to do this for dylibs, otherwise we'll need to use a helper | |
326 | dnl script. Check the version of gcc to see which way we can go: | |
327 | AC_CACHE_CHECK([for gcc 3.1 or later], bakefile_cv_gcc31, [ | |
328 | AC_TRY_COMPILE([], | |
329 | [ | |
330 | #if (__GNUC__ < 3) || \ | |
331 | ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1)) | |
332 | This is old gcc | |
333 | #endif | |
334 | ], | |
335 | [ | |
336 | bakefile_cv_gcc31=yes | |
337 | ], | |
338 | [ | |
339 | bakefile_cv_gcc31=no | |
340 | ] | |
341 | ) | |
342 | ]) | |
343 | if test "$bakefile_cv_gcc31" = "no"; then | |
344 | dnl Use the shared-ld-sh helper script | |
345 | SHARED_LD_CC="`pwd`/shared-ld-sh -dynamiclib -headerpad_max_install_names -o" | |
346 | SHARED_LD_CXX="$SHARED_LD_CC" | |
347 | else | |
348 | dnl Use the -single_module flag and let the linker do it for us | |
349 | SHARED_LD_CC="\${CC} -dynamiclib -single_module -headerpad_max_install_names -o" | |
350 | SHARED_LD_CXX="\${CXX} -dynamiclib -single_module -headerpad_max_install_names -o" | |
351 | fi | |
352 | ||
353 | if test "x$GCC" == "xyes"; then | |
354 | PIC_FLAG="-dynamic -fPIC" | |
355 | fi | |
356 | if test "x$XLCC" = "xyes"; then | |
357 | PIC_FLAG="-dynamic -DPIC" | |
358 | fi | |
359 | ;; | |
360 | ||
361 | *-*-aix* ) | |
362 | if test "x$GCC" = "xyes"; then | |
363 | dnl at least gcc 2.95 warns that -fPIC is ignored when | |
364 | dnl compiling each and every file under AIX which is annoying, | |
365 | dnl so don't use it there (it's useless as AIX runs on | |
366 | dnl position-independent architectures only anyhow) | |
367 | PIC_FLAG="" | |
368 | ||
369 | dnl -bexpfull is needed by AIX linker to export all symbols (by | |
370 | dnl default it doesn't export any and even with -bexpall it | |
371 | dnl doesn't export all C++ support symbols, e.g. vtable | |
372 | dnl pointers) but it's only available starting from 5.1 (with | |
373 | dnl maintenance pack 2, whatever this is), see | |
374 | dnl http://www-128.ibm.com/developerworks/eserver/articles/gnu.html | |
375 | case "${BAKEFILE_HOST}" in | |
376 | *-*-aix5* ) | |
377 | LD_EXPFULL="-Wl,-bexpfull" | |
378 | ;; | |
379 | esac | |
380 | ||
381 | SHARED_LD_CC="\$(CC) -shared $LD_EXPFULL -o" | |
382 | SHARED_LD_CXX="\$(CXX) -shared $LD_EXPFULL -o" | |
383 | else | |
384 | dnl FIXME: makeC++SharedLib is obsolete, what should we do for | |
385 | dnl recent AIX versions? | |
386 | AC_CHECK_PROG(AIX_CXX_LD, makeC++SharedLib, | |
387 | makeC++SharedLib, /usr/lpp/xlC/bin/makeC++SharedLib) | |
388 | SHARED_LD_CC="$AIX_CC_LD -p 0 -o" | |
389 | SHARED_LD_CXX="$AIX_CXX_LD -p 0 -o" | |
390 | fi | |
391 | ;; | |
392 | ||
393 | *-*-beos* ) | |
394 | dnl can't use gcc under BeOS for shared library creation because it | |
395 | dnl complains about missing 'main' | |
396 | SHARED_LD_CC="${LD} -nostart -o" | |
397 | SHARED_LD_CXX="${LD} -nostart -o" | |
398 | ;; | |
399 | ||
400 | *-*-irix* ) | |
401 | dnl default settings are ok for gcc | |
402 | if test "x$GCC" != "xyes"; then | |
403 | PIC_FLAG="-KPIC" | |
404 | fi | |
405 | ;; | |
406 | ||
407 | *-*-cygwin* | *-*-mingw32* ) | |
408 | PIC_FLAG="" | |
409 | SHARED_LD_CC="\$(CC) -shared -o" | |
410 | SHARED_LD_CXX="\$(CXX) -shared -o" | |
411 | WINDOWS_IMPLIB=1 | |
412 | ;; | |
413 | ||
414 | *-pc-os2_emx | *-pc-os2-emx ) | |
415 | SHARED_LD_CC="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o" | |
416 | SHARED_LD_CXX="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o" | |
417 | PIC_FLAG="" | |
418 | AC_BAKEFILE_CREATE_FILE_DLLAR_SH | |
419 | chmod +x dllar.sh | |
420 | ;; | |
421 | ||
422 | powerpc-apple-macos* | \ | |
423 | *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | *-*-k*bsd*-gnu | \ | |
424 | *-*-sunos4* | \ | |
425 | *-*-osf* | \ | |
426 | *-*-dgux5* | \ | |
427 | *-*-sysv5* | \ | |
428 | *-pc-msdosdjgpp ) | |
429 | dnl defaults are ok | |
430 | ;; | |
431 | ||
432 | *) | |
433 | dnl wxWidgets specific: allow unknown unix systems | |
434 | dnl AC_MSG_ERROR(unknown system type $BAKEFILE_HOST.) | |
435 | esac | |
436 | ||
437 | if test "x$PIC_FLAG" != "x" ; then | |
438 | PIC_FLAG="$PIC_FLAG -DPIC" | |
439 | fi | |
440 | ||
441 | if test "x$SHARED_LD_MODULE_CC" = "x" ; then | |
442 | SHARED_LD_MODULE_CC="$SHARED_LD_CC" | |
443 | fi | |
444 | if test "x$SHARED_LD_MODULE_CXX" = "x" ; then | |
445 | SHARED_LD_MODULE_CXX="$SHARED_LD_CXX" | |
446 | fi | |
447 | ||
448 | AC_SUBST(SHARED_LD_CC) | |
449 | AC_SUBST(SHARED_LD_CXX) | |
450 | AC_SUBST(SHARED_LD_MODULE_CC) | |
451 | AC_SUBST(SHARED_LD_MODULE_CXX) | |
452 | AC_SUBST(PIC_FLAG) | |
453 | AC_SUBST(WINDOWS_IMPLIB) | |
454 | ]) | |
455 | ||
456 | ||
457 | dnl --------------------------------------------------------------------------- | |
458 | dnl AC_BAKEFILE_SHARED_VERSIONS | |
459 | dnl | |
460 | dnl Detects linker options for attaching versions (sonames) to shared libs. | |
461 | dnl --------------------------------------------------------------------------- | |
462 | ||
463 | AC_DEFUN([AC_BAKEFILE_SHARED_VERSIONS], | |
464 | [ | |
465 | USE_SOVERSION=0 | |
466 | USE_SOVERLINUX=0 | |
467 | USE_SOVERSOLARIS=0 | |
468 | USE_SOVERCYGWIN=0 | |
469 | USE_SOSYMLINKS=0 | |
470 | USE_MACVERSION=0 | |
471 | SONAME_FLAG= | |
472 | ||
473 | case "${BAKEFILE_HOST}" in | |
474 | *-*-linux* | *-*-freebsd* | *-*-k*bsd*-gnu ) | |
475 | SONAME_FLAG="-Wl,-soname," | |
476 | USE_SOVERSION=1 | |
477 | USE_SOVERLINUX=1 | |
478 | USE_SOSYMLINKS=1 | |
479 | ;; | |
480 | ||
481 | *-*-solaris2* ) | |
482 | SONAME_FLAG="-h " | |
483 | USE_SOVERSION=1 | |
484 | USE_SOVERSOLARIS=1 | |
485 | USE_SOSYMLINKS=1 | |
486 | ;; | |
487 | ||
488 | *-*-darwin* ) | |
489 | USE_MACVERSION=1 | |
490 | USE_SOVERSION=1 | |
491 | USE_SOSYMLINKS=1 | |
492 | ;; | |
493 | ||
494 | *-*-cygwin* ) | |
495 | USE_SOVERSION=1 | |
496 | USE_SOVERCYGWIN=1 | |
497 | ;; | |
498 | esac | |
499 | ||
500 | AC_SUBST(USE_SOVERSION) | |
501 | AC_SUBST(USE_SOVERLINUX) | |
502 | AC_SUBST(USE_SOVERSOLARIS) | |
503 | AC_SUBST(USE_SOVERCYGWIN) | |
504 | AC_SUBST(USE_MACVERSION) | |
505 | AC_SUBST(USE_SOSYMLINKS) | |
506 | AC_SUBST(SONAME_FLAG) | |
507 | ]) | |
508 | ||
509 | ||
510 | dnl --------------------------------------------------------------------------- | |
511 | dnl AC_BAKEFILE_DEPS | |
512 | dnl | |
513 | dnl Detects available C/C++ dependency tracking options | |
514 | dnl --------------------------------------------------------------------------- | |
515 | ||
516 | AC_DEFUN([AC_BAKEFILE_DEPS], | |
517 | [ | |
518 | AC_ARG_ENABLE([dependency-tracking], | |
519 | AS_HELP_STRING([--disable-dependency-tracking], | |
520 | [don't use dependency tracking even if the compiler can]), | |
521 | [bk_use_trackdeps="$enableval"]) | |
522 | ||
523 | AC_MSG_CHECKING([for dependency tracking method]) | |
524 | ||
525 | if test "x$bk_use_trackdeps" = "xno" ; then | |
526 | DEPS_TRACKING=0 | |
527 | AC_MSG_RESULT([disabled]) | |
528 | else | |
529 | DEPS_TRACKING=1 | |
530 | ||
531 | if test "x$GCC" = "xyes"; then | |
532 | DEPSMODE=gcc | |
533 | case "${BAKEFILE_HOST}" in | |
534 | *-*-darwin* ) | |
535 | dnl -cpp-precomp (the default) conflicts with -MMD option | |
536 | dnl used by bk-deps (see also http://developer.apple.com/documentation/Darwin/Conceptual/PortingUnix/compiling/chapter_4_section_3.html) | |
537 | DEPSFLAG="-no-cpp-precomp -MMD" | |
538 | ;; | |
539 | * ) | |
540 | DEPSFLAG="-MMD" | |
541 | ;; | |
542 | esac | |
543 | AC_MSG_RESULT([gcc]) | |
544 | elif test "x$MWCC" = "xyes"; then | |
545 | DEPSMODE=mwcc | |
546 | DEPSFLAG="-MM" | |
547 | AC_MSG_RESULT([mwcc]) | |
548 | elif test "x$SUNCC" = "xyes"; then | |
549 | DEPSMODE=unixcc | |
550 | DEPSFLAG="-xM1" | |
551 | AC_MSG_RESULT([Sun cc]) | |
552 | elif test "x$SGICC" = "xyes"; then | |
553 | DEPSMODE=unixcc | |
554 | DEPSFLAG="-M" | |
555 | AC_MSG_RESULT([SGI cc]) | |
556 | elif test "x$HPCC" = "xyes"; then | |
557 | DEPSMODE=unixcc | |
558 | DEPSFLAG="+make" | |
559 | AC_MSG_RESULT([HP cc]) | |
560 | elif test "x$COMPAQCC" = "xyes"; then | |
561 | DEPSMODE=gcc | |
562 | DEPSFLAG="-MD" | |
563 | AC_MSG_RESULT([Compaq cc]) | |
564 | else | |
565 | DEPS_TRACKING=0 | |
566 | AC_MSG_RESULT([none]) | |
567 | fi | |
568 | ||
569 | if test $DEPS_TRACKING = 1 ; then | |
570 | AC_BAKEFILE_CREATE_FILE_BK_DEPS | |
571 | chmod +x bk-deps | |
572 | fi | |
573 | fi | |
574 | ||
575 | AC_SUBST(DEPS_TRACKING) | |
576 | ]) | |
577 | ||
578 | dnl --------------------------------------------------------------------------- | |
579 | dnl AC_BAKEFILE_CHECK_BASIC_STUFF | |
580 | dnl | |
581 | dnl Checks for presence of basic programs, such as C and C++ compiler, "ranlib" | |
582 | dnl or "install" | |
583 | dnl --------------------------------------------------------------------------- | |
584 | ||
585 | AC_DEFUN([AC_BAKEFILE_CHECK_BASIC_STUFF], | |
586 | [ | |
587 | AC_PROG_RANLIB | |
588 | AC_PROG_INSTALL | |
589 | AC_PROG_LN_S | |
590 | ||
591 | AC_PROG_MAKE_SET | |
592 | AC_SUBST(MAKE_SET) | |
593 | ||
594 | AC_CHECK_TOOL(AR, ar, ar) | |
595 | AC_CHECK_TOOL(STRIP, strip, :) | |
596 | AC_CHECK_TOOL(NM, nm, :) | |
597 | ||
598 | case ${BAKEFILE_HOST} in | |
599 | *-hp-hpux* ) | |
600 | dnl HP-UX install doesn't handle the "-d" switch so don't | |
601 | dnl use it there | |
602 | INSTALL_DIR="mkdir -p" | |
603 | ;; | |
604 | *) INSTALL_DIR="$INSTALL -d" | |
605 | ;; | |
606 | esac | |
607 | AC_SUBST(INSTALL_DIR) | |
608 | ||
609 | LDFLAGS_GUI= | |
610 | case ${BAKEFILE_HOST} in | |
611 | *-*-cygwin* | *-*-mingw32* ) | |
612 | LDFLAGS_GUI="-mwindows" | |
613 | esac | |
614 | AC_SUBST(LDFLAGS_GUI) | |
615 | ]) | |
616 | ||
617 | ||
618 | dnl --------------------------------------------------------------------------- | |
619 | dnl AC_BAKEFILE_RES_COMPILERS | |
620 | dnl | |
621 | dnl Checks for presence of resource compilers for win32 or mac | |
622 | dnl --------------------------------------------------------------------------- | |
623 | ||
624 | AC_DEFUN([AC_BAKEFILE_RES_COMPILERS], | |
625 | [ | |
626 | case ${BAKEFILE_HOST} in | |
627 | *-*-cygwin* | *-*-mingw32* ) | |
628 | dnl Check for win32 resources compiler: | |
629 | AC_CHECK_TOOL(WINDRES, windres) | |
630 | ;; | |
631 | ||
632 | *-*-darwin* | powerpc-apple-macos* ) | |
633 | AC_CHECK_PROG(REZ, Rez, Rez, /Developer/Tools/Rez) | |
634 | AC_CHECK_PROG(SETFILE, SetFile, SetFile, /Developer/Tools/SetFile) | |
635 | ;; | |
636 | esac | |
637 | ||
638 | AC_SUBST(WINDRES) | |
639 | AC_SUBST(REZ) | |
640 | AC_SUBST(SETFILE) | |
641 | ]) | |
642 | ||
643 | dnl --------------------------------------------------------------------------- | |
644 | dnl AC_BAKEFILE_PRECOMP_HEADERS | |
645 | dnl | |
646 | dnl Check for precompiled headers support (GCC >= 3.4) | |
647 | dnl --------------------------------------------------------------------------- | |
648 | ||
649 | AC_DEFUN([AC_BAKEFILE_PRECOMP_HEADERS], | |
650 | [ | |
651 | ||
652 | AC_ARG_ENABLE([precomp-headers], | |
653 | AS_HELP_STRING([--disable-precomp-headers], | |
654 | [don't use precompiled headers even if compiler can]), | |
655 | [bk_use_pch="$enableval"]) | |
656 | ||
657 | GCC_PCH=0 | |
658 | ICC_PCH=0 | |
659 | USE_PCH=0 | |
660 | ||
661 | case ${BAKEFILE_HOST} in | |
662 | *-*-cygwin* ) | |
663 | dnl PCH support is broken in cygwin gcc because of unportable | |
664 | dnl assumptions about mmap() in gcc code which make PCH generation | |
665 | dnl fail erratically; disable PCH completely until this is fixed | |
666 | bk_use_pch="no" | |
667 | ;; | |
668 | esac | |
669 | ||
670 | if test "x$bk_use_pch" = "x" -o "x$bk_use_pch" = "xyes" ; then | |
671 | if test "x$GCC" = "xyes"; then | |
672 | dnl test if we have gcc-3.4: | |
673 | AC_MSG_CHECKING([if the compiler supports precompiled headers]) | |
674 | AC_TRY_COMPILE([], | |
675 | [ | |
676 | #if !defined(__GNUC__) || !defined(__GNUC_MINOR__) | |
677 | There is no PCH support | |
678 | #endif | |
679 | #if (__GNUC__ < 3) | |
680 | There is no PCH support | |
681 | #endif | |
682 | #if (__GNUC__ == 3) && \ | |
683 | ((!defined(__APPLE_CC__) && (__GNUC_MINOR__ < 4)) || \ | |
684 | ( defined(__APPLE_CC__) && (__GNUC_MINOR__ < 3))) || \ | |
685 | ( defined(__INTEL_COMPILER) ) | |
686 | There is no PCH support | |
687 | #endif | |
688 | ], | |
689 | [ | |
690 | AC_MSG_RESULT([yes]) | |
691 | GCC_PCH=1 | |
692 | ], | |
693 | [ | |
694 | AC_TRY_COMPILE([], | |
695 | [ | |
696 | #if !defined(__INTEL_COMPILER) || \ | |
697 | (__INTEL_COMPILER < 800) | |
698 | There is no PCH support | |
699 | #endif | |
700 | ], | |
701 | [ | |
702 | AC_MSG_RESULT([yes]) | |
703 | ICC_PCH=1 | |
704 | ], | |
705 | [ | |
706 | AC_MSG_RESULT([no]) | |
707 | ]) | |
708 | ]) | |
709 | if test $GCC_PCH = 1 -o $ICC_PCH = 1 ; then | |
710 | USE_PCH=1 | |
711 | AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH | |
712 | chmod +x bk-make-pch | |
713 | fi | |
714 | fi | |
715 | fi | |
716 | ||
717 | AC_SUBST(GCC_PCH) | |
718 | AC_SUBST(ICC_PCH) | |
719 | ]) | |
720 | ||
721 | ||
722 | ||
723 | dnl --------------------------------------------------------------------------- | |
724 | dnl AC_BAKEFILE([autoconf_inc.m4 inclusion]) | |
725 | dnl | |
726 | dnl To be used in configure.in of any project using Bakefile-generated mks | |
727 | dnl | |
728 | dnl Behaviour can be modified by setting following variables: | |
729 | dnl BAKEFILE_CHECK_BASICS set to "no" if you don't want bakefile to | |
730 | dnl to perform check for basic tools like ranlib | |
731 | dnl BAKEFILE_HOST set this to override host detection, defaults | |
732 | dnl to ${host} | |
733 | dnl BAKEFILE_FORCE_PLATFORM set to override platform detection | |
734 | dnl | |
735 | dnl Example usage: | |
736 | dnl | |
737 | dnl AC_BAKEFILE([FOO(autoconf_inc.m4)]) | |
738 | dnl | |
739 | dnl (replace FOO with m4_include above, aclocal would die otherwise) | |
740 | dnl (yes, it's ugly, but thanks to a bug in aclocal, it's the only thing | |
741 | dnl we can do...) | |
742 | dnl --------------------------------------------------------------------------- | |
743 | ||
744 | AC_DEFUN([AC_BAKEFILE], | |
745 | [ | |
746 | AC_PREREQ(2.58) | |
747 | ||
748 | if test "x$BAKEFILE_HOST" = "x"; then | |
749 | if test "x${host}" = "x" ; then | |
750 | AC_MSG_ERROR([You must call the autoconf "CANONICAL_HOST" macro in your configure.ac (or .in) file.]) | |
751 | fi | |
752 | ||
753 | BAKEFILE_HOST="${host}" | |
754 | fi | |
755 | ||
756 | if test "x$BAKEFILE_CHECK_BASICS" != "xno"; then | |
757 | AC_BAKEFILE_CHECK_BASIC_STUFF | |
758 | fi | |
759 | AC_BAKEFILE_GNUMAKE | |
760 | AC_BAKEFILE_PLATFORM | |
761 | AC_BAKEFILE_PLATFORM_SPECIFICS | |
762 | AC_BAKEFILE_SUFFIXES | |
763 | AC_BAKEFILE_SHARED_LD | |
764 | AC_BAKEFILE_SHARED_VERSIONS | |
765 | AC_BAKEFILE_DEPS | |
766 | AC_BAKEFILE_RES_COMPILERS | |
767 | ||
768 | BAKEFILE_BAKEFILE_M4_VERSION="0.2.0" | |
769 | ||
770 | dnl includes autoconf_inc.m4: | |
771 | $1 | |
772 | ||
773 | if test "$BAKEFILE_AUTOCONF_INC_M4_VERSION" = "" ; then | |
774 | AC_MSG_ERROR([No version found in autoconf_inc.m4 - bakefile macro was changed to take additional argument, perhaps configure.in wasn't updated (see the documentation)?]) | |
775 | fi | |
776 | ||
777 | if test "$BAKEFILE_BAKEFILE_M4_VERSION" != "$BAKEFILE_AUTOCONF_INC_M4_VERSION" ; then | |
778 | AC_MSG_ERROR([Versions of Bakefile used to generate makefiles ($BAKEFILE_AUTOCONF_INC_M4_VERSION) and configure ($BAKEFILE_BAKEFILE_M4_VERSION) do not match.]) | |
779 | fi | |
780 | ]) | |
781 | ||
782 | ||
783 | dnl --------------------------------------------------------------------------- | |
784 | dnl Embedded copies of helper scripts follow: | |
785 | dnl --------------------------------------------------------------------------- | |
786 | ||
787 | AC_DEFUN([AC_BAKEFILE_CREATE_FILE_DLLAR_SH], | |
788 | [ | |
789 | dnl ===================== dllar.sh begins here ===================== | |
790 | dnl (Created by merge-scripts.py from dllar.sh | |
791 | dnl file do not edit here!) | |
792 | D='$' | |
793 | cat <<EOF >dllar.sh | |
794 | #!/bin/sh | |
795 | # | |
796 | # dllar - a tool to build both a .dll and an .a file | |
797 | # from a set of object (.o) files for EMX/OS2. | |
798 | # | |
799 | # Written by Andrew Zabolotny, bit@freya.etu.ru | |
800 | # Ported to Unix like shell by Stefan Neis, Stefan.Neis@t-online.de | |
801 | # | |
802 | # This script will accept a set of files on the command line. | |
803 | # All the public symbols from the .o files will be exported into | |
804 | # a .DEF file, then linker will be run (through gcc) against them to | |
805 | # build a shared library consisting of all given .o files. All libraries | |
806 | # (.a) will be first decompressed into component .o files then act as | |
807 | # described above. You can optionally give a description (-d "description") | |
808 | # which will be put into .DLL. To see the list of accepted options (as well | |
809 | # as command-line format) simply run this program without options. The .DLL | |
810 | # is built to be imported by name (there is no guarantee that new versions | |
811 | # of the library you build will have same ordinals for same symbols). | |
812 | # | |
813 | # dllar is free software; you can redistribute it and/or modify | |
814 | # it under the terms of the GNU General Public License as published by | |
815 | # the Free Software Foundation; either version 2, or (at your option) | |
816 | # any later version. | |
817 | # | |
818 | # dllar is distributed in the hope that it will be useful, | |
819 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
820 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
821 | # GNU General Public License for more details. | |
822 | # | |
823 | # You should have received a copy of the GNU General Public License | |
824 | # along with dllar; see the file COPYING. If not, write to the Free | |
825 | # Software Foundation, 59 Temple Place - Suite 330, Boston, MA | |
826 | # 02111-1307, USA. | |
827 | ||
828 | # To successfuly run this program you will need: | |
829 | # - Current drive should have LFN support (HPFS, ext2, network, etc) | |
830 | # (Sometimes dllar generates filenames which won't fit 8.3 scheme) | |
831 | # - gcc | |
832 | # (used to build the .dll) | |
833 | # - emxexp | |
834 | # (used to create .def file from .o files) | |
835 | # - emximp | |
836 | # (used to create .a file from .def file) | |
837 | # - GNU text utilites (cat, sort, uniq) | |
838 | # used to process emxexp output | |
839 | # - GNU file utilities (mv, rm) | |
840 | # - GNU sed | |
841 | # - lxlite (optional, see flag below) | |
842 | # (used for general .dll cleanup) | |
843 | # | |
844 | ||
845 | flag_USE_LXLITE=1; | |
846 | ||
847 | # | |
848 | # helper functions | |
849 | # basnam, variant of basename, which does _not_ remove the path, _iff_ | |
850 | # second argument (suffix to remove) is given | |
851 | basnam(){ | |
852 | case ${D}# in | |
853 | 1) | |
854 | echo ${D}1 | sed 's/.*\\///' | sed 's/.*\\\\//' | |
855 | ;; | |
856 | 2) | |
857 | echo ${D}1 | sed 's/'${D}2'${D}//' | |
858 | ;; | |
859 | *) | |
860 | echo "error in basnam ${D}*" | |
861 | exit 8 | |
862 | ;; | |
863 | esac | |
864 | } | |
865 | ||
866 | # Cleanup temporary files and output | |
867 | CleanUp() { | |
868 | cd ${D}curDir | |
869 | for i in ${D}inputFiles ; do | |
870 | case ${D}i in | |
871 | *!) | |
872 | rm -rf \`basnam ${D}i !\` | |
873 | ;; | |
874 | *) | |
875 | ;; | |
876 | esac | |
877 | done | |
878 | ||
879 | # Kill result in case of failure as there is just to many stupid make/nmake | |
880 | # things out there which doesn't do this. | |
881 | if @<:@ ${D}# -eq 0 @:>@; then | |
882 | rm -f ${D}arcFile ${D}arcFile2 ${D}defFile ${D}dllFile | |
883 | fi | |
884 | } | |
885 | ||
886 | # Print usage and exit script with rc=1. | |
887 | PrintHelp() { | |
888 | echo 'Usage: dllar.sh @<:@-o@<:@utput@:>@ output_file@:>@ @<:@-i@<:@mport@:>@ importlib_name@:>@' | |
889 | echo ' @<:@-name-mangler-script script.sh@:>@' | |
890 | echo ' @<:@-d@<:@escription@:>@ "dll descrption"@:>@ @<:@-cc "CC"@:>@ @<:@-f@<:@lags@:>@ "CFLAGS"@:>@' | |
891 | echo ' @<:@-ord@<:@inals@:>@@:>@ -ex@<:@clude@:>@ "symbol(s)"' | |
892 | echo ' @<:@-libf@<:@lags@:>@ "{INIT|TERM}{GLOBAL|INSTANCE}"@:>@ @<:@-nocrt@<:@dll@:>@@:>@ @<:@-nolxl@<:@ite@:>@@:>@' | |
893 | echo ' @<:@*.o@:>@ @<:@*.a@:>@' | |
894 | echo '*> "output_file" should have no extension.' | |
895 | echo ' If it has the .o, .a or .dll extension, it is automatically removed.' | |
896 | echo ' The import library name is derived from this and is set to "name".a,' | |
897 | echo ' unless overridden by -import' | |
898 | echo '*> "importlib_name" should have no extension.' | |
899 | echo ' If it has the .o, or .a extension, it is automatically removed.' | |
900 | echo ' This name is used as the import library name and may be longer and' | |
901 | echo ' more descriptive than the DLL name which has to follow the old ' | |
902 | echo ' 8.3 convention of FAT.' | |
903 | echo '*> "script.sh may be given to override the output_file name by a' | |
904 | echo ' different name. It is mainly useful if the regular make process' | |
905 | echo ' of some package does not take into account OS/2 restriction of' | |
906 | echo ' DLL name lengths. It takes the importlib name as input and is' | |
907 | echo ' supposed to procude a shorter name as output. The script should' | |
908 | echo ' expect to get importlib_name without extension and should produce' | |
909 | echo ' a (max.) 8 letter name without extension.' | |
910 | echo '*> "cc" is used to use another GCC executable. (default: gcc.exe)' | |
911 | echo '*> "flags" should be any set of valid GCC flags. (default: -s -Zcrtdll)' | |
912 | echo ' These flags will be put at the start of GCC command line.' | |
913 | echo '*> -ord@<:@inals@:>@ tells dllar to export entries by ordinals. Be careful.' | |
914 | echo '*> -ex@<:@clude@:>@ defines symbols which will not be exported. You can define' | |
915 | echo ' multiple symbols, for example -ex "myfunc yourfunc _GLOBAL*".' | |
916 | echo ' If the last character of a symbol is "*", all symbols beginning' | |
917 | echo ' with the prefix before "*" will be exclude, (see _GLOBAL* above).' | |
918 | echo '*> -libf@<:@lags@:>@ can be used to add INITGLOBAL/INITINSTANCE and/or' | |
919 | echo ' TERMGLOBAL/TERMINSTANCE flags to the dynamically-linked library.' | |
920 | echo '*> -nocrt@<:@dll@:>@ switch will disable linking the library against emx''s' | |
921 | echo ' C runtime DLLs.' | |
922 | echo '*> -nolxl@<:@ite@:>@ switch will disable running lxlite on the resulting DLL.' | |
923 | echo '*> All other switches (for example -L./ or -lmylib) will be passed' | |
924 | echo ' unchanged to GCC at the end of command line.' | |
925 | echo '*> If you create a DLL from a library and you do not specify -o,' | |
926 | echo ' the basename for DLL and import library will be set to library name,' | |
927 | echo ' the initial library will be renamed to 'name'_s.a (_s for static)' | |
928 | echo ' i.e. "dllar gcc.a" will create gcc.dll and gcc.a, and the initial' | |
929 | echo ' library will be renamed into gcc_s.a.' | |
930 | echo '--------' | |
931 | echo 'Example:' | |
932 | echo ' dllar -o gcc290.dll libgcc.a -d "GNU C runtime library" -ord' | |
933 | echo ' -ex "__main __ctordtor*" -libf "INITINSTANCE TERMINSTANCE"' | |
934 | CleanUp | |
935 | exit 1 | |
936 | } | |
937 | ||
938 | # Execute a command. | |
939 | # If exit code of the commnad <> 0 CleanUp() is called and we'll exit the script. | |
940 | # @Uses Whatever CleanUp() uses. | |
941 | doCommand() { | |
942 | echo "${D}*" | |
943 | eval ${D}* | |
944 | rcCmd=${D}? | |
945 | ||
946 | if @<:@ ${D}rcCmd -ne 0 @:>@; then | |
947 | echo "command failed, exit code="${D}rcCmd | |
948 | CleanUp | |
949 | exit ${D}rcCmd | |
950 | fi | |
951 | } | |
952 | ||
953 | # main routine | |
954 | # setup globals | |
955 | cmdLine=${D}* | |
956 | outFile="" | |
957 | outimpFile="" | |
958 | inputFiles="" | |
959 | renameScript="" | |
960 | description="" | |
961 | CC=gcc.exe | |
962 | CFLAGS="-s -Zcrtdll" | |
963 | EXTRA_CFLAGS="" | |
964 | EXPORT_BY_ORDINALS=0 | |
965 | exclude_symbols="" | |
966 | library_flags="" | |
967 | curDir=\`pwd\` | |
968 | curDirS=curDir | |
969 | case ${D}curDirS in | |
970 | */) | |
971 | ;; | |
972 | *) | |
973 | curDirS=${D}{curDirS}"/" | |
974 | ;; | |
975 | esac | |
976 | # Parse commandline | |
977 | libsToLink=0 | |
978 | omfLinking=0 | |
979 | while @<:@ ${D}1 @:>@; do | |
980 | case ${D}1 in | |
981 | -ord*) | |
982 | EXPORT_BY_ORDINALS=1; | |
983 | ;; | |
984 | -o*) | |
985 | shift | |
986 | outFile=${D}1 | |
987 | ;; | |
988 | -i*) | |
989 | shift | |
990 | outimpFile=${D}1 | |
991 | ;; | |
992 | -name-mangler-script) | |
993 | shift | |
994 | renameScript=${D}1 | |
995 | ;; | |
996 | -d*) | |
997 | shift | |
998 | description=${D}1 | |
999 | ;; | |
1000 | -f*) | |
1001 | shift | |
1002 | CFLAGS=${D}1 | |
1003 | ;; | |
1004 | -c*) | |
1005 | shift | |
1006 | CC=${D}1 | |
1007 | ;; | |
1008 | -h*) | |
1009 | PrintHelp | |
1010 | ;; | |
1011 | -ex*) | |
1012 | shift | |
1013 | exclude_symbols=${D}{exclude_symbols}${D}1" " | |
1014 | ;; | |
1015 | -libf*) | |
1016 | shift | |
1017 | library_flags=${D}{library_flags}${D}1" " | |
1018 | ;; | |
1019 | -nocrt*) | |
1020 | CFLAGS="-s" | |
1021 | ;; | |
1022 | -nolxl*) | |
1023 | flag_USE_LXLITE=0 | |
1024 | ;; | |
1025 | -* | /*) | |
1026 | case ${D}1 in | |
1027 | -L* | -l*) | |
1028 | libsToLink=1 | |
1029 | ;; | |
1030 | -Zomf) | |
1031 | omfLinking=1 | |
1032 | ;; | |
1033 | *) | |
1034 | ;; | |
1035 | esac | |
1036 | EXTRA_CFLAGS=${D}{EXTRA_CFLAGS}" "${D}1 | |
1037 | ;; | |
1038 | *.dll) | |
1039 | EXTRA_CFLAGS="${D}{EXTRA_CFLAGS} \`basnam ${D}1 .dll\`" | |
1040 | if @<:@ ${D}omfLinking -eq 1 @:>@; then | |
1041 | EXTRA_CFLAGS="${D}{EXTRA_CFLAGS}.lib" | |
1042 | else | |
1043 | EXTRA_CFLAGS="${D}{EXTRA_CFLAGS}.a" | |
1044 | fi | |
1045 | ;; | |
1046 | *) | |
1047 | found=0; | |
1048 | if @<:@ ${D}libsToLink -ne 0 @:>@; then | |
1049 | EXTRA_CFLAGS=${D}{EXTRA_CFLAGS}" "${D}1 | |
1050 | else | |
1051 | for file in ${D}1 ; do | |
1052 | if @<:@ -f ${D}file @:>@; then | |
1053 | inputFiles="${D}{inputFiles} ${D}file" | |
1054 | found=1 | |
1055 | fi | |
1056 | done | |
1057 | if @<:@ ${D}found -eq 0 @:>@; then | |
1058 | echo "ERROR: No file(s) found: "${D}1 | |
1059 | exit 8 | |
1060 | fi | |
1061 | fi | |
1062 | ;; | |
1063 | esac | |
1064 | shift | |
1065 | done # iterate cmdline words | |
1066 | ||
1067 | # | |
1068 | if @<:@ -z "${D}inputFiles" @:>@; then | |
1069 | echo "dllar: no input files" | |
1070 | PrintHelp | |
1071 | fi | |
1072 | ||
1073 | # Now extract all .o files from .a files | |
1074 | newInputFiles="" | |
1075 | for file in ${D}inputFiles ; do | |
1076 | case ${D}file in | |
1077 | *.a | *.lib) | |
1078 | case ${D}file in | |
1079 | *.a) | |
1080 | suffix=".a" | |
1081 | AR="ar" | |
1082 | ;; | |
1083 | *.lib) | |
1084 | suffix=".lib" | |
1085 | AR="emxomfar" | |
1086 | EXTRA_CFLAGS="${D}EXTRA_CFLAGS -Zomf" | |
1087 | ;; | |
1088 | *) | |
1089 | ;; | |
1090 | esac | |
1091 | dirname=\`basnam ${D}file ${D}suffix\`"_%" | |
1092 | mkdir ${D}dirname | |
1093 | if @<:@ ${D}? -ne 0 @:>@; then | |
1094 | echo "Failed to create subdirectory ./${D}dirname" | |
1095 | CleanUp | |
1096 | exit 8; | |
1097 | fi | |
1098 | # Append '!' to indicate archive | |
1099 | newInputFiles="${D}newInputFiles ${D}{dirname}!" | |
1100 | doCommand "cd ${D}dirname; ${D}AR x ../${D}file" | |
1101 | cd ${D}curDir | |
1102 | found=0; | |
1103 | for subfile in ${D}dirname/*.o* ; do | |
1104 | if @<:@ -f ${D}subfile @:>@; then | |
1105 | found=1 | |
1106 | if @<:@ -s ${D}subfile @:>@; then | |
1107 | # FIXME: This should be: is file size > 32 byte, _not_ > 0! | |
1108 | newInputFiles="${D}newInputFiles ${D}subfile" | |
1109 | fi | |
1110 | fi | |
1111 | done | |
1112 | if @<:@ ${D}found -eq 0 @:>@; then | |
1113 | echo "WARNING: there are no files in archive \\'${D}file\\'" | |
1114 | fi | |
1115 | ;; | |
1116 | *) | |
1117 | newInputFiles="${D}{newInputFiles} ${D}file" | |
1118 | ;; | |
1119 | esac | |
1120 | done | |
1121 | inputFiles="${D}newInputFiles" | |
1122 | ||
1123 | # Output filename(s). | |
1124 | do_backup=0; | |
1125 | if @<:@ -z ${D}outFile @:>@; then | |
1126 | do_backup=1; | |
1127 | set outFile ${D}inputFiles; outFile=${D}2 | |
1128 | fi | |
1129 | ||
1130 | # If it is an archive, remove the '!' and the '_%' suffixes | |
1131 | case ${D}outFile in | |
1132 | *_%!) | |
1133 | outFile=\`basnam ${D}outFile _%!\` | |
1134 | ;; | |
1135 | *) | |
1136 | ;; | |
1137 | esac | |
1138 | case ${D}outFile in | |
1139 | *.dll) | |
1140 | outFile=\`basnam ${D}outFile .dll\` | |
1141 | ;; | |
1142 | *.DLL) | |
1143 | outFile=\`basnam ${D}outFile .DLL\` | |
1144 | ;; | |
1145 | *.o) | |
1146 | outFile=\`basnam ${D}outFile .o\` | |
1147 | ;; | |
1148 | *.obj) | |
1149 | outFile=\`basnam ${D}outFile .obj\` | |
1150 | ;; | |
1151 | *.a) | |
1152 | outFile=\`basnam ${D}outFile .a\` | |
1153 | ;; | |
1154 | *.lib) | |
1155 | outFile=\`basnam ${D}outFile .lib\` | |
1156 | ;; | |
1157 | *) | |
1158 | ;; | |
1159 | esac | |
1160 | case ${D}outimpFile in | |
1161 | *.a) | |
1162 | outimpFile=\`basnam ${D}outimpFile .a\` | |
1163 | ;; | |
1164 | *.lib) | |
1165 | outimpFile=\`basnam ${D}outimpFile .lib\` | |
1166 | ;; | |
1167 | *) | |
1168 | ;; | |
1169 | esac | |
1170 | if @<:@ -z ${D}outimpFile @:>@; then | |
1171 | outimpFile=${D}outFile | |
1172 | fi | |
1173 | defFile="${D}{outFile}.def" | |
1174 | arcFile="${D}{outimpFile}.a" | |
1175 | arcFile2="${D}{outimpFile}.lib" | |
1176 | ||
1177 | #create ${D}dllFile as something matching 8.3 restrictions, | |
1178 | if @<:@ -z ${D}renameScript @:>@ ; then | |
1179 | dllFile="${D}outFile" | |
1180 | else | |
1181 | dllFile=\`${D}renameScript ${D}outimpFile\` | |
1182 | fi | |
1183 | ||
1184 | if @<:@ ${D}do_backup -ne 0 @:>@ ; then | |
1185 | if @<:@ -f ${D}arcFile @:>@ ; then | |
1186 | doCommand "mv ${D}arcFile ${D}{outFile}_s.a" | |
1187 | fi | |
1188 | if @<:@ -f ${D}arcFile2 @:>@ ; then | |
1189 | doCommand "mv ${D}arcFile2 ${D}{outFile}_s.lib" | |
1190 | fi | |
1191 | fi | |
1192 | ||
1193 | # Extract public symbols from all the object files. | |
1194 | tmpdefFile=${D}{defFile}_% | |
1195 | rm -f ${D}tmpdefFile | |
1196 | for file in ${D}inputFiles ; do | |
1197 | case ${D}file in | |
1198 | *!) | |
1199 | ;; | |
1200 | *) | |
1201 | doCommand "emxexp -u ${D}file >> ${D}tmpdefFile" | |
1202 | ;; | |
1203 | esac | |
1204 | done | |
1205 | ||
1206 | # Create the def file. | |
1207 | rm -f ${D}defFile | |
1208 | echo "LIBRARY \`basnam ${D}dllFile\` ${D}library_flags" >> ${D}defFile | |
1209 | dllFile="${D}{dllFile}.dll" | |
1210 | if @<:@ ! -z ${D}description @:>@; then | |
1211 | echo "DESCRIPTION \\"${D}{description}\\"" >> ${D}defFile | |
1212 | fi | |
1213 | echo "EXPORTS" >> ${D}defFile | |
1214 | ||
1215 | doCommand "cat ${D}tmpdefFile | sort.exe | uniq.exe > ${D}{tmpdefFile}%" | |
1216 | grep -v "^ *;" < ${D}{tmpdefFile}% | grep -v "^ *${D}" >${D}tmpdefFile | |
1217 | ||
1218 | # Checks if the export is ok or not. | |
1219 | for word in ${D}exclude_symbols; do | |
1220 | grep -v ${D}word < ${D}tmpdefFile >${D}{tmpdefFile}% | |
1221 | mv ${D}{tmpdefFile}% ${D}tmpdefFile | |
1222 | done | |
1223 | ||
1224 | ||
1225 | if @<:@ ${D}EXPORT_BY_ORDINALS -ne 0 @:>@; then | |
1226 | sed "=" < ${D}tmpdefFile | \\ | |
1227 | sed ' | |
1228 | N | |
1229 | : loop | |
1230 | s/^\\(@<:@0-9@:>@\\+\\)\\(@<:@^;@:>@*\\)\\(;.*\\)\\?/\\2 @\\1 NONAME/ | |
1231 | t loop | |
1232 | ' > ${D}{tmpdefFile}% | |
1233 | grep -v "^ *${D}" < ${D}{tmpdefFile}% > ${D}tmpdefFile | |
1234 | else | |
1235 | rm -f ${D}{tmpdefFile}% | |
1236 | fi | |
1237 | cat ${D}tmpdefFile >> ${D}defFile | |
1238 | rm -f ${D}tmpdefFile | |
1239 | ||
1240 | # Do linking, create implib, and apply lxlite. | |
1241 | gccCmdl=""; | |
1242 | for file in ${D}inputFiles ; do | |
1243 | case ${D}file in | |
1244 | *!) | |
1245 | ;; | |
1246 | *) | |
1247 | gccCmdl="${D}gccCmdl ${D}file" | |
1248 | ;; | |
1249 | esac | |
1250 | done | |
1251 | doCommand "${D}CC ${D}CFLAGS -Zdll -o ${D}dllFile ${D}defFile ${D}gccCmdl ${D}EXTRA_CFLAGS" | |
1252 | touch "${D}{outFile}.dll" | |
1253 | ||
1254 | doCommand "emximp -o ${D}arcFile ${D}defFile" | |
1255 | if @<:@ ${D}flag_USE_LXLITE -ne 0 @:>@; then | |
1256 | add_flags=""; | |
1257 | if @<:@ ${D}EXPORT_BY_ORDINALS -ne 0 @:>@; then | |
1258 | add_flags="-ynd" | |
1259 | fi | |
1260 | doCommand "lxlite -cs -t: -mrn -mln ${D}add_flags ${D}dllFile" | |
1261 | fi | |
1262 | doCommand "emxomf -s -l ${D}arcFile" | |
1263 | ||
1264 | # Successful exit. | |
1265 | CleanUp 1 | |
1266 | exit 0 | |
1267 | EOF | |
1268 | dnl ===================== dllar.sh ends here ===================== | |
1269 | ]) | |
1270 | ||
1271 | AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_DEPS], | |
1272 | [ | |
1273 | dnl ===================== bk-deps begins here ===================== | |
1274 | dnl (Created by merge-scripts.py from bk-deps | |
1275 | dnl file do not edit here!) | |
1276 | D='$' | |
1277 | cat <<EOF >bk-deps | |
1278 | #!/bin/sh | |
1279 | ||
1280 | # This script is part of Bakefile (http://bakefile.sourceforge.net) autoconf | |
1281 | # script. It is used to track C/C++ files dependencies in portable way. | |
1282 | # | |
1283 | # Permission is given to use this file in any way. | |
1284 | ||
1285 | DEPSMODE=${DEPSMODE} | |
1286 | DEPSDIR=.deps | |
1287 | DEPSFLAG="${DEPSFLAG}" | |
1288 | ||
1289 | mkdir -p ${D}DEPSDIR | |
1290 | ||
1291 | if test ${D}DEPSMODE = gcc ; then | |
1292 | ${D}* ${D}{DEPSFLAG} | |
1293 | status=${D}? | |
1294 | if test ${D}{status} != 0 ; then | |
1295 | exit ${D}{status} | |
1296 | fi | |
1297 | # move created file to the location we want it in: | |
1298 | while test ${D}# -gt 0; do | |
1299 | case "${D}1" in | |
1300 | -o ) | |
1301 | shift | |
1302 | objfile=${D}1 | |
1303 | ;; | |
1304 | -* ) | |
1305 | ;; | |
1306 | * ) | |
1307 | srcfile=${D}1 | |
1308 | ;; | |
1309 | esac | |
1310 | shift | |
1311 | done | |
1312 | depfile=\`basename ${D}srcfile | sed -e 's/\\..*${D}/.d/g'\` | |
1313 | depobjname=\`echo ${D}depfile |sed -e 's/\\.d/.o/g'\` | |
1314 | if test -f ${D}depfile ; then | |
1315 | sed -e "s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{DEPSDIR}/${D}{objfile}.d | |
1316 | rm -f ${D}depfile | |
1317 | else | |
1318 | # "g++ -MMD -o fooobj.o foosrc.cpp" produces fooobj.d | |
1319 | depfile=\`basename ${D}objfile | sed -e 's/\\..*${D}/.d/g'\` | |
1320 | if test ! -f ${D}depfile ; then | |
1321 | # "cxx -MD -o fooobj.o foosrc.cpp" creates fooobj.o.d (Compaq C++) | |
1322 | depfile="${D}objfile.d" | |
1323 | fi | |
1324 | if test -f ${D}depfile ; then | |
1325 | sed -e "/^${D}objfile/!s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{DEPSDIR}/${D}{objfile}.d | |
1326 | rm -f ${D}depfile | |
1327 | fi | |
1328 | fi | |
1329 | exit 0 | |
1330 | elif test ${D}DEPSMODE = mwcc ; then | |
1331 | ${D}* || exit ${D}? | |
1332 | # Run mwcc again with -MM and redirect into the dep file we want | |
1333 | # NOTE: We can't use shift here because we need ${D}* to be valid | |
1334 | prevarg= | |
1335 | for arg in ${D}* ; do | |
1336 | if test "${D}prevarg" = "-o"; then | |
1337 | objfile=${D}arg | |
1338 | else | |
1339 | case "${D}arg" in | |
1340 | -* ) | |
1341 | ;; | |
1342 | * ) | |
1343 | srcfile=${D}arg | |
1344 | ;; | |
1345 | esac | |
1346 | fi | |
1347 | prevarg="${D}arg" | |
1348 | done | |
1349 | ${D}* ${D}DEPSFLAG >${D}{DEPSDIR}/${D}{objfile}.d | |
1350 | exit 0 | |
1351 | elif test ${D}DEPSMODE = unixcc; then | |
1352 | ${D}* || exit ${D}? | |
1353 | # Run compiler again with deps flag and redirect into the dep file. | |
1354 | # It doesn't work if the '-o FILE' option is used, but without it the | |
1355 | # dependency file will contain the wrong name for the object. So it is | |
1356 | # removed from the command line, and the dep file is fixed with sed. | |
1357 | cmd="" | |
1358 | while test ${D}# -gt 0; do | |
1359 | case "${D}1" in | |
1360 | -o ) | |
1361 | shift | |
1362 | objfile=${D}1 | |
1363 | ;; | |
1364 | * ) | |
1365 | eval arg${D}#=\\${D}1 | |
1366 | cmd="${D}cmd \\${D}arg${D}#" | |
1367 | ;; | |
1368 | esac | |
1369 | shift | |
1370 | done | |
1371 | eval "${D}cmd ${D}DEPSFLAG" | sed "s|.*:|${D}objfile:|" >${D}{DEPSDIR}/${D}{objfile}.d | |
1372 | exit 0 | |
1373 | else | |
1374 | ${D}* | |
1375 | exit ${D}? | |
1376 | fi | |
1377 | EOF | |
1378 | dnl ===================== bk-deps ends here ===================== | |
1379 | ]) | |
1380 | ||
1381 | AC_DEFUN([AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH], | |
1382 | [ | |
1383 | dnl ===================== shared-ld-sh begins here ===================== | |
1384 | dnl (Created by merge-scripts.py from shared-ld-sh | |
1385 | dnl file do not edit here!) | |
1386 | D='$' | |
1387 | cat <<EOF >shared-ld-sh | |
1388 | #!/bin/sh | |
1389 | #----------------------------------------------------------------------------- | |
1390 | #-- Name: distrib/mac/shared-ld-sh | |
1391 | #-- Purpose: Link a mach-o dynamic shared library for Darwin / Mac OS X | |
1392 | #-- Author: Gilles Depeyrot | |
1393 | #-- Copyright: (c) 2002 Gilles Depeyrot | |
1394 | #-- Licence: any use permitted | |
1395 | #----------------------------------------------------------------------------- | |
1396 | ||
1397 | verbose=0 | |
1398 | args="" | |
1399 | objects="" | |
1400 | linking_flag="-dynamiclib" | |
1401 | ldargs="-r -keep_private_externs -nostdlib" | |
1402 | ||
1403 | while test ${D}# -gt 0; do | |
1404 | case ${D}1 in | |
1405 | ||
1406 | -v) | |
1407 | verbose=1 | |
1408 | ;; | |
1409 | ||
1410 | -o|-compatibility_version|-current_version|-framework|-undefined|-install_name) | |
1411 | # collect these options and values | |
1412 | args="${D}{args} ${D}1 ${D}2" | |
1413 | shift | |
1414 | ;; | |
1415 | ||
1416 | -s|-Wl,*) | |
1417 | # collect these load args | |
1418 | ldargs="${D}{ldargs} ${D}1" | |
1419 | ;; | |
1420 | ||
1421 | -l*|-L*|-flat_namespace|-headerpad_max_install_names) | |
1422 | # collect these options | |
1423 | args="${D}{args} ${D}1" | |
1424 | ;; | |
1425 | ||
1426 | -dynamiclib|-bundle) | |
1427 | linking_flag="${D}1" | |
1428 | ;; | |
1429 | ||
1430 | -*) | |
1431 | echo "shared-ld: unhandled option '${D}1'" | |
1432 | exit 1 | |
1433 | ;; | |
1434 | ||
1435 | *.o | *.a | *.dylib) | |
1436 | # collect object files | |
1437 | objects="${D}{objects} ${D}1" | |
1438 | ;; | |
1439 | ||
1440 | *) | |
1441 | echo "shared-ld: unhandled argument '${D}1'" | |
1442 | exit 1 | |
1443 | ;; | |
1444 | ||
1445 | esac | |
1446 | shift | |
1447 | done | |
1448 | ||
1449 | status=0 | |
1450 | ||
1451 | # | |
1452 | # Link one module containing all the others | |
1453 | # | |
1454 | if test ${D}{verbose} = 1; then | |
1455 | echo "c++ ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o" | |
1456 | fi | |
1457 | c++ ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o | |
1458 | status=${D}? | |
1459 | ||
1460 | # | |
1461 | # Link the shared library from the single module created, but only if the | |
1462 | # previous command didn't fail: | |
1463 | # | |
1464 | if test ${D}{status} = 0; then | |
1465 | if test ${D}{verbose} = 1; then | |
1466 | echo "c++ ${D}{linking_flag} master.${D}${D}.o ${D}{args}" | |
1467 | fi | |
1468 | c++ ${D}{linking_flag} master.${D}${D}.o ${D}{args} | |
1469 | status=${D}? | |
1470 | fi | |
1471 | ||
1472 | # | |
1473 | # Remove intermediate module | |
1474 | # | |
1475 | rm -f master.${D}${D}.o | |
1476 | ||
1477 | exit ${D}status | |
1478 | EOF | |
1479 | dnl ===================== shared-ld-sh ends here ===================== | |
1480 | ]) | |
1481 | ||
1482 | AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH], | |
1483 | [ | |
1484 | dnl ===================== bk-make-pch begins here ===================== | |
1485 | dnl (Created by merge-scripts.py from bk-make-pch | |
1486 | dnl file do not edit here!) | |
1487 | D='$' | |
1488 | cat <<EOF >bk-make-pch | |
1489 | #!/bin/sh | |
1490 | ||
1491 | # This script is part of Bakefile (http://bakefile.sourceforge.net) autoconf | |
1492 | # script. It is used to generated precompiled headers. | |
1493 | # | |
1494 | # Permission is given to use this file in any way. | |
1495 | ||
1496 | outfile="${D}{1}" | |
1497 | header="${D}{2}" | |
1498 | shift | |
1499 | shift | |
1500 | ||
1501 | compiler="" | |
1502 | headerfile="" | |
1503 | ||
1504 | while test ${D}{#} -gt 0; do | |
1505 | add_to_cmdline=1 | |
1506 | case "${D}{1}" in | |
1507 | -I* ) | |
1508 | incdir=\`echo ${D}{1} | sed -e 's/-I\\(.*\\)/\\1/g'\` | |
1509 | if test "x${D}{headerfile}" = "x" -a -f "${D}{incdir}/${D}{header}" ; then | |
1510 | headerfile="${D}{incdir}/${D}{header}" | |
1511 | fi | |
1512 | ;; | |
1513 | -use-pch|-use_pch ) | |
1514 | shift | |
1515 | add_to_cmdline=0 | |
1516 | ;; | |
1517 | esac | |
1518 | if test ${D}add_to_cmdline = 1 ; then | |
1519 | compiler="${D}{compiler} ${D}{1}" | |
1520 | fi | |
1521 | shift | |
1522 | done | |
1523 | ||
1524 | if test "x${D}{headerfile}" = "x" ; then | |
1525 | echo "error: can't find header ${D}{header} in include paths" >&2 | |
1526 | else | |
1527 | if test -f ${D}{outfile} ; then | |
1528 | rm -f ${D}{outfile} | |
1529 | else | |
1530 | mkdir -p \`dirname ${D}{outfile}\` | |
1531 | fi | |
1532 | depsfile=".deps/\`echo ${D}{outfile} | tr '/.' '__'\`.d" | |
1533 | mkdir -p .deps | |
1534 | if test "x${GCC_PCH}" = "x1" ; then | |
1535 | # can do this because gcc is >= 3.4: | |
1536 | ${D}{compiler} -o ${D}{outfile} -MMD -MF "${D}{depsfile}" "${D}{headerfile}" | |
1537 | elif test "x${ICC_PCH}" = "x1" ; then | |
1538 | filename=pch_gen-${D}${D} | |
1539 | file=${D}{filename}.c | |
1540 | dfile=${D}{filename}.d | |
1541 | cat > ${D}file <<EOT | |
1542 | #include "${D}header" | |
1543 | EOT | |
1544 | # using -MF icc complains about differing command lines in creation/use | |
1545 | ${D}compiler -c -create_pch ${D}outfile -MMD ${D}file && \\ | |
1546 | sed -e "s,^.*:,${D}outfile:," -e "s, ${D}file,," < ${D}dfile > ${D}depsfile && \\ | |
1547 | rm -f ${D}file ${D}dfile ${D}{filename}.o | |
1548 | fi | |
1549 | exit ${D}{?} | |
1550 | fi | |
1551 | EOF | |
1552 | dnl ===================== bk-make-pch ends here ===================== | |
1553 | ]) |