# po2tbl.sed.in is invalid on MSDOS.
s|po2tbl\.sed\.in|po2tblsed.in|g

# .deps is invalid on MSDOS.
s|\.deps|_deps|g

# Additional editing of Makefiles
/^ *(echo ':t/ c\
      (echo '\
#  DJGPP specific Makefile changes.\
  /^aliaspath *	*=/s,:,";",g\
  /^lispdir *	*=/ c\\\
lispdir = $(prefix)/gnu/emacs/site-lisp\
  /TEXINPUTS=/s,:,";",g\
  /PATH=/s,:,";",g\
  s,\\.old\\.,_old.,g\
  s,po2tbl\\.sed\\.in,po2tblsed.in,g\
  s,config\\.h\\.in,config.h-in,g\
  s,\\.tab\\.c,_tab.c,g\
  s,\\.tab\\.h,_tab.h,g\
  s,Makefile\\.in\\.in,Makefile.in-in,g\
  s,Makefile\\.am\\.in,Makefile.am-in,g\
  s,\\.env-warn,_env-warn,g\
  s,jm-winsz\\([12]\\)\\.m4,jm\\1-winsz.m4,g\
  s,NN-strne-\\([12]\\)\\.,NN\\1-strne.,g\
  s,N-strne-\\([12]\\)\\.,N\\1-strne.,g\
  s,NN-streq-\\([12]\\)\\.,NN\\1q-stre.,g\
  s,N-streq-\\([12]\\)\\.,N\\1q-stre.,g\
  s,date2sec-\\([01]\\)\\.,d2sec-\\1.,g\
  s,date2sec-0a\\.,d2sec-0a.,g\
  s,ref-add\\.sed\\.in,ref-add-sed.in,g\
  s,ref-del\\.sed\\.in,ref-del-sed.in,g\
  s,relative-\\([12]\\)\\.X,relat-\\1.X,g\
  s,charset\\.alias,charset.al,g\
  /^\\.c\\.o:/,/^$/ s,`test -f .*`,,\
  /^\\.sin\\.sed:/,/^$/ s,\\$@-t,t-$@,\
  /^MANS *=.*$/ s,=.*$,=,\
  /^install-info-am:/,/^$/ {\
    /@list=/ s,\\\$(INFO_DEPS),& sh-utils.i,\
    /@for *file/ s,\\\$(INFO_DEPS),& sh-utils.i,\
    s,file-\\[0-9\\]\\[0-9\\],& $$file[0-9] $$file[0-9][0-9],\
  }\
  /^\\.y\\.c:/,/^$/ {\
    /\\\$(YACC)/ {\
      s,[ 	]*&&.*$,,\
      a\\\
	-@test -f y_tab.c && mv -f y_tab.c $*.c\\\
	-@test -f y.tab.c && mv -f y.tab.c $*.c\\\
	-@test -f y.tab.h && mv -f y.tab.h y_tab.h\
    }\
  }\
  /^ *bin_PROGRAMS *=/,/stty/ {\
    s/ *stty//\
  }\
  s/^\\( *bin_SCRIPTS *=\\).*/\\1 /\
  /^bin_PROGRAMS[ 	]*=.*$/,/^$/ s,yes,& su,\
  /^install-exec-am:.*$/,/^$/ {\
    s,[ 	]\\+\\\\$,,\
    /install-exec-local$/ d\
  }\
  s/^check[ 	]*:[ 	]*\\\$(maint_gen)$/check: #\$(maint_gen)/\
:t

# Makefile.in.in is renamed to Makefile.in-in...
/config_files="/,/^$/ {
  s|po/Makefile\.in|&:po/Makefile.in-in|
}

# ...and config.h.in into config.h-in
/config_headers="/,/^$/ {
  s|config\.h|&:config.h-in|
}

# Makefile.in.in is renamed to Makefile.in-in
# and config.h.in into config.h-in
/# Handling of arguments./,/^$/ {
  s|po/Makefile\.in|&:po/Makefile.in-in|2
  s|config\.h|&:config.h-in|2
}

