?RCS: $Id$ ?RCS: ?RCS: Copyright (c) 1991-1997, 2004-2006, 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 4.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 Warn 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 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 . ?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 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 . ?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 " found." >&4 valstd="$define" else echo " NOT found." >&4 valstd="$undef" fi : see if varags is available echo " " if $test `./findhdr varargs.h`; then echo " found." >&4 else echo " 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 < #endif #ifdef I_VARARGS #include #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 </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 '') ./warn "I could not find the definition for va_dcl... You have problems..." 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*