1 # $NetBSD: mknative.common,v 1.11 2014/02/17 21:39:43 christos Exp $
3 # from: NetBSD: mknative,v 1.12 2003/03/05 06:17:17 mrg Exp
5 # shell-fragment common to all "mknative" scripts
13 # Make sure we can run OK.
14 if [ -x "$MAKE" ]; then
20 # usage: getvars MAKEFILE VARNAME [VARNAME...]
27 env MAKEFLAGS= $MAKE --quiet -f - -f "$_TMPDIR/$_mf" _x_ <<EOF || bomb "getvars $_mf $* failed"
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'
33 \$(foreach var,$*,\$(echo_var))
37 $MAKE -B -f - _x_ <<EOF || bomb "getvars $_mf $* failed"
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'
42 .include "$_TMPDIR/$_mf"
48 # usage: getlinks <config.status> <subdir>
54 echo -n G_CONFIGLINKS=
55 grep "^config_links=" $_cs | sed -e 's@config_links="\([^"]*\)"@\1@g' -e "s@\([^:]*\):\([^ ]*\)@\${GNUHOSTDIST}/${_dir}/\2 \1 @g"
58 # usage: write_c FILENAME
62 echo '/* This file is automatically generated. DO NOT EDIT! */' >$_TOP/$1.tmp || \
63 bomb "cannot create $1"
64 grep '$''NetBSD' $0 | sed 's,[ #$],,g;s,.*,/* Generated from: & */,' >>$_TOP/$1.tmp
65 echo '$NetBSD: mknative.common,v 1.11 2014/02/17 21:39:43 christos Exp $' | sed 's,[#$],,g;s,.*,/* Generated from: & */,' >>$_TOP/$1.tmp
66 echo '' >>$_TOP/$1.tmp
70 # usage: write_mk FILENAME
74 echo '# This file is automatically generated. DO NOT EDIT!' >$_TOP/$1.tmp || \
75 bomb "cannot create $1"
76 grep '$''NetBSD' $0 | sed 's,[ #$],,g;s,.*,# Generated from: &,' >>$_TOP/$1.tmp
77 echo '$NetBSD: mknative.common,v 1.11 2014/02/17 21:39:43 christos Exp $' | sed 's,[#$],,g;s,.*,# Generated from: &,' >>$_TOP/$1.tmp
78 echo '#' >>$_TOP/$1.tmp
84 sed -e 's,netbsd\(elf\)*1[0-9\.]*\(_\)*[A-Z]*,netbsd\1,' \
85 -e 's,^/\* #undef HAVE_MMAP \*/$,#define HAVE_MMAP 1,' \
88 # Compare new file, sans "generated from" comments and RCS Id,
89 # to old file. If they match, don't change anything.
90 rm -f $_TMPDIR/.1 $_TMPDIR/.2
91 grep -v 'Generated from:' $_TOP/$1 >$_TMPDIR/.1 2>/dev/null
92 grep -v 'Generated from:' $_TOP/$1.tmp >$_TMPDIR/.2
94 # will not overwrite a file that has the same content
95 if cmp $_TMPDIR/.1 $_TMPDIR/.2 >/dev/null 2>&1; then
99 mv -f $_TOP/$1.tmp $_TOP/$1