Do not run mandoc for lintmanpages if MANPAGES is empty.
[netbsd-mini2440.git] / tools / gcc / mknative.common
blobfa2d3feee6972b1af0276371cc3cbcaa31eb95ac
1 #       $NetBSD: mknative.common,v 1.8 2006/05/26 19:17:21 mrg Exp $
3 # from: NetBSD: mknative,v 1.12 2003/03/05 06:17:17 mrg Exp
5 # shell-fragment common to all "mknative" scripts
7 bomb()
9         echo >&2 "ABORT: $*"
10         exit 1
13 # Make sure we can run OK.
14 if [ -x "$MAKE" ]; then
15         :
16 else
17         bomb "MAKE not set"
20 # usage: getvars MAKEFILE VARNAME [VARNAME...]
22 getvars()
24         _mf="$1"; shift
25         case "$MAKE" in
26         *gmake)
27         env MAKEFLAGS= $MAKE -f - -f "$_TMPDIR/$_mf" _x_ <<EOF || bomb "getvars $_mf $* failed"
28 define echo_var
29         @echo G_\${var}="\${\${var}}" | sed -e 's,\([^\.]\)\./\([a-zA-Z0-9_-]*\.o\),\1\2,g' -e 's,$_VPATH,\$\${GNUHOSTDIST},g' -e 's,$_GNU_DIST,\$\${GNUHOSTDIST},g'
31 endef
32 _x_:
33         \$(foreach var,$*,\$(echo_var))
34 EOF
35                 ;;
36         *)
37         $MAKE -B -f - _x_ <<EOF || bomb "getvars $_mf $* failed"
38 _x_:
39 .for var in $*
40         @echo G_\${var}=\${\${var}:Q} | sed -e 's,\([^\.]\)\./\([a-zA-Z0-9_-]*\.o\),\1\2,g' -e 's,$_VPATH,\$\${GNUHOSTDIST},g' -e 's,$_GNU_DIST,\$\${GNUHOSTDIST},g'
41 .endfor
42 .include "$_TMPDIR/$_mf"
43 EOF
44         ;;
45         esac
48 # usage: write_c FILENAME
50 write_c()
52         echo '/* This file is automatically generated.  DO NOT EDIT! */' >$_TOP/$1.tmp || \
53                 bomb "cannot create $1"
54         grep '$''NetBSD' $0 | sed 's,[#$],,g;s,.*,/* Generated from: & */,' >>$_TOP/$1.tmp
55         echo '$NetBSD: mknative.common,v 1.8 2006/05/26 19:17:21 mrg Exp $' | sed 's,[#$],,g;s,.*,/* Generated from: & */,' >>$_TOP/$1.tmp
56         echo '' >>$_TOP/$1.tmp
57         writefile $1
60 # usage: write_mk FILENAME
62 write_mk()
64         echo '# This file is automatically generated.  DO NOT EDIT!' >$_TOP/$1.tmp || \
65                 bomb "cannot create $1"
66         grep '$''NetBSD' $0 | sed 's,[#$],,g;s,.*,# Generated from: &,' >>$_TOP/$1.tmp
67         echo '$NetBSD: mknative.common,v 1.8 2006/05/26 19:17:21 mrg Exp $' | sed 's,[#$],,g;s,.*,# Generated from: &,' >>$_TOP/$1.tmp
68         echo '#' >>$_TOP/$1.tmp
69         writefile $1
72 writefile()
74         sed -e 's,netbsd\(elf\)*1[0-9\.]*\(_\)*[A-Z]*,netbsd\1,' \
75             -e 's,^/\* #undef HAVE_MMAP \*/$,#define HAVE_MMAP 1,' \
76             >>$_TOP/$1.tmp
78                 # Compare new file, sans "generated from" comments and RCS Id,
79                 # to old file.  If they match, don't change anything.
80         rm -f $_TMPDIR/.1 $_TMPDIR/.2
81         grep -v 'Generated from:' $_TOP/$1 >$_TMPDIR/.1 2>/dev/null
82         grep -v 'Generated from:' $_TOP/$1.tmp >$_TMPDIR/.2
84                 # will not overwrite a file that has the same content
85         if cmp $_TMPDIR/.1 $_TMPDIR/.2 >/dev/null 2>&1; then
86                 rm -f $_TOP/$1.tmp
87         else
88                 echo >&2 "$1 changed"
89                 mv -f $_TOP/$1.tmp $_TOP/$1
90         fi