(am_dir): Don't apply transform to install directory name
[automake.git] / automake.in
blobae49fc310db4fb8ffd326204a92611cdaff97217
1 #! /bin/sh
2 # @configure_input@
4 # automake - create Makefile.in from Makefile.am
5 # Copyright (C) 1994 Free Software Foundation, Inc.
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.
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
21 # Sample usage: automake Makefile lib/Makefile src/Makefile man/Makefile
22 # Written by David Mackenzie <djm@gnu.ai.mit.edu>.
24 # Caveat: must use all lowercase variables in this file. User
25 # Makefile.am can cause any uppercase variable to be set.
27 version=@VERSION@
29 # We need prefix because datadir might depend on it.
30 prefix=@prefix@
31 am_dir=@datadir@/@PACKAGE@
33 # These are commonly found files that we look for and automatically
34 # include in DIST_FILES. NOTE if you add something here, make sure
35 # you add it in the right place -- that is, so that the "--help" still
36 # lines up nicely.
37 common='THANKS TODO README NEWS COPYING COPYING.LIB INSTALL NLS ChangeLog configure configure.in config.guess config.sub mkinstalldirs install-sh texinfo.tex acconfig.h config.h.top config.h.bot'
39 # $echo will eventually be used to handle NLS matters.
40 echo=echo
42 mfiles=
43 am_usedeps=no
44 am_incdeps=no
45 while test $# -gt 0; do
46 case "$1" in
47 --help | --h* )
48 $echo "Usage: automake [OPTION]... [Makefile]..."
49 $echo "\
50 --help print this help, then exit
51 --version print version number, then exit
52 --use-deps include code to auto-generate dependencies
53 --include-deps include generated dependencies in Makefile"
54 echo
55 $echo "Files which are automatically distributed, if found:"
56 set $common
57 while test $# -gt 0; do
58 echo " $1 $2"
59 shift
60 # Ignore errors here, in case we have an odd number.
61 shift 2>/dev/null
62 done
63 exit 0
66 --version | --v* )
67 $echo "Automake version $version"
68 exit 0
71 --use-deps)
72 am_usedeps=yes
75 --include-deps)
76 am_incdeps=yes
79 -- ) # Stop option processing.
80 shift
81 while test $# -gt 0; do
82 mfiles="$mfiles $1"
83 shift
84 done
85 break
88 -*)
89 # FIXME consider "-" meaning stdin as input?
90 $echo "automake: unrecognized option -- \`$1'" 1>&2
91 exit 1
94 * )
95 mfiles="$mfiles $1"
97 esac
98 shift
99 done
101 if test "$am_usedeps" = yes && test "$am_incdeps" = yes; then
102 $echo "automake: can't specify both --use-deps and --include-deps" 1>&2
103 exit 1
106 test -n "$mfiles" || {
107 # Look around.
108 mfiles=`echo */Makefile.am`
109 if test "$mfiles" = '*/Makefile.am'; then
110 mfiles=
111 else
112 mfiles=`echo "$mfiles" | sed 's/\.am//g'`
115 if test -f Makefile.am; then
116 mfiles="Makefile $mfiles"
119 if test -n "$mfiles"; then
120 $echo "automake: using $mfiles" 1>&2
121 else
122 $echo "automake: no \"Makefile.am\" found or specified" 1>&2
123 exit 1
128 am_status=0
130 # Some handy sed scripts.
131 am_rmnl=$am_dir/nl-remove.sed
132 am_ass=$am_dir/hack-make.sed
134 for am_makefile in $mfiles; do
136 if test ! -f ${am_makefile}.am; then
137 $echo "automake: ${am_makefile}.am: No such honkin' file" 1>&2
138 am_status=1
139 continue
142 $echo "creating ${am_makefile}.in"
144 exec 4> ${am_makefile}.vars
145 exec 5> ${am_makefile}.rules
147 echo "# Makefile.in generated automatically by automake $version from Makefile.am." >&4
148 cat $am_dir/header-vars.am >&4
149 cat $am_dir/header.am >&5
151 DEFS= INCLUDES= CPPFLAGS= CFLAGS=
152 SOURCES= CONFIG_HEADER= SUBDIRS= PROGRAMS= LIBPROGRAMS= SCRIPTS= LIBSCRIPTS=
153 LIBRARIES= TEXINFOS= MANS= AM_PROGRAMS=
154 am_suffixes=
155 # The following are targets that formerly were implemented as
156 # double-colon rules. Nowadays we have to construct such lists
157 # explicitly.
158 installexec= uninstallexec= id= tags= info= dvi= check=
159 installdata= uninstalldata= all='${ALL}'
160 install= uninstall=
162 eval `sed -n -f $am_rmnl ${am_makefile}.am | sed -n -f $am_ass`
165 # If a variable is set at configure time, we still need to know the
166 # values it can assume (statically). This is done using the AM_
167 # forms in the Makefile.am. Handle it now.
169 test -n "$AM_PROGRAMS" && {
170 PROGRAMS=$AM_PROGRAMS
172 test -n "$AM_LIBPROGRAMS" && {
173 LIBPROGRAMS=$AM_LIBPROGRAMS
175 test -n "$AM_SCRIPTS" && {
176 SCRIPTS=$AM_SCRIPTS
178 test -n "$AM_LIBSCRIPTS" && {
179 LIBSCRIPTS=$AM_LIBSCRIPTS
181 test -n "$AM_LIBRARIES" && {
182 LIBRARIES=$AM_LIBRARIES
185 if grep @kr@ ${am_makefile}.am >/dev/null; then
186 kr='${kr}'
187 else
191 if test -n "$PROGRAMS$LIBPROGRAMS$LIBRARIES"; then
192 cat $am_dir/compile-vars.am >&4
193 cat $am_dir/compile.am >&5
195 # Check for automatic de-ANSIfication.
196 if grep @kr@ ${am_makefile}.am >/dev/null; then
197 cat $am_dir/compile-kr.am >&5
198 am_suffixes=".krc .krh .kro $am_suffixes"
201 for am_file in $PROGRAMS $LIBPROGRAMS $LIBRARIES; do
202 if eval "test \"\$var_${am_file}_SOURCES\" = explicit"; then
203 if eval "test \"\$var_${am_file}_OBJECTS\" = explicit"; then
205 else
206 sed -n -f $am_rmnl ${am_makefile}.am |
207 sed -n "/^[ ]*${am_file}_SOURCES[ ]*=/{
208 s/SOURCES/OBJECTS/
209 s/@[^@]*@//g
210 s/\$([^)]*)//g
211 s/\${[^}]*}//g
212 s/\\.cc/.${kr}o/g
213 s/\\.\${kr}c/.${kr}o/g
214 s/\\.\$(kr)c/.${kr}o/g
215 s/\\.[cCmylfs]/.${kr}o/g
217 }" >&4
219 SOURCES="$SOURCES \${${am_file}_SOURCES}"
220 OBJECTS="$OBJECTS \${${am_file}_OBJECTS}"
221 else
222 echo "${am_file}_SOURCES = ${am_file}.c" >&4
223 echo "${am_file}_OBJECTS = ${am_file}.${kr}o" >&4
224 SOURCES="$SOURCES ${am_file}.c"
225 OBJECTS="$OBJECTS ${am_file}.${kr}o"
227 if test -n "$CONFIG_HEADER"; then
228 echo "\$(${am_file}_OBJECTS): $CONFIG_HEADER" >&5
230 done
235 # Boilerplate for scripts or programs.
237 if test -n "$PROGRAMS"; then
238 cat $am_dir/programs.am >&5
239 installexec="install-programs $installexec"
240 uninstallexec="uninstall-programs $uninstallexec"
242 if test -n "$SCRIPTS"; then
243 cat $am_dir/scripts.am >&5
244 installexec="install-scripts $installexec"
245 uninstallexec="uninstall-scripts $uninstallexec"
247 if test -n "$LIBPROGRAMS$LIBSCRIPTS"; then
248 cat $am_dir/libprograms.am >&5
249 installexec="install-libprograms $installexec"
250 uninstallexec="uninstall-libprograms $uninstallexec"
252 if test -n "$LIBSCRIPTS"; then
253 cat $am_dir/libscripts.am >&5
254 installexec="install-libscripts $installexec"
255 uninstallexec="uninstall-libscripts $uninstallexec"
258 if test -n "$PROGRAMS$LIBPROGRAMS$SCRIPTS$LIBSCRIPTS"; then
259 if test -n "$PROGRAMS$LIBPROGRAMS"; then
260 for am_prog in $PROGRAMS $LIBPROGRAMS; do
261 # If `prog_LDADD' is explicitly defined, use it. Otherwise,
262 # use LDADD.
263 eval "test \"\$var_${am_prog}_LDADD\" = explicit" || {
264 # Not set, so set it.
265 echo "${am_prog}_LDADD = \${LDADD}" >&5
268 # Insert rule for this target, unless it is explicitly given
269 # in Makefile.am.
270 eval "test \"\$target_$am_prog\" != explicit" &&
271 sed "s/@PROGRAM@/$am_prog/g" $am_dir/program.am >&5
272 done
276 if test -n "$LIBRARIES"; then
277 echo "LIBFILES = " `echo "$LIBRARIES"|sed 's/\([a-zA-Z0-9_][a-zA-Z0-9_]*\)/lib\1.a/g'` >&4
278 cat $am_dir/libraries-vars.am >&4
279 cat $am_dir/libraries.am >&5
281 installexec="install-libraries $installexec"
282 uninstallexec="uninstall-libraries $uninstallexec"
284 for am_lib in $LIBRARIES; do
285 sed "s/@LIBRARY@/$am_lib/g" $am_dir/library.am >&5
286 done
289 if test -n "$TEXINFOS"; then
290 cat $am_dir/texinfos-vars.am >&4
291 cat $am_dir/texinfos.am >&5
292 am_suffixes=".texi .info .dvi $am_suffixes"
293 installdata="install-info $installdata"
294 uninstalldata="uninstall-info $uninstalldata"
295 info="\$(INFO_DEPS) $info"
296 dvi="\$(DVIS) $dvi"
298 echo "$TEXINFOS" | sed 's/^/INFOS = /; s/\.texi/.info*/g' >&4
299 echo "$TEXINFOS" | sed 's/^/INFO_DEPS = /; s/\.texi/.info/g' >&4
300 echo "$TEXINFOS" | sed 's/^/DVIS = /; s/\.texi/.dvi/g' >&4
303 if test -n "$MANS"; then
304 cat $am_dir/mans-vars.am >&4
305 cat $am_dir/mans.am >&5
307 installdata="install-man $installdata"
308 uninstalldata="uninstall-man $uninstall"
313 # Handle DATA and PACKAGEDATA.
315 if test -n "$DATA"; then
316 cat $am_dir/data.am >&5
317 installdata="install-ddata $installdata"
318 uninstalldata="uninstall-ddata $uninstalldata"
320 if test -n "$PACKAGEDATA"; then
321 cat $am_dir/packagedata.am >&5
322 installdata="install-pdata $installdata"
323 uninstalldata="uninstall-pdata $uninstalldata"
326 case "$SUBDIRS" in
328 if grep @kr@ ${am_makefile}.am >/dev/null; then
329 cat $am_dir/clean-kr.am >&5
330 else
331 cat $am_dir/clean.am >&5
333 cat $am_dir/footer.am >&5
336 cat $am_dir/subdirs.am >&5
338 all="all-recursive $all"
339 installdata="install-data-recursive $installdata"
340 installexec="install-exec-recursive $installexec"
341 uninstalldata="uninstall-data-recursive $uninstalldata"
342 uninstallexec="uninstall-exec-recursive $uninstallexec"
343 check="check-recursive $check"
344 info="info-recursive $info"
345 dvi="dvi-recursive $dvi"
346 install="install-recursive $install"
347 uninstall="uninstall-recursive $uninstall"
349 esac
351 case "$am_makefile" in
352 */*)
353 cat $am_dir/remake-subd.am >&5
356 test -f aclocal.m4 && echo "ACLOCAL = aclocal.m4" >&4
357 cat $am_dir/remake.am >&5
359 esac
361 case "$CONFIG_HEADER" in
362 "") ;;
363 */*) ;; # It's in some other directory, so don't remake it in this one.
365 test -f acconfig.h && echo "ACCONFIG = acconfig.h" >&4
366 test -f config.h.top && echo "CONFIG_TOP = config.h.top" >&4
367 test -f config.h.bot && echo "CONFIG_BOT = config.h.bot" >&4
368 cat $am_dir/remake-hdr.am >&5 ;;
369 esac
372 # Handle TAGS.
374 case "$am_makefile" in
375 */*)
376 if test -n "${SOURCES}${HEADERS}${ETAGS_ARGS}"; then
377 cat $am_dir/tags-subd.am >&5
381 if test -n "${SUBDIRS}"; then
382 cat $am_dir/tags.am >&5
383 else
384 if test -n "${SOURCES}${HEADERS}${ETAGS_ARGS}"; then
385 cat $am_dir/tags-subd.am >&5
389 esac
392 # Handle "dist" targets.
394 am_reldir=`echo "$am_makefile" | sed 's,//*[^/][^/]*$,,g'`
395 if test "$am_reldir" = "$am_makefile"; then
396 # Bogus.
397 am_reldir=.
399 # Look for certain common files and make sure they are included.
400 dlist=
401 for cfile in $common; do
402 if test -f $am_reldir/$cfile; then
403 dlist="$dlist $cfile"
405 done
406 echo "DIST_COMMON = $dlist" >&4
407 # Include "dist" boilerplate.
408 case "$am_makefile" in
409 */*)
410 cat $am_dir/dist-subd-vars.am >&4
411 echo "subdir = $am_reldir" >&5
412 cat $am_dir/dist-subd.am >&5
415 cat $am_dir/dist-vars.am >&4
416 if test -n "$SUBDIRS"; then
417 cat $am_dir/dist-subd-top.am >&5
418 else
419 cat $am_dir/dist.am >&5
422 esac
425 # Put .SUFFIXES way down at the bottom.
427 if test -n "$am_suffixes"; then
428 echo ".SUFFIXES:" >&5
429 echo ".SUFFIXES: $am_suffixes" >&5
430 echo >&5
435 # Handle auto-generating dependencies.
437 if test "$am_usedeps" = yes && test -n "$SOURCES"; then
438 # Include code to auto-generate dependencies.
439 cat $am_dir/depend.am >&5
441 if test "$am_incdeps" = yes; then
442 # Include any already generated dependencies.
443 if test -d $am_reldir/.deps && test -f $am_reldir/.deps/empty.P; then
444 cat $am_reldir/.deps/*.P >&5
449 # Some final checks.
451 test -z "$TEXINFOS" || test -f $am_reldir/texinfo.tex || {
452 $echo "automake: ${am_makefile}.am defines TEXINFOS, but" 1>&2
453 $echo "automake: ${am_reldir}/texinfo.tex does not exist" 1>&2
457 # Copy from Makefile.am to output.
458 sed '/^[^#=]*:/,$d' ${am_makefile}.am >&4
459 sed -n '/^[^#=]*:/,$p' ${am_makefile}.am >&5
461 echo "SOURCES = $SOURCES" >&4
462 echo "OBJECTS = $OBJECTS" >&4
465 # Output variable definitions.
466 exec 6> ${am_makefile}.in
468 cat ${am_makefile}.vars >&6
471 # Merge any targets that need to be merged.
473 for am_target in all info dvi check; do
474 # If user specified the local form of the target, then include it.
475 if eval "test \"\$target_${am_target}_local\" = explicit"; then
476 eval "${am_target}=\"${am_target}-local \$${am_target}\""
479 # Always print these targets; GNU makefile standards require it.
480 eval "am_val=\"\$${am_target}\""
481 echo "${am_target}: ${am_val}" >&6
482 echo >&6
483 done
485 # Handle the various install targets specially, because we do name
486 # hackery. This is truly gross.
487 if test -n "$target_install_exec_local"; then
488 installexec="install-exec-local $installexec"
490 if test -n "$target_uninstall_exec_local"; then
491 uninstallexec="uninstall-exec-local $uninstallexec"
493 if test -n "$target_install_data_local"; then
494 installdata="install-data-local $installdata"
496 if test -n "$target_uninstall_data_local"; then
497 uninstalldata="uninstall-data-local $uninstalldata"
500 if test -n "$installexec"; then
501 install="install-exec $install"
502 echo "install-exec: $installexec" >&6
503 echo >&6
505 if test -n "$uninstallexec"; then
506 uninstall="uninstall-exec $uninstall"
507 echo "uninstall-exec: $uninstallexec" >&6
508 echo >&6
510 if test -n "$installdata"; then
511 install="install-data $install"
512 echo "install-data: $installdata" >&6
513 echo >&6
515 if test -n "$uninstalldata"; then
516 uninstall="uninstall-data $uninstall"
517 echo "uninstall-data: $uninstalldata" >&6
518 echo >&6
521 echo "install: $install" >&6
522 echo >&6
523 echo "uninstall: $uninstall" >&6
524 echo >&6
527 cat ${am_makefile}.rules >&6
528 rm -f ${am_makefile}.vars ${am_makefile}.rules
531 done
533 exit $am_status