llvm.org GIT mirror llvm / 2b6c038
Ensure timestamp on saved contents of configure.ac is not changed. Use correct options to automake. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16879 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Spencer 15 years ago
6 changed file(s) with 1819 addition(s) and 702 deletion(s). Raw diff Collapse all Expand all
66 outfile=configure_am
77 configfile=configure.am
88 with_automake=1
9 else
9 elif test -z "$1" ; then
1010 outfile=configure
1111 configfile=configure.ac
1212 with_automake=0
13 else
14 die "Invalid option: $1"
1315 fi
1416 test -d autoconf && test -f autoconf/$configfile && cd autoconf
1517 test -f $configfile || die "Can't find 'autoconf' dir; please cd into it first"
4749 echo "Regenerating aclocal.m4 with aclocal"
4850 cwd=`pwd`
4951 if test $with_automake -eq 1 ; then
50 cp configure.ac .configure.ac.save
52 mv configure.ac .configure.ac.save
5153 cp configure.am configure.ac
5254 cp configure.am ../configure.ac
5355 fi
6062 if test $with_automake -eq 1 ; then
6163 echo "Regenerating makefiles with automake 1.9.2"
6264 cp autoconf/aclocal.m4 .
63 automake --foreign --add-missing --copy
64 rm configure.ac
65 automake --gnu --add-missing --copy --force-missing
6566 cd $cwd
66 cp .configure.ac.save configure.ac
67 mv .configure.ac.save configure.ac
6768 fi
6869 exit 0
0 dnl -- configure.am - Automake based configuration --------------------------===
1 dnl
2 dnl The LLVM Compiler Infrastructure
3 dnl
4 dnl This file was developed by Reid Spencer and is distributed under the
5 dnl University of Illinois Open Source License. See LICENSE.TXT for details.
6 dnl
7 dnl ===----------------------------------------------------------------------===
8 dnl
9
10 dnl ===----------------------------------------------------------------------===
11 dnl --
12 dnl -- SECTION 1: Initialization & Setup
13 dnl --
14 dnl ===----------------------------------------------------------------------===
15
16 dnl Initialize autoconf
117 AC_INIT([[LLVM]],[[1.4]],[llvmbugs@cs.uiuc.edu])
218
925 dnl Verify that the source directory is valid
1026 AC_CONFIG_SRCDIR(["lib/VMCore/Module.cpp"])
1127
12 dnl Check which host for which we're compiling. This will tell us which LLVM
13 dnl compiler will be used for compiling SSA into object code.
28 dnl Check which host/target for which we're compiling. This will tell us which
29 dnl LLVM compiler will be used for compiling SSA into object code.
1430 AC_CANONICAL_TARGET
1531
1632 dnl Quit if the source directory has already been configured.
2238 fi
2339
2440 dnl Initialize automake
25 AM_INIT_AUTOMAKE
26
41 AM_INIT_AUTOMAKE([foreign dejagnu dist-zip nostdinc -Wnone -Wunsupported -Wsyntax -Wobsolete])
42
43 dnl Make sure we are using the right version of autoconf
44 AC_PREREQ(2.59)
45
46 dnl ===----------------------------------------------------------------------===
47 dnl --
48 dnl -- SECTION 2: Setup The Command Line Arguments For "configure"
49 dnl --
50 dnl ===----------------------------------------------------------------------===
51
52 dnl Specify where to find the llvm-gcc install directory
53 AC_ARG_WITH(llvmgccdir,
54 AS_HELP_STRING([--with-llvmgccdir],[Location of LLVM GCC front-end]),
55 [case "${withval}" in
56 /*|*/*) LLVMGCCDIR=$withval ;;
57 *) AC_MSG_ERROR([bad value ${withval} for --with-llvmgccdir]) ;;
58 esac],
59 [LLVMGCCDIR=/usr/local/llvm-gcc])
60 AC_SUBST(LLVMGCCDIR)
61
62 dnl Specify whether to build optimized or not
63 AC_ARG_ENABLE(optimized,
64 AS_HELP_STRING([--enable-optimized],[Build an optimized version of LLVM
65 (default=no)]),
66 [case "${withval}" in
67 yes) ENABLE_OPTIMIZED=1 ;;
68 no) ENABLE_OPTIMIZED=0 ;;
69 "") ENABLE_OPTIMIZED=0 ;;
70 *) AC_MSG_ERROR([bad value ${withval} for --enable-optimized]) ;;
71 esac],
72 [ENABLE_OPTIMIZED=0])
73 AC_SUBST(ENABLE_OPTIMIZED)
74 AM_CONDITIONAL(ENABLE_OPTIMIZED,test $ENABLE_OPTIMIZED = 1)
75
76 dnl Specify whether to build profiled or not
77 AC_ARG_ENABLE(profiled,
78 AS_HELP_STRING([--enable-profiled],[Build a profiled version of LLVM
79 (default=no)]),
80 [case "${withval}" in
81 yes) ENABLE_PROFILED=1 ;;
82 no) ENABLE_PROFILED=0 ;;
83 "") ENABLE_PROFILED=0 ;;
84 *) AC_MSG_ERROR([bad value ${withval} for --enable-profiled]) ;;
85 esac],
86 [ENABLE_PROFILED=0])
87 AC_SUBST(ENABLE_PROFILED,$ENABLE_PROFILED)
88 AM_CONDITIONAL(ENABLE_PROFILED,test $ENABLE_PROFILED = 1)
89
90 dnl JIT Option
91 AC_ARG_ENABLE(jit,
92 AS_HELP_STRING([--enable-jit],
93 [Enable Just In Time Compiling (default is YES)]),,
94 enableval=default)
95
96 if test ${enableval} = "no"
97 then
98 AC_SUBST(JIT,[[]])
99 else
100 case $target in
101 *i*86*) AC_SUBST(JIT,[[TARGET_HAS_JIT=1]]) ;;
102 *sparc*) AC_SUBST(JIT,[[TARGET_HAS_JIT=1]]) ;;
103 *) AC_SUBST(JIT,[[]]) ;;
104 esac
105 fi
106
107 dnl ===----------------------------------------------------------------------===
108 dnl --
109 dnl -- SECTION 3: Platform/Architecture Configuration
110 dnl --
111 dnl ===----------------------------------------------------------------------===
27112
28113 dnl Set the "OS" Makefile variable based on the system we are building on.
114 AC_MSG_CHECKING([support for generic build operating system])
115 case $build in
116 *-*-aix*) llvm_platform_type="AIX" ;;
117 *-*-cygwin*) llvm_platform_type="Cygwin" ;;
118 *-*-darwin*) llvm_platform_type="Darwin" ;;
119 *-*-freebsd*) llvm_platform_type="FreeBSD" ;;
120 *-*-interix*) llvm_platform_type="Interix" ;;
121 *-*-linux*) llvm_platform_type="Linux" ;;
122 *-*-solaris*) llvm_platform_type="SunOS" ;;
123 *-*-win32*) llvm_platform_type="Win32" ;;
124 *-*-mingw*) llvm_platform_type="Win32" ;;
125 *)
126 AC_MSG_ERROR([Platform is unknown, configure can't continue])
127 llvm_platform_type="Unknown"
128 ;;
129 esac
130 AC_SUBST(OS,$llvm_platform_type)
131 AC_MSG_RESULT($llvm_platform_type)
132
133 AC_MSG_CHECKING(target architecture)
134 dnl If we are targetting a Sparc machine running Solaris, pretend that it is
135 dnl V9, since that is all that we support at the moment, and autoconf will only
136 dnl tell us we're a sparc.
137 case $target in
138 sparc*-*-solaris*) AC_SUBST(target,[[sparcv9-sun-solaris2.8]]) ;;
139 esac
140
141 dnl Determine what our target architecture is and configure accordingly.
142 dnl This will allow Makefiles to make a distinction between the hardware and
143 dnl the OS.
144 case $target in
145 i*86-*) ARCH="x86" ;;
146 sparc*-*) ARCH="Sparc" ;;
147 powerpc*-*) ARCH="PowerPC" ;;
148 *) ARCH="Unknown";;
149 esac
150 AM_CONDITIONAL(ARCH_X86,test $ARCH = "x86")
151 AM_CONDITIONAL(ARCH_SPARC,test $ARCH = "Sparc")
152 AM_CONDITIONAL(ARCH_PPC,test $ARCH = "PowerPC")
153 AM_CONDITIONAL(ARCH_UNKNOWN,test $ARCH = "Unknown")
154 AC_SUBST(ARCH,$ARCH)
155 AC_MSG_RESULT($ARCH)
156
157 dnl Check for the endianness of the target
158 AC_C_BIGENDIAN(AC_SUBST([ENDIAN],[big]),AC_SUBST([ENDIAN],[little]))
159
160 dnl ===----------------------------------------------------------------------===
161 dnl --
162 dnl -- SECTION 4: Check For Programs We Need
163 dnl --
164 dnl ===----------------------------------------------------------------------===
165
166 dnl Find the install program (needs to be done before canonical stuff)
167 AC_PROG_INSTALL
168
169 dnl Check for compilation tools
170 AC_PROG_CXX
171 AC_PROG_CC(gcc)
172 AC_PROG_CPP
173
174 dnl Checks for other build tools
175 AC_PROG_FLEX
176 AC_PROG_BISON
177 AC_PROG_LIBTOOL
178
179 dnl Checks for tools we can get away with not having:
180 AC_PATH_PROG(DOT,[dot],[true dot])
181 AC_PATH_PROG(ETAGS,[etags],[true etags])
182 AC_PATH_PROG(PYTHON,[python],[true python])
183 AC_PATH_PROG(QMTEST,[qmtest],[true qmtest])
184
185 dnl ===----------------------------------------------------------------------===
186 dnl --
187 dnl -- SECTION 5: Basic sanity checks on dependent programs we need
188 dnl --
189 dnl ===----------------------------------------------------------------------===
190
191 dnl Ensure that compilation tools are GCC; we use GCC specific extensions
192 if test "$GCC" != "yes"
193 then
194 AC_MSG_ERROR([gcc required but not found])
195 fi
196
197 dnl Ensure that compilation tools are GCC; we use GCC specific extensions
198 if test "$GXX" != "yes"
199 then
200 AC_MSG_ERROR([g++ required but not found])
201 fi
202
203 dnl Verify that GCC is version 3.0 or higher
204 gccmajor=`$CC --version | head -n 1 | awk '{print $NF;}' | cut -d. -f1`
205 if test "$gccmajor" -lt "3"
206 then
207 AC_MSG_ERROR([gcc 3.x required, but you have a lower version])
208 fi
209
210 dnl Check for GNU Make. We use its extensions too, so don't build without it
211 AC_CHECK_GNU_MAKE
212 if test -z "$_cv_gnu_make_command"
213 then
214 AC_MSG_ERROR([GNU Make required but not found])
215 fi
216
217 dnl Find the LLVM GCC-based C/C++ front end
218 AC_MSG_CHECKING([for llvm-gcc])
219 LLVM_GCC_CHECK=no
220 if test -d "$LLVMGCCDIR"
221 then
222 if test -x "$LLVMGCCDIR/bin/gcc"
223 then
224 LLVM_GCC_CHECK="$LLVMGCCDIR/bin/gcc"
225 fi
226 fi
227 llvmgccwarn=no
228 AC_MSG_RESULT($LLVM_GCC_CHECK)
229 if test "$LLVM_GCC_CHECK" = "no"
230 then
231 llvmgccwarn=yes
232 fi
233
234 dnl Determine if the "gcc" found produces LLVM assembly. If so its "sane"
235 AC_MSG_CHECKING([whether llvm-gcc is sane])
236 LLVM_GCC_SANE=no
237 if test -x "$LLVM_GCC_CHECK"
238 then
239 cp /dev/null conftest.c
240 "$LLVM_GCC_CHECK" -S -o - conftest.c | grep implementation > /dev/null 2>&1
241 if test $? -eq 0
242 then
243 LLVM_GCC_SANE=yes
244 fi
245 rm conftest.c
246 llvmcc1path=`"$LLVM_GCC_CHECK" --print-prog-name=cc1`
247 AC_SUBST(LLVMCC1,$llvmcc1path)
248 llvmcc1pluspath=`"$LLVM_GCC_CHECK" --print-prog-name=cc1plus`
249 AC_SUBST(LLVMCC1PLUS,$llvmcc1pluspath)
250 fi
251 AC_MSG_RESULT($LLVM_GCC_SANE)
252 if test "$LLVM_GCC_SANE" = "no"
253 then
254 llvmgccwarn=yes
255 fi
256
257 dnl Check if we know how to tell etags we are using C++:
258 etags_version=`$ETAGS --version 2>&1`
259 case "$etags_version" in
260 *[Ee]xuberant*) ETAGSFLAGS="--language-force=c++" ;;
261 *GNU\ Emacs*) ETAGSFLAGS="-l c++" ;;
262 *) ETAGSFLAGS="" ;;
263 esac
264 AC_SUBST(ETAGSFLAGS,$ETAGSFLAGS)
265
266 if test "$PYTHON" = "false"
267 then
268 AC_MSG_WARN([Python is required for the test suite, but it was not found])
269 fi
270 if test "$QMTEST" = "false"
271 then
272 AC_MSG_WARN([QMTest is required for the test suite, but it was not found])
273 fi
274
275 dnl Verify that the version of python available is high enough for qmtest
276 pyversion=`$PYTHON -V 2>&1 | cut -d\ -f2`
277 pymajor=`echo $pyversion | cut -d. -f1`
278 pyminor=`echo $pyversion | cut -d. -f2`
279
280 if test "$pymajor" -ge "2"
281 then
282 if test "$pymajor" -eq "2"
283 then
284 if test "$pyminor" -lt "2"
285 then
286 AC_MSG_WARN([QMTest requires Python 2.2 or later])
287 fi
288 fi
289 else
290 AC_MSG_WARN([QMTest requires Python 2.2 or later])
291 fi
292
293 dnl ===----------------------------------------------------------------------===
294 dnl --
295 dnl -- SECTION 6: Check For Needed Libraries
296 dnl --
297 dnl ===----------------------------------------------------------------------===
298
299 dnl libelf is for sparc only; we can ignore it if we don't have it
300 AC_CHECK_LIB(elf, elf_begin)
301
302 dnl Check for bzip2 and zlib compression libraries needed for archive
303 dnl reading/writing
304 AC_CHECK_LIB(bz2,BZ2_bzCompressInit,[bzip2_found=1],[bzip2_found=0])
305 AC_CHECK_LIB(z,gzopen,[zlib_found=1],[zlib_found=0])
306
307 dnl dlopen() is required for plugin support.
308 AC_SEARCH_LIBS(dlopen,dl,
309 AC_DEFINE([HAVE_DLOPEN],[1],
310 [Define if dlopen() is available on this platform.]),
311 AC_MSG_WARN([dlopen() not found - disabling plugin support]))
312
313 dnl mallinfo is optional; the code can compile (minus features) without it
314 AC_SEARCH_LIBS(mallinfo,malloc,
315 AC_DEFINE([HAVE_MALLINFO],[1],
316 [Define if mallinfo() is available on this platform.]))
317
318 dnl pthread locking functions are optional - but llvm will not be thread-safe
319 dnl without locks.
320 AC_SEARCH_LIBS(pthread_mutex_lock,pthread,
321 AC_DEFINE([HAVE_PTHREAD_MUTEX_LOCK],[1],[Have pthread_mutex_lock]))
322
323
324 dnl ===----------------------------------------------------------------------===
325 dnl --
326 dnl -- SECTION 7: Check For Needed Header Files
327 dnl --
328 dnl ===----------------------------------------------------------------------===
329
330 dnl We don't check for ancient stuff or things that are guaranteed to be there
331 dnl by the C++ standard. We always use the versions of C headers.
332 AC_HEADER_STDC
333 AC_HEADER_SYS_WAIT
334 AC_HEADER_TIME
335 AC_HEADER_MMAP_ANONYMOUS
336
337 dnl Checks for POSIX and other various system-specific header files
338 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h malloc.h sys/mman.h)
339 AC_CHECK_HEADERS(sys/resource.h dlfcn.h link.h execinfo.h windows.h)
340
341 dnl Check for things that need to be included in public headers, and so
342 dnl for which we may not have access to a HAVE_* preprocessor #define.
343 dnl (primarily used in DataTypes.h)
344 AC_CHECK_HEADER([sys/types.h])
345 AC_CHECK_HEADER([inttypes.h])
346 AC_CHECK_HEADER([stdint.h])
347
348 dnl Checks for compression headers:
349 AC_CHECK_HEADERS([bzlib.h],[bzlib_h_found=1],[bzlib_h_found=0],[])
350 AC_CHECK_HEADERS([zlib.h],[zlib_h_found=1],[zlib_h_found=0],[])
351
352 dnl ===----------------------------------------------------------------------===
353 dnl --
354 dnl -- SECTION 8: Check for specific features (types/functions/options/etc)
355 dnl --
356 dnl ===----------------------------------------------------------------------===
357
358 dnl Check for types
359 AC_TYPE_PID_T
360 AC_TYPE_SIZE_T
361 AC_TYPE_SIGNAL
362 AC_STRUCT_TM
363 AC_CHECK_TYPES([int64_t],,AC_MSG_ERROR([Type int64_t required but not found]))
364 AC_CHECK_TYPES([uint64_t],,
365 AC_CHECK_TYPES([u_int64_t],,
366 AC_MSG_ERROR([Type uint64_t or u_int64_t required but not found])))
367
368 dnl Check for various C features
369 AC_C_PRINTF_A
370 AC_FUNC_ISNAN
371 AC_FUNC_ISINF
372 AC_FUNC_ALLOCA
373 AC_FUNC_MMAP
374 if test "$ac_cv_func_mmap_fixed_mapped" = "no"
375 then
376 AC_MSG_WARN([mmap() required but not found])
377 fi
378 AC_FUNC_MMAP_FILE
379 if test "$ac_cv_func_mmap_file" = "no"
380 then
381 AC_MSG_WARN([mmap() of files required but not found])
382 fi
383 AC_CHECK_FUNCS(getcwd gettimeofday strdup strtoq strtoll backtrace isatty)
384 AC_CHECK_FUNCS(mkstemp getrusage)
385 AC_CHECK_FUNC(mprotect,,
386 AC_MSG_ERROR([Function mprotect() required but not found]))
387
388 dnl Check for C++ extensions
389 AC_CXX_HAVE_HASH_MAP
390 AC_CXX_HAVE_HASH_SET
391 AC_CXX_HAVE_STD_ITERATOR
392 AC_CXX_HAVE_BI_ITERATOR
393 AC_CXX_HAVE_FWD_ITERATOR
394
395 dnl Determine if the linker supports the -R option.
396 AC_LINK_USE_R
397
398 dnl ===----------------------------------------------------------------------===
399 dnl --
400 dnl -- SECTION 9: Remaining LLVM specific configuration items
401 dnl --
402 dnl ===----------------------------------------------------------------------===
403
404 dnl Set up substitutions for compression libraries
405 if test $zlib_found -eq 1 -a $zlib_h_found -eq 1; then
406 AC_DEFINE([HAVE_ZLIB],[1],
407 [Define if zlib library is available on this platform.])
408 AC_SUBST([HAVE_ZLIB],[1])
409 else
410 AC_SUBST([HAVE_ZLIB],[0])
411 fi
412 if test $bzip2_found -eq 1 -a $bzlib_h_found -eq 1 ; then
413 AC_DEFINE([HAVE_BZIP2],[1],
414 [Define if bzip2 library is available on this platform.])
415 AC_SUBST([HAVE_BZIP2],[1])
416 else
417 AC_SUBST([HAVE_BZIP2],[0])
418 fi
419
420 dnl Get libtool's idea of what the shared library suffix is.
421 dnl This is a hack; it relies on undocumented behavior.
422 AC_MSG_CHECKING([for shared library suffix])
423 eval "SHLIBEXT=$shrext_cmds"
424 AC_MSG_RESULT($SHLIBEXT)
425
426 dnl Propagate it to the Makefiles and config.h (for gccld & bugpoint).
427 AC_SUBST(SHLIBEXT,$SHLIBEXT)
428 AC_DEFINE_UNQUOTED(SHLIBEXT,"$SHLIBEXT",
429 [Extension that shared libraries have, e.g., ".so".])
430
431 # Translate the various configuration directories and other basic
432 # information into substitutions that will end up in config.h.in so
433 # that these configured values can be hard-wired into a program.
434 eval LLVM_PREFIX="${prefix}";
435 eval LLVM_BINDIR="${prefix}/bin";
436 eval LLVM_LIBDIR="${prefix}/lib";
437 eval LLVM_DATADIR="${prefix}/data";
438 eval LLVM_DOCSDIR="${prefix}/docs";
439 eval LLVM_ETCDIR="${prefix}/etc";
440 eval LLVM_INCLUDEDIR="${prefix}/include";
441 eval LLVM_INFODIR="${prefix}/info";
442 eval LLVM_MANDIR="${prefix}/man";
443 LLVM_CONFIGTIME=`date`
444
445 AC_SUBST(LLVM_PREFIX)
446 AC_SUBST(LLVM_BINDIR)
447 AC_SUBST(LLVM_LIBDIR)
448 AC_SUBST(LLVM_DATADIR)
449 AC_SUBST(LLVM_DOCSDIR)
450 AC_SUBST(LLVM_ETCDIR)
451 AC_SUBST(LLVM_INCLUDEDIR)
452 AC_SUBST(LLVM_INFODIR)
453 AC_SUBST(LLVM_MANDIR)
454 AC_SUBST(LLVM_CONFIGTIME)
455
456 AC_DEFINE_UNQUOTED(LLVM_PREFIX,"$LLVM_PREFIX",
457 [Installation prefix directory])
458 AC_DEFINE_UNQUOTED(LLVM_BINDIR, "$LLVM_BINDIR",
459 [Installation directory for binary executables])
460 AC_DEFINE_UNQUOTED(LLVM_LIBDIR, "$LLVM_LIBDIR",
461 [Installation directory for libraries])
462 AC_DEFINE_UNQUOTED(LLVM_DATADIR, "$LLVM_DATADIR",
463 [Installation directory for data files])
464 AC_DEFINE_UNQUOTED(LLVM_DATADIR, "$LLVM_DOCSDIR",
465 [Installation directory for documentation])
466 AC_DEFINE_UNQUOTED(LLVM_ETCDIR, "$LLVM_ETCDIR",
467 [Installation directory for config files])
468 AC_DEFINE_UNQUOTED(LLVM_INCLUDEDIR, "$LLVM_INCLUDEDIR",
469 [Installation directory for include files])
470 AC_DEFINE_UNQUOTED(LLVM_INFODIR, "$LLVM_INFODIR",
471 [Installation directory for .info files])
472 AC_DEFINE_UNQUOTED(LLVM_MANDIR, "$LLVM_MANDIR",
473 [Installation directory for man pages])
474 AC_DEFINE_UNQUOTED(LLVM_CONFIGTIME, "$LLVM_CONFIGTIME",
475 [Time at which LLVM was configured])
476
477 dnl ===----------------------------------------------------------------------===
478 dnl -- SECTION 10: Define the output and put it out
479 dnl ===----------------------------------------------------------------------===
480
481 dnl Configure header files
482 AC_CONFIG_HEADERS([include/llvm/Config/config.h])
483 AC_CONFIG_HEADERS([include/llvm/Support/DataTypes.h])
484 AC_CONFIG_HEADERS([include/llvm/ADT/hash_map])
485 AC_CONFIG_HEADERS([include/llvm/ADT/hash_set])
486 AC_CONFIG_HEADERS([include/llvm/Support/ThreadSupport.h])
487 AC_CONFIG_HEADERS([include/llvm/ADT/iterator])
488
489 dnl Configure makefiles
490 AC_CONFIG_FILES([Makefile])
491 AC_CONFIG_FILES([lib/Makefile])
492 AC_CONFIG_FILES([lib/Analysis/IPA/Makefile])
493 AC_CONFIG_FILES([lib/Analysis/Makefile])
494 AC_CONFIG_FILES([lib/Analysis/DataStructure/Makefile])
495 AC_CONFIG_FILES([lib/AsmParser/Makefile])
496 AC_CONFIG_FILES([lib/System/Makefile])
497 AC_CONFIG_FILES([lib/Bytecode/Reader/Makefile])
498 AC_CONFIG_FILES([lib/Bytecode/Makefile])
499 AC_CONFIG_FILES([lib/Bytecode/Writer/Makefile])
500 AC_CONFIG_FILES([lib/Bytecode/Archive/Makefile])
501 AC_CONFIG_FILES([lib/CodeGen/InstrSched/Makefile])
502 AC_CONFIG_FILES([lib/CodeGen/Makefile])
503 AC_CONFIG_FILES([lib/CodeGen/ModuloScheduling/Makefile])
504 AC_CONFIG_FILES([lib/CodeGen/SelectionDAG/Makefile])
505 AC_CONFIG_FILES([lib/Debugger/Makefile])
506 AC_CONFIG_FILES([lib/ExecutionEngine/Interpreter/Makefile])
507 AC_CONFIG_FILES([lib/ExecutionEngine/Makefile])
508 AC_CONFIG_FILES([lib/ExecutionEngine/JIT/Makefile])
509 AC_CONFIG_FILES([lib/Support/Makefile])
510 AC_CONFIG_FILES([lib/Target/CBackend/Makefile])
511 AC_CONFIG_FILES([lib/Target/Makefile])
512 AC_CONFIG_FILES([lib/Target/Skeleton/Makefile])
513 AC_CONFIG_FILES([lib/Target/PowerPC/Makefile])
514 AC_CONFIG_FILES([lib/Target/SparcV9/Makefile])
515 AC_CONFIG_FILES([lib/Target/SparcV9/LiveVar/Makefile])
516 AC_CONFIG_FILES([lib/Target/SparcV9/RegAlloc/Makefile])
517 AC_CONFIG_FILES([lib/Target/X86/Makefile])
518 AC_CONFIG_FILES([lib/Transforms/Hello/Makefile])
519 AC_CONFIG_FILES([lib/Transforms/Makefile])
520 AC_CONFIG_FILES([lib/Transforms/IPO/Makefile])
521 AC_CONFIG_FILES([lib/Transforms/Instrumentation/ProfilePaths/Makefile])
522 AC_CONFIG_FILES([lib/Transforms/Instrumentation/Makefile])
523 AC_CONFIG_FILES([lib/Transforms/Scalar/Makefile])
524 AC_CONFIG_FILES([lib/Transforms/Utils/Makefile])
525 AC_CONFIG_FILES([lib/VMCore/Makefile])
526 AC_CONFIG_FILES([utils/Makefile])
527 AC_CONFIG_FILES([utils/Burg/Makefile])
528 AC_CONFIG_FILES([utils/fpcmp/Makefile])
529 AC_CONFIG_FILES([utils/TableGen/Makefile])
530 AC_CONFIG_FILES([tools/Makefile])
531 AC_CONFIG_FILES([tools/analyze/Makefile])
532 AC_CONFIG_FILES([tools/llvmc/Makefile])
533 AC_CONFIG_FILES([tools/bugpoint/Makefile])
534 AC_CONFIG_FILES([tools/extract/Makefile])
535 AC_CONFIG_FILES([tools/gccas/Makefile])
536 AC_CONFIG_FILES([tools/gccld/Makefile])
537 AC_CONFIG_FILES([tools/llvm-bcanalyzer/Makefile])
538 AC_CONFIG_FILES([tools/llc/Makefile])
539 AC_CONFIG_FILES([tools/llee/Makefile])
540 AC_CONFIG_FILES([tools/lli/Makefile])
541 AC_CONFIG_FILES([tools/llvm-ar/Makefile])
542 AC_CONFIG_FILES([tools/llvm-as/Makefile])
543 AC_CONFIG_FILES([tools/llvm-db/Makefile])
544 AC_CONFIG_FILES([tools/llvm-dis/Makefile])
545 AC_CONFIG_FILES([tools/llvm-link/Makefile])
546 AC_CONFIG_FILES([tools/llvm-nm/Makefile])
547 AC_CONFIG_FILES([tools/llvm-prof/Makefile])
548 AC_CONFIG_FILES([tools/opt/Makefile])
549 AC_CONFIG_FILES([tools/llvm-ld/Makefile])
550 AC_CONFIG_FILES([tools/llvm-stub/Makefile])
551
552 dnl Make a link from lib/System/platform to lib/System/$llvm_platform_type
553 dnl This helps the #inclusion of the system specific include files
554 dnl for the operating system abstraction library
555 AC_CONFIG_LINKS(lib/System/platform:lib/System/$llvm_platform_type)
556
29557 dnl Configure all of the projects present in our source tree.
30558 for i in `ls ${srcdir}/projects`
31559 do
46574 esac
47575 fi
48576 done
49
50 dnl Configure header files
51 AC_CONFIG_HEADERS([include/llvm/Config/config.h])
52
53 dnl Configure other output files
54 AC_CONFIG_FILES([Makefile.config])
55 AC_CONFIG_FILES([Makefile])
56 AC_CONFIG_FILES([lib/Makefile])
57
58 AC_CONFIG_HEADERS([include/llvm/Support/DataTypes.h])
59 AC_CONFIG_HEADERS([include/llvm/ADT/hash_map])
60 AC_CONFIG_HEADERS([include/llvm/ADT/hash_set])
61 AC_CONFIG_HEADERS([include/llvm/Support/ThreadSupport.h])
62 AC_CONFIG_HEADERS([include/llvm/ADT/iterator])
63
64 dnl Do special configuration of Makefiles
65 dnl AC_CONFIG_MAKEFILE(Makefile)
66 dnl AC_CONFIG_MAKEFILE(Makefile.common)
67 dnl AC_CONFIG_MAKEFILE(examples/Makefile)
68 dnl AC_CONFIG_MAKEFILE(lib/Makefile)
69 dnl AC_CONFIG_MAKEFILE(runtime/Makefile)
70 dnl AC_CONFIG_MAKEFILE(test/Makefile)
71 dnl AC_CONFIG_MAKEFILE(test/Makefile.tests)
72 dnl AC_CONFIG_MAKEFILE(test/QMTest/llvm.py)
73 dnl AC_CONFIG_MAKEFILE(test/QMTest/llvmdb.py)
74 dnl AC_CONFIG_MAKEFILE(tools/Makefile)
75 dnl AC_CONFIG_MAKEFILE(utils/Makefile)
76 dnl AC_CONFIG_MAKEFILE(projects/Makefile)
77
78 dnl Find the install program (needs to be done before canonical stuff)
79 AC_PROG_INSTALL
80
81 dnl We will use the build machine information to set some variables.
82
83 AC_MSG_CHECKING([support for generic build operating system])
84 case $build in
85 *-*-aix*)
86 AC_SUBST(OS,[AIX])
87 platform_type="AIX"
88 ;;
89 *-*-cygwin*)
90 AC_SUBST(OS,[Cygwin])
91 platform_type="Cygwin"
92 ;;
93 *-*-darwin*)
94 AC_SUBST(OS,[Darwin])
95 platform_type="Darwin"
96 ;;
97 *-*-freebsd*)
98 AC_SUBST(OS,[Linux])
99 platform_type="FreeBSD"
100 ;;
101 *-*-interix*)
102 AC_SUBST(OS,[SunOS])
103 platform_type="Interix"
104 ;;
105 *-*-linux*)
106 AC_SUBST(OS,[Linux])
107 platform_type="Linux"
108 if test -d /home/vadve/lattner/local/x86/llvm-gcc
109 then
110 AC_SUBST(LLVMGCCDIR,[/home/vadve/lattner/local/x86/llvm-gcc/])
111 fi
112 ;;
113 *-*-solaris*)
114 AC_SUBST(OS,[SunOS])
115 platform_type="SunOS"
116 if test -d /home/vadve/lattner/local/sparc/llvm-gcc
117 then
118 AC_SUBST(LLVMGCCDIR,[/home/vadve/lattner/local/sparc/llvm-gcc/])
119 fi
120 ;;
121 *-*-win32*)
122 AC_SUBST(OS,[Win32])
123 platform_type="Win32"
124 ;;
125 *-*-mingw*)
126 AC_SUBST(OS,[Win32])
127 platform_type="Win32"
128 ;;
129 *)
130 AC_SUBST(OS,[Unknown])
131 platform_type="Unknown"
132 ;;
133 esac
134
135 dnl Make sure we aren't attempting to configure for an unknown system
136 if test "$platform_type" = "Unknown" ; then
137 AC_MSG_ERROR([Platform is unknown, configure can't continue])
138 fi
139
140 dnl Make a link from lib/System/platform to lib/System/$platform_type
141 dnl This helps the #inclusion of the system specific include files
142 dnl for the operating system abstraction library
143 AC_CONFIG_LINKS(lib/System/platform:lib/System/$platform_type)
144
145
146 AC_MSG_CHECKING(target architecture)
147 dnl If we are targetting a Sparc machine running Solaris, pretend that it is
148 dnl V9, since that is all that we support at the moment, and autoconf will only
149 dnl tell us we're a sparc.
150 case $target in
151 sparc*-*-solaris*) AC_SUBST(target,[[sparcv9-sun-solaris2.8]])
152 ;;
153 esac
154
155 dnl Determine what our target architecture is and configure accordingly.
156 dnl This will allow Makefiles to make a distinction between the hardware and
157 dnl the OS.
158 case $target in
159 i*86-*)
160 ARCH="x86"
161 AC_SUBST(ARCH,[x86])
162 ;;
163 sparc*-*)
164 ARCH="Sparc"
165 AC_SUBST(ARCH,[Sparc])
166 ;;
167 powerpc*-*)
168 ARCH="PowerPC"
169 AC_SUBST(ARCH,[PowerPC])
170 ;;
171 *)
172 ARCH="Unknown"
173 AC_SUBST(ARCH,[Unknown])
174 ;;
175 esac
176
177 AC_MSG_RESULT($ARCH)
178
179 dnl Check for compilation tools
180 AC_PROG_CXX
181 AC_PROG_CC(gcc)
182 dnl Ensure that compilation tools are GCC; we use GCC specific extensions
183 if test "$GCC" != "yes"
184 then
185 AC_MSG_ERROR([gcc required but not found])
186 fi
187 AC_PROG_CPP
188 dnl Ensure that compilation tools are GCC; we use GCC specific extensions
189 if test "$GXX" != "yes"
190 then
191 AC_MSG_ERROR([g++ required but not found])
192 fi
193
194 dnl Verify that GCC is version 3.0 or higher
195 gccmajor=`$CC --version | head -n 1 | awk '{print $NF;}' | cut -d. -f1`
196 if test "$gccmajor" -lt "3"
197 then
198 AC_MSG_ERROR([gcc 3.x required, but you have a lower version])
199 fi
200
201 dnl Check for GNU Make. We use its extensions too, so don't build without it
202 AC_CHECK_GNU_MAKE
203 if test -z "$_cv_gnu_make_command"
204 then
205 AC_MSG_ERROR([GNU Make required but not found])
206 fi
207
208 dnl Checks for other tools
209 AC_PROG_FLEX
210 AC_PROG_BISON
211 AC_PROG_LIBTOOL
212
213 dnl Checks for tools we can get away with not having:
214 AC_PATH_PROG(DOT,[dot],[true dot])
215 AC_PATH_PROG(ETAGS,[etags],[true etags])
216 dnl Check if we know how to tell etags we are using C++:
217 etags_version=`$ETAGS --version 2>&1`
218 case "$etags_version" in
219 *[Ee]xuberant*) ETAGSFLAGS="--language-force=c++" ;;
220 *GNU\ Emacs*) ETAGSFLAGS="-l c++" ;;
221 *) ETAGSFLAGS="" ;;
222 esac
223 AC_SUBST(ETAGSFLAGS,$ETAGSFLAGS)
224 AC_PATH_PROG(PYTHON,[python],[true python])
225 if test "$PYTHON" = "false"
226 then
227 AC_MSG_WARN([Python is required for the test suite, but it was not found])
228 fi
229 AC_PATH_PROG(QMTEST,[qmtest],[true qmtest])
230 if test "$QMTEST" = "false"
231 then
232 AC_MSG_WARN([QMTest is required for the test suite, but it was not found])
233 fi
234
235 dnl Verify that the version of python available is high enough for qmtest
236 pyversion=`$PYTHON -V 2>&1 | cut -d\ -f2`
237 pymajor=`echo $pyversion | cut -d. -f1`
238 pyminor=`echo $pyversion | cut -d. -f2`
239
240 if test "$pymajor" -ge "2"
241 then
242 if test "$pymajor" -eq "2"
243 then
244 if test "$pyminor" -lt "2"
245 then
246 AC_MSG_WARN([QMTest requires Python 2.2 or later])
247 fi
248 fi
249 else
250 AC_MSG_WARN([QMTest requires Python 2.2 or later])
251 fi
252
253 dnl Checks for libraries:
254 dnl libelf is for sparc only; we can ignore it if we don't have it
255 AC_CHECK_LIB(elf, elf_begin)
256
257 dnl Check for bzip2 and zlib compression libraries needed for archive reading/writing
258 AC_CHECK_LIB(bz2,BZ2_bzCompressInit,[bzip2_found=1],[bzip2_found=0])
259 AC_CHECK_HEADERS([bzlib.h],[bzlib_h_found=1],[bzlib_h_found=0],[])
260 AC_CHECK_LIB(z,gzopen,[zlib_found=1],[zlib_found=0])
261 AC_CHECK_HEADERS([zlib.h],[zlib_h_found=1],[zlib_h_found=0],[])
262 if test $zlib_found -eq 1 -a $zlib_h_found -eq 1; then
263 AC_DEFINE([HAVE_ZLIB],[1],[Define if zlib library is available on this platform.])
264 AC_SUBST([HAVE_ZLIB],[1])
265 else
266 AC_SUBST([HAVE_ZLIB],[0])
267 fi
268 if test $bzip2_found -eq 1 -a $bzlib_h_found -eq 1 ; then
269 AC_DEFINE([HAVE_BZIP2],[1],[Define if bzip2 library is available on this platform.])
270 AC_SUBST([HAVE_BZIP2],[1])
271 else
272 AC_SUBST([HAVE_BZIP2],[0])
273 fi
274 dnl dlopen() is required for plugin support.
275 AC_SEARCH_LIBS(dlopen,dl,AC_DEFINE([HAVE_DLOPEN],[1],[Define if dlopen() is available on this platform.]),AC_MSG_WARN([dlopen() not found - disabling plugin support]))
276
277 dnl mallinfo is optional; the code can compile (minus features) without it
278 AC_SEARCH_LIBS(mallinfo,malloc,AC_DEFINE([HAVE_MALLINFO],[1],[Define if mallinfo() is available on this platform.]))
279
280 dnl pthread locking functions are optional - but llvm will not be thread-safe
281 dnl without locks.
282 AC_SEARCH_LIBS(pthread_mutex_lock,pthread,AC_DEFINE([HAVE_PTHREAD_MUTEX_LOCK],[1],[Have pthread_mutex_lock]))
283 dnl AC_SUBST(HAVE_PTHREAD_MUTEX_LOCK)
284
285 dnl Checks for header files.
286 dnl We don't check for ancient stuff or things that are guaranteed to be there
287 dnl by the C++ standard. We always use the versions of C headers.
288 AC_HEADER_STDC
289 AC_HEADER_SYS_WAIT
290
291 dnl Checks for POSIX and other various system-specific header files
292 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h malloc.h sys/mman.h sys/resource.h dlfcn.h link.h execinfo.h windows.h)
293
294 dnl Check for things that need to be included in public headers, and so
295 dnl for which we may not have access to a HAVE_* preprocessor #define.
296 dnl (primarily used in DataTypes.h)
297 AC_CHECK_HEADER([sys/types.h])
298 AC_CHECK_HEADER([inttypes.h])
299 AC_CHECK_HEADER([stdint.h])
300
301 dnl Check for types
302 AC_TYPE_PID_T
303 AC_TYPE_SIZE_T
304 AC_CHECK_TYPES([int64_t],,AC_MSG_ERROR([Type int64_t required but not found]))
305 AC_CHECK_TYPES([uint64_t],,
306 AC_CHECK_TYPES([u_int64_t],,
307 AC_MSG_ERROR([Type uint64_t or u_int64_t required but not found])))
308 AC_HEADER_TIME
309 AC_STRUCT_TM
310
311 dnl Check for various C features
312 AC_C_PRINTF_A
313
314 dnl Check for the endianness of the target
315 AC_C_BIGENDIAN(AC_SUBST([ENDIAN],[big]),AC_SUBST([ENDIAN],[little]))
316
317 dnl Check for C++ extensions
318 AC_CXX_HAVE_HASH_MAP
319 AC_CXX_HAVE_HASH_SET
320 AC_CXX_HAVE_STD_ITERATOR
321 AC_CXX_HAVE_BI_ITERATOR
322 AC_CXX_HAVE_FWD_ITERATOR
323
324 AC_FUNC_ISNAN
325 AC_FUNC_ISINF
326
327 dnl Checks for library functions.
328 AC_FUNC_ALLOCA
329 AC_FUNC_MMAP
330 if test "$ac_cv_func_mmap_fixed_mapped" = "no"
331 then
332 AC_MSG_WARN([mmap() required but not found])
333 fi
334 AC_FUNC_MMAP_FILE
335 if test "$ac_cv_func_mmap_file" = "no"
336 then
337 AC_MSG_WARN([mmap() of files required but not found])
338 fi
339 AC_HEADER_MMAP_ANONYMOUS
340 AC_TYPE_SIGNAL
341 AC_CHECK_FUNCS(getcwd gettimeofday strdup strtoq strtoll backtrace isatty mkstemp getrusage)
342 AC_CHECK_FUNC(mprotect,,AC_MSG_ERROR([Function mprotect() required but not found]))
343
344 dnl Determine if the linker supports the -R option.
345 AC_LINK_USE_R
346
347 dnl --enable/--with command-line options:
348 dnl Check whether they want to do an optimized build:
349 AC_ARG_ENABLE(optimized,AS_HELP_STRING(--enable-optimized,Compile with optimizations enabled (default is NO)),,enableval=no)
350 if test ${enableval} = "no"
351 then
352 AC_SUBST(ENABLE_OPTIMIZED,[[]])
353 else
354 AC_SUBST(ENABLE_OPTIMIZED,[[ENABLE_OPTIMIZED=1]])
355 fi
356
357 dnl JIT Option
358 AC_ARG_ENABLE(jit,AS_HELP_STRING(--enable-jit,Enable Just In Time Compiling (default is YES)),,enableval=default)
359 if test ${enableval} = "no"
360 then
361 AC_SUBST(JIT,[[]])
362 else
363 case $target in
364 *i*86*)
365 AC_SUBST(JIT,[[TARGET_HAS_JIT=1]])
366 ;;
367 *sparc*)
368 AC_SUBST(JIT,[[TARGET_HAS_JIT=1]])
369 ;;
370 *)
371 AC_SUBST(JIT,[[]])
372 ;;
373 esac
374 fi
375
376 dnl Find the LLVM GCC-based C/C++ front end
377 AC_ARG_WITH(llvmgccdir,AS_HELP_STRING(--with-llvmgccdir,Location of LLVM GCC front-end),AC_SUBST(LLVMGCCDIR,[$withval]))
378 AC_MSG_CHECKING([for llvm-gcc])
379 LLVM_GCC_CHECK=no
380 if test -d "$LLVMGCCDIR"
381 then
382 if test -x "$LLVMGCCDIR/bin/gcc"
383 then
384 LLVM_GCC_CHECK="$LLVMGCCDIR/bin/gcc"
385 fi
386 fi
387 llvmgccwarn=no
388 AC_MSG_RESULT($LLVM_GCC_CHECK)
389 if test "$LLVM_GCC_CHECK" = "no"
390 then
391 llvmgccwarn=yes
392 fi
393 AC_MSG_CHECKING([whether llvm-gcc is sane])
394 LLVM_GCC_SANE=no
395 if test -x "$LLVM_GCC_CHECK"
396 then
397 cp /dev/null conftest.c
398 "$LLVM_GCC_CHECK" -S -o - conftest.c | grep implementation > /dev/null 2>&1
399 if test $? -eq 0
400 then
401 LLVM_GCC_SANE=yes
402 fi
403 rm conftest.c
404 llvmcc1path=`"$LLVM_GCC_CHECK" --print-prog-name=cc1`
405 AC_SUBST(LLVMCC1,$llvmcc1path)
406 llvmcc1pluspath=`"$LLVM_GCC_CHECK" --print-prog-name=cc1plus`
407 AC_SUBST(LLVMCC1PLUS,$llvmcc1pluspath)
408 fi
409 AC_MSG_RESULT($LLVM_GCC_SANE)
410 if test "$LLVM_GCC_SANE" = "no"
411 then
412 llvmgccwarn=yes
413 fi
414
415 dnl Get libtool's idea of what the shared library suffix is.
416 dnl (This is a hack; it relies on undocumented behavior.)
417 AC_MSG_CHECKING([for shared library suffix])
418 eval "SHLIBEXT=$shrext_cmds"
419 AC_MSG_RESULT($SHLIBEXT)
420 dnl Propagate it to the Makefiles and config.h (for gccld & bugpoint).
421 AC_SUBST(SHLIBEXT,$SHLIBEXT)
422 AC_DEFINE_UNQUOTED(SHLIBEXT,"$SHLIBEXT",
423 [Extension that shared libraries have, e.g., ".so".])
424
425 # Translate the various configuration directories and other basic
426 # information into substitutions that will end up in config.h.in so
427 # that these configured values can be hard-wired into a program.
428 eval LLVM_PREFIX="${prefix}";
429 eval LLVM_BINDIR="${prefix}/bin";
430 eval LLVM_LIBDIR="${prefix}/lib";
431 eval LLVM_DATADIR="${prefix}/data";
432 eval LLVM_DOCSDIR="${prefix}/docs";
433 eval LLVM_ETCDIR="${prefix}/etc";
434 eval LLVM_INCLUDEDIR="${prefix}/include";
435 eval LLVM_INFODIR="${prefix}/info";
436 eval LLVM_MANDIR="${prefix}/man";
437 LLVM_CONFIGTIME=`date`
438 AC_SUBST(LLVM_PREFIX)
439 AC_SUBST(LLVM_BINDIR)
440 AC_SUBST(LLVM_LIBDIR)
441 AC_SUBST(LLVM_DATADIR)
442 AC_SUBST(LLVM_DOCSDIR)
443 AC_SUBST(LLVM_ETCDIR)
444 AC_SUBST(LLVM_INCLUDEDIR)
445 AC_SUBST(LLVM_INFODIR)
446 AC_SUBST(LLVM_MANDIR)
447 AC_SUBST(LLVM_CONFIGTIME)
448 AC_DEFINE_UNQUOTED(LLVM_PREFIX,"$LLVM_PREFIX", [Installation prefix directory])
449 AC_DEFINE_UNQUOTED(LLVM_BINDIR, "$LLVM_BINDIR", [Installation directory for binary executables])
450 AC_DEFINE_UNQUOTED(LLVM_LIBDIR, "$LLVM_LIBDIR", [Installation directory for libraries])
451 AC_DEFINE_UNQUOTED(LLVM_DATADIR, "$LLVM_DATADIR", [Installation directory for data files])
452 AC_DEFINE_UNQUOTED(LLVM_DATADIR, "$LLVM_DOCSDIR", [Installation directory for documentation])
453 AC_DEFINE_UNQUOTED(LLVM_ETCDIR, "$LLVM_ETCDIR", [Installation directory for config files])
454 AC_DEFINE_UNQUOTED(LLVM_INCLUDEDIR, "$LLVM_INCLUDEDIR", [Installation directory for include files])
455 AC_DEFINE_UNQUOTED(LLVM_INFODIR, "$LLVM_INFODIR", [Installation directory for .info files])
456 AC_DEFINE_UNQUOTED(LLVM_MANDIR, "$LLVM_MANDIR", [Installation directory for man pages])
457 AC_DEFINE_UNQUOTED(LLVM_CONFIGTIME, "$LLVM_CONFIGTIME", [Time at which LLVM was configured])
458
459577 dnl Create the output files
460578 AC_OUTPUT
579
580 dnl ===----------------------------------------------------------------------===
581 dnl -- SECTION 11: Output warnings to user (always last so they see it)
582 dnl ===----------------------------------------------------------------------===
461583
462584 dnl Warn if we don't have a compression library
463585 if test $bzip2_found -ne 1 ; then
464586 if test $zlib_found -ne 1 ; then
465587 AC_MSG_WARN([*** Neither zlib nor bzip2 compression libraries were found.])
466588 AC_MSG_WARN([*** Bytecode archives will not support compression!])
467 AC_MSG_WARN([*** To correct, install the libraries and and re-run configure.])
589 AC_MSG_WARN([*** To correct, install the libraries and re-run configure.])
468590 fi
469591 fi
470592
471593 dnl Warn loudly if llvm-gcc was not obviously working
472594 if test $llvmgccwarn = yes
473595 then
474 AC_MSG_WARN([***** llvm C/C++ front end was not found, or does not])
475 AC_MSG_WARN([***** appear to be working.])
476 AC_MSG_WARN([***** ])
477 AC_MSG_WARN([***** Please check configure's --with-llvmgccdir option.])
478 AC_MSG_WARN([***** Runtime libraries (in llvm/runtime) will not be built,])
479 AC_MSG_WARN([***** but you should be able to build the llvm tools.])
480 fi
481
596 AC_MSG_WARN([***** llvm C/C++ front end was not found, or does not])
597 AC_MSG_WARN([***** appear to be working.])
598 AC_MSG_WARN([***** ])
599 AC_MSG_WARN([***** Please check configure's --with-llvmgccdir option.])
600 AC_MSG_WARN([***** Runtime libraries (in llvm/runtime) will not be built,])
601 AC_MSG_WARN([***** but you should be able to build the llvm tools.])
602 fi
0 #! /bin/sh
1 # depcomp - compile a program generating dependencies as side-effects
2
3 scriptversion=2004-05-31.23
4
5 # Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
10 # any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 # 02111-1307, USA.
21
22 # As a special exception to the GNU General Public License, if you
23 # distribute this file as part of a program that contains a
24 # configuration script generated by Autoconf, you may include it under
25 # the same distribution terms that you use for the rest of that program.
26
27 # Originally written by Alexandre Oliva .
28
29 case $1 in
30 '')
31 echo "$0: No command. Try \`$0 --help' for more information." 1>&2
32 exit 1;
33 ;;
34 -h | --h*)
35 cat <<\EOF
36 Usage: depcomp [--help] [--version] PROGRAM [ARGS]
37
38 Run PROGRAMS ARGS to compile a file, generating dependencies
39 as side-effects.
40
41 Environment variables:
42 depmode Dependency tracking mode.
43 source Source file read by `PROGRAMS ARGS'.
44 object Object file output by `PROGRAMS ARGS'.
45 DEPDIR directory where to store dependencies.
46 depfile Dependency file to output.
47 tmpdepfile Temporary file to use when outputing dependencies.
48 libtool Whether libtool is used (yes/no).
49
50 Report bugs to .
51 EOF
52 exit 0
53 ;;
54 -v | --v*)
55 echo "depcomp $scriptversion"
56 exit 0
57 ;;
58 esac
59
60 if test -z "$depmode" || test -z "$source" || test -z "$object"; then
61 echo "depcomp: Variables source, object and depmode must be set" 1>&2
62 exit 1
63 fi
64
65 # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
66 depfile=${depfile-`echo "$object" |
67 sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
68 tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
69
70 rm -f "$tmpdepfile"
71
72 # Some modes work just like other modes, but use different flags. We
73 # parameterize here, but still list the modes in the big case below,
74 # to make depend.m4 easier to write. Note that we *cannot* use a case
75 # here, because this file can only contain one case statement.
76 if test "$depmode" = hp; then
77 # HP compiler uses -M and no extra arg.
78 gccflag=-M
79 depmode=gcc
80 fi
81
82 if test "$depmode" = dashXmstdout; then
83 # This is just like dashmstdout with a different argument.
84 dashmflag=-xM
85 depmode=dashmstdout
86 fi
87
88 case "$depmode" in
89 gcc3)
90 ## gcc 3 implements dependency tracking that does exactly what
91 ## we want. Yay! Note: for some reason libtool 1.4 doesn't like
92 ## it if -MD -MP comes after the -MF stuff. Hmm.
93 "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
94 stat=$?
95 if test $stat -eq 0; then :
96 else
97 rm -f "$tmpdepfile"
98 exit $stat
99 fi
100 mv "$tmpdepfile" "$depfile"
101 ;;
102
103 gcc)
104 ## There are various ways to get dependency output from gcc. Here's
105 ## why we pick this rather obscure method:
106 ## - Don't want to use -MD because we'd like the dependencies to end
107 ## up in a subdir. Having to rename by hand is ugly.
108 ## (We might end up doing this anyway to support other compilers.)
109 ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
110 ## -MM, not -M (despite what the docs say).
111 ## - Using -M directly means running the compiler twice (even worse
112 ## than renaming).
113 if test -z "$gccflag"; then
114 gccflag=-MD,
115 fi
116 "$@" -Wp,"$gccflag$tmpdepfile"
117 stat=$?
118 if test $stat -eq 0; then :
119 else
120 rm -f "$tmpdepfile"
121 exit $stat
122 fi
123 rm -f "$depfile"
124 echo "$object : \\" > "$depfile"
125 alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
126 ## The second -e expression handles DOS-style file names with drive letters.
127 sed -e 's/^[^:]*: / /' \
128 -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
129 ## This next piece of magic avoids the `deleted header file' problem.
130 ## The problem is that when a header file which appears in a .P file
131 ## is deleted, the dependency causes make to die (because there is
132 ## typically no way to rebuild the header). We avoid this by adding
133 ## dummy dependencies for each header file. Too bad gcc doesn't do
134 ## this for us directly.
135 tr ' ' '
136 ' < "$tmpdepfile" |
137 ## Some versions of gcc put a space before the `:'. On the theory
138 ## that the space means something, we add a space to the output as
139 ## well.
140 ## Some versions of the HPUX 10.20 sed can't process this invocation
141 ## correctly. Breaking it into two sed invocations is a workaround.
142 sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
143 rm -f "$tmpdepfile"
144 ;;
145
146 hp)
147 # This case exists only to let depend.m4 do its work. It works by
148 # looking at the text of this script. This case will never be run,
149 # since it is checked for above.
150 exit 1
151 ;;
152
153 sgi)
154 if test "$libtool" = yes; then
155 "$@" "-Wp,-MDupdate,$tmpdepfile"
156 else
157 "$@" -MDupdate "$tmpdepfile"
158 fi
159 stat=$?
160 if test $stat -eq 0; then :
161 else
162 rm -f "$tmpdepfile"
163 exit $stat
164 fi
165 rm -f "$depfile"
166
167 if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
168 echo "$object : \\" > "$depfile"
169
170 # Clip off the initial element (the dependent). Don't try to be
171 # clever and replace this with sed code, as IRIX sed won't handle
172 # lines with more than a fixed number of characters (4096 in
173 # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
174 # the IRIX cc adds comments like `#:fec' to the end of the
175 # dependency line.
176 tr ' ' '
177 ' < "$tmpdepfile" \
178 | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
179 tr '
180 ' ' ' >> $depfile
181 echo >> $depfile
182
183 # The second pass generates a dummy entry for each header file.
184 tr ' ' '
185 ' < "$tmpdepfile" \
186 | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
187 >> $depfile
188 else
189 # The sourcefile does not contain any dependencies, so just
190 # store a dummy comment line, to avoid errors with the Makefile
191 # "include basename.Plo" scheme.
192 echo "#dummy" > "$depfile"
193 fi
194 rm -f "$tmpdepfile"
195 ;;
196
197 aix)
198 # The C for AIX Compiler uses -M and outputs the dependencies
199 # in a .u file. In older versions, this file always lives in the
200 # current directory. Also, the AIX compiler puts `$object:' at the
201 # start of each line; $object doesn't have directory information.
202 # Version 6 uses the directory in both cases.
203 stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
204 tmpdepfile="$stripped.u"
205 if test "$libtool" = yes; then
206 "$@" -Wc,-M
207 else
208 "$@" -M
209 fi
210 stat=$?
211
212 if test -f "$tmpdepfile"; then :
213 else
214 stripped=`echo "$stripped" | sed 's,^.*/,,'`
215 tmpdepfile="$stripped.u"
216 fi
217
218 if test $stat -eq 0; then :
219 else
220 rm -f "$tmpdepfile"
221 exit $stat
222 fi
223
224 if test -f "$tmpdepfile"; then
225 outname="$stripped.o"
226 # Each line is of the form `foo.o: dependent.h'.
227 # Do two passes, one to just change these to
228 # `$object: dependent.h' and one to simply `dependent.h:'.
229 sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
230 sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
231 else
232 # The sourcefile does not contain any dependencies, so just
233 # store a dummy comment line, to avoid errors with the Makefile
234 # "include basename.Plo" scheme.
235 echo "#dummy" > "$depfile"
236 fi
237 rm -f "$tmpdepfile"
238 ;;
239
240 icc)
241 # Intel's C compiler understands `-MD -MF file'. However on
242 # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
243 # ICC 7.0 will fill foo.d with something like
244 # foo.o: sub/foo.c
245 # foo.o: sub/foo.h
246 # which is wrong. We want:
247 # sub/foo.o: sub/foo.c
248 # sub/foo.o: sub/foo.h
249 # sub/foo.c:
250 # sub/foo.h:
251 # ICC 7.1 will output
252 # foo.o: sub/foo.c sub/foo.h
253 # and will wrap long lines using \ :
254 # foo.o: sub/foo.c ... \
255 # sub/foo.h ... \
256 # ...
257
258 "$@" -MD -MF "$tmpdepfile"
259 stat=$?
260 if test $stat -eq 0; then :
261 else
262 rm -f "$tmpdepfile"
263 exit $stat
264 fi
265 rm -f "$depfile"
266 # Each line is of the form `foo.o: dependent.h',
267 # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
268 # Do two passes, one to just change these to
269 # `$object: dependent.h' and one to simply `dependent.h:'.
270 sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
271 # Some versions of the HPUX 10.20 sed can't process this invocation
272 # correctly. Breaking it into two sed invocations is a workaround.
273 sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
274 sed -e 's/$/ :/' >> "$depfile"
275 rm -f "$tmpdepfile"
276 ;;
277
278 tru64)
279 # The Tru64 compiler uses -MD to generate dependencies as a side
280 # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
281 # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
282 # dependencies in `foo.d' instead, so we check for that too.
283 # Subdirectories are respected.
284 dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
285 test "x$dir" = "x$object" && dir=
286 base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
287
288 if test "$libtool" = yes; then
289 # Dependencies are output in .lo.d with libtool 1.4.
290 # With libtool 1.5 they are output both in $dir.libs/$base.o.d
291 # and in $dir.libs/$base.o.d and $dir$base.o.d. We process the
292 # latter, because the former will be cleaned when $dir.libs is
293 # erased.
294 tmpdepfile1="$dir.libs/$base.lo.d"
295 tmpdepfile2="$dir$base.o.d"
296 tmpdepfile3="$dir.libs/$base.d"
297 "$@" -Wc,-MD
298 else
299 tmpdepfile1="$dir$base.o.d"
300 tmpdepfile2="$dir$base.d"
301 tmpdepfile3="$dir$base.d"
302 "$@" -MD
303 fi
304
305 stat=$?
306 if test $stat -eq 0; then :
307 else
308 rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
309 exit $stat
310 fi
311
312 if test -f "$tmpdepfile1"; then
313 tmpdepfile="$tmpdepfile1"
314 elif test -f "$tmpdepfile2"; then
315 tmpdepfile="$tmpdepfile2"
316 else
317 tmpdepfile="$tmpdepfile3"
318 fi
319 if test -f "$tmpdepfile"; then
320 sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
321 # That's a tab and a space in the [].
322 sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
323 else
324 echo "#dummy" > "$depfile"
325 fi
326 rm -f "$tmpdepfile"
327 ;;
328
329 #nosideeffect)
330 # This comment above is used by automake to tell side-effect
331 # dependency tracking mechanisms from slower ones.
332
333 dashmstdout)
334 # Important note: in order to support this mode, a compiler *must*
335 # always write the preprocessed file to stdout, regardless of -o.
336 "$@" || exit $?
337
338 # Remove the call to Libtool.
339 if test "$libtool" = yes; then
340 while test $1 != '--mode=compile'; do
341 shift
342 done
343 shift
344 fi
345
346 # Remove `-o $object'.
347 IFS=" "
348 for arg
349 do
350 case $arg in
351 -o)
352 shift
353 ;;
354 $object)
355 shift
356 ;;
357 *)
358 set fnord "$@" "$arg"
359 shift # fnord
360 shift # $arg
361 ;;
362 esac
363 done
364
365 test -z "$dashmflag" && dashmflag=-M
366 # Require at least two characters before searching for `:'
367 # in the target name. This is to cope with DOS-style filenames:
368 # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
369 "$@" $dashmflag |
370 sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
371 rm -f "$depfile"
372 cat < "$tmpdepfile" > "$depfile"
373 tr ' ' '
374 ' < "$tmpdepfile" | \
375 ## Some versions of the HPUX 10.20 sed can't process this invocation
376 ## correctly. Breaking it into two sed invocations is a workaround.
377 sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
378 rm -f "$tmpdepfile"
379 ;;
380
381 dashXmstdout)
382 # This case only exists to satisfy depend.m4. It is never actually
383 # run, as this mode is specially recognized in the preamble.
384 exit 1
385 ;;
386
387 makedepend)
388 "$@" || exit $?
389 # Remove any Libtool call
390 if test "$libtool" = yes; then
391 while test $1 != '--mode=compile'; do
392 shift
393 done
394 shift
395 fi
396 # X makedepend
397 shift
398 cleared=no
399 for arg in "$@"; do
400 case $cleared in
401 no)
402 set ""; shift
403 cleared=yes ;;
404 esac
405 case "$arg" in
406 -D*|-I*)
407 set fnord "$@" "$arg"; shift ;;
408 # Strip any option that makedepend may not understand. Remove
409 # the object too, otherwise makedepend will parse it as a source file.
410 -*|$object)
411 ;;
412 *)
413 set fnord "$@" "$arg"; shift ;;
414 esac
415 done
416 obj_suffix="`echo $object | sed 's/^.*\././'`"
417 touch "$tmpdepfile"
418 ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
419 rm -f "$depfile"
420 cat < "$tmpdepfile" > "$depfile"
421 sed '1,2d' "$tmpdepfile" | tr ' ' '
422 ' | \
423 ## Some versions of the HPUX 10.20 sed can't process this invocation
424 ## correctly. Breaking it into two sed invocations is a workaround.
425 sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
426 rm -f "$tmpdepfile" "$tmpdepfile".bak
427 ;;
428
429 cpp)
430 # Important note: in order to support this mode, a compiler *must*
431 # always write the preprocessed file to stdout.
432 "$@" || exit $?
433
434 # Remove the call to Libtool.
435 if test "$libtool" = yes; then
436 while test $1 != '--mode=compile'; do
437 shift
438 done
439 shift
440 fi
441
442 # Remove `-o $object'.
443 IFS=" "
444 for arg
445 do
446 case $arg in
447 -o)
448 shift
449 ;;
450 $object)
451 shift
452 ;;
453 *)
454 set fnord "$@" "$arg"
455 shift # fnord
456 shift # $arg
457 ;;
458 esac
459 done
460
461 "$@" -E |
462 sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
463 sed '$ s: \\$::' > "$tmpdepfile"
464 rm -f "$depfile"
465 echo "$object : \\" > "$depfile"
466 cat < "$tmpdepfile" >> "$depfile"
467 sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
468 rm -f "$tmpdepfile"
469 ;;
470
471 msvisualcpp)
472 # Important note: in order to support this mode, a compiler *must*
473 # always write the preprocessed file to stdout, regardless of -o,
474 # because we must use -o when running libtool.
475 "$@" || exit $?
476 IFS=" "
477 for arg
478 do
479 case "$arg" in
480 "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
481 set fnord "$@"
482 shift
483 shift
484 ;;
485 *)
486 set fnord "$@" "$arg"
487 shift
488 shift
489 ;;
490 esac
491 done
492 "$@" -E |
493 sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
494 rm -f "$depfile"
495 echo "$object : \\" > "$depfile"
496 . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
497 echo " " >> "$depfile"
498 . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
499 rm -f "$tmpdepfile"
500 ;;
501
502 none)
503 exec "$@"
504 ;;
505
506 *)
507 echo "Unknown depmode $depmode" 1>&2
508 exit 1
509 ;;
510 esac
511
512 exit 0
513
514 # Local Variables:
515 # mode: shell-script
516 # sh-indentation: 2
517 # eval: (add-hook 'write-file-hooks 'time-stamp)
518 # time-stamp-start: "scriptversion="
519 # time-stamp-format: "%:y-%02m-%02d.%02H"
520 # time-stamp-end: "$"
521 # End:
0 #!/bin/sh
1 #
21 # install - install a program, script, or datafile
3 # This comes from X11R5 (mit/util/scripts/install.sh).
4 #
5 # Copyright 1991 by the Massachusetts Institute of Technology
6 #
7 # Permission to use, copy, modify, distribute, and sell this software and its
8 # documentation for any purpose is hereby granted without fee, provided that
9 # the above copyright notice appear in all copies and that both that
10 # copyright notice and this permission notice appear in supporting
11 # documentation, and that the name of M.I.T. not be used in advertising or
12 # publicity pertaining to distribution of the software without specific,
13 # written prior permission. M.I.T. makes no representations about the
14 # suitability of this software for any purpose. It is provided "as is"
15 # without express or implied warranty.
2
3 scriptversion=2004-09-10.20
4
5 # This originates from X11R5 (mit/util/scripts/install.sh), which was
6 # later released in X11R6 (xc/config/util/install.sh) with the
7 # following copyright and license.
8 #
9 # Copyright (C) 1994 X Consortium
10 #
11 # Permission is hereby granted, free of charge, to any person obtaining a copy
12 # of this software and associated documentation files (the "Software"), to
13 # deal in the Software without restriction, including without limitation the
14 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
15 # sell copies of the Software, and to permit persons to whom the Software is
16 # furnished to do so, subject to the following conditions:
17 #
18 # The above copyright notice and this permission notice shall be included in
19 # all copies or substantial portions of the Software.
20 #
21 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
25 # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
26 # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 #
28 # Except as contained in this notice, the name of the X Consortium shall not
29 # be used in advertising or otherwise to promote the sale, use or other deal-
30 # ings in this Software without prior written authorization from the X Consor-
31 # tium.
32 #
33 #
34 # FSF changes to this file are in the public domain.
1635 #
1736 # Calling this script install-sh is preferred over install.sh, to prevent
1837 # `make' implicit rules from creating a file called install from it
2241 # from scratch. It can only install one file at a time, a restriction
2342 # shared with many OS's install programs.
2443
25
2644 # set DOITPROG to echo to test this script
2745
2846 # Don't use :- since 4.3BSD and earlier shells don't like it.
2947 doit="${DOITPROG-}"
30
3148
3249 # put in absolute paths if you don't have them in your path; or use env. vars.
3350
4057 rmprog="${RMPROG-rm}"
4158 mkdirprog="${MKDIRPROG-mkdir}"
4259
43 transformbasename=""
44 transform_arg=""
45 instcmd="$mvprog"
4660 chmodcmd="$chmodprog 0755"
47 chowncmd=""
48 chgrpcmd=""
49 stripcmd=""
61 chowncmd=
62 chgrpcmd=
63 stripcmd=
5064 rmcmd="$rmprog -f"
5165 mvcmd="$mvprog"
52 src=""
53 dst=""
54 dir_arg=""
55
56 while [ x"$1" != x ]; do
57 case $1 in
58 -c) instcmd="$cpprog"
59 shift
60 continue;;
61
62 -d) dir_arg=true
63 shift
64 continue;;
65
66 -m) chmodcmd="$chmodprog $2"
67 shift
68 shift
69 continue;;
70
71 -o) chowncmd="$chownprog $2"
72 shift
73 shift
74 continue;;
75
76 -g) chgrpcmd="$chgrpprog $2"
77 shift
78 shift
79 continue;;
80
81 -s) stripcmd="$stripprog"
82 shift
83 continue;;
84
85 -t=*) transformarg=`echo $1 | sed 's/-t=//'`
86 shift
87 continue;;
88
89 -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
90 shift
91 continue;;
92
93 *) if [ x"$src" = x ]
94 then
95 src=$1
96 else
97 # this colon is to work around a 386BSD /bin/sh bug
98 :
99 dst=$1
100 fi
101 shift
102 continue;;
66 src=
67 dst=
68 dir_arg=
69 dstarg=
70 no_target_directory=
71
72 usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
73 or: $0 [OPTION]... SRCFILES... DIRECTORY
74 or: $0 [OPTION]... -t DIRECTORY SRCFILES...
75 or: $0 [OPTION]... -d DIRECTORIES...
76
77 In the 1st form, copy SRCFILE to DSTFILE.
78 In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
79 In the 4th, create DIRECTORIES.
80
81 Options:
82 -c (ignored)
83 -d create directories instead of installing files.
84 -g GROUP $chgrpprog installed files to GROUP.
85 -m MODE $chmodprog installed files to MODE.
86 -o USER $chownprog installed files to USER.
87 -s $stripprog installed files.
88 -t DIRECTORY install into DIRECTORY.
89 -T report an error if DSTFILE is a directory.
90 --help display this help and exit.
91 --version display version info and exit.
92
93 Environment variables override the default commands:
94 CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
95 "
96
97 while test -n "$1"; do
98 case $1 in
99 -c) shift
100 continue;;
101
102 -d) dir_arg=true
103 shift
104 continue;;
105
106 -g) chgrpcmd="$chgrpprog $2"
107 shift
108 shift
109 continue;;
110
111 --help) echo "$usage"; exit 0;;
112
113 -m) chmodcmd="$chmodprog $2"
114 shift
115 shift
116 continue;;
117
118 -o) chowncmd="$chownprog $2"
119 shift
120 shift
121 continue;;
122
123 -s) stripcmd=$stripprog
124 shift
125 continue;;
126
127 -t) dstarg=$2
128 shift
129 shift
130 continue;;
131
132 -T) no_target_directory=true
133 shift
134 continue;;
135
136 --version) echo "$0 $scriptversion"; exit 0;;
137
138 *) # When -d is used, all remaining arguments are directories to create.
139 # When -t is used, the destination is already specified.
140 test -n "$dir_arg$dstarg" && break
141 # Otherwise, the last argument is the destination. Remove it from $@.
142 for arg
143 do
144 if test -n "$dstarg"; then
145 # $@ is not empty: it contains at least $arg.
146 set fnord "$@" "$dstarg"
147 shift # fnord
148 fi
149 shift # arg
150 dstarg=$arg
151 done
152 break;;
153 esac
154 done
155
156 if test -z "$1"; then
157 if test -z "$dir_arg"; then
158 echo "$0: no input file specified." >&2
159 exit 1
160 fi
161 # It's OK to call `install-sh -d' without argument.
162 # This can happen when creating conditional directories.
163 exit 0
164 fi
165
166 for src
167 do
168 # Protect names starting with `-'.
169 case $src in
170 -*) src=./$src ;;
171 esac
172
173 if test -n "$dir_arg"; then
174 dst=$src
175 src=
176
177 if test -d "$dst"; then
178 mkdircmd=:
179 chmodcmd=
180 else
181 mkdircmd=$mkdirprog
182 fi
183 else
184 # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
185 # might cause directories to be created, which would be especially bad
186 # if $src (and thus $dsttmp) contains '*'.
187 if test ! -f "$src" && test ! -d "$src"; then
188 echo "$0: $src does not exist." >&2
189 exit 1
190 fi
191
192 if test -z "$dstarg"; then
193 echo "$0: no destination specified." >&2
194 exit 1
195 fi
196
197 dst=$dstarg
198 # Protect names starting with `-'.
199 case $dst in
200 -*) dst=./$dst ;;
103201 esac
202
203 # If destination is a directory, append the input filename; won't work
204 # if double slashes aren't ignored.
205 if test -d "$dst"; then
206 if test -n "$no_target_directory"; then
207 echo "$0: $dstarg: Is a directory" >&2
208 exit 1
209 fi
210 dst=$dst/`basename "$src"`
211 fi
212 fi
213
214 # This sed command emulates the dirname command.
215 dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
216
217 # Make sure that the destination directory exists.
218
219 # Skip lots of stat calls in the usual case.
220 if test ! -d "$dstdir"; then
221 defaultIFS='
222 '
223 IFS="${IFS-$defaultIFS}"
224
225 oIFS=$IFS
226 # Some sh's can't handle IFS=/ for some reason.
227 IFS='%'
228 set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
229 IFS=$oIFS
230
231 pathcomp=
232
233 while test $# -ne 0 ; do
234 pathcomp=$pathcomp$1
235 shift
236 if test ! -d "$pathcomp"; then
237 $mkdirprog "$pathcomp"
238 # mkdir can fail with a `File exist' error in case several
239 # install-sh are creating the directory concurrently. This
240 # is OK.
241 test -d "$pathcomp" || exit
242 fi
243 pathcomp=$pathcomp/
244 done
245 fi
246
247 if test -n "$dir_arg"; then
248 $doit $mkdircmd "$dst" \
249 && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
250 && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
251 && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
252 && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
253
254 else
255 dstfile=`basename "$dst"`
256
257 # Make a couple of temp file names in the proper directory.
258 dsttmp=$dstdir/_inst.$$_
259 rmtmp=$dstdir/_rm.$$_
260
261 # Trap to clean up those temp files at exit.
262 trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
263 trap '(exit $?); exit' 1 2 13 15
264
265 # Copy the file name to the temp name.
266 $doit $cpprog "$src" "$dsttmp" &&
267
268 # and set any options; do chmod last to preserve setuid bits.
269 #
270 # If any of these fail, we abort the whole thing. If we want to
271 # ignore errors from any of these, just make sure not to ignore
272 # errors from the above "$doit $cpprog $src $dsttmp" command.
273 #
274 { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
275 && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
276 && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
277 && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
278
279 # Now rename the file to the real destination.
280 { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
281 || {
282 # The rename failed, perhaps because mv can't rename something else
283 # to itself, or perhaps because mv is so ancient that it does not
284 # support -f.
285
286 # Now remove or move aside any old file at destination location.
287 # We try this two ways since rm can't unlink itself on some
288 # systems and the destination file might be busy for other
289 # reasons. In this case, the final cleanup might fail but the new
290 # file should still install successfully.
291 {
292 if test -f "$dstdir/$dstfile"; then
293 $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
294 || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
295 || {
296 echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
297 (exit 1); exit
298 }
299 else
300 :
301 fi
302 } &&
303
304 # Now rename the file to the real destination.
305 $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
306 }
307 }
308 fi || { (exit 1); exit; }
104309 done
105310
106 if [ x"$src" = x ]
107 then
108 echo "install: no input file specified"
109 exit 1
110 else
111 :
112 fi
113
114 if [ x"$dir_arg" != x ]; then
115 dst=$src
116 src=""
117
118 if [ -d $dst ]; then
119 instcmd=:
120 chmodcmd=""
121 else
122 instcmd=$mkdirprog
123 fi
124 else
125
126 # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
127 # might cause directories to be created, which would be especially bad
128 # if $src (and thus $dsttmp) contains '*'.
129
130 if [ -f $src -o -d $src ]
131 then
132 :
133 else
134 echo "install: $src does not exist"
135 exit 1
136 fi
137
138 if [ x"$dst" = x ]
139 then
140 echo "install: no destination specified"
141 exit 1
142 else
143 :
144 fi
145
146 # If destination is a directory, append the input filename; if your system
147 # does not like double slashes in filenames, you may need to add some logic
148
149 if [ -d $dst ]
150 then
151 dst="$dst"/`basename $src`
152 else
153 :
154 fi
155 fi
156
157 ## this sed command emulates the dirname command
158 dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
159
160 # Make sure that the destination directory exists.
161 # this part is taken from Noah Friedman's mkinstalldirs script
162
163 # Skip lots of stat calls in the usual case.
164 if [ ! -d "$dstdir" ]; then
165 defaultIFS='
166 '
167 IFS="${IFS-${defaultIFS}}"
168
169 oIFS="${IFS}"
170 # Some sh's can't handle IFS=/ for some reason.
171 IFS='%'
172 set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
173 IFS="${oIFS}"
174
175 pathcomp=''
176
177 while [ $# -ne 0 ] ; do
178 pathcomp="${pathcomp}${1}"
179 shift
180
181 if [ ! -d "${pathcomp}" ] ;
182 then
183 $mkdirprog "${pathcomp}"
184 else
185 :
186 fi
187
188 pathcomp="${pathcomp}/"
189 done
190 fi
191
192 if [ x"$dir_arg" != x ]
193 then
194 $doit $instcmd $dst &&
195
196 if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi &&
197 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi &&
198 if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi &&
199 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi
200 else
201
202 # If we're going to rename the final executable, determine the name now.
203
204 if [ x"$transformarg" = x ]
205 then
206 dstfile=`basename $dst`
207 else
208 dstfile=`basename $dst $transformbasename |
209 sed $transformarg`$transformbasename
210 fi
211
212 # don't allow the sed command to completely eliminate the filename
213
214 if [ x"$dstfile" = x ]
215 then
216 dstfile=`basename $dst`
217 else
218 :
219 fi
220
221 # Make a temp file name in the proper directory.
222
223 dsttmp=$dstdir/#inst.$$#
224
225 # Move or copy the file name to the temp name
226
227 $doit $instcmd $src $dsttmp &&
228
229 trap "rm -f ${dsttmp}" 0 &&
230
231 # and set any options; do chmod last to preserve setuid bits
232
233 # If any of these fail, we abort the whole thing. If we want to
234 # ignore errors from any of these, just make sure not to ignore
235 # errors from the above "$doit $instcmd $src $dsttmp" command.
236
237 if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi &&
238 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi &&
239 if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi &&
240 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi &&
241
242 # Now rename the file to the real destination.
243
244 $doit $rmcmd -f $dstdir/$dstfile &&
245 $doit $mvcmd $dsttmp $dstdir/$dstfile
246
247 fi &&
248
249
250 exit 0
311 # The final little trick to "correctly" pass the exit status to the exit trap.
312 {
313 (exit 0); exit
314 }
315
316 # Local variables:
317 # eval: (add-hook 'write-file-hooks 'time-stamp)
318 # time-stamp-start: "scriptversion="
319 # time-stamp-format: "%:y-%02m-%02d.%02H"
320 # time-stamp-end: "$"
321 # End:
0 #! /bin/sh
1 # Common stub for a few missing GNU programs while installing.
2
3 scriptversion=2004-09-07.08
4
5 # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004
6 # Free Software Foundation, Inc.
7 # Originally by Fran,cois Pinard , 1996.
8
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2, or (at your option)
12 # any later version.
13
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22 # 02111-1307, USA.
23
24 # As a special exception to the GNU General Public License, if you
25 # distribute this file as part of a program that contains a
26 # configuration script generated by Autoconf, you may include it under
27 # the same distribution terms that you use for the rest of that program.
28
29 if test $# -eq 0; then
30 echo 1>&2 "Try \`$0 --help' for more information"
31 exit 1
32 fi
33
34 run=:
35
36 # In the cases where this matters, `missing' is being run in the
37 # srcdir already.
38 if test -f configure.ac; then
39 configure_ac=configure.ac
40 else
41 configure_ac=configure.in
42 fi
43
44 msg="missing on your system"
45
46 case "$1" in
47 --run)
48 # Try to run requested program, and just exit if it succeeds.
49 run=
50 shift
51 "$@" && exit 0
52 # Exit code 63 means version mismatch. This often happens
53 # when the user try to use an ancient version of a tool on
54 # a file that requires a minimum version. In this case we
55 # we should proceed has if the program had been absent, or
56 # if --run hadn't been passed.
57 if test $? = 63; then
58 run=:
59 msg="probably too old"
60 fi
61 ;;
62
63 -h|--h|--he|--hel|--help)
64 echo "\
65 $0 [OPTION]... PROGRAM [ARGUMENT]...
66
67 Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
68 error status if there is no known handling for PROGRAM.
69
70 Options:
71 -h, --help display this help and exit
72 -v, --version output version information and exit
73 --run try to run the given command, and emulate it if it fails
74
75 Supported PROGRAM values:
76 aclocal touch file \`aclocal.m4'
77 autoconf touch file \`configure'
78 autoheader touch file \`config.h.in'
79 automake touch all \`Makefile.in' files
80 bison create \`y.tab.[ch]', if possible, from existing .[ch]
81 flex create \`lex.yy.c', if possible, from existing .c
82 help2man touch the output file
83 lex create \`lex.yy.c', if possible, from existing .c
84 makeinfo touch the output file
85 tar try tar, gnutar, gtar, then tar without non-portable flags
86 yacc create \`y.tab.[ch]', if possible, from existing .[ch]
87
88 Send bug reports to ."
89 exit 0
90 ;;
91
92 -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
93 echo "missing $scriptversion (GNU Automake)"
94 exit 0
95 ;;
96
97 -*)
98 echo 1>&2 "$0: Unknown \`$1' option"
99 echo 1>&2 "Try \`$0 --help' for more information"
100 exit 1
101 ;;
102
103 esac
104
105 # Now exit if we have it, but it failed. Also exit now if we
106 # don't have it and --version was passed (most likely to detect
107 # the program).
108 case "$1" in
109 lex|yacc)
110 # Not GNU programs, they don't have --version.
111 ;;
112
113 tar)
114 if test -n "$run"; then
115 echo 1>&2 "ERROR: \`tar' requires --run"
116 exit 1
117 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
118 exit 1
119 fi
120 ;;
121
122 *)
123 if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
124 # We have it, but it failed.
125 exit 1
126 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
127 # Could not run --version or --help. This is probably someone
128 # running `$TOOL --version' or `$TOOL --help' to check whether
129 # $TOOL exists and not knowing $TOOL uses missing.
130 exit 1
131 fi
132 ;;
133 esac
134
135 # If it does not exist, or fails to run (possibly an outdated version),
136 # try to emulate it.
137 case "$1" in
138 aclocal*)
139 echo 1>&2 "\
140 WARNING: \`$1' is $msg. You should only need it if
141 you modified \`acinclude.m4' or \`${configure_ac}'. You might want
142 to install the \`Automake' and \`Perl' packages. Grab them from
143 any GNU archive site."
144 touch aclocal.m4
145 ;;
146
147 autoconf)
148 echo 1>&2 "\
149 WARNING: \`$1' is $msg. You should only need it if
150 you modified \`${configure_ac}'. You might want to install the
151 \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
152 archive site."
153 touch configure
154 ;;
155
156 autoheader)
157 echo 1>&2 "\
158 WARNING: \`$1' is $msg. You should only need it if
159 you modified \`acconfig.h' or \`${configure_ac}'. You might want
160 to install the \`Autoconf' and \`GNU m4' packages. Grab them
161 from any GNU archive site."
162 files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
163 test -z "$files" && files="config.h"
164 touch_files=
165 for f in $files; do
166 case "$f" in
167 *:*) touch_files="$touch_files "`echo "$f" |
168 sed -e 's/^[^:]*://' -e 's/:.*//'`;;
169 *) touch_files="$touch_files $f.in";;
170 esac
171 done
172 touch $touch_files
173 ;;
174
175 automake*)
176 echo 1>&2 "\
177 WARNING: \`$1' is $msg. You should only need it if
178 you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
179 You might want to install the \`Automake' and \`Perl' packages.
180 Grab them from any GNU archive site."
181 find . -type f -name Makefile.am -print |
182 sed 's/\.am$/.in/' |
183 while read f; do touch "$f"; done
184 ;;
185
186 autom4te)
187 echo 1>&2 "\
188 WARNING: \`$1' is needed, but is $msg.
189 You might have modified some files without having the
190 proper tools for further handling them.
191 You can get \`$1' as part of \`Autoconf' from any GNU
192 archive site."
193
194 file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
195 test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
196 if test -f "$file"; then
197 touch $file
198 else
199 test -z "$file" || exec >$file
200 echo "#! /bin/sh"
201 echo "# Created by GNU Automake missing as a replacement of"
202 echo "# $ $@"
203 echo "exit 0"
204 chmod +x $file
205 exit 1
206 fi
207 ;;
208
209 bison|yacc)
210 echo 1>&2 "\
211 WARNING: \`$1' $msg. You should only need it if
212 you modified a \`.y' file. You may need the \`Bison' package
213 in order for those modifications to take effect. You can get
214 \`Bison' from any GNU archive site."
215 rm -f y.tab.c y.tab.h
216 if [ $# -ne 1 ]; then
217 eval LASTARG="\${$#}"
218 case "$LASTARG" in
219 *.y)
220 SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
221 if [ -f "$SRCFILE" ]; then
222 cp "$SRCFILE" y.tab.c
223 fi
224 SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
225 if [ -f "$SRCFILE" ]; then
226 cp "$SRCFILE" y.tab.h
227 fi
228 ;;
229 esac
230 fi
231 if [ ! -f y.tab.h ]; then
232 echo >y.tab.h
233 fi
234 if [ ! -f y.tab.c ]; then
235 echo 'main() { return 0; }' >y.tab.c
236 fi
237 ;;
238
239 lex|flex)
240 echo 1>&2 "\
241 WARNING: \`$1' is $msg. You should only need it if
242 you modified a \`.l' file. You may need the \`Flex' package
243 in order for those modifications to take effect. You can get
244 \`Flex' from any GNU archive site."
245 rm -f lex.yy.c
246 if [ $# -ne 1 ]; then
247 eval LASTARG="\${$#}"
248 case "$LASTARG" in
249 *.l)
250 SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
251 if [ -f "$SRCFILE" ]; then
252 cp "$SRCFILE" lex.yy.c
253 fi
254 ;;
255 esac
256 fi
257 if [ ! -f lex.yy.c ]; then
258 echo 'main() { return 0; }' >lex.yy.c
259 fi
260 ;;
261
262 help2man)
263 echo 1>&2 "\
264 WARNING: \`$1' is $msg. You should only need it if
265 you modified a dependency of a manual page. You may need the
266 \`Help2man' package in order for those modifications to take
267 effect. You can get \`Help2man' from any GNU archive site."
268
269 file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
270 if test -z "$file"; then
271 file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
272 fi
273 if [ -f "$file" ]; then
274 touch $file
275 else
276 test -z "$file" || exec >$file
277 echo ".ab help2man is required to generate this page"
278 exit 1
279 fi
280 ;;
281
282 makeinfo)
283 echo 1>&2 "\
284 WARNING: \`$1' is $msg. You should only need it if
285 you modified a \`.texi' or \`.texinfo' file, or any other file
286 indirectly affecting the aspect of the manual. The spurious
287 call might also be the consequence of using a buggy \`make' (AIX,
288 DU, IRIX). You might want to install the \`Texinfo' package or
289 the \`GNU make' package. Grab either from any GNU archive site."
290 file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
291 if test -z "$file"; then
292 file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
293 file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
294 fi
295 touch $file
296 ;;
297
298 tar)
299 shift
300
301 # We have already tried tar in the generic part.
302 # Look for gnutar/gtar before invocation to avoid ugly error
303 # messages.
304 if (gnutar --version > /dev/null 2>&1); then
305 gnutar "$@" && exit 0
306 fi
307 if (gtar --version > /dev/null 2>&1); then
308 gtar "$@" && exit 0
309 fi
310 firstarg="$1"
311 if shift; then
312 case "$firstarg" in
313 *o*)
314 firstarg=`echo "$firstarg" | sed s/o//`
315 tar "$firstarg" "$@" && exit 0
316 ;;
317 esac
318 case "$firstarg" in
319 *h*)
320 firstarg=`echo "$firstarg" | sed s/h//`
321 tar "$firstarg" "$@" && exit 0
322 ;;
323 esac
324 fi
325
326 echo 1>&2 "\
327 WARNING: I can't seem to be able to run \`tar' with the given arguments.
328 You may want to install GNU tar or Free paxutils, or check the
329 command line arguments."
330 exit 1
331 ;;
332
333 *)
334 echo 1>&2 "\
335 WARNING: \`$1' is needed, and is $msg.
336 You might have modified some files without having the
337 proper tools for further handling them. Check the \`README' file,
338 it often tells you about the needed prerequisites for installing
339 this package. You may also peek at any GNU archive site, in case
340 some other package would contain this missing \`$1' program."
341 exit 1
342 ;;
343 esac
344
345 exit 0
346
347 # Local variables:
348 # eval: (add-hook 'write-file-hooks 'time-stamp)
349 # time-stamp-start: "scriptversion="
350 # time-stamp-format: "%:y-%02m-%02d.%02H"
351 # time-stamp-end: "$"
352 # End:
0 #! /bin/sh
11 # mkinstalldirs --- make directory hierarchy
2 # Author: Noah Friedman
2
3 scriptversion=2004-02-15.20
4
5 # Original author: Noah Friedman
36 # Created: 1993-05-16
4 # Public domain
5
6 # $Id$
7 # Public domain.
8 #
9 # This file is maintained in Automake, please report
10 # bugs to or send patches to
11 # .
712
813 errstatus=0
914 dirmode=""
1015
1116 usage="\
12 Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
17 Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
18
19 Create each directory DIR (with mode MODE, if specified), including all
20 leading file name components.
21
22 Report bugs to ."
1323
1424 # process command line arguments
1525 while test $# -gt 0 ; do
16 case "${1}" in
17 -h | --help | --h* ) # -h for help
18 echo "${usage}" 1>&2; exit 0 ;;
19 -m ) # -m PERM arg
20 shift
21 test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
22 dirmode="${1}"
23 shift ;;
24 -- ) shift; break ;; # stop option processing
25 -* ) echo "${usage}" 1>&2; exit 1 ;; # unknown option
26 * ) break ;; # first non-opt arg
27 esac
26 case $1 in
27 -h | --help | --h*) # -h for help
28 echo "$usage"
29 exit 0
30 ;;
31 -m) # -m PERM arg
32 shift
33 test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
34 dirmode=$1
35 shift
36 ;;
37 --version)
38 echo "$0 $scriptversion"
39 exit 0
40 ;;
41 --) # stop option processing
42 shift
43 break
44 ;;
45 -*) # unknown option
46 echo "$usage" 1>&2
47 exit 1
48 ;;
49 *) # first non-opt arg
50 break
51 ;;
52 esac
2853 done
2954
3055 for file
3762 done
3863
3964 case $# in
40 0) exit 0 ;;
65 0) exit 0 ;;
4166 esac
4267
68 # Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
69 # mkdir -p a/c at the same time, both will detect that a is missing,
70 # one will create a, then the other will try to create a and die with
71 # a "File exists" error. This is a problem when calling mkinstalldirs
72 # from a parallel make. We use --version in the probe to restrict
73 # ourselves to GNU mkdir, which is thread-safe.
4374 case $dirmode in
44 '')
45 if mkdir -p -- . 2>/dev/null; then
46 echo "mkdir -p -- $*"
47 exec mkdir -p -- "$@"
48 fi ;;
49 *)
50 if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
51 echo "mkdir -m $dirmode -p -- $*"
52 exec mkdir -m "$dirmode" -p -- "$@"
53 fi ;;
75 '')
76 if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
77 echo "mkdir -p -- $*"
78 exec mkdir -p -- "$@"
79 else
80 # On NextStep and OpenStep, the `mkdir' command does not
81 # recognize any option. It will interpret all options as
82 # directories to create, and then abort because `.' already
83 # exists.
84 test -d ./-p && rmdir ./-p
85 test -d ./--version && rmdir ./--version
86 fi
87 ;;
88 *)
89 if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
90 test ! -d ./--version; then
91 echo "mkdir -m $dirmode -p -- $*"
92 exec mkdir -m "$dirmode" -p -- "$@"
93 else
94 # Clean up after NextStep and OpenStep mkdir.
95 for d in ./-m ./-p ./--version "./$dirmode";
96 do
97 test -d $d && rmdir $d
98 done
99 fi
100 ;;
54101 esac
55102
56103 for file
57104 do
58 set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
59 shift
105 set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
106 shift
60107
61 pathcomp=
62 for d
63 do
64 pathcomp="$pathcomp$d"
65 case "$pathcomp" in
66 -* ) pathcomp=./$pathcomp ;;
67 esac
108 pathcomp=
109 for d
110 do
111 pathcomp="$pathcomp$d"
112 case $pathcomp in
113 -*) pathcomp=./$pathcomp ;;
114 esac
68115
69 if test ! -d "$pathcomp"; then
70 echo "mkdir $pathcomp"
116 if test ! -d "$pathcomp"; then
117 echo "mkdir $pathcomp"
71118
72 mkdir "$pathcomp" || lasterr=$?
119 mkdir "$pathcomp" || lasterr=$?
73120
74 if test ! -d "$pathcomp"; then
75 errstatus=$lasterr
76 else
77 if test ! -z "$dirmode"; then
78 echo "chmod $dirmode $pathcomp"
121 if test ! -d "$pathcomp"; then
122 errstatus=$lasterr
123 else
124 if test ! -z "$dirmode"; then
125 echo "chmod $dirmode $pathcomp"
126 lasterr=""
127 chmod "$dirmode" "$pathcomp" || lasterr=$?
79128
80 lasterr=""
81 chmod "$dirmode" "$pathcomp" || lasterr=$?
82
83 if test ! -z "$lasterr"; then
84 errstatus=$lasterr
85 fi
129 if test ! -z "$lasterr"; then
130 errstatus=$lasterr
86131 fi
87132 fi
88 fi
133 fi
134 fi
89135
90 pathcomp="$pathcomp/"
91 done
136 pathcomp="$pathcomp/"
137 done
92138 done
93139
94140 exit $errstatus
95141
96142 # Local Variables:
97143 # mode: shell-script
98 # sh-indentation: 3
144 # sh-indentation: 2
145 # eval: (add-hook 'write-file-hooks 'time-stamp)
146 # time-stamp-start: "scriptversion="
147 # time-stamp-format: "%:y-%02m-%02d.%02H"
148 # time-stamp-end: "$"
99149 # End:
100 # mkinstalldirs ends here