home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 4 / FreshFish_May-June1994.bin / bbs / gnu / gcc-2.3.3-src.lha / src / amiga / gcc-2.3.3 / fixinc.svr4 < prev    next >
Encoding:
Text File  |  1994-02-07  |  30.5 KB  |  1,261 lines

  1. #! /bin/sh
  2. #
  3. #   fixinc.svr4  --  Install modified versions of certain ANSI-incompatible
  4. #   native System V Release 4 system include files.
  5. #
  6. #   Written by Ron Guilmette (rfg@ncd.com).
  7. #
  8. # This file is part of GNU CC.
  9. # GNU CC is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation; either version 2, or (at your option)
  12. # any later version.
  13. # GNU CC is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. # GNU General Public License for more details.
  17. # You should have received a copy of the GNU General Public License
  18. # along with GNU CC; see the file COPYING.  If not, write to
  19. # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  20. #
  21. #    This script munges the native include files provided with System V
  22. #    Release 4 systems so as to remove things which are violations of the
  23. #    ANSI C standard.  Once munged, the resulting new system include files
  24. #    are placed in a directory that GNU C will search *before* searching
  25. #    the /usr/include directory. This script should work properly for most
  26. #    System V Release 4 systems.  For other types of systems, you should
  27. #    use the `fixincludes' script instead.
  28. #
  29. #    See README-fixinc for more information.
  30.  
  31. # Directory where gcc sources (and sometimes special include files) live.
  32. SRCDIR=${3-${SRCDIR-.}}
  33.  
  34. # Directory containing the original header files.
  35. INPUT=${2-${INPUT-/usr/include}}
  36.  
  37. # Fail if no arg to specify a directory for the output.
  38. if [ x$1 = x ]
  39. then echo fixincludes: no output directory specified
  40. exit 1
  41. fi
  42.  
  43. # Directory in which to store the results.
  44. LIB=${1?"fixincludes: output directory not specified"}
  45.  
  46. # Make sure it exists.
  47. if [ ! -d $LIB ]; then
  48.   mkdir $LIB || exit 1
  49. fi
  50.  
  51. ORIG_DIR=`pwd`
  52.  
  53. # Make LIB absolute.
  54. cd $LIB; LIB=`pwd`
  55.  
  56. # This prevents /bin/ex from failing if the current terminal type is
  57. # unrecognizable.
  58. TERM=dumb
  59. export TERM
  60. # This prevents /bin/ex from failing if the EXINIT environment variable
  61. # was set to something invalid.
  62. EXINIT=""
  63. export EXINIT
  64.  
  65. echo 'Building fixincludes in ' ${LIB}
  66.  
  67. # Determine whether this filesystem has symbolic links.
  68. if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
  69.   rm -f $LIB/ShouldNotExist
  70.   LINKS=true
  71. else
  72.   LINKS=false
  73. fi
  74.  
  75. echo 'Making directories:'
  76. cd ${INPUT}
  77. if $LINKS; then
  78.   files=`ls -LR | sed -n s/:$//p`
  79. else
  80.   files=`find . -type d -print | sed '/^.$/d'`
  81. fi
  82. for file in $files; do
  83.   rm -rf $LIB/$file
  84.   if [ ! -d $LIB/$file ]
  85.   then mkdir $LIB/$file
  86.   fi
  87. done
  88.  
  89. # treetops gets an alternating list
  90. # of old directories to copy
  91. # and the new directories to copy to.
  92. treetops="${INPUT} ${LIB}"
  93.  
  94. if $LINKS; then
  95.   echo 'Making internal symbolic directory links'
  96.   for file in $files; do
  97.     dest=`ls -ld $file | sed -n 's/.*-> //p'`
  98.     if [ "$dest" ]; then    
  99.       cwd=`pwd`
  100.       # In case $dest is relative, get to $file's dir first.
  101.       cd ${INPUT}
  102.       cd `echo ./$file | sed -n 's&[^/]*$&&p'`
  103.       # Check that the target directory exists.
  104.       # Redirections changed to avoid bug in sh on Ultrix.
  105.       (cd $dest) > /dev/null 2>&1
  106.       if [ $? = 0 ]; then
  107.     cd $dest
  108.     # X gets the dir that the link actually leads to.
  109.     x=`pwd`
  110.     # If link leads back into ${INPUT},
  111.     # make a similar link here.
  112.     if expr $x : "${INPUT}/.*" > /dev/null; then
  113.       # Y gets the actual target dir name, relative to ${INPUT}.
  114.       y=`echo $x | sed -n "s&${INPUT}/&&p"`
  115.       echo $file '->' $y ': Making link'
  116.       rm -fr ${LIB}/$file > /dev/null 2>&1
  117.       ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
  118.     else
  119.       # If the link is to outside ${INPUT},
  120.       # treat this directory as if it actually contained the files.
  121. # This line used to have $dest instead of $x.
  122. # $dest seemed to be wrong for links found in subdirectories
  123. # of ${INPUT}.  Does this change break anything?
  124.       treetops="$treetops $x ${LIB}/$file"
  125.     fi
  126.       fi
  127.       cd $cwd
  128.     fi
  129.   done
  130. fi
  131.  
  132. set - $treetops
  133. while [ $# != 0 ]; do
  134.   # $1 is an old directory to copy, and $2 is the new directory to copy to.
  135.   echo "Finding header files in $1:"
  136.   cd ${INPUT}
  137.   cd $1
  138.   files=`find . -name '*.h' -type f -print`
  139.   echo 'Checking header files:'
  140.   for file in $files; do
  141.       echo Fixing $file
  142.       if [ -r $file ]; then
  143.     cp $file $2/$file >/dev/null 2>&1 || echo "Can't copy $file"
  144.     chmod +w $2/$file
  145.  
  146. # The following have been removed from the sed command below
  147. # because it is more useful to leave these things in.
  148. # The only reason to remove them was for -pedantic,
  149. # which isn't much of a reason. -- rms.
  150. #      /^[     ]*#[     ]*ident/d
  151.  
  152. # This code makes Solaris SCSI fail, because it changes the
  153. # alignment within some critical structures.  See <sys/scsi/impl/commands.h>.
  154. #      s/u_char\([     ][     ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[     ]*:[     ]*[0-9][0-9]*\)/u_int\1/
  155. # Disable these also, since they probably aren't safe either.
  156. #      s/u_short\([     ][     ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[     ]*:[     ]*[0-9][0-9]*\)/u_int\1/
  157. #      s/ushort\([     ][     ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[     ]*:[     ]*[0-9][0-9]*\)/u_int\1/
  158. #      s/evcm_t\([     ][     ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[     ]*:[     ]*[0-9][0-9]*\)/u_int\1/
  159. #      s/Pbyte\([     ][     ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[     ]*:[     ]*SEQSIZ\)/unsigned int\1/
  160.  
  161. # The change of u_char, etc, to u_int
  162. # applies to bit fields.
  163.     sed -e '
  164.       s%^\([     ]*#[     ]*endif[     ]*\)\([^/     ].*\)$%\1/* \2 */%
  165.       s%^\([     ]*#[     ]*else[     ]*\)\([^/     ].*\)$%\1/* \2 */%
  166.         s/#lint(on)/defined(lint)/g
  167.         s/#lint(off)/!defined(lint)/g
  168.         s/#machine(\([^)]*\))/defined(__\1__)/g
  169.         s/#system(\([^)]*\))/defined(__\1__)/g
  170.         s/#cpu(\([^)]*\))/defined(__\1__)/g
  171.       /#[a-z]*if.*[     (]m68k/        s/\([^_]\)m68k/\1__m68k__/g
  172.       /#[a-z]*if.*[     (]__i386\([^_]\)/    s/__i386/__i386__/g
  173.       /#[a-z]*if.*[     (]i386/        s/\([^_]\)i386/\1__i386__/g
  174.       /#[a-z]*if.*[     (]sparc/    s/\([^_]\)sparc/\1__sparc__/g
  175.       /#[a-z]*if.*[     (]mc68000/    s/\([^_]\)mc68000/\1__mc68000__/g
  176.       /#[a-z]*if.*[     (]vax/        s/\([^_]\)vax/\1__vax__/g
  177.       /#[a-z]*if.*[     (]sun/        s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
  178.       /#[a-z]*if.*[     (]sun/        s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
  179.       /#[a-z]*if.*[     (]ns32000/    s/\([^_]\)ns32000/\1__ns32000__/g
  180.       /#[a-z]*if.*[     (]pyr/        s/\([^_]\)pyr/\1__pyr__/g
  181.       /#[a-z]*if.*[     (]is68k/    s/\([^_]\)is68k/\1__is68k__/g
  182.       s/__STDC__ == 0/!defined (__STRICT_ANSI__)/g
  183.       s/__STDC__ != 0/defined (__STRICT_ANSI__)/g
  184.       s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
  185.     ' $2/$file > $2/$file.sed
  186.     mv $2/$file.sed $2/$file
  187.     if cmp $file $2/$file >/dev/null 2>&1; then
  188.        echo Deleting $2/$file\; no fixes were needed.
  189.        rm $2/$file
  190.     fi
  191.       fi
  192.   done
  193.   shift; shift
  194. done
  195.  
  196. # Fix first broken decl of getcwd present on some svr4 systems.
  197.  
  198. file=stdlib.h
  199. base=`basename $file`
  200. if [ -r ${LIB}/$file ]; then
  201.   file_to_fix=${LIB}/$file
  202. else
  203.   if [ -r ${INPUT}/$file ]; then
  204.     file_to_fix=${INPUT}/$file
  205.   else
  206.     file_to_fix=""
  207.   fi
  208. fi
  209. if [ \! -z "$file_to_fix" ]; then
  210.   echo Checking $file_to_fix
  211.   sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base
  212.   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
  213.     echo No change needed in $file_to_fix
  214.   else
  215.     echo Fixed $file_to_fix
  216.     rm -f ${LIB}/$file
  217.     cp /tmp/$base ${LIB}/$file
  218.   fi
  219.   rm -f /tmp/$base
  220. fi
  221.  
  222. # Fix second broken decl of getcwd present on some svr4 systems.  Also
  223. # fix the incorrect decl of profil present on some svr4 systems.
  224.  
  225. file=unistd.h
  226. base=`basename $file`
  227. if [ -r ${LIB}/$file ]; then
  228.   file_to_fix=${LIB}/$file
  229. else
  230.   if [ -r ${INPUT}/$file ]; then
  231.     file_to_fix=${INPUT}/$file
  232.   else
  233.     file_to_fix=""
  234.   fi
  235. fi
  236. if [ \! -z "$file_to_fix" ]; then
  237.   echo Checking $file_to_fix
  238.   sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
  239.     | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base
  240.   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
  241.     echo No change needed in $file_to_fix
  242.   else
  243.     echo Fixed $file_to_fix
  244.     rm -f ${LIB}/$file
  245.     cp /tmp/$base ${LIB}/$file
  246.   fi
  247.   rm -f /tmp/$base
  248. fi
  249.  
  250. # Fix the definition of NULL in <sys/param.h> so that it is conditional
  251. # and so that it is correct for both C and C++.
  252.  
  253. file=sys/param.h
  254. base=`basename $file`
  255. if [ -r ${LIB}/$file ]; then
  256.   file_to_fix=${LIB}/$file
  257. else
  258.   if [ -r ${INPUT}/$file ]; then
  259.     file_to_fix=${INPUT}/$file
  260.   else
  261.     file_to_fix=""
  262.   fi
  263. fi
  264. if [ \! -z "$file_to_fix" ]; then
  265.   echo Checking $file_to_fix
  266.   cp $file_to_fix /tmp/$base
  267.   chmod +w /tmp/$base
  268.   ex /tmp/$base <<EOF
  269.   /^#define[     ]*NULL[     ]*0$/c
  270. #ifndef NULL
  271. #ifdef __cplusplus
  272. #define __NULL_TYPE
  273. #else /* !defined(__cplusplus) */
  274. #define __NULL_TYPE (void *)
  275. #endif /* !defined(__cplusplus) */
  276. #define NULL (__NULL_TYPE 0)
  277. #endif /* !defined(NULL) */
  278. .
  279.   wq
  280. EOF
  281.   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
  282.     echo No change needed in $file_to_fix
  283.   else
  284.     echo Fixed $file_to_fix
  285.     rm -f ${LIB}/$file
  286.     cp /tmp/$base ${LIB}/$file
  287.   fi
  288.   rm -f /tmp/$base
  289. fi
  290.  
  291. # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
  292. # and so that it is correct for both C and C++.
  293.  
  294. file=stdio.h
  295. base=`basename $file`
  296. if [ -r ${LIB}/$file ]; then
  297.   file_to_fix=${LIB}/$file
  298. else
  299.   if [ -r ${INPUT}/$file ]; then
  300.     file_to_fix=${INPUT}/$file
  301.   else
  302.     file_to_fix=""
  303.   fi
  304. fi
  305. if [ \! -z "$file_to_fix" ]; then
  306.   echo Checking $file_to_fix
  307.   cp $file_to_fix /tmp/$base
  308.   chmod +w /tmp/$base
  309.   ex /tmp/$base <<EOF
  310.   /^#define[     ]*NULL[     ]*0$/c
  311. #ifdef __cplusplus
  312. #define __NULL_TYPE
  313. #else /* !defined(__cplusplus) */
  314. #define __NULL_TYPE (void *)
  315. #endif /* !defined(__cplusplus) */
  316. #define NULL (__NULL_TYPE 0)
  317. .
  318.   wq
  319. EOF
  320.   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
  321.     echo No change needed in $file_to_fix
  322.   else
  323.     echo Fixed $file_to_fix
  324.     rm -f ${LIB}/$file
  325.     cp /tmp/$base ${LIB}/$file
  326.   fi
  327.   rm -f /tmp/$base
  328. fi
  329.  
  330. # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
  331. # and so that it is correct for both C and C++.
  332.  
  333. file=dbm.h
  334. base=`basename $file`
  335. if [ -r ${LIB}/$file ]; then
  336.   file_to_fix=${LIB}/$file
  337. else
  338.   if [ -r ${INPUT}/$file ]; then
  339.     file_to_fix=${INPUT}/$file
  340.   else
  341.     file_to_fix=""
  342.   fi
  343. fi
  344. if [ \! -z "$file_to_fix" ]; then
  345.   echo Checking $file_to_fix
  346.   cp $file_to_fix /tmp/$base
  347.   chmod +w /tmp/$base
  348.   ex /tmp/$base <<EOF
  349.   /^#define[     ]*NULL[     ]*((char \*) 0)$/c
  350. #ifndef NULL
  351. #ifdef __cplusplus
  352. #define __NULL_TYPE
  353. #else /* !defined(__cplusplus) */
  354. #define __NULL_TYPE (void *)
  355. #endif /* !defined(__cplusplus) */
  356. #define NULL (__NULL_TYPE 0)
  357. #endif /* !defined(NULL) */
  358. .
  359.   wq
  360. EOF
  361.   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
  362.     echo No change needed in $file_to_fix
  363.   else
  364.     echo Fixed $file_to_fix
  365.     rm -f ${LIB}/$file
  366.     cp /tmp/$base ${LIB}/$file
  367.   fi
  368.   rm -f /tmp/$base
  369. fi
  370.  
  371. # Add a prototyped declaration of mmap to <sys/mman.h>.
  372.  
  373. file=sys/mman.h
  374. base=`basename $file`
  375. if [ -r ${LIB}/$file ]; then
  376.   file_to_fix=${LIB}/$file
  377. else
  378.   if [ -r ${INPUT}/$file ]; then
  379.     file_to_fix=${INPUT}/$file
  380.   else
  381.     file_to_fix=""
  382.   fi
  383. fi
  384. if [ \! -z "$file_to_fix" ]; then
  385.   echo Checking $file_to_fix
  386.   cp $file_to_fix /tmp/$base
  387.   chmod +w /tmp/$base
  388.   ex /tmp/$base <<EOF
  389.   /^extern caddr_t mmap();$/c
  390. #ifdef __STDC__
  391. extern caddr_t mmap (caddr_t addr, size_t len, int prot, int flags,
  392.                      int fd, off_t off);
  393. #else /* !defined(__STDC__) */
  394. extern caddr_t mmap ();
  395. #endif /* !defined(__STDC__) */
  396. .
  397.   wq
  398. EOF
  399.   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
  400.     echo No changed needed in $file_to_fix
  401.   else
  402.     echo Fixed $file_to_fix
  403.     rm -f ${LIB}/$file
  404.     cp /tmp/$base ${LIB}/$file
  405.   fi
  406.   rm -f /tmp/$base
  407. fi
  408.  
  409. # Fix declarations of `ftw' and `nftw' in <ftw.h>.
  410.  
  411. file=ftw.h
  412. base=`basename $file`
  413. if [ -r ${LIB}/$file ]; then
  414.   file_to_fix=${LIB}/$file
  415. else
  416.   if [ -r ${INPUT}/$file ]; then
  417.     file_to_fix=${INPUT}/$file
  418.   else
  419.     file_to_fix=""
  420.   fi
  421. fi
  422. if [ \! -z "$file_to_fix" ]; then
  423.   echo Checking $file_to_fix
  424.   cp $file_to_fix /tmp/$base
  425.   chmod +w /tmp/$base
  426.   ex /tmp/$base <<EOF
  427.   /^extern int ftw(const/c
  428. #if !defined(_STYPES)
  429. static
  430. #else
  431. extern
  432. #endif
  433.   int ftw(const char *, int (*)(const char *, const struct stat *, int), int);
  434. .
  435.   /^extern int nftw/c
  436. #if defined(_STYPES)
  437. static
  438. #else
  439. extern
  440. #endif
  441.   int nftw(const char *, int (*)(const char *, const struct stat *, int, struct FTW *),int, int);
  442. .
  443.   /^extern int ftw(),/c
  444. #if !defined(_STYPES)
  445. static
  446. #else
  447. extern
  448. #endif
  449.   int ftw();
  450. #if defined(_STYPES)
  451. static
  452. #else
  453. extern
  454. #endif
  455.   int nftw();
  456. .
  457.   wq
  458. EOF
  459.   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
  460.     echo No change needed in $file_to_fix
  461.   else
  462.     echo Fixed $file_to_fix
  463.     rm -f ${LIB}/$file
  464.     cp /tmp/$base ${LIB}/$file
  465.   fi
  466.   rm -f /tmp/$base
  467. fi
  468.  
  469. # Add a `static' declaration of `getrnge' into <regexp.h>.
  470.  
  471. # Don't do this if there is already a `static void getrnge' declaration
  472. # present, since this would cause a redeclaration error.  Solaris 2.x has
  473. # such a declaration.
  474.  
  475. file=regexp.h
  476. base=`basename $file`
  477. if [ -r ${LIB}/$file ]; then
  478.   file_to_fix=${LIB}/$file
  479. else
  480.   if [ -r ${INPUT}/$file ]; then
  481.     file_to_fix=${INPUT}/$file
  482.   else
  483.     file_to_fix=""
  484.   fi
  485. fi
  486. if [ \! -z "$file_to_fix" ]; then
  487.   echo Checking $file_to_fix
  488.   if grep "static void getrnge" $file_to_fix > /dev/null; then
  489.     true
  490.   else
  491.     cp $file_to_fix /tmp/$base
  492.     chmod +w /tmp/$base
  493.     ex /tmp/$base <<EOF
  494.     /^static int[     ]*size;/c
  495. static int    size ;
  496.  
  497. static int getrnge ();
  498. .
  499.     wq
  500. EOF
  501.     if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
  502.       No change needed in $file_to_fix
  503.     else
  504.       echo Fixed $file_to_fix
  505.       rm -f ${LIB}/$file
  506.       cp /tmp/$base ${LIB}/$file
  507.     fi
  508.   fi
  509.   rm -f /tmp/$base
  510. fi
  511.  
  512. # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
  513. # that is visible to any ANSI compiler using this include.  Simply
  514. # delete the lines the #define some string functions to internal forms.
  515.  
  516. file=string.h
  517. base=`basename $file`
  518. if [ -r ${LIB}/$file ]; then
  519.   file_to_fix=${LIB}/$file
  520. else
  521.   if [ -r ${INPUT}/$file ]; then
  522.     file_to_fix=${INPUT}/$file
  523.   else
  524.     file_to_fix=""
  525.   fi
  526. fi
  527. if [ \! -z "$file_to_fix" ]; then
  528.   echo Checking $file_to_fix
  529.   cp $file_to_fix /tmp/$base
  530.   chmod +w /tmp/$base
  531.   ex /tmp/$base <<EOF
  532.   g/#define.*__std_hdr_/d
  533.   wq
  534. EOF
  535.   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
  536.     echo No change needed in $file_to_fix
  537.   else
  538.     echo Fixed $file_to_fix
  539.     rm -f ${LIB}/$file
  540.     cp /tmp/$base ${LIB}/$file
  541.   fi
  542.   rm -f /tmp/$base
  543. fi
  544.  
  545. # Add a #define of _SIGACTION_ into <sys/signal.h>.
  546. # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
  547.  
  548. file=sys/signal.h
  549. base=`basename $file`
  550. if [ -r ${LIB}/$file ]; then
  551.   file_to_fix=${LIB}/$file
  552. else
  553.   if [ -r ${INPUT}/$file ]; then
  554.     file_to_fix=${INPUT}/$file
  555.   else
  556.     file_to_fix=""
  557.   fi
  558. fi
  559. if [ \! -z "$file_to_fix" ]; then
  560.   echo Checking $file_to_fix
  561.   cp $file_to_fix /tmp/$base
  562.   chmod +w /tmp/$base
  563.   ex /tmp/$base <<EOF
  564.   /^struct sigaction {/c
  565. #define _SIGACTION_
  566. struct  sigaction  {
  567. .
  568.   1,\$s/(void *(\*)())/(void (*)(int))/
  569.   wq
  570. EOF
  571.   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
  572.     echo No change needed in $file_to_fix
  573.   else
  574.     echo Fixed $file_to_fix
  575.     rm -f ${LIB}/$file
  576.     cp /tmp/$base ${LIB}/$file
  577.   fi
  578.   rm -f /tmp/$base
  579. fi
  580.  
  581. # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
  582.  
  583. file=sys/mkdev.h
  584. base=`basename $file`
  585. if [ -r ${LIB}/$file ]; then
  586.   file_to_fix=${LIB}/$file
  587. else
  588.   if [ -r ${INPUT}/$file ]; then
  589.     file_to_fix=${INPUT}/$file
  590.   else
  591.     file_to_fix=""
  592.   fi
  593. fi
  594. if [ \! -z "$file_to_fix" ]; then
  595.   echo Checking $file_to_fix
  596.   cp $file_to_fix /tmp/$base
  597.   chmod +w /tmp/$base
  598.   ex /tmp/$base <<EOF
  599.   /^dev_t makedev(const/c
  600. static dev_t makedev(const major_t, const minor_t);
  601. .
  602.   /^dev_t makedev()/c
  603. static dev_t makedev();
  604. .
  605.   /^major_t major(const/c
  606. static major_t major(const dev_t);
  607. .
  608.   /^major_t major()/c
  609. static major_t major();
  610. .
  611.   /^minor_t minor(const/c
  612. static minor_t minor(const dev_t);
  613. .
  614.   /^minor_t minor()/c
  615. static minor_t minor();
  616. .
  617.   wq
  618. EOF
  619.   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
  620.     echo No change needed in $file_to_fix
  621.   else
  622.     echo Fixed $file_to_fix
  623.     rm -f ${LIB}/$file
  624.     cp /tmp/$base ${LIB}/$file
  625.   fi
  626.   rm -f /tmp/$base
  627. fi
  628.  
  629. # Fix reference to NMSZ in <sys/adv.h>.
  630.  
  631. file=sys/adv.h
  632. base=`basename $file`
  633. if [ -r ${LIB}/$file ]; then
  634.   file_to_fix=${LIB}/$file
  635. else
  636.   if [ -r ${INPUT}/$file ]; then
  637.     file_to_fix=${INPUT}/$file
  638.   else
  639.     file_to_fix=""
  640.   fi
  641. fi
  642. if [ \! -z "$file_to_fix" ]; then
  643.   echo Checking $file_to_fix
  644.   sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base
  645.   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
  646.     echo No change needed in $file_to_fix
  647.   else
  648.     echo Fixed $file_to_fix
  649.     rm -f ${LIB}/$file
  650.     cp /tmp/$base ${LIB}/$file
  651.   fi
  652.   rm -f /tmp/$base
  653. fi
  654.  
  655. # Fix reference to NC_NPI_RAW in <sys/netcspace.h>.  Also fix types of
  656. # array initializers.
  657.  
  658. file=sys/netcspace.h
  659. base=`basename $file`
  660. if [ -r ${LIB}/$file ]; then
  661.   file_to_fix=${LIB}/$file
  662. else
  663.   if [ -r ${INPUT}/$file ]; then
  664.     file_to_fix=${INPUT}/$file
  665.   else
  666.     file_to_fix=""
  667.   fi
  668. fi
  669. if [ \! -z "$file_to_fix" ]; then
  670.   echo Checking $file_to_fix
  671.   sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
  672.     | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base
  673.   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
  674.     echo No change needed in $file_to_fix
  675.   else
  676.     echo Fixed $file_to_fix
  677.     rm -f ${LIB}/$file
  678.     cp /tmp/$base ${LIB}/$file
  679.   fi
  680.   rm -f /tmp/$base
  681. fi
  682.  
  683. # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
  684.  
  685. file=fs/rfs/rf_cache.h
  686. base=`basename $file`
  687. if [ -r ${LIB}/$file ]; then
  688.   file_to_fix=${LIB}/$file
  689. else
  690.   if [ -r ${INPUT}/$file ]; then
  691.     file_to_fix=${INPUT}/$file
  692.   else
  693.     file_to_fix=""
  694.   fi
  695. fi
  696. if [ \! -z "$file_to_fix" ]; then
  697.   echo Checking $file_to_fix
  698.   if grep _KERNEL $file_to_fix > /dev/null; then
  699.     echo No change needed in $file_to_fix
  700.   else
  701.     echo '#ifdef _KERNEL' > /tmp/$base
  702.     cat $file_to_fix >> /tmp/$base
  703.     echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
  704.     echo Fixed $file_to_fix
  705.     rm -f ${LIB}/$file
  706.     cp /tmp/$base ${LIB}/$file
  707.     rm -f /tmp/$base
  708.   fi
  709. fi
  710.  
  711. # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
  712.  
  713. file=sys/erec.h
  714. base=`basename $file`
  715. if [ -r ${LIB}/$file ]; then
  716.   file_to_fix=${LIB}/$file
  717. else
  718.   if [ -r ${INPUT}/$file ]; then
  719.     file_to_fix=${INPUT}/$file
  720.   else
  721.     file_to_fix=""
  722.   fi
  723. fi
  724. if [ \! -z "$file_to_fix" ]; then
  725.   echo Checking $file_to_fix
  726.   if grep _KERNEL $file_to_fix > /dev/null; then
  727.     echo No change needed in $file_to_fix
  728.   else
  729.     echo '#ifdef _KERNEL' > /tmp/$base
  730.     cat $file_to_fix >> /tmp/$base
  731.     echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
  732.     echo Fixed $file_to_fix
  733.     rm -f ${LIB}/$file
  734.     cp /tmp/$base ${LIB}/$file
  735.     rm -f /tmp/$base
  736.   fi
  737. fi
  738.  
  739. # Conditionalize all of <sys/err.h> on _KERNEL being defined.
  740.  
  741. file=sys/err.h
  742. base=`basename $file`
  743. if [ -r ${LIB}/$file ]; then
  744.   file_to_fix=${LIB}/$file
  745. else
  746.   if [ -r ${INPUT}/$file ]; then
  747.     file_to_fix=${INPUT}/$file
  748.   else
  749.     file_to_fix=""
  750.   fi
  751. fi
  752. if [ \! -z "$file_to_fix" ]; then
  753.   echo Checking $file_to_fix
  754.   if grep _KERNEL $file_to_fix > /dev/null; then
  755.     echo No change needed in $file_to_fix
  756.   else
  757.     echo '#ifdef _KERNEL' > /tmp/$base
  758.     cat $file_to_fix >> /tmp/$base
  759.     echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
  760.     echo Fixed $file_to_fix
  761.     rm -f ${LIB}/$file
  762.     cp /tmp/$base ${LIB}/$file
  763.     rm -f /tmp/$base
  764.   fi
  765. fi
  766.  
  767. # Conditionalize all of <sys/char.h> on _KERNEL being defined.
  768.  
  769. file=sys/char.h
  770. base=`basename $file`
  771. if [ -r ${LIB}/$file ]; then
  772.   file_to_fix=${LIB}/$file
  773. else
  774.   if [ -r ${INPUT}/$file ]; then
  775.     file_to_fix=${INPUT}/$file
  776.   else
  777.     file_to_fix=""
  778.   fi
  779. fi
  780. if [ \! -z "$file_to_fix" ]; then
  781.   echo Checking $file_to_fix
  782.   if grep _KERNEL $file_to_fix > /dev/null; then
  783.     echo No change needed in $file_to_fix
  784.   else
  785.     echo '#ifdef _KERNEL' > /tmp/$base
  786.     cat $file_to_fix >> /tmp/$base
  787.     echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
  788.     echo Fixed $file_to_fix
  789.     rm -f ${LIB}/$file
  790.     cp /tmp/$base ${LIB}/$file
  791.     rm -f /tmp/$base
  792.   fi
  793. fi
  794.  
  795. # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
  796.  
  797. file=sys/getpages.h
  798. base=`basename $file`
  799. if [ -r ${LIB}/$file ]; then
  800.   file_to_fix=${LIB}/$file
  801. else
  802.   if [ -r ${INPUT}/$file ]; then
  803.     file_to_fix=${INPUT}/$file
  804.   else
  805.     file_to_fix=""
  806.   fi
  807. fi
  808. if [ \! -z "$file_to_fix" ]; then
  809.   echo Checking $file_to_fix
  810.   if grep _KERNEL $file_to_fix > /dev/null; then
  811.     echo No change needed in $file_to_fix
  812.   else
  813.     echo '#ifdef _KERNEL' > /tmp/$base
  814.     cat $file_to_fix >> /tmp/$base
  815.     echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
  816.     echo Fixed $file_to_fix
  817.     rm -f ${LIB}/$file
  818.     cp /tmp/$base ${LIB}/$file
  819.     rm -f /tmp/$base
  820.   fi
  821. fi
  822.  
  823. # Conditionalize all of <sys/map.h> on _KERNEL being defined.
  824.  
  825. file=sys/map.h
  826. base=`basename $file`
  827. if [ -r ${LIB}/$file ]; then
  828.   file_to_fix=${LIB}/$file
  829. else
  830.   if [ -r ${INPUT}/$file ]; then
  831.     file_to_fix=${INPUT}/$file
  832.   else
  833.     file_to_fix=""
  834.   fi
  835. fi
  836. if [ \! -z "$file_to_fix" ]; then
  837.   echo Checking $file_to_fix
  838.   if grep _KERNEL $file_to_fix > /dev/null; then
  839.     echo No change needed in $file_to_fix
  840.   else
  841.     echo '#ifdef _KERNEL' > /tmp/$base
  842.     cat $file_to_fix >> /tmp/$base
  843.     echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
  844.     echo Fixed $file_to_fix
  845.     rm -f ${LIB}/$file
  846.     cp /tmp/$base ${LIB}/$file
  847.     rm -f /tmp/$base
  848.   fi
  849. fi
  850.  
  851. # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
  852.  
  853. file=sys/cmn_err.h
  854. base=`basename $file`
  855. if [ -r ${LIB}/$file ]; then
  856.   file_to_fix=${LIB}/$file
  857. else
  858.   if [ -r ${INPUT}/$file ]; then
  859.     file_to_fix=${INPUT}/$file
  860.   else
  861.     file_to_fix=""
  862.   fi
  863. fi
  864. if [ \! -z "$file_to_fix" ]; then
  865.   echo Checking $file_to_fix
  866.   if grep _KERNEL $file_to_fix > /dev/null; then
  867.     echo No change needed in $file_to_fix
  868.   else
  869.     echo '#ifdef _KERNEL' > /tmp/$base
  870.     cat $file_to_fix >> /tmp/$base
  871.     echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
  872.     echo Fixed $file_to_fix
  873.     rm -f ${LIB}/$file
  874.     cp /tmp/$base ${LIB}/$file
  875.     rm -f /tmp/$base
  876.   fi
  877. fi
  878.  
  879. # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
  880.  
  881. file=sys/kdebugger.h
  882. base=`basename $file`
  883. if [ -r ${LIB}/$file ]; then
  884.   file_to_fix=${LIB}/$file
  885. else
  886.   if [ -r ${INPUT}/$file ]; then
  887.     file_to_fix=${INPUT}/$file
  888.   else
  889.     file_to_fix=""
  890.   fi
  891. fi
  892. if [ \! -z "$file_to_fix" ]; then
  893.   echo Checking $file_to_fix
  894.   if grep _KERNEL $file_to_fix > /dev/null; then
  895.     echo No change needed in $file_to_fix
  896.   else
  897.     echo '#ifdef _KERNEL' > /tmp/$base
  898.     cat $file_to_fix >> /tmp/$base
  899.     echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
  900.     echo Fixed $file_to_fix
  901.     rm -f ${LIB}/$file
  902.     cp /tmp/$base ${LIB}/$file
  903.     rm -f /tmp/$base
  904.   fi
  905. fi
  906.  
  907. # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
  908.  
  909. file=netinet/in.h
  910. base=`basename $file`
  911. if [ -r ${LIB}/$file ]; then
  912.   file_to_fix=${LIB}/$file
  913. else
  914.   if [ -r ${INPUT}/$file ]; then
  915.     file_to_fix=${INPUT}/$file
  916.   else
  917.     file_to_fix=""
  918.   fi
  919. fi
  920. if [ \! -z "$file_to_fix" ]; then
  921.   echo Checking $file_to_fix
  922.   if grep _KERNEL $file_to_fix > /dev/null; then
  923.     echo No change needed in $file_to_fix
  924.   else
  925.     sed -e '/#ifdef INKERNEL/i\
  926. #ifdef _KERNEL' \
  927.     -e '/#endif[     ]*\/\* INKERNEL \*\//a\
  928. #endif /* _KERNEL */' \
  929.     $file_to_fix > ${LIB}/${file}.sed
  930.     rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  931.     echo Fixed $file_to_fix
  932.   fi
  933. fi
  934.  
  935. # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
  936.  
  937. file=sys/endian.h
  938. base=`basename $file`
  939. if [ -r ${LIB}/$file ]; then
  940.   file_to_fix=${LIB}/$file
  941. else
  942.   if [ -r ${INPUT}/$file ]; then
  943.     file_to_fix=${INPUT}/$file
  944.   else
  945.     file_to_fix=""
  946.   fi
  947. fi
  948. if [ \! -z "$file_to_fix" ]; then
  949.   echo Checking $file_to_fix
  950.   if grep __GNUC__ $file_to_fix > /dev/null; then
  951.     echo No change needed in $file_to_fix
  952.   else
  953.     sed -e '/#    ifdef    __STDC__/i\
  954. #   if !defined (__GNUC__) && !defined (__GNUG__)' \
  955.     -e '/#        include    <sys\/byteorder.h>/s/        /   /'\
  956.     -e '/#   include    <sys\/byteorder.h>/i\
  957. #   endif /* !defined (__GNUC__) && !defined (__GNUG__) */'\
  958.     $file_to_fix > ${LIB}/${file}.sed
  959.     rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  960.     echo Fixed $file_to_fix
  961.   fi
  962. fi
  963.  
  964. # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
  965. # and the text in types.h is not erroneous.
  966. ## In sys/types.h, don't name the enum for booleans.
  967. #
  968. #file=sys/types.h
  969. #base=`basename $file`
  970. #if [ -r ${LIB}/$file ]; then
  971. #  file_to_fix=${LIB}/$file
  972. #else
  973. #  if [ -r ${INPUT}/$file ]; then
  974. #    file_to_fix=${INPUT}/$file
  975. #  else
  976. #    file_to_fix=""
  977. #  fi
  978. #fi
  979. #if [ \! -z "$file_to_fix" ]; then
  980. #  echo Checking $file_to_fix
  981. #  if grep "enum boolean" $file_to_fix > /dev/null; then
  982. #    sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
  983. #    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  984. #    echo Fixed $file_to_fix
  985. #  else
  986. #    echo No change needed in $file_to_fix
  987. #  fi
  988. #fi
  989.  
  990. # Remove useless extern keyword from struct forward declarations in
  991. # <sys/stream.h> and <sys/strsubr.h>
  992.  
  993. file=sys/stream.h
  994. base=`basename $file`
  995. if [ -r ${LIB}/$file ]; then
  996.   file_to_fix=${LIB}/$file
  997. else
  998.   if [ -r ${INPUT}/$file ]; then
  999.     file_to_fix=${INPUT}/$file
  1000.   else
  1001.     file_to_fix=""
  1002.   fi
  1003. fi
  1004. if [ \! -z "$file_to_fix" ]; then
  1005.   echo Checking $file_to_fix
  1006.   sed -e '
  1007.     s/extern struct stdata;/struct stdata;/g
  1008.     s/extern struct strevent;/struct strevent;/g
  1009.   ' $file_to_fix > /tmp/$base 
  1010.   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
  1011.     echo No change needed in $file_to_fix
  1012.   else
  1013.     echo Fixed $file_to_fix
  1014.     rm -f ${LIB}/$file
  1015.     cp /tmp/$base ${LIB}/$file
  1016.   fi
  1017.   rm -f /tmp/$base
  1018. fi
  1019.  
  1020. file=sys/strsubr.h
  1021. base=`basename $file`
  1022. if [ -r ${LIB}/$file ]; then
  1023.   file_to_fix=${LIB}/$file
  1024. else
  1025.   if [ -r ${INPUT}/$file ]; then
  1026.     file_to_fix=${INPUT}/$file
  1027.   else
  1028.     file_to_fix=""
  1029.   fi
  1030. fi
  1031. if [ \! -z "$file_to_fix" ]; then
  1032.   echo Checking $file_to_fix
  1033.   sed -e '
  1034.     s/extern struct strbuf;/struct strbuf;/g
  1035.     s/extern struct uio;/struct uio;/g
  1036.     s/extern struct thread;/struct thread;/g
  1037.     s/extern struct proc;/struct proc;/g
  1038.   ' $file_to_fix > /tmp/$base 
  1039.   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
  1040.     echo No change needed in $file_to_fix
  1041.   else
  1042.     echo Fixed $file_to_fix
  1043.     rm -f ${LIB}/$file
  1044.     cp /tmp/$base ${LIB}/$file
  1045.   fi
  1046.   rm -f /tmp/$base
  1047. fi
  1048.  
  1049. # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
  1050.  
  1051. file=sys/stat.h
  1052. base=`basename $file`
  1053. if [ -r ${LIB}/$file ]; then
  1054.   file_to_fix=${LIB}/$file
  1055. else
  1056.   if [ -r ${INPUT}/$file ]; then
  1057.     file_to_fix=${INPUT}/$file
  1058.   else
  1059.     file_to_fix=""
  1060.   fi
  1061. fi
  1062. if [ \! -z "$file_to_fix" ]; then
  1063.   echo Checking $file_to_fix
  1064.   cp $file_to_fix /tmp/$base
  1065.   chmod +w /tmp/$base
  1066.   ex /tmp/$base <<EOF
  1067. /^stat(path, buf)/j
  1068. j
  1069. -
  1070. /^stat(path, buf)/c
  1071. stat (const char *path, struct stat *buf)
  1072. .
  1073. /^lstat(path, buf)/j
  1074. j
  1075. -
  1076. /^lstat(path, buf)/c
  1077. lstat (const char *path, struct stat *buf)
  1078. .
  1079. /^fstat(fd, buf)/j
  1080. j
  1081. -
  1082. /^fstat(fd, buf)/c
  1083. fstat (int fd, struct stat *buf)
  1084. .
  1085. /^mknod(path, mode, dev)/j
  1086. j
  1087. j
  1088. -
  1089. /^mknod(path, mode, dev)/c
  1090. mknod (const char *path, mode_t mode, dev_t dev)
  1091. .
  1092. 1,\$s/path/__path/g
  1093. 1,\$s/buf/__buf/g
  1094. 1,\$s/fd/__fd/g
  1095. 1,\$s/ret\\([^u]\\)/__ret\1/g
  1096. 1,\$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g
  1097. 1,\$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g
  1098. wq
  1099. EOF
  1100.   echo Fixed $file_to_fix
  1101.   rm -f ${LIB}/$file
  1102.   cp /tmp/$base ${LIB}/$file
  1103.   rm -f /tmp/$base
  1104. fi
  1105.  
  1106. # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
  1107.  
  1108. if [ -x /bin/sony ]; then
  1109.   if /bin/sony; then
  1110.  
  1111.     # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
  1112.  
  1113.     file=stdio.h
  1114.     base=`basename $file`
  1115.     if [ -r ${LIB}/$file ]; then
  1116.       file_to_fix=${LIB}/$file
  1117.     else
  1118.       if [ -r ${INPUT}/$file ]; then
  1119.         file_to_fix=${INPUT}/$file
  1120.       else
  1121.         file_to_fix=""
  1122.       fi
  1123.     fi
  1124.     if [ \! -z "$file_to_fix" ]; then
  1125.       echo Checking $file_to_fix
  1126.       cp $file_to_fix /tmp/$base
  1127.       chmod +w /tmp/$base
  1128.       sed -e '
  1129.         s/__filbuf/_filbuf/g
  1130.         s/__flsbuf/_flsbuf/g
  1131.         s/__iob/_iob/g
  1132.       ' /tmp/$base > /tmp/$base.sed
  1133.       mv /tmp/$base.sed /tmp/$base
  1134.       if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
  1135.         echo No change needed in $file_to_fix
  1136.       else
  1137.         echo Fixed $file_to_fix
  1138.         rm -f ${LIB}/$file
  1139.         cp /tmp/$base ${LIB}/$file
  1140.       fi
  1141.       rm -f /tmp/$base
  1142.     fi
  1143.  
  1144.     # Change <ctype.h> to not define __ctype
  1145.  
  1146.     file=ctype.h
  1147.     base=`basename $file`
  1148.     if [ -r ${LIB}/$file ]; then
  1149.       file_to_fix=${LIB}/$file
  1150.     else
  1151.       if [ -r ${INPUT}/$file ]; then
  1152.         file_to_fix=${INPUT}/$file
  1153.       else
  1154.         file_to_fix=""
  1155.       fi
  1156.     fi
  1157.     if [ \! -z "$file_to_fix" ]; then
  1158.       echo Checking $file_to_fix
  1159.       cp $file_to_fix /tmp/$base
  1160.       chmod +w /tmp/$base
  1161.       sed -e '
  1162.         s/__ctype/_ctype/g
  1163.       ' /tmp/$base > /tmp/$base.sed
  1164.       mv /tmp/$base.sed /tmp/$base
  1165.       if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
  1166.         echo No change needed in $file_to_fix
  1167.       else
  1168.         echo Fixed $file_to_fix
  1169.         rm -f ${LIB}/$file
  1170.         cp /tmp/$base ${LIB}/$file
  1171.       fi
  1172.       rm -f /tmp/$base
  1173.     fi
  1174.   fi
  1175. fi
  1176.  
  1177. # In limits.h, put #ifndefs around things that are supposed to be defined
  1178. # in float.h to avoid redefinition errors if float.h is included first.
  1179. # Solaris 2.1 has this problem.
  1180.  
  1181. file=limits.h
  1182. base=`basename $file`
  1183. if [ -r ${LIB}/$file ]; then
  1184.   file_to_fix=${LIB}/$file
  1185. else
  1186.   if [ -r ${INPUT}/$file ]; then
  1187.     file_to_fix=${INPUT}/$file
  1188.   else
  1189.     file_to_fix=""
  1190.   fi
  1191. fi
  1192. if [ \! -z "$file_to_fix" ]; then
  1193.   echo Checking $file_to_fix
  1194.   sed -e '/[     ]FLT_MIN[     ]/i\
  1195. #ifndef FLT_MIN'\
  1196.       -e '/[     ]FLT_MIN[     ]/a\
  1197. #endif'\
  1198.       -e '/[     ]FLT_MAX[     ]/i\
  1199. #ifndef FLT_MAX'\
  1200.       -e '/[     ]FLT_MAX[     ]/a\
  1201. #endif'\
  1202.       -e '/[     ]FLT_DIG[     ]/i\
  1203. #ifndef FLT_DIG'\
  1204.       -e '/[     ]FLT_DIG[     ]/a\
  1205. #endif'\
  1206.       -e '/[     ]DBL_MIN[     ]/i\
  1207. #ifndef DBL_MIN'\
  1208.       -e '/[     ]DBL_MIN[     ]/a\
  1209. #endif'\
  1210.       -e '/[     ]DBL_MAX[     ]/i\
  1211. #ifndef DBL_MAX'\
  1212.       -e '/[     ]DBL_MAX[     ]/a\
  1213. #endif'\
  1214.       -e '/[     ]DBL_DIG[     ]/i\
  1215. #ifndef DBL_DIG'\
  1216.       -e '/[     ]DBL_DIG[     ]/a\
  1217. #endif' $file_to_fix > /tmp/$base
  1218.   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
  1219.     echo No change needed in $file_to_fix
  1220.   else
  1221.     echo Fixed $file_to_fix
  1222.     rm -f ${LIB}/$file
  1223.     cp /tmp/$base ${LIB}/$file
  1224.   fi
  1225.   rm -f /tmp/$base
  1226. fi
  1227.  
  1228. echo 'Removing unneeded directories:'
  1229. cd $LIB
  1230. files=`find . -type d -print | sort -r`
  1231. for file in $files; do
  1232.   rmdir $LIB/$file > /dev/null 2>&1
  1233. done
  1234.  
  1235. if $LINKS; then
  1236.   echo 'Making internal symbolic non-directory links'
  1237.   cd ${INPUT}
  1238.   files=`find . -type l -print`
  1239.   for file in $files; do
  1240.     dest=`ls -ld $file | sed -n 's/.*-> //p'`
  1241.     if expr "$dest" : '[^/].*' > /dev/null; then    
  1242.       target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
  1243.       if [ -f $target ]; then
  1244.         ln -s $dest ${LIB}/$file >/dev/null 2>&1
  1245.       fi
  1246.     fi
  1247.   done
  1248. fi
  1249.  
  1250. cd ${ORIG_DIR}
  1251.  
  1252. echo 'Replacing <sys/byteorder.h>'
  1253. rm -f ${LIB}/sys/byteorder.h
  1254. cp ${SRCDIR}/byteorder.h ${LIB}/sys/byteorder.h
  1255.  
  1256. exit 0
  1257.  
  1258.