#!/bin/sh
# $NetBSD: mkioctls,v 1.57 2020/09/12 01:36:26 roy Exp $
#
# Copyright (c) 1994
# The Regents of the University of California. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the University of
# California, Berkeley and its contributors.
# 4. Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# @(#)mkioctls 8.2 (Berkeley) 4/28/95
#
# kernel headers <sys/*.h> and <net/*.h> should not include stdbool.h
# but they do; then xf86Opt.h needs a bool struct field.
needundef=true
for i
do
case $i in
*X11*)
if $needundef; then
echo "#undef bool"
needundef=false;
fi;;
esac
echo "#include <$i>"
done | ${SED} -e "s,${DESTDIR}/usr/include/,,g" \
-e "s,${DESTDIR}/usr/X11R7/include/,,g" \
-e "s,${NETBSDSRCDIR}/external/cddl/osnet/dist/uts/common/,,g"
if ! $needundef; then
echo "#define bool _Bool"
fi
${CC} -E -nostdinc -isystem ${DESTDIR}/usr/include ${CPPFLAGS} -dM "${@}" | \
${AWK} '
BEGIN {
keep["SLIOCGUNIT"] = 1; # Same as PPPIOCGASYNCMAP
keep["TUNSLMODE"] = 1; # Same as PPPIOCGASYNCMAP
keep["SIOCRMNAT"] = 1; # Same as SIOCRMAFR
keep["SIOCADNAT"] = 1; # Same as SIOCADAFR
keep["SIOCDELST"] = 1; # Same as SIOCRMNAT
keep["SIOCPROXY"] = 1; # Same as SIOCLOOKUPSTAT
keep["CHIOGPICKER"] = 1; # Same as CDIOREADTOCHEADER
keep["KBDSTPMAT"] = 1; # Same as LMREADY, pcvt is gone so ok.
keep["SIOCSLOWAT"] = 1; # Same as SATIOSBUFSIZE
keep["UTOPPYIOTURBO"] = 1; # Same as OTIOCSETD
keep["TIOCHPCL"] = 1; # Same as UTOPPYIOCANCEL
keep["TIOCCBRK"] = 1; # Same as CONSOLE_X_MODE_OFF
keep["TIOCSDTR"] = 1; # Same as CONSOLE_X_MODE_ON
keep["APM_IOC_SUSPEND"] = 1; # Same as AGPIOC_RELEASE
keep["APM_IOC_STANDBY"] = 1; # Same as AGPIOC_ACQUIRE
keep["BTDEV_GETINFO"] = 1; # Same as BTSCO_GETINFO
keep["BTHSET_GETINFO"] = 1; # Same as BTSCO_GETINFO
keep["JOY_GET_X_OFFSET"] = 1; # Same as GDT_IOCTL_CTRCNT
keep["JOY_GET_X_OFFSET"] = 1; # Same as GDT_IOCTL_CTRCNT
keep["SCIOC_USE_ADF"] = 1; # Same as STICIO_STARTQ
keep["SCBUSIOLLSCAN"] = 1; # Same as USB_DISCOVER
keep["OPIOCGETNEXT"] = 1; # Same as OFIOCGETNEXT
keep["OPIOCGET"] = 1; # Same as OFIOCGET
keep["OPIOCGETCHILD"] = 1; # Same as OFIOCGETCHILD
keep["OPIOCFINDDEVICE"] = 1; # Same as OFIOCFINDDEVICE
keep["OPIOCGETOPTNODE"] = 1; # Same as OFIOCGETOPTNODE
keep["OPIOCNEXTPROP"] = 1; # Same as OFIOCNEXTPROP
keep["OPIOCSET"] = 1; # Same as OFIOCSET
keep["MBPPIOCSPARAM"] = 1; # Same as PARIOCSPARAM
keep["MBPPIOCGPARAM"] = 1; # Same as PARIOCGPARAM
keep["CLOCKCTL_ADJTIME"] = 1; # Same as TCTRL_MODEM_PWR
keep["OFIOCNEXTPROP"] = 1; # Same as PNVIOCGETNUMGE
keep["OFIOCGET"] = 1; # Same as PNVIOCGET
keep["SIOCPHASE2"] = 1; # Same as GRESADDRS
keep["I4B_CTL_CLR_CHIPSTAT"] = 1; # Same as CLOCKCTL_NTP_ADJTIME
keep["STICIO_STARTQ"] = 1; # Same as SPKRTONE
keep["STICIO_RESET860"] = 1; # Same as SCIOCRESTART
keep["STICIO_START860"] = 1; # Same as SPKRTUNE
keep["I4B_CTL_SET_DEBUG"] = 1; # Same as CLOCKCTL_SETTIMEOFDAY
keep["SIOCGETSGCNT_IN6"] = 1; # Type sioc_sg_req6 not exported
keep["SIOCGPRLST_IN6"] = 1; Type in6_oprlist not exported
keep["SIOCGETMIFCNT_IN6"] = 1; Type sioc_mif_req6 not exported