summaryrefslogtreecommitdiff
path: root/agen5/bootstrap.dir
blob: 4d128ba468994d3052d943178a43d30d22c65289 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#! /bin/echo This_file_must_be_sourced,_not_executed
#
# ----------------------------------------------------------------------
# agen5/bootstrap.dir --- maintainer's bootstrap script
#
# Author:            Bruce Korb <bkorb@gnu.org>
# Time-stamp:        "2012-04-14 09:39:36 bkorb"
##
##  This file is part of AutoGen.
##  AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
##
## AutoGen 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 3 of the License, or
## (at your option) any later version.
##
## AutoGen 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, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
#
#  This script rebuilds sources not kept in the GIT repository.
#  These files are distributed, so it is not necessary to invoke
#  AutoGen before building AutoGen.

#  "make" will invoke this file with the name of the desired output
#  as an argument.  We do this here rather than in the make file
#  because some of the rules are complex and we don't want to
#  deal with the dual update problem.

readonly stamp_list=$(echo "stamp-opts${nl}stamp-proto"
    sed -n '/^make_[a-z_]*[(]/{;s/^make_/stamp-/;s/[()].*//;p;}' \
        ${srcdir}/mk-stamps.sh)

set_defaults()
{
    builddir=$(pwd)
    srcdir=${srcdir:-$builddir}
    AGexe=$(command -v autogen)
    CLexe=$(command -v columns)
    GDexe=$(command -v getdefs)

    test -x "${AGexe}" -a -x "${GDexe}" -a -x "${CLexe}" || \
        die "autogen is required"

    export builddir srcdir AGexe CLexe GDexe

    #  Make sure we have a default for top build and source.
    #  Some of the templates need this information.
    #
    local verdata=$(egrep '^AG_' ${top_srcdir}/VERSION | \
       sed 's,^\(AG[^=]*\)\(.*\),\1\2 export \1,')
    eval "set -a;${verdata};set +a"

    #  disable any $HOME defaults
    #
    HOME=/dev/null
    SHELL=${POSIX_SHELL-/bin/sh}

    ${VERBOSE:-false} && set -x || :
    #  Ensure complete success or a noticable failure
    #
    set -e
}

assemble_Makefile() {
    {
        sed '/# *start-generated-text/q' ${srcdir}/Makefile.am
        echo

        echo list_stamps = '\'
        sflist=''
        for f in $stamp_list
        do sflist=${sflist}$f${nl}
        done
        printf %s "$sflist" | \
            ${CLexe} --spread=1 -I4 --line=' \'

        echo "if AMDEP"
        for f in $stamp_list
        do
            echo "@am__include@ @am__quote@./\$(DEPDIR)/${f}.d@am__quote@"
        done
        echo endif

        fmt='\n%s:\n\t@target="$(AUTOGEN_%s_TList)" \\\n'
        fmt=${fmt}'\t$(MAKE_STAMP)\n'
        for f in $stamp_list
        do
            g=$(echo $f | sed 's/[^a-zA-Z0-9]/_/g')
            printf "$fmt" $f $g
        done
        printf '\n# end-generated-text\n# end of Makefile.am\n'

    } > Makefile.XX

    if  cmp -s Makefile.XX Makefile.am
    then rm -f Makefile.XX
    else mv -f Makefile.XX Makefile.am
    fi
}

assemble_fmemopen() {
    fmemdir=~bkorb/tools/mine/lib/fmemopen
    test -f ${fmemdir}/fmemopen.c || return

    test -f agen5/fmemopen.c && rm -f agen5/fmemopen.c
    {
        echo '#if defined(ENABLE_FMEMOPEN)'
        echo '#include <sys/ioctl.h>'
        echo
        sed -n '/^typedef enum/,/_IOWR(/p' ${fmemdir}/libfmem.h
        sed -e '/^#if defined(HAVE_FOPENCOOKIE)/p' \
            -e '/=--subblock/,/^#if defined(HAVE_FOPENCOOKIE)/d' \
            -e "s% @file .*% @file $(realpath ${fmemdir}/fmemopen.c)%" \
            ${fmemdir}/fmemopen.c
        echo '#endif /* ENABLE_FMEMOPEN */'
    } > fmemopen.c
}

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
#  M A I N
#
PS4='>bsag-${FUNCNAME}> '
set_defaults ${1+"$@"}
DEPDIR=
. ${srcdir}/mk-stamps.sh $stamp_list
assemble_fmemopen
assemble_Makefile

#  IF we symlinked in columns or getdefs,
#  THEN it is time to unlink them
#
test -z "$rmlist" || rm -f $rmlist

# Local Variables:
# mode:shell-script
# sh-indentation:4
# sh-basic-offset:4
# indent-tabs-mode: nil
# End:

# end of agen5/bootstrap.dir