fi
fi
-# assert.h and sys/mman.h on HP/UX are not C++ ready, even though
+# sys/mman.h on HP/UX is not C++ ready, even though
# NO_IMPLICIT_EXTERN_C is defined on HP/UX.
-for file in assert.h sys/mman.h; do
+for file in sys/mman.h; do
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
chmod +w ${LIB}/$file 2>/dev/null
fi
done
-# check for broken assert.h that needs stdio.h or stdlib.h
-file=assert.h
-if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
- cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
- chmod +w ${LIB}/$file 2>/dev/null
- chmod a+r ${LIB}/$file 2>/dev/null
-fi
-
-if [ -r ${LIB}/$file ]; then
- if grep 'stderr' ${LIB}/$file >/dev/null 2>/dev/null; then
- if grep 'include.*stdio.h' ${LIB}/$file >/dev/null 2>/dev/null; then
- true
- else
- echo "Fixing $file (needs stdio.h)"
- echo '#include <stdio.h>' >>${LIB}/$file
- fi
- fi
- if grep 'exit *(' ${LIB}/$file >/dev/null 2>/dev/null ||
- grep 'abort *(' ${LIB}/$file >/dev/null 2>/dev/null; then
- if grep 'include.*stdlib.h' ${LIB}/$file >/dev/null 2>/dev/null; then
- true
- else
- echo "Fixing $file (needs stdlib.h)"
- echo '#ifdef __cplusplus
-#include <stdlib.h>
-#endif' >>${LIB}/$file
- fi
- fi
- if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- rm -f ${LIB}/$file
- else
- # Find any include directives that use "file".
- for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
- dir=`echo $file | sed -e s'|/[^/]*$||'`
- required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
- done
- fi
-fi
-
# Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
file=unistd.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
required_unistd_h="_exit access alarm chdir chown close ctermid cuserid dup dup2 execl execle execlp execv execve execvp fork fpathconf getcwd getegid geteuid getgid getlogin getopt getpgrp getpid getppid getuid isatty link lseek pathconf pause pipe read rmdir setgid setpgid setsid setuid sleep sysconf tcgetpgrp tcsetpgrp ttyname unlink write"
done_dirs=""
+subdirs_made=""
echo "" >fixproto.list
for code in ALL STD ; do
abs_target_subdir=${abs_target_dir}/${rel_source_subdir}
if [ \! -d $abs_target_subdir ] ; then
- mkdir $abs_target_subdir
+ if mkdir $abs_target_subdir ; then
+ subdirs_made="$abs_target_subdir $subdirs_made"
+ fi
fi
# Append "/"; remove initial "./". Hence "." -> "" and "sys" -> "sys/".
rel_source_prefix=`echo $rel_source_subdir | sed -e 's|$|/|' -e 's|^./||'`
# Create the dir where this file will go when fixed.
xxdir=`echo ./$file | sed -e 's|/[^/]*$||'`
if [ \! -d $abs_target_subdir/$xxdir ] ; then
- mkdir $abs_target_subdir/$xxdir
+ if mkdir $abs_target_subdir/$xxdir ; then
+ subdirs_made="$abs_target_subdir/$xxdir $subdirs_made"
+ fi
fi
# Just in case we have edited out a symbolic link
if [ -f $src_dir_std/$file -a -f $src_dir_std/$xxfile ] ; then
cat >tmp.h <<EOF
#ifndef ${rel_source_ident}
#define ${rel_source_ident}
-#endif
+EOF
+ if test $rel_source_file = stdlib.h
+ then
+ # Make sure it contains a definition of size_t.
+ cat >>tmp.h <<EOF
+
+#define __need_size_t
+#include <stddef.h>
+EOF
+ fi
+ cat >>tmp.h <<EOF
+
+#endif /* ${rel_source_ident} */
EOF
${FIX_HEADER} $rel_source_file tmp.h $abs_target_dir/$rel_source_file ${DEFINES} $include_path
rm tmp.h
fi
done
+
+# Remove any directories that we made that are still empty.
+rmdir $subdirs_made 2>/dev/null
+
exit 0