2003-11-23 18:29:08 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2023-12-18 07:12:48 +00:00
|
|
|
test -f "$PLAN9/config" && . "$PLAN9/config"
|
2003-11-23 18:29:08 +00:00
|
|
|
usegcc()
|
|
|
|
{
|
2010-02-23 00:53:37 +00:00
|
|
|
cc=${CC9:-gcc}
|
2020-05-18 00:07:52 +00:00
|
|
|
cflags=" \
|
2003-11-23 18:29:08 +00:00
|
|
|
-O2 \
|
|
|
|
-c \
|
|
|
|
-Wall \
|
|
|
|
-Wno-parentheses \
|
|
|
|
-Wno-missing-braces \
|
|
|
|
-Wno-switch \
|
2004-02-09 19:33:05 +00:00
|
|
|
-Wno-comment \
|
2003-11-25 02:36:46 +00:00
|
|
|
-Wno-sign-compare \
|
2004-05-03 17:26:17 +00:00
|
|
|
-Wno-unknown-pragmas \
|
2020-01-12 20:05:40 +00:00
|
|
|
-Wno-misleading-indentation \
|
|
|
|
-Wno-stringop-truncation \
|
|
|
|
-Wno-stringop-overflow \
|
|
|
|
-Wno-format-truncation \
|
2024-06-15 14:55:15 +00:00
|
|
|
-Wno-deprecated-pragma \
|
|
|
|
-Wno-unused-but-set-variable \
|
|
|
|
-Wno-deprecated-declarations \
|
2004-04-29 17:13:24 +00:00
|
|
|
-fno-omit-frame-pointer \
|
2012-10-20 17:51:01 +00:00
|
|
|
-fsigned-char \
|
2020-04-29 10:21:35 +00:00
|
|
|
-fcommon \
|
2003-11-23 18:29:08 +00:00
|
|
|
"
|
2004-04-29 17:13:24 +00:00
|
|
|
# want to put -fno-optimize-sibling-calls here but
|
|
|
|
# that option only works with gcc3+ it seems
|
2020-05-18 00:07:52 +00:00
|
|
|
cflags="$cflags -ggdb"
|
|
|
|
cflags="$cflags $CC9FLAGS"
|
2003-11-23 18:29:08 +00:00
|
|
|
}
|
|
|
|
|
2010-02-23 00:53:37 +00:00
|
|
|
quiet()
|
|
|
|
{
|
|
|
|
# The uniq at the end is for gcc's strcmp/etc. built-in nonsense,
|
|
|
|
# which multiplies single errors as a result of its expansion.
|
|
|
|
# The "Cursor. is deprecated" kills off warnings from Apple
|
|
|
|
# about using SetCursor/InitCursor. (Okay, they're deprecated,
|
|
|
|
# but you could at least tell us what to use instead, Apple!)
|
|
|
|
|
|
|
|
ignore=': error: .Each undeclared identifier'
|
|
|
|
ignore=$ignore'|: error: for each function it appears'
|
|
|
|
ignore=$ignore'|is dangerous, better use'
|
|
|
|
ignore=$ignore'|is almost always misused'
|
|
|
|
ignore=$ignore'|: In function '
|
|
|
|
ignore=$ignore'|: At top level:'
|
|
|
|
ignore=$ignore'|support .long long.'
|
|
|
|
ignore=$ignore'|In file included from'
|
|
|
|
ignore=$ignore'| from'
|
|
|
|
ignore=$ignore'|use of C99 long long'
|
|
|
|
ignore=$ignore'|ISO C forbids conversion'
|
2017-01-06 21:32:31 +00:00
|
|
|
ignore=$ignore'|marked deprecated'
|
2010-02-23 00:53:37 +00:00
|
|
|
ignore=$ignore'|is deprecated'
|
|
|
|
ignore=$ignore'|warn_unused_result'
|
2017-01-06 21:32:31 +00:00
|
|
|
ignore=$ignore'|expanded from macro'
|
2010-02-23 00:53:37 +00:00
|
|
|
|
2023-12-18 07:12:48 +00:00
|
|
|
grep -v '__p9l_autolib_' "$1" |
|
2010-02-23 00:53:37 +00:00
|
|
|
egrep -v "$ignore" |
|
|
|
|
sed 's/ .first use in this function.$//; s/\"\([^\"][^\"]*\)\", line \([0-9][0-9]*\)/\1:\2/g' |
|
2011-05-17 22:48:42 +00:00
|
|
|
$(which uniq) 1>&2 # avoid built-in uniq on SunOS
|
2010-02-23 00:53:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
useclang()
|
|
|
|
{
|
|
|
|
cc=${CC9:-clang}
|
2020-05-18 00:07:52 +00:00
|
|
|
cflags=" \
|
2010-02-23 00:53:37 +00:00
|
|
|
-O2 \
|
|
|
|
-c \
|
|
|
|
-Wall \
|
|
|
|
-Wno-parentheses \
|
2012-10-20 17:51:01 +00:00
|
|
|
-Wno-missing-braces \
|
|
|
|
-Wno-switch \
|
|
|
|
-Wno-comment \
|
|
|
|
-Wno-sign-compare \
|
2010-02-23 00:53:37 +00:00
|
|
|
-Wno-unknown-pragmas \
|
2012-10-20 17:51:01 +00:00
|
|
|
-Wno-empty-body \
|
2010-02-23 00:53:37 +00:00
|
|
|
-Wno-unused-value \
|
2012-10-21 16:01:13 +00:00
|
|
|
-Wno-array-bounds \
|
|
|
|
-Wno-gnu-designator \
|
2014-10-21 12:22:12 +00:00
|
|
|
-Wno-array-bounds \
|
|
|
|
-Wno-unneeded-internal-declaration \
|
2024-06-15 14:55:15 +00:00
|
|
|
-Wno-deprecated-pragma \
|
|
|
|
-Wno-unused-but-set-variable \
|
2012-10-20 17:51:01 +00:00
|
|
|
-fsigned-char \
|
2012-10-21 16:01:13 +00:00
|
|
|
-fno-caret-diagnostics \
|
2020-12-30 05:06:35 +00:00
|
|
|
-fcommon \
|
2010-02-23 00:53:37 +00:00
|
|
|
"
|
2020-05-18 00:07:52 +00:00
|
|
|
cflags="$cflags -g"
|
|
|
|
cflags="$cflags $CC9FLAGS"
|
2010-02-23 00:53:37 +00:00
|
|
|
}
|
|
|
|
|
2020-05-05 02:52:02 +00:00
|
|
|
usexlc()
|
|
|
|
{
|
|
|
|
cc=${CC9:-xlc_r}
|
2020-05-18 00:07:52 +00:00
|
|
|
cflags=" \
|
2020-05-05 02:52:02 +00:00
|
|
|
-c \
|
2021-08-29 20:36:30 +00:00
|
|
|
-O2 \
|
2020-05-05 02:52:02 +00:00
|
|
|
-qmaxmem=-1 \
|
|
|
|
-qsuppress=1506-236 \
|
|
|
|
-qsuppress=1506-358 \
|
|
|
|
-qsuppress=1500-010 \
|
|
|
|
-qsuppress=1506-224 \
|
|
|
|
-qsuppress=1506-1300 \
|
|
|
|
-qsuppress=1506-342 \
|
|
|
|
"
|
2021-08-29 20:36:30 +00:00
|
|
|
cflags="$cflags -g -qdbxextra -qfullpath"
|
2020-05-18 00:07:52 +00:00
|
|
|
cflags="$cflags $CC9FLAGS"
|
2020-05-05 02:52:02 +00:00
|
|
|
}
|
|
|
|
|
2020-12-30 12:39:16 +00:00
|
|
|
tag="${SYSNAME:-`uname`}-${CC9:-cc}"
|
2003-11-23 18:29:08 +00:00
|
|
|
case "$tag" in
|
2020-01-07 22:27:39 +00:00
|
|
|
*DragonFly*gcc*|*BSD*gcc*) usegcc ;;
|
|
|
|
*DragonFly*clang|*BSD*clang*) useclang ;;
|
2020-12-30 12:39:16 +00:00
|
|
|
*Darwin*)
|
2012-10-21 16:01:13 +00:00
|
|
|
useclang
|
2020-05-18 00:07:52 +00:00
|
|
|
cflags="$cflags -g3 -m64"
|
2012-10-21 16:01:13 +00:00
|
|
|
;;
|
2010-02-23 00:53:37 +00:00
|
|
|
*HP-UX*) cc=${CC9:-cc}; cflags="-g -O -c -Ae" ;;
|
2020-01-20 02:10:11 +00:00
|
|
|
*Linux*) usegcc
|
2005-07-22 18:56:31 +00:00
|
|
|
case "${CC9:-gcc}" in
|
|
|
|
tcc)
|
|
|
|
cc=tcc
|
|
|
|
cflags="-c -g"
|
|
|
|
;;
|
|
|
|
esac
|
2004-09-17 22:09:31 +00:00
|
|
|
;;
|
2010-02-23 00:53:37 +00:00
|
|
|
*OSF1*) cc=${CC9:-cc}; cflags="-g -O -c" ;;
|
2004-03-26 05:01:11 +00:00
|
|
|
*SunOS*-cc) cc=cc;
|
2020-01-20 02:10:11 +00:00
|
|
|
cflags="-mt -g -O -c -xCC -D__sun__"
|
2004-03-26 05:01:11 +00:00
|
|
|
u=`uname`
|
2004-03-26 05:05:33 +00:00
|
|
|
v=`uname -r`
|
|
|
|
s=`echo $u$v | tr '. ' '__'`
|
2005-01-19 16:45:27 +00:00
|
|
|
cflags="$cflags -D__${s}__"
|
2004-03-26 05:01:11 +00:00
|
|
|
;;
|
|
|
|
*SunOS*-gcc) usegcc
|
|
|
|
u=`uname`
|
2004-03-26 05:05:33 +00:00
|
|
|
v=`uname -r`
|
|
|
|
s=`echo $u$v | tr '. ' '__'`
|
2020-05-18 00:07:52 +00:00
|
|
|
cflags="$cflags -g"
|
2008-05-31 16:09:43 +00:00
|
|
|
cflags="$cflags -D__sun__ -D__${s}__"
|
2004-03-26 05:01:11 +00:00
|
|
|
;;
|
2020-05-19 02:38:54 +00:00
|
|
|
*AIX*) usexlc
|
2020-05-18 00:07:52 +00:00
|
|
|
cflags="$cflags -g -D__AIX__"
|
2009-07-15 05:55:52 +00:00
|
|
|
;;
|
2003-11-23 18:29:08 +00:00
|
|
|
*)
|
|
|
|
echo 9c does not know how to compile on "$tag" 1>&2
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|
2023-12-18 07:12:48 +00:00
|
|
|
# Must use temp file to avoid pipe; pipe loses status.
|
2019-11-11 22:06:55 +00:00
|
|
|
xtmp=${TMPDIR-/tmp}/9c.$$.$USER.out
|
2023-12-18 07:12:48 +00:00
|
|
|
$cc -DPLAN9PORT -I"$PLAN9/include" $cflags "$@" 2>"$xtmp"
|
2005-01-07 07:15:31 +00:00
|
|
|
status=$?
|
2023-12-18 07:12:48 +00:00
|
|
|
quiet "$xtmp"
|
|
|
|
rm -f "$xtmp"
|
2005-01-04 21:13:58 +00:00
|
|
|
exit $status
|