summaryrefslogtreecommitdiff
path: root/mcon/U/i_varhdr.U
diff options
context:
space:
mode:
authorManoj Srivastava <srivasta@debian.org>2003-12-01 17:11:15 +0000
committerManoj Srivastava <srivasta@debian.org>2003-12-01 17:11:15 +0000
commit371472d9fb6a936149b105a6563a0550d35bdf1a (patch)
tree6d23751e44a7dddf4e29918551f1ea0513352622 /mcon/U/i_varhdr.U
Initial import of upstream branch
Initial import of upstream branch git-archimport-id: srivasta@debian.org--2003-primary/dist--upstream--3.70--base-0
Diffstat (limited to 'mcon/U/i_varhdr.U')
-rw-r--r--mcon/U/i_varhdr.U164
1 files changed, 164 insertions, 0 deletions
diff --git a/mcon/U/i_varhdr.U b/mcon/U/i_varhdr.U
new file mode 100644
index 0000000..909724e
--- /dev/null
+++ b/mcon/U/i_varhdr.U
@@ -0,0 +1,164 @@
+?RCS: $Id: i_varhdr.U,v 3.0.1.3 1997/02/28 15:54:42 ram Exp $
+?RCS:
+?RCS: Copyright (c) 1991-1993, Raphael Manfredi
+?RCS:
+?RCS: You may redistribute only under the terms of the Artistic Licence,
+?RCS: as specified in the README file that comes with the distribution.
+?RCS: You may reuse parts of this distribution only within the terms of
+?RCS: that same Artistic Licence; a copy of which may be found at the root
+?RCS: of the source tree for dist 3.0.
+?RCS:
+?RCS: $Log: i_varhdr.U,v $
+?RCS: Revision 3.0.1.3 1997/02/28 15:54:42 ram
+?RCS: patch61: varargs script now starts with leading "startsh"
+?RCS:
+?RCS: Revision 3.0.1.2 1994/10/29 16:21:02 ram
+?RCS: patch36: added ?F: line for metalint file checking
+?RCS:
+?RCS: Revision 3.0.1.1 1994/05/13 15:26:05 ram
+?RCS: patch27: this unit now supersedes old i_stdarg.U and i_varargs.U
+?RCS: patch27: modified to avoid spurious Whoa warnings (ADO)
+?RCS:
+?RCS: Revision 3.0 1993/08/18 12:08:49 ram
+?RCS: Baseline for dist 3.0 netwide release.
+?RCS:
+?MAKE:i_stdarg i_varargs i_varhdr: cat +cc +ccflags rm test Setvar \
+ Findhdr startsh _o
+?MAKE: -pick add $@ %<
+?S:i_stdarg:
+?S: This variable conditionally defines the I_STDARG symbol, which
+?S: indicates to the C program that <stdarg.h> exists and should
+?S: be included.
+?S:.
+?S:i_varargs:
+?S: This variable conditionally defines I_VARARGS, which indicates
+?S: to the C program that it should include <varargs.h>.
+?S:.
+?S:i_varhdr:
+?S: Contains the name of the header to be included to get va_dcl definition.
+?S: Typically one of varargs.h or stdarg.h.
+?S:.
+?C:I_STDARG:
+?C: This symbol, if defined, indicates that <stdarg.h> exists and should
+?C: be included.
+?C:.
+?C:I_VARARGS:
+?C: This symbol, if defined, indicates to the C program that it should
+?C: include <varargs.h>.
+?C:.
+?H:#$i_stdarg I_STDARG /**/
+?H:#$i_varargs I_VARARGS /**/
+?H:.
+?W:%<:va_dcl
+?F:!varargs
+?T:valstd
+?LINT:set i_stdarg i_varargs
+?X:
+?X: Don't use setvar because the varags test below might override these.
+?X: Actually, the messages here are just informative. We don't wish to set
+?X: i_varargs or i_stdarg to their final value before knowing which of the
+?X: two we'll include.
+?X:
+: see if stdarg is available
+echo " "
+if $test `./findhdr stdarg.h`; then
+ echo "<stdarg.h> found." >&4
+ valstd="$define"
+else
+ echo "<stdarg.h> NOT found." >&4
+ valstd="$undef"
+fi
+
+: see if varags is available
+echo " "
+if $test `./findhdr varargs.h`; then
+ echo "<varargs.h> found." >&4
+else
+ echo "<varargs.h> NOT found, but that's ok (I hope)." >&4
+fi
+
+?X:
+?X: if you have stdarg.h, you need to support prototypes to actually use it;
+?X: but if stdarg.h exists and the compiler doesn't support prototypes (for some
+?X: bizarre reason), we'll fall back to varargs.h anyway so it's not so bad.
+?X:
+: set up the varargs testing programs
+$cat > varargs.c <<EOP
+#ifdef I_STDARG
+#include <stdarg.h>
+#endif
+#ifdef I_VARARGS
+#include <varargs.h>
+#endif
+
+#ifdef I_STDARG
+int f(char *p, ...)
+#else
+int f(va_alist)
+va_dcl
+#endif
+{
+ va_list ap;
+#ifndef I_STDARG
+ char *p;
+#endif
+#ifdef I_STDARG
+ va_start(ap,p);
+#else
+ va_start(ap);
+ p = va_arg(ap, char *);
+#endif
+ va_end(ap);
+}
+EOP
+$cat > varargs <<EOP
+$startsh
+if $cc -c $ccflags -D\$1 varargs.c >/dev/null 2>&1; then
+ echo "true"
+else
+ echo "false"
+fi
+$rm -f varargs$_o
+EOP
+chmod +x varargs
+
+: now check which varargs header should be included
+echo " "
+i_varhdr=''
+case "$valstd" in
+"$define")
+ if `./varargs I_STDARG`; then
+ val='stdarg.h'
+ elif `./varargs I_VARARGS`; then
+ val='varargs.h'
+ fi
+ ;;
+*)
+ if `./varargs I_VARARGS`; then
+ val='varargs.h'
+ fi
+ ;;
+esac
+case "$val" in
+'')
+echo "I could not find the definition for va_dcl... You have problems..." >&4
+ val="$undef"; set i_stdarg; eval $setvar
+ val="$undef"; set i_varargs; eval $setvar
+ ;;
+*)
+ set i_varhdr
+ eval $setvar
+ case "$i_varhdr" in
+ stdarg.h)
+ val="$define"; set i_stdarg; eval $setvar
+ val="$undef"; set i_varargs; eval $setvar
+ ;;
+ varargs.h)
+ val="$undef"; set i_stdarg; eval $setvar
+ val="$define"; set i_varargs; eval $setvar
+ ;;
+ esac
+ echo "We'll include <$i_varhdr> to get va_dcl definition." >&4;;
+esac
+$rm -f varargs*
+