# Replace (command) > /dev/null with `command > /dev/null`, since
# parenthesized commands always return zero status in the ported Bash,
# even if the named command doesn't exist
/if ([^|;]*null/{
  s,(,`,
  s,),,
  s,;  *then,`; then,
}

# Rename `conftest.defines.hdr' and `conftest.undefs.hdr' in
# `conftest.defines_hdr' and `conftest.undefs_hdr'.
s|\$ac_cs_root\.hdr|${ac_cs_root}_hdr|g

# DOS-style absolute file names should be supported as well
/\*) srcdir=/s,/\*,[\\\\/]* | [A-z]:[\\\\/]*,
/\$]\*) INSTALL=/s,\[/\$\]\*,[\\\\/$]* | [A-z]:[\\\\/]*,
/\$]\*) ac_rel_source=/s,\[/\$\]\*,[\\\\/$]* | [A-z]:[\\\\/]*,

# Switch the order of the two Sed commands, since DOS path names
# could include a colon
# This matches the configure script produced by Autoconf 2.12
/ac_file_inputs=/s,\( -e "s%\^%\$ac_given_srcdir/%"\)\( -e "s%:% $ac_given_srcdir/%g"\),\2\1,
# This matches the configure script produced by Autoconf 2.14a
/ac_file_inputs=/,/^EOF/s,\(s%\^%\$ac_given_srcdir/%\);\(s%:% \$ac_given_srcdir/%g\),\2;\1,

# Prevent the spliting of conftest.subs.
# The sed script: conftest.subs or $ac_cs_root.subs is split into 90 or 48 lines long files.
# This will produce sed scripts called conftest.s1, conftest.s2, etc. or similar
# that will not work if conftest.subs contains a multi line sed command
# at line #90. In this case the first part of the sed command will be the
# last line of conftest.s1 and the rest of the command will be the first lines
# of conftest.s2. So both script will not work properly. For GNU sed and GNU bash
# this splitting is not needed at all and will be suppresed.
# This matches the configure script produced by Autoconf 2.14a
/ac_max_sed_lines=[0-9]/ s,=.*$,=`sed -n "$=" $tmp/subs.sed`,

# We prefer gettext__ instead of gettext.
/checking for gettext in -lintl/,/^EOF$/ s,gettext[ 	]*(,gettext__(,g

# The following two items are changes needed for configuring
# and compiling across partitions.
# 1) The given srcdir value is always translated from the
#    "x:" syntax into "/dev/x" syntax while we run configure.
/^[ 	]*-srcdir=\*.*$/ a\
    ac_optarg=`echo "$ac_optarg" | sed "s,^\\([A-Za-z]\\):,/dev/\\1,"`
/set X `ls -Lt \$srcdir/ i\
   if `echo $srcdir | grep "^/dev/" - > /dev/null`; then\
     srcdir=`echo "$srcdir" | sed -e "s%^/dev/%%" -e "s%/%:/%"`\
   fi

#  2) We need links across partitions, so we will use "cp -pf" instead of "ln".
/# Make a symlink if possible; otherwise try a hard link./,/EOF/ {
  s,;.*then, 2>/dev/null || cp -pf \$srcdir/\$ac_source \$ac_dest&,
}

# DJGPP symbolik links always appends an .exe extension.
# This cause difficulties on plain DOS so we remove the .sym extension.
/ln -s conftest.file conftest.sym/ s|\.sym||
/lstat ("conftest.sym\/", &sbuf) ? 0 : 1/ s|\.sym|.exe|

# DJGPP's port of gettext 0.10.36 makes use of libiconv.a to recode
# on the fly .gmo files from UNIX charset to MSDOS codepage. This implies
# that in all link phases, -liconv MUST be added to -lintl.
/bindtextdomain[ 	]*in[ 	]*-lintl/,/failed[ 	]*program[ 	]*was:/ s,eval[ 	]*\$ac_link,& -liconv,
# /gettext[ 	]*in[ 	]*libintl/,/failed[ 	]*program[ 	]*was:/ s,eval[ 	]*\$ac_link,& -liconv,
/gettext[ 	]*in[ 	]*-lintl/,/failed[ 	]*program[ 	]*was:/ s,eval[ 	]*\$ac_link,& -liconv,
/HAVE_LIBINTL[ 	]*1/,/fi/ {
  /LIBS=/ s,-lintl,& -liconv,
}
