Edit

kc3-lang/automake/automake.in

Branch :

  • Show log

    Commit

  • Author : Tom Tromey
    Date : 1995-11-16 18:33:25
    Hash : 3dc2a1f4
    Message : Use am_dir, not AM_DIR. Use version, not VERSION. Bug fix in TAGS code.

  • automake.in
  • #! /bin/sh
    # automake - create Makefile.in from Makefile.am
    # Copyright (C) 1994 Free Software Foundation, Inc.
    
    # This program is free software; you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation; either version 2, or (at your option)
    # any later version.
    
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    
    # You should have received a copy of the GNU General Public License
    # along with this program; if not, write to the Free Software
    # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    
    # Sample usage: automake Makefile lib/Makefile src/Makefile man/Makefile
    # Written by David Mackenzie <djm@gnu.ai.mit.edu>.
    
    # Caveat: must use all lowercase variables in this file.  User
    # Makefile.am can cause any uppercase variable to be set.
    
    version=@VERSION@
    am_dir=@prefix@/share/automake
    
    usage="Usage: automake [--help] [--version] [Makefile]..."
    
    # These are commonly found files that we look for and automatically
    # include in DIST_FILES.
    common='TODO THANKS README NEWS COPYING COPYING.LIB INSTALL NLS ChangeLog configure configure.in config.guess config.sub mkinstalldirs install-sh texinfo.tex'
    
    # NLS nuisances.
    # Only set `LANG' and `LC_ALL' to "C" if already set.
    # These must not be set unconditionally because not all systems understand
    # e.g. LANG=C (notably SCO).
    if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
    if test "${LANG+set}"   = set; then LANG=C;   export LANG;   fi
    
    mfiles=
    while test $# -gt 0; do
       case "$1" in
        --help | --h* )
           echo "${usage}" 1>&2
           exit 0
           ;;
    
        --version | --v* )
           echo "Automake version $version"
           exit 0
           ;;
    
        -- ) # Stop option processing.
           shift
           break
           ;;
    
        -*)
           # FIXME consider "-" meaning stdin as input?
           echo "automake: unrecognized option -- \`$1'" 1>&2
           echo "${usage}" 1>&2
           exit 1
           ;;
    
        * )
           mfiles="$mfiles $1"
           ;;
       esac
       shift
    done
    
    test -n "$mfiles" || {
       # Look around.
       mfiles=`echo */Makefile.am`
       if test "$mfiles" = '*/Makefile.am'; then
          mfiles=
       else
          mfiles=`echo "$mfiles" | sed 's/\.am//g'`
       fi
    
       if test -f Makefile.am; then
          mfiles="Makefile $mfiles"
       fi
    
       if test -n "$mfiles"; then
          echo "automake: using $mfiles" 1>&2
       else
          echo "${usage}" 1>&2
          exit 1
       fi
    }
    
    
    am_status=0
    
    # Remove \newline.
    am_rmnl=/tmp/am.sed1
    cat > $am_rmnl <<\EOF
    /\\$/{
      s///
      H
      d
    }
    /[^\\]$/{
      H
      x
      s/\n//g
      p
      s/.*//
      h
    }
    EOF
    
    # Turn Makefile target and variable assignments into shell variable
    # assignments:
    # * For targets, define the variable `target_NAME' to "explicit".
    # * For variables whose names are uppercase, perform the actual assignment.
    #   We only do this for all-upper variables to avoid conflict with variables
    #   used in automake.
    # * For other variables, define `var_NAME' to "explicit".  Such variables
    #   can only be used as flags; any use of their values must be done
    #   later, in the generated Makefile.
    am_ass=/tmp/am.sed2
    cat > $am_ass <<\EOF
    s/(/{/g
    s/)/}/g
    /^ *\([a-zA-Z_.][a-zA-Z0-9_.]*\):.*/{
    s//target_\1=explicit/
    s/\./_/g
    p
    }
    s/^ *\([A-Z][A-Z0-9_]*\)[	 ]*=[	 ]*\(.*\)/\1='\2'/p
    s/^ *\([A-Za-z][A-Za-z0-9_]*\)[ 	]*=[ 	]*\(.*\)/var_\1=explicit/p
    EOF
    
    for am_makefile in $mfiles; do
    (
      if test ! -f ${am_makefile}.am; then
         echo "automake: ${am_makefile}.am: No such honkin' file" 1>&2
         am_status=1
         continue
      fi
    
      echo creating ${am_makefile}.in
    
      exec 4> ${am_makefile}.vars
      exec 5> ${am_makefile}.rules
    
      echo "# Makefile.in generated automatically by automake $version from Makefile.am." >&4
      cat $am_dir/header-vars.am >&4
      cat $am_dir/header.am >&5
    
      DEFS= INCLUDES= CPPFLAGS= CFLAGS=
      SOURCES= CONFIG_HEADER= SUBDIRS= PROGRAMS= LIBPROGRAMS= SCRIPTS= LIBSCRIPTS=
      LIBRARIES= TEXINFOS= MANS= AM_PROGRAMS=
    
      eval `sed -n -f $am_rmnl ${am_makefile}.am | sed -n -f $am_ass`
    
      test -n "$AM_PROGRAMS" && {
         PROGRAMS=$AM_PROGRAMS
      }
    
      if grep @kr@ ${am_makefile}.am >/dev/null; then
        kr='${kr}'
      else
        kr=
      fi
    
      if test -n "$PROGRAMS$LIBPROGRAMS$LIBRARIES"; then
        cat $am_dir/compile-vars.am >&4
        cat $am_dir/compile.am >&5
        grep @kr@ ${am_makefile}.am >/dev/null && cat $am_dir/compile-kr.am >&5
        for am_file in $PROGRAMS $LIBPROGRAMS $LIBRARIES; do
          if grep "^[	 ]*${am_file}_SOURCES[	 ]*=" ${am_makefile}.am >/dev/null; then
            if grep "^[	 ]*${am_file}_OBJECTS[	 ]*=" ${am_makefile}.am >/dev/null; then
              :
            else
              sed -n -f $am_rmnl ${am_makefile}.am |
              sed -n "/^[	 ]*${am_file}_SOURCES[	 ]*=/{
    s/SOURCES/OBJECTS/
    s/@[^@]*@//g
    s/\$([^)]*)//g
    s/\${[^}]*}//g
    s/\\.cc/.${kr}o/g
    s/\\.\${kr}c/.${kr}o/g
    s/\\.\$(kr)c/.${kr}o/g
    s/\\.[cCmylfs]/.${kr}o/g
    p
    }" >&4
            fi
            SOURCES="$SOURCES \${${am_file}_SOURCES}"
          else
            echo "${am_file}_SOURCES = ${am_file}.c
    ${am_file}_OBJECTS = ${am_file}.${kr}o" >&4
            SOURCES="$SOURCES ${am_file}.c"
          fi
          if test -n "$CONFIG_HEADER"; then
            echo "\$(${am_file}_OBJECTS): $CONFIG_HEADER" >&5
          fi
        done
      fi
    
      if test -n "$PROGRAMS$LIBPROGRAMS$SCRIPTS$LIBSCRIPTS"; then
        if test -n "$PROGRAMS$SCRIPTS"; then
          cat $am_dir/programs.am >&5
        fi
        if test -n "$LIBPROGRAMS$LIBSCRIPTS"; then
          cat $am_dir/libprograms.am >&5
        fi
        if test -n "$PROGRAMS$LIBPROGRAMS"; then
           for am_prog in $PROGRAMS $LIBPROGRAMS; do
    	  # If `prog_LDADD' is explicitly defined, use it.  Otherwise,
    	  # use LDADD.
    	  eval "test \"\$var_${am_prog}_LDADD\" = explicit" || {
    	     # Not set, so set it.
    	     echo "${am_prog}_LDADD = \${LDADD}" >&5
    	  }
    
    	  # Insert rule for this target, unless it is explicitly given
    	  # in Makefile.am.
    	  eval "test \"\$target_$am_prog\" != explicit" &&
    	  sed "s/@PROGRAM@/$am_prog/g" $am_dir/program.am >&5
           done
        fi
      fi
    
      if test -n "$LIBRARIES"; then
        echo "LIBFILES = " `echo "$LIBRARIES"|sed 's/\([a-zA-Z0-9_][a-zA-Z0-9_]*\)/lib\1.a/g'` >&4
        cat $am_dir/libraries-vars.am >&4
        cat $am_dir/libraries.am >&5
        for am_lib in $LIBRARIES; do
          sed "s/@LIBRARY@/$am_lib/g" $am_dir/library.am >&5
        done
      fi
    
      if test -n "$TEXINFOS"; then
        cat $am_dir/texinfos-vars.am >&4
        cat $am_dir/texinfos.am >&5
        echo "$TEXINFOS" | sed 's/^/INFOS = /; s/\.texi/.info*/g' >&4
        echo "$TEXINFOS" | sed 's/^/INFO_DEPS = /; s/\.texi/.info/g' >&4
        echo "$TEXINFOS" | sed 's/^/DVIS = /; s/\.texi/.dvi/g' >&4
      fi
    
      if test -n "$MANS"; then
        cat $am_dir/mans-vars.am >&4
        cat $am_dir/mans.am >&5
      fi
    
      case "$SUBDIRS" in
      "") if grep @kr@ ${am_makefile}.am >/dev/null; then
          cat $am_dir/clean-kr.am >&5
          else cat $am_dir/clean.am >&5
          fi
          cat $am_dir/footer.am >&5 ;;
      *) cat $am_dir/subdirs.am >&5 ;;
      esac
    
      case "$am_makefile" in
       */*)
          cat $am_dir/remake-subd.am >&5
          ;;
       *)
          test -f aclocal.m4 && echo "ACLOCAL = aclocal.m4" >&4
          cat $am_dir/remake.am >&5
          ;;
      esac
    
      case "$CONFIG_HEADER" in
      "") ;;
      */*) ;; # It's in some other directory, so don't remake it in this one.
      *)
        test -f acconfig.h && echo "ACCONFIG = acconfig.h" >&4
        test -f config.h.top && echo "CONFIG_TOP = config.h.top" >&4
        test -f config.h.bot && echo "CONFIG_BOT = config.h.bot" >&4
        cat $am_dir/remake-hdr.am >&5 ;;
      esac
    
      echo "SOURCES = $SOURCES" >&4
    
    
      #
      # Handle TAGS.
      #
      case "$am_makefile" in
       */*)
          if test -n "${SOURCES}${HEADERS}${ETAGS_ARGS}"; then
    	 cat $am_dir/tags-subd.am >&5
          fi
          ;;
       *)
          if test -n "${SUBDIRS}"; then
    	 cat $am_dir/tags.am >&5
          else
    	 if test -n "${SOURCES}${HEADERS}${ETAGS_ARGS}"; then
    	    cat $am_dir/tags-subd.am >&5
    	 fi
          fi
          ;;
      esac
    
      #
      # Handle "dist" targets.
      #
      am_reldir=`echo "$am_makefile" | sed 's,//*[^/][^/]*$,,g'`
      if test "$am_reldir" = "$am_makefile"; then
         # Bogus.
         am_reldir=.
      fi
      # Look for certain common files and make sure they are included.
      dlist=
      for cfile in $common; do
         if test -f $am_reldir/$cfile; then
    	dlist="$dlist $cfile"
         fi
      done
      echo "DIST_COMMON = $dlist" >&4
      # Include "dist" boilerplate.
      case "$am_makefile" in
      */*) 
         cat $am_dir/dist-subd-vars.am >&4
         echo "subdir = $am_reldir" >&5
         cat $am_dir/dist-subd.am >&5
         ;;
      *)
         cat $am_dir/dist-vars.am >&4
         if test -n "$SUBDIRS"; then
    	cat $am_dir/dist-subd-top.am >&5
         else
    	cat $am_dir/dist.am >&5
         fi
         ;;
      esac
    
      sed '/^[^#=]*:/,$d' ${am_makefile}.am >&4
      sed -n '/^[^#=]*:/,$p' ${am_makefile}.am >&5
      cat ${am_makefile}.vars ${am_makefile}.rules > ${am_makefile}.in
      rm -f ${am_makefile}.vars ${am_makefile}.rules
    
    )
    done
    
    rm -f $am_rmnl $am_ass
    
    exit $am_status