summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorYaroslav Tykhiy <ytykhiy@gmail.com>2005-10-14 23:30:17 +0000
committerYaroslav Tykhiy <ytykhiy@gmail.com>2005-10-14 23:30:17 +0000
commit822923447e454b30d310cb46903c9ddeca9f0a7a (patch)
tree40653d874a438a3202bb62dd66566bfd5b1386c1 /sys
parent10d645b7e5a073fc2d4c2bd7472966b4381caf7c (diff)
Notes
Diffstat (limited to 'sys')
-rw-r--r--sys/modules/3dfx/Makefile2
-rw-r--r--sys/modules/acpi/acpi/Makefile2
-rw-r--r--sys/modules/aha/Makefile2
-rw-r--r--sys/modules/ahb/Makefile2
-rw-r--r--sys/modules/an/Makefile2
-rw-r--r--sys/modules/ar/Makefile6
-rw-r--r--sys/modules/arcnet/Makefile2
-rw-r--r--sys/modules/arl/Makefile2
-rw-r--r--sys/modules/awi/Makefile2
-rw-r--r--sys/modules/bktr/bktr/Makefile3
-rw-r--r--sys/modules/cam/Makefile2
-rw-r--r--sys/modules/coda5/Makefile2
-rw-r--r--sys/modules/cp/Makefile24
-rw-r--r--sys/modules/ctau/Makefile22
-rw-r--r--sys/modules/cx/Makefile23
-rw-r--r--sys/modules/dcons/Makefile2
-rw-r--r--sys/modules/digi/digi/Makefile2
-rw-r--r--sys/modules/en/Makefile2
-rw-r--r--sys/modules/fatm/Makefile2
-rw-r--r--sys/modules/firewire/fwip/Makefile2
-rw-r--r--sys/modules/hatm/Makefile2
-rw-r--r--sys/modules/hifn/Makefile2
-rw-r--r--sys/modules/if_bridge/Makefile2
-rw-r--r--sys/modules/if_disc/Makefile2
-rw-r--r--sys/modules/if_ef/Makefile2
-rw-r--r--sys/modules/if_faith/Makefile2
-rw-r--r--sys/modules/if_gif/Makefile2
-rw-r--r--sys/modules/if_gre/Makefile2
-rw-r--r--sys/modules/if_ppp/Makefile2
-rw-r--r--sys/modules/if_sl/Makefile2
-rw-r--r--sys/modules/if_stf/Makefile2
-rw-r--r--sys/modules/if_tap/Makefile2
-rw-r--r--sys/modules/if_tun/Makefile2
-rw-r--r--sys/modules/if_vlan/Makefile2
-rw-r--r--sys/modules/ip_mroute_mod/Makefile2
-rw-r--r--sys/modules/ipfilter/Makefile3
-rw-r--r--sys/modules/kbdmux/Makefile2
-rw-r--r--sys/modules/linux/Makefile2
-rw-r--r--sys/modules/netgraph/gif/Makefile2
-rw-r--r--sys/modules/netgraph/iface/Makefile2
-rw-r--r--sys/modules/netgraph/mppc/Makefile2
-rw-r--r--sys/modules/netgraph/sync_ar/Makefile2
-rw-r--r--sys/modules/netgraph/sync_sr/Makefile2
-rw-r--r--sys/modules/nfs4client/Makefile8
-rw-r--r--sys/modules/nfsclient/Makefile8
-rw-r--r--sys/modules/nfsserver/Makefile3
-rw-r--r--sys/modules/nmdm/Makefile2
-rw-r--r--sys/modules/nwfs/Makefile5
-rw-r--r--sys/modules/osf1/Makefile2
-rw-r--r--sys/modules/patm/Makefile2
-rw-r--r--sys/modules/pf/Makefile2
-rw-r--r--sys/modules/rc/Makefile2
-rw-r--r--sys/modules/rp/Makefile2
-rw-r--r--sys/modules/safe/Makefile2
-rw-r--r--sys/modules/sio/Makefile2
-rw-r--r--sys/modules/smbfs/Makefile8
-rw-r--r--sys/modules/snc/Makefile2
-rw-r--r--sys/modules/sppp/Makefile2
-rw-r--r--sys/modules/sr/Makefile6
-rw-r--r--sys/modules/svr4/Makefile2
-rw-r--r--sys/modules/trm/Makefile2
-rw-r--r--sys/modules/ubsec/Makefile2
-rw-r--r--sys/modules/ukbd/Makefile2
-rw-r--r--sys/modules/vkbd/Makefile2
-rw-r--r--sys/modules/wi/Makefile2
-rw-r--r--sys/modules/wlan/Makefile2
66 files changed, 155 insertions, 72 deletions
diff --git a/sys/modules/3dfx/Makefile b/sys/modules/3dfx/Makefile
index fd0d010ed994..208e9a7cd105 100644
--- a/sys/modules/3dfx/Makefile
+++ b/sys/modules/3dfx/Makefile
@@ -18,7 +18,9 @@ TDFX_OPTS= "\#define TDFX_LINUX"
# Uncomment this for debugging messages
#CFLAGS+= -DDEBUG
+.if !defined(KERNBUILDDIR)
opt_tdfx.h:
echo $(TDFX_OPTS) > opt_tdfx.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/acpi/acpi/Makefile b/sys/modules/acpi/acpi/Makefile
index d4b84e72b59d..06cf146d4c92 100644
--- a/sys/modules/acpi/acpi/Makefile
+++ b/sys/modules/acpi/acpi/Makefile
@@ -63,6 +63,7 @@ DBSRC+= dbinput.c dbstats.c dbutils.c dbxface.c
DBSRC+= dmbuffer.c dmnames.c dmopcode.c dmobject.c dmresrc.c dmresrcl.c
DBSRC+= dmresrcs.c dmutils.c dmwalk.c
+.if !defined(KERNBUILDDIR)
.if ACPI_MAX_THREADS
CFLAGS+=-DACPI_MAX_THREADS=${ACPI_MAX_THREADS}
.endif
@@ -78,6 +79,7 @@ opt_ddb.h: Makefile
opt_ddb.h: Makefile
echo -n > ${.TARGET}
.endif
+.endif
# Machine-specific code such as sleep/wakeup
SRCS+= acpi_machdep.c acpi_wakecode.h acpi_wakeup.c
diff --git a/sys/modules/aha/Makefile b/sys/modules/aha/Makefile
index 44b4f93540bd..36c7359d2aa6 100644
--- a/sys/modules/aha/Makefile
+++ b/sys/modules/aha/Makefile
@@ -6,7 +6,9 @@ KMOD= aha
SRCS= aha.c aha_isa.c ahareg.h opt_cam.h device_if.h bus_if.h \
opt_scsi.h isa_if.h
+.if !defined(KERNBUILDDIR)
opt_scsi.h:
echo "#define SCSI_DELAY 15000" > opt_scsi.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/ahb/Makefile b/sys/modules/ahb/Makefile
index d759bbbe39b9..d015237b3bf4 100644
--- a/sys/modules/ahb/Makefile
+++ b/sys/modules/ahb/Makefile
@@ -6,7 +6,9 @@ KMOD= ahb
SRCS= ahb.c opt_cam.h device_if.h bus_if.h \
eisa_if.h opt_scsi.h
+.if !defined(KERNBUILDDIR)
opt_scsi.h:
echo "#define SCSI_DELAY 15000" > opt_scsi.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/an/Makefile b/sys/modules/an/Makefile
index c2c66d5fa700..7b7ad7898a5b 100644
--- a/sys/modules/an/Makefile
+++ b/sys/modules/an/Makefile
@@ -7,7 +7,9 @@ SRCS= if_an.c if_an_pccard.c if_an_pci.c if_an_isa.c
SRCS+= opt_inet.h device_if.h bus_if.h pci_if.h isa_if.h card_if.h
SRCS+= pccarddevs.h
+.if !defined(KERNBUILDDIR)
opt_inet.h:
echo "#define INET 1" > opt_inet.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/ar/Makefile b/sys/modules/ar/Makefile
index fae9452ef414..78fe22e758b7 100644
--- a/sys/modules/ar/Makefile
+++ b/sys/modules/ar/Makefile
@@ -5,13 +5,13 @@ KMOD = if_ar
SRCS = if_ar.c if_ar_isa.c if_ar_pci.c
SRCS += device_if.h bus_if.h pci_if.h isa_if.h opt_netgraph.h
+.if !defined(KERNBUILDDIR)
NETGRAPH?= 0
-opt_netgraph.h:
.if ${NETGRAPH} != 0
+opt_netgraph.h:
echo "#define NETGRAPH ${NETGRAPH}" > opt_netgraph.h
-.else
- echo "" > opt_netgraph.h
+.endif
.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/arcnet/Makefile b/sys/modules/arcnet/Makefile
index ab1d961bdfe0..a4bac23f7d89 100644
--- a/sys/modules/arcnet/Makefile
+++ b/sys/modules/arcnet/Makefile
@@ -16,10 +16,12 @@ EXPORT_SYMS= arc_frag_init \
arc_output \
arc_storelladdr
+.if !defined(KERNBUILDDIR)
opt_inet.h opt_inet6.h:
echo "#define INET 1" > ${.TARGET}
opt_ipx.h:
echo "#define IPX 1" > ${.TARGET}
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/arl/Makefile b/sys/modules/arl/Makefile
index 37c6529f74a0..011a66e214b3 100644
--- a/sys/modules/arl/Makefile
+++ b/sys/modules/arl/Makefile
@@ -8,7 +8,9 @@ SRCS= if_arl.c if_arl_isa.c
SRCS+= opt_inet.h device_if.h bus_if.h isa_if.h
CFLAGS+= -I${.CURDIR}/../..
+.if !defined(KERNBUILDDIR)
opt_inet.h:
echo "#define INET 1" > opt_inet.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/awi/Makefile b/sys/modules/awi/Makefile
index 554ffe5c01ab..228d9c13023b 100644
--- a/sys/modules/awi/Makefile
+++ b/sys/modules/awi/Makefile
@@ -6,7 +6,9 @@ KMOD= if_awi
SRCS= am79c930.c awi.c if_awi_pccard.c
SRCS+= bus_if.h card_if.h device_if.h opt_inet.h pccarddevs.h
+.if !defined(KERNBUILDDIR)
opt_inet.h:
echo "#define INET 1" > opt_inet.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/bktr/bktr/Makefile b/sys/modules/bktr/bktr/Makefile
index bd0286420c63..4543994830d6 100644
--- a/sys/modules/bktr/bktr/Makefile
+++ b/sys/modules/bktr/bktr/Makefile
@@ -9,7 +9,6 @@ SRCS= bktr_core.c bktr_os.c bktr_audio.c bktr_tuner.c bktr_card.c msp34xx.c \
opt_devfs.h opt_bktr.h bus_if.h device_if.h \
pci_if.h
-opt_bktr.h:
- echo "#define BKTR_FREEBSD_MODULE 1" > opt_bktr.h
+CFLAGS+= -DBKTR_FREEBSD_MODULE
.include <bsd.kmod.mk>
diff --git a/sys/modules/cam/Makefile b/sys/modules/cam/Makefile
index d175dbf8141b..af908c77f1bb 100644
--- a/sys/modules/cam/Makefile
+++ b/sys/modules/cam/Makefile
@@ -26,7 +26,9 @@ SRCS+= scsi_targ_bh.c scsi_target.c
EXPORT_SYMS= YES # XXX evaluate
+.if !defined(KERNBUILDDIR)
opt_scsi.h:
echo "#define SCSI_DELAY 15000" > ${.TARGET}
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/coda5/Makefile b/sys/modules/coda5/Makefile
index f974cc09b31b..4c0226e80348 100644
--- a/sys/modules/coda5/Makefile
+++ b/sys/modules/coda5/Makefile
@@ -8,7 +8,9 @@ SRCS= vnode_if.h \
coda_venus.c coda_vfsops.c coda_vnops.c \
opt_coda.h
+.if !defined(KERNBUILDDIR)
opt_coda.h:
echo "#define CODA_COMPAT_5" > ${.TARGET}
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/cp/Makefile b/sys/modules/cp/Makefile
index fb8d951da4ad..92446329929d 100644
--- a/sys/modules/cp/Makefile
+++ b/sys/modules/cp/Makefile
@@ -4,36 +4,26 @@
.PATH: ${.CURDIR}/../../dev/cp
KMOD = if_cp
SRCS = if_cp.c cpddk.c
-SRCS += opt_netgraph.h opt_ng_cronyx.h device_if.h bus_if.h bpf.h\
- pci_if.h sppp.h
+SRCS += opt_netgraph.h opt_ng_cronyx.h device_if.h bus_if.h \
+ pci_if.h
NO_MAN=
-NBPF?= 0
+.if !defined(KERNBUILDDIR)
PROTOS?= -DINET
NG_CRONYX?= 0
NETGRAPH= ${NG_CRONYX}
CFLAGS+= ${PROTOS}
-CLEANFILES+= bpf.h sppp.h
+.if ${NETGRAPH} != 0
opt_netgraph.h:
echo "#define NETGRAPH ${NETGRAPH}" > opt_netgraph.h
+.endif
-opt_ng_cronyx.h:
.if ${NG_CRONYX} != 0
+opt_ng_cronyx.h:
echo "#define NETGRAPH_CRONYX 1" > opt_ng_cronyx.h
-.else
- echo "" > opt_ng_cronyx.h
.endif
-
-sppp.h:
-.if ${NG_CRONYX} == 0
- echo "#define NSPPP 1" > sppp.h
-.else
- echo "#define NSPPP 0" > sppp.h
-.endif
-
-bpf.h:
- echo "#define NBPF ${NBPF}" > bpf.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/ctau/Makefile b/sys/modules/ctau/Makefile
index 75ad7f0a96f9..2f210f8918cb 100644
--- a/sys/modules/ctau/Makefile
+++ b/sys/modules/ctau/Makefile
@@ -2,36 +2,26 @@
# $FreeBSD$
.PATH: ${.CURDIR}/../../dev/ctau
KMOD= if_ct
-SRCS= if_ct.c ctddk.c ctau.c opt_netgraph.h opt_ng_cronyx.h bpf.h sppp.h \
+SRCS= if_ct.c ctddk.c ctau.c opt_netgraph.h opt_ng_cronyx.h \
device_if.h bus_if.h isa_if.h
-NBPF?= 0
+.if !defined(KERNBUILDDIR)
NCTAU?= 3
PROTOS?= -DINET
NG_CRONYX?= 0
NETGRAPH= ${NG_CRONYX}
CFLAGS+= ${PROTOS}
-CLEANFILES+= bpf.h sppp.h
+.if ${NETGRAPH} != 0
opt_netgraph.h:
echo "#define NETGRAPH $(NETGRAPH)" > opt_netgraph.h
+.endif
-opt_ng_cronyx.h:
.if ${NG_CRONYX} != 0
+opt_ng_cronyx.h:
echo "#define NETGRAPH_CRONYX 1" > opt_ng_cronyx.h
-.else
- echo "" > opt_ng_cronyx.h
.endif
-
-sppp.h:
-.if ${NG_CRONYX} == 0
- echo "#define NSPPP 1" > sppp.h
-.else
- echo "#define NSPPP 0" > sppp.h
-.endif
-
-bpf.h:
- echo "#define NBPF ${NBPF}" > bpf.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/cx/Makefile b/sys/modules/cx/Makefile
index ce9932c1e0c1..0716f9055b93 100644
--- a/sys/modules/cx/Makefile
+++ b/sys/modules/cx/Makefile
@@ -3,36 +3,25 @@
.PATH: ${.CURDIR}/../../dev/cx
KMOD= if_cx
-SRCS= if_cx.c cxddk.c csigma.c opt_netgraph.h opt_ng_cronyx.h bpf.h \
- sppp.h device_if.h bus_if.h isa_if.h
+SRCS= if_cx.c cxddk.c csigma.c opt_netgraph.h opt_ng_cronyx.h \
+ device_if.h bus_if.h isa_if.h
-NBPF?= 0
+.if !defined(KERNBUILDDIR)
PROTOS?= -DINET
NG_CRONYX?= 0
NETGRAPH= ${NG_CRONYX}
-
CFLAGS+= ${PROTOS}
-CLEANFILES+= bpf.h sppp.h
+.if ${NETGRAPH} != 0
opt_netgraph.h:
echo "#define NETGRAPH $(NETGRAPH)" > opt_netgraph.h
+.endif
-opt_ng_cronyx.h:
.if ${NG_CRONYX} != 0
+opt_ng_cronyx.h:
echo "#define NETGRAPH_CRONYX 1" > opt_ng_cronyx.h
-.else
- echo "" > opt_ng_cronyx.h
.endif
-
-sppp.h:
-.if ${NG_CRONYX} == 0
- echo "#define NSPPP 1" > sppp.h
-.else
- echo "#define NSPPP 0" > sppp.h
.endif
-bpf.h:
- echo "#define NBPF ${NBPF}" > bpf.h
-
.include <bsd.kmod.mk>
diff --git a/sys/modules/dcons/Makefile b/sys/modules/dcons/Makefile
index 555dd688709f..e430a6573614 100644
--- a/sys/modules/dcons/Makefile
+++ b/sys/modules/dcons/Makefile
@@ -7,11 +7,13 @@ KMOD = dcons
SRCS = dcons.c dcons.h dcons_os.c dcons_os.h \
opt_dcons.h opt_ddb.h opt_comconsole.h
+.if !defined(KERNBUILDDIR)
opt_ddb.h:
echo "#define KDB 1" > $@
opt_comconsole.h:
echo "#define ALT_BREAK_TO_DEBUGGER 1" > $@
+.endif
CFLAGS+= -I${.CURDIR}/../..
diff --git a/sys/modules/digi/digi/Makefile b/sys/modules/digi/digi/Makefile
index 5737af536f05..6ba9c6ed219e 100644
--- a/sys/modules/digi/digi/Makefile
+++ b/sys/modules/digi/digi/Makefile
@@ -7,7 +7,9 @@ SRCS+= digi.h digi_pci.h digireg.h digi_mod.h
SRCS+= bus_if.h pci_if.h device_if.h
SRCS+= opt_compat.h
+.if !defined(KERNBUILDDIR)
opt_compat.h:
echo "#define COMPAT_43 1" > opt_compat.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/en/Makefile b/sys/modules/en/Makefile
index 42909facad40..8f342e32fb3b 100644
--- a/sys/modules/en/Makefile
+++ b/sys/modules/en/Makefile
@@ -8,6 +8,7 @@ SRCS+= opt_inet.h opt_natm.h opt_ddb.h
CFLAGS+= -DENABLE_BPF
# CFLAGS+= -DINVARIANT_SUPPORT -DINVARIANTS -DEN_DEBUG=0
+.if !defined(KERNBUILDDIR)
opt_inet.h:
echo "#define INET 1" > ${.TARGET}
@@ -16,5 +17,6 @@ opt_natm.h:
# opt_ddb.h:
# echo "#define DDB 1" > ${.TARGET}
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/fatm/Makefile b/sys/modules/fatm/Makefile
index f6d39672a4f2..c77ea7109e34 100644
--- a/sys/modules/fatm/Makefile
+++ b/sys/modules/fatm/Makefile
@@ -9,10 +9,12 @@ SRCS= if_fatm.c device_if.h bus_if.h pci_if.h opt_inet.h opt_natm.h
# CFLAGS+= -DFATM_DEBUG=0 -DINVARIANT_SUPPORT -DINVARIANTS
+.if !defined(KERNBUILDDIR)
opt_inet.h:
echo "#define INET 1" > opt_inet.h
opt_natm.h:
echo "#define NATM 1" > opt_natm.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/firewire/fwip/Makefile b/sys/modules/firewire/fwip/Makefile
index 002bd9a85491..ed2ca4a02b91 100644
--- a/sys/modules/firewire/fwip/Makefile
+++ b/sys/modules/firewire/fwip/Makefile
@@ -11,8 +11,10 @@ SRCS = bus_if.h device_if.h \
firewire.h firewirereg.h \
if_fwsubr.c
+.if !defined(KERNBUILDDIR)
opt_inet.h:
echo "#define INET 1" > ${.TARGET}
+.endif
#CFLAGS += -DDEVICE_POLLING
diff --git a/sys/modules/hatm/Makefile b/sys/modules/hatm/Makefile
index f455f810a6c2..5dcf113924e6 100644
--- a/sys/modules/hatm/Makefile
+++ b/sys/modules/hatm/Makefile
@@ -11,10 +11,12 @@ SRCS= if_hatm.c if_hatm_intr.c if_hatm_ioctl.c if_hatm_tx.c if_hatm_rx.c \
CFLAGS+= -DENABLE_BPF
# CFLAGS+= -DHATM_DEBUG -DINVARIANT_SUPPORT -DINVARIANTS
+.if !defined(KERNBUILDDIR)
opt_inet.h:
echo "#define INET 1" > opt_inet.h
opt_natm.h:
echo "#define NATM 1" > opt_natm.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/hifn/Makefile b/sys/modules/hifn/Makefile
index a3f4f850b6ff..5cd804d28b2c 100644
--- a/sys/modules/hifn/Makefile
+++ b/sys/modules/hifn/Makefile
@@ -6,7 +6,9 @@ SRCS = hifn7751.c opt_hifn.h
SRCS += device_if.h bus_if.h pci_if.h
SRCS += opt_bus.h crypto_if.h
+.if !defined(KERNBUILDDIR)
opt_hifn.h:
echo "#define HIFN_DEBUG 1" > opt_hifn.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/if_bridge/Makefile b/sys/modules/if_bridge/Makefile
index 1727d750211a..fa47a7659313 100644
--- a/sys/modules/if_bridge/Makefile
+++ b/sys/modules/if_bridge/Makefile
@@ -4,6 +4,7 @@
KMOD= if_bridge
SRCS= if_bridge.c bridgestp.c opt_inet.h opt_inet6.h
+.if !defined(KERNBUILDDIR)
opt_inet.h:
echo "#define INET 1" > ${.TARGET}
@@ -11,5 +12,6 @@ opt_inet.h:
opt_inet6.h:
echo "#define INET6 1" > ${.TARGET}
.endif
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/if_disc/Makefile b/sys/modules/if_disc/Makefile
index f88df14eb649..9dc5742eaa0b 100644
--- a/sys/modules/if_disc/Makefile
+++ b/sys/modules/if_disc/Makefile
@@ -5,10 +5,12 @@
KMOD= if_disc
SRCS= if_disc.c opt_inet.h opt_inet6.h
+.if !defined(KERNBUILDDIR)
opt_inet.h:
echo "#define INET 1" > ${.TARGET}
#opt_inet6.h:
# echo "#define INET6 1" > ${.TARGET}
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/if_ef/Makefile b/sys/modules/if_ef/Makefile
index 03e1e5087cf4..3e6ef70075bf 100644
--- a/sys/modules/if_ef/Makefile
+++ b/sys/modules/if_ef/Makefile
@@ -16,6 +16,7 @@ ETHER_SNAP=
CFLAGS+= -DEF_DEBUG
.endif
+.if !defined(KERNBUILDDIR)
opt_inet.h:
echo "#define INET 1" > opt_inet.h
@@ -28,5 +29,6 @@ opt_ef.h:
echo "#define ${frame} 1" >> opt_ef.h
.endif
.endfor
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/if_faith/Makefile b/sys/modules/if_faith/Makefile
index 959d5e287fc0..a46d5fd399d6 100644
--- a/sys/modules/if_faith/Makefile
+++ b/sys/modules/if_faith/Makefile
@@ -5,10 +5,12 @@
KMOD= if_faith
SRCS= if_faith.c opt_inet.h opt_inet6.h
+.if !defined(KERNBUILDDIR)
opt_inet.h:
echo "#define INET 1" > ${.TARGET}
opt_inet6.h:
echo "#define INET6 1" > ${.TARGET}
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/if_gif/Makefile b/sys/modules/if_gif/Makefile
index df04cba7ba0c..0aa4deeb0aa9 100644
--- a/sys/modules/if_gif/Makefile
+++ b/sys/modules/if_gif/Makefile
@@ -9,6 +9,7 @@ SRCS= if_gif.c in_gif.c opt_inet.h opt_inet6.h opt_mac.h \
SRCS+= in6_gif.c
.endif
+.if !defined(KERNBUILDDIR)
opt_inet.h:
echo "#define INET 1" > ${.TARGET}
@@ -19,5 +20,6 @@ opt_inet6.h:
opt_mrouting.h:
echo "#define MROUTING 1" > ${.TARGET}
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/if_gre/Makefile b/sys/modules/if_gre/Makefile
index b7b70895b343..87da7b037d03 100644
--- a/sys/modules/if_gre/Makefile
+++ b/sys/modules/if_gre/Makefile
@@ -5,6 +5,7 @@
KMOD= if_gre
SRCS= if_gre.c ip_gre.c opt_inet.h opt_inet6.h opt_atalk.h
+.if !defined(KERNBUILDDIR)
opt_inet.h:
echo "#define INET 1" > ${.TARGET}
@@ -13,5 +14,6 @@ opt_inet6.h:
opt_atalk.h:
echo "#define NETATALK 1" > ${.TARGET}
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/if_ppp/Makefile b/sys/modules/if_ppp/Makefile
index 95f81f9de80e..eef495fce88c 100644
--- a/sys/modules/if_ppp/Makefile
+++ b/sys/modules/if_ppp/Makefile
@@ -19,6 +19,7 @@ SRCS+= bsd_comp.c
SRCS+= ppp_deflate.c zlib.c
.endif
+.if !defined(KERNBUILDDIR)
.if ${PPP_INET} > 0
opt_inet.h:
echo "#define INET 1" >> ${.TARGET}
@@ -40,5 +41,6 @@ opt_ppp.h:
.if ${PPP_FILTER} > 0
echo "#define PPP_FILTER ${PPP_FILTER}" >> ${.TARGET}
.endif
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/if_sl/Makefile b/sys/modules/if_sl/Makefile
index e57301317f08..800a9847943c 100644
--- a/sys/modules/if_sl/Makefile
+++ b/sys/modules/if_sl/Makefile
@@ -5,7 +5,9 @@
KMOD= if_sl
SRCS= if_sl.c slcompress.c opt_inet.h opt_slip.h
+.if !defined(KERNBUILDDIR)
opt_inet.h:
echo "#define INET 1" > ${.TARGET}
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/if_stf/Makefile b/sys/modules/if_stf/Makefile
index 2ea7363437a0..c231b002229c 100644
--- a/sys/modules/if_stf/Makefile
+++ b/sys/modules/if_stf/Makefile
@@ -5,10 +5,12 @@
KMOD= if_stf
SRCS= if_stf.c opt_inet.h opt_inet6.h opt_mac.h
+.if !defined(KERNBUILDDIR)
opt_inet.h:
echo "#define INET 1" > ${.TARGET}
opt_inet6.h:
echo "#define INET6 1" > ${.TARGET}
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/if_tap/Makefile b/sys/modules/if_tap/Makefile
index dcd6df39b51b..3b75586acd59 100644
--- a/sys/modules/if_tap/Makefile
+++ b/sys/modules/if_tap/Makefile
@@ -7,7 +7,9 @@
KMOD= if_tap
SRCS= if_tap.c opt_inet.h vnode_if.h
+.if !defined(KERNBUILDDIR)
opt_inet.h:
echo "#define INET 1" > opt_inet.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/if_tun/Makefile b/sys/modules/if_tun/Makefile
index e94f835dd5ac..17dbf33b9dd9 100644
--- a/sys/modules/if_tun/Makefile
+++ b/sys/modules/if_tun/Makefile
@@ -5,6 +5,7 @@
KMOD= if_tun
SRCS= if_tun.c opt_atalk.h opt_inet.h opt_inet6.h opt_ipx.h opt_mac.h
+.if !defined(KERNBUILDDIR)
opt_atalk.h:
echo "#define NETATALK 1" > ${.TARGET}
@@ -16,5 +17,6 @@ opt_inet6.h:
opt_ipx.h:
echo "#define IPX 1" > ${.TARGET}
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/if_vlan/Makefile b/sys/modules/if_vlan/Makefile
index 797ece457eda..8b46e42fed32 100644
--- a/sys/modules/if_vlan/Makefile
+++ b/sys/modules/if_vlan/Makefile
@@ -5,7 +5,9 @@
KMOD= if_vlan
SRCS= if_vlan.c opt_inet.h
+.if !defined(KERNBUILDDIR)
opt_inet.h:
echo "#define INET 1" > ${.TARGET}
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/ip_mroute_mod/Makefile b/sys/modules/ip_mroute_mod/Makefile
index be135def4026..b78d735b4e06 100644
--- a/sys/modules/ip_mroute_mod/Makefile
+++ b/sys/modules/ip_mroute_mod/Makefile
@@ -7,7 +7,9 @@ SRCS= ip_mroute.c opt_mac.h opt_mrouting.h
CFLAGS+= -DMROUTE_KLD
+.if !defined(KERNBUILDDIR)
opt_mrouting.h:
echo "#define MROUTING 1" > ${.TARGET}
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/ipfilter/Makefile b/sys/modules/ipfilter/Makefile
index 9cb029068b6f..542af84efa3f 100644
--- a/sys/modules/ipfilter/Makefile
+++ b/sys/modules/ipfilter/Makefile
@@ -8,14 +8,15 @@ SRCS= mlfk_ipl.c ip_nat.c ip_frag.c ip_state.c ip_proxy.c ip_auth.c \
ip_sync.c
SRCS+= opt_bpf.h opt_inet6.h
+.if !defined(KERNBUILDDIR)
opt_bpf.h:
echo "#define DEV_BPF 1" > ${.TARGET}
.if !defined(NO_INET6)
-CFLAGS+= -DUSE_INET6
opt_inet6.h:
echo "#define INET6 1" > ${.TARGET}
.endif
+.endif
CFLAGS+= -I${.CURDIR}/../../contrib/ipfilter
CFLAGS+= -DIPFILTER=1 -DIPFILTER_LKM -DIPFILTER_LOG -DIPFILTER_LOOKUP
#
diff --git a/sys/modules/kbdmux/Makefile b/sys/modules/kbdmux/Makefile
index 78569edbc0e5..9ac6de35792f 100644
--- a/sys/modules/kbdmux/Makefile
+++ b/sys/modules/kbdmux/Makefile
@@ -6,7 +6,9 @@
KMOD= kbdmux
SRCS= kbdmux.c opt_kbd.h
+.if !defined(KERNBUILDDIR)
opt_kbd.h:
echo "#define KBD_INSTALL_CDEV 1" > ${.TARGET}
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/linux/Makefile b/sys/modules/linux/Makefile
index e446790c0a27..213fa4d5e80c 100644
--- a/sys/modules/linux/Makefile
+++ b/sys/modules/linux/Makefile
@@ -37,10 +37,12 @@ linux_locore.o: linux_locore.s linux_assym.h
linux_genassym.o: linux_genassym.c linux.h @ machine
${CC} -c ${CFLAGS:N-fno-common} ${.IMPSRC}
+.if !defined(KERNBUILDDIR)
opt_compat.h:
echo "#define COMPAT_43 1" > opt_compat.h
opt_inet6.h:
echo "#define INET6 1" > opt_inet6.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/netgraph/gif/Makefile b/sys/modules/netgraph/gif/Makefile
index 4c18c27e50c2..acf4373f26bf 100644
--- a/sys/modules/netgraph/gif/Makefile
+++ b/sys/modules/netgraph/gif/Makefile
@@ -3,10 +3,12 @@
KMOD= ng_gif
SRCS= ng_gif.c opt_inet.h opt_inet6.h
+.if !defined(KERNBUILDDIR)
opt_inet.h:
echo "#define INET 1" > ${.TARGET}
opt_inet6.h:
echo "#define INET6 1" > ${.TARGET}
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/netgraph/iface/Makefile b/sys/modules/netgraph/iface/Makefile
index 98940efbf564..2a6819bb709d 100644
--- a/sys/modules/netgraph/iface/Makefile
+++ b/sys/modules/netgraph/iface/Makefile
@@ -4,6 +4,7 @@
KMOD= ng_iface
SRCS= ng_iface.c opt_atalk.h opt_inet.h opt_inet6.h opt_ipx.h
+.if !defined(KERNBUILDDIR)
opt_atalk.h:
echo "#define NETATALK 1" > ${.TARGET}
@@ -15,5 +16,6 @@ opt_inet6.h:
opt_ipx.h:
echo "#define IPX 1" > ${.TARGET}
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/netgraph/mppc/Makefile b/sys/modules/netgraph/mppc/Makefile
index 7e337f4f4c44..968e2ac007dc 100644
--- a/sys/modules/netgraph/mppc/Makefile
+++ b/sys/modules/netgraph/mppc/Makefile
@@ -18,6 +18,7 @@ SRCS+= mppcc.c mppcd.c
SRCS+= sha1.c
.endif
+.if !defined(KERNBUILDDIR)
opt_netgraph.h:
touch ${.TARGET}
.if ${NETGRAPH_MPPC_COMPRESSION} > 0
@@ -26,5 +27,6 @@ opt_netgraph.h:
.if ${NETGRAPH_MPPC_ENCRYPTION} > 0
echo "#define NETGRAPH_MPPC_ENCRYPTION 1" >> ${.TARGET}
.endif
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/netgraph/sync_ar/Makefile b/sys/modules/netgraph/sync_ar/Makefile
index bc51040f0d15..11136c2a3bd7 100644
--- a/sys/modules/netgraph/sync_ar/Makefile
+++ b/sys/modules/netgraph/sync_ar/Makefile
@@ -5,7 +5,9 @@ KMOD = ng_sync_ar
SRCS = if_ar.c if_ar_isa.c if_ar_pci.c
SRCS += device_if.h bus_if.h pci_if.h isa_if.h opt_netgraph.h
+.if !defined(KERNBUILDDIR)
opt_netgraph.h:
echo "#define NETGRAPH" > opt_netgraph.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/netgraph/sync_sr/Makefile b/sys/modules/netgraph/sync_sr/Makefile
index 16a291ca4654..ae49a3a40bbc 100644
--- a/sys/modules/netgraph/sync_sr/Makefile
+++ b/sys/modules/netgraph/sync_sr/Makefile
@@ -5,7 +5,9 @@ KMOD = ng_sync_sr
SRCS = if_sr.c if_sr_isa.c if_sr_pci.c
SRCS += device_if.h bus_if.h pci_if.h isa_if.h opt_netgraph.h
+.if !defined(KERNBUILDDIR)
opt_netgraph.h:
echo "#define NETGRAPH" > opt_netgraph.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/nfs4client/Makefile b/sys/modules/nfs4client/Makefile
index 5d6a695f8842..83c2017a8600 100644
--- a/sys/modules/nfs4client/Makefile
+++ b/sys/modules/nfs4client/Makefile
@@ -11,9 +11,6 @@ SRCS= vnode_if.h \
nfs4_vfs_subs.c nfs4_vfsops.c nfs4_vn_subs.c nfs4_vnops.c
SRCS+= opt_inet6.h
-NFS_INET?= 1 # 0/1 - requires INET to be configured in kernel
-NFS_INET6?= 1 # 0/1 - requires INET6 to be configured in kernel
-
# USE THE RPCCLNT:
CFLAGS+= -DRPCCLNT_DEBUG
SRCS+= rpcclnt.c
@@ -21,6 +18,10 @@ SRCS+= rpcclnt.c
# USE THE NEW IDMAPPER
CFLAGS+= -DUSE_NEW_IDMAPPER
+.if !defined(KERNBUILDDIR)
+NFS_INET?= 1 # 0/1 - requires INET to be configured in kernel
+NFS_INET6?= 1 # 0/1 - requires INET6 to be configured in kernel
+
.if ${NFS_INET} > 0
opt_inet.h:
echo "#define INET 1" > ${.TARGET}
@@ -30,6 +31,7 @@ opt_inet.h:
opt_inet6.h:
echo "#define INET6 1" > ${.TARGET}
.endif
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/nfsclient/Makefile b/sys/modules/nfsclient/Makefile
index 1d7565e719ea..7b4a29d20065 100644
--- a/sys/modules/nfsclient/Makefile
+++ b/sys/modules/nfsclient/Makefile
@@ -12,9 +12,6 @@ SRCS+= nfs4_dev.c nfs4_idmap.c nfs4_socket.c nfs4_subs.c \
nfs4_vfs_subs.c nfs4_vfsops.c nfs4_vn_subs.c nfs4_vnops.c
SRCS+= opt_inet6.h
-NFS_INET?= 1 # 0/1 - requires INET to be configured in kernel
-NFS_INET6?= 1 # 0/1 - requires INET6 to be configured in kernel
-
# USE THE RPCCLNT:
CFLAGS+= -DRPCCLNT_DEBUG
SRCS+= rpcclnt.c
@@ -22,6 +19,10 @@ SRCS+= rpcclnt.c
# USE THE NEW IDMAPPER
CFLAGS+= -DUSE_NEW_IDMAPPER
+.if !defined(KERNBUILDDIR)
+NFS_INET?= 1 # 0/1 - requires INET to be configured in kernel
+NFS_INET6?= 1 # 0/1 - requires INET6 to be configured in kernel
+
.if ${NFS_INET} > 0
opt_inet.h:
echo "#define INET 1" > ${.TARGET}
@@ -31,6 +32,7 @@ opt_inet.h:
opt_inet6.h:
echo "#define INET6 1" > ${.TARGET}
.endif
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/nfsserver/Makefile b/sys/modules/nfsserver/Makefile
index fb9d0f2dae09..8e33c46cef31 100644
--- a/sys/modules/nfsserver/Makefile
+++ b/sys/modules/nfsserver/Makefile
@@ -8,11 +8,14 @@ SRCS= vnode_if.h \
opt_mac.h \
opt_nfs.h
SRCS+= opt_inet6.h
+
+.if !defined(KERNBUILDDIR)
NFS_INET6?= 1 # 0/1 - requires INET6 to be configured in kernel
.if ${NFS_INET6} > 0
opt_inet6.h:
echo "#define INET6 1" > ${.TARGET}
.endif
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/nmdm/Makefile b/sys/modules/nmdm/Makefile
index 4982c382a45f..b788334869f0 100644
--- a/sys/modules/nmdm/Makefile
+++ b/sys/modules/nmdm/Makefile
@@ -6,10 +6,12 @@ KMOD= nmdm
SRCS= nmdm.c
SRCS+= opt_compat.h opt_tty.h vnode_if.h
+.if !defined(KERNBUILDDIR)
opt_compat.h:
echo "#define COMPAT_43 1" >opt_compat.h
opt_tty.h:
echo "#define TTYHOG 8192" >opt_tty.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/nwfs/Makefile b/sys/modules/nwfs/Makefile
index 255aabc51a4b..69349de44709 100644
--- a/sys/modules/nwfs/Makefile
+++ b/sys/modules/nwfs/Makefile
@@ -6,13 +6,10 @@ KMOD= nwfs
SRCS= vnode_if.h \
nwfs_node.c nwfs_ioctl.c nwfs_io.c nwfs_vfsops.c nwfs_vnops.c \
- nwfs_subr.c opt_ncp.h opt_vmpage.h
+ nwfs_subr.c opt_vmpage.h
.if defined(VNPRINT)
CFLAGS+= -DVNPRINT
.endif
-opt_ncp.h:
- echo "#define NCP 1" > ${.TARGET}
-
.include <bsd.kmod.mk>
diff --git a/sys/modules/osf1/Makefile b/sys/modules/osf1/Makefile
index d8a8896c3015..b03350ef4439 100644
--- a/sys/modules/osf1/Makefile
+++ b/sys/modules/osf1/Makefile
@@ -8,7 +8,9 @@ SRCS= osf1_ioctl.c osf1_misc.c osf1_signal.c osf1_sysent.c \
opt_ddb.h opt_mac.h opt_nfs.h device_if.h bus_if.h \
vnode_if.h
+.if !defined(KERNBUILDDIR)
opt_compat.h:
echo "#define COMPAT_43 1" > ${.TARGET}
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/patm/Makefile b/sys/modules/patm/Makefile
index daa483b6529d..7e33a36c0348 100644
--- a/sys/modules/patm/Makefile
+++ b/sys/modules/patm/Makefile
@@ -12,10 +12,12 @@ SRCS= if_patm.c if_patm_attach.c if_patm_ioctl.c if_patm_intr.c \
CFLAGS+= -DENABLE_BPF
# CFLAGS+= -DPATM_DEBUG=0x0 -DINVARIANT_SUPPORT -DINVARIANTS -DDIAGNOSTIC
+.if !defined(KERNBUILDDIR)
opt_inet.h:
echo "#define INET 1" > opt_inet.h
opt_natm.h:
echo "#define NATM 1" > opt_natm.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/pf/Makefile b/sys/modules/pf/Makefile
index d52119b25904..9a73c41923dc 100644
--- a/sys/modules/pf/Makefile
+++ b/sys/modules/pf/Makefile
@@ -12,6 +12,7 @@ SRCS = pf.c pf_if.c pf_subr.c pf_osfp.c pf_ioctl.c pf_norm.c pf_table.c \
CFLAGS+= -I${.CURDIR}/../../contrib/pf
+.if !defined(KERNBUILDDIR)
opt_pf.h:
echo "#define DEV_PF 1" > opt_pf.h
echo "#define DEV_PFLOG 1" >> opt_pf.h
@@ -26,5 +27,6 @@ opt_inet6.h:
opt_bpf.h:
echo "#define DEV_BPF 1" > opt_bpf.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/rc/Makefile b/sys/modules/rc/Makefile
index 9cc8f0306552..cc8d22826a45 100644
--- a/sys/modules/rc/Makefile
+++ b/sys/modules/rc/Makefile
@@ -5,7 +5,9 @@
KMOD= rc
SRCS= rc.c device_if.h bus_if.h isa_if.h opt_tty.h
+.if !defined(KERNBUILDDIR)
opt_tty.h:
echo "#define TTYHOG 8192" >opt_tty.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/rp/Makefile b/sys/modules/rp/Makefile
index cff6e12dad00..8c4c9d972bbc 100644
--- a/sys/modules/rp/Makefile
+++ b/sys/modules/rp/Makefile
@@ -5,7 +5,9 @@
KMOD= rp
SRCS= rp.c rp_pci.c device_if.h bus_if.h pci_if.h opt_compat.h
+.if !defined(KERNBUILDDIR)
opt_compat.h:
echo "#define COMPAT_43 1" > opt_compat.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/safe/Makefile b/sys/modules/safe/Makefile
index 688689735fa1..2e4bb84f05d5 100644
--- a/sys/modules/safe/Makefile
+++ b/sys/modules/safe/Makefile
@@ -32,7 +32,9 @@ SRCS = safe.c opt_safe.h
SRCS += device_if.h bus_if.h pci_if.h
SRCS += opt_bus.h crypto_if.h
+.if !defined(KERNBUILDDIR)
opt_safe.h:
echo "#define SAFE_DEBUG 1" > opt_safe.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/sio/Makefile b/sys/modules/sio/Makefile
index 8ec6b4efe2ee..59386e6b0efb 100644
--- a/sys/modules/sio/Makefile
+++ b/sys/modules/sio/Makefile
@@ -15,6 +15,7 @@ SRCS+= sio_cbus.c
SRCS+= sio_isa.c
.endif
+.if !defined(KERNBUILDDIR)
opt_compat.h:
echo "#define COMPAT_43 1" > ${.TARGET}
@@ -23,5 +24,6 @@ opt_sio.h:
echo "#define COM_MULTIPORT 1" > ${.TARGET}
echo "#define COM_ESP 1" >> ${.TARGET}
.endif
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/smbfs/Makefile b/sys/modules/smbfs/Makefile
index c9a0d19eb500..17aa4487e348 100644
--- a/sys/modules/smbfs/Makefile
+++ b/sys/modules/smbfs/Makefile
@@ -42,6 +42,7 @@ CFLAGS+= ${KDEBUG}
CFLAGS+= -DVNPRINT
.endif
+.if !defined(KERNBUILDDIR)
.if ${SMB_INET} > 0
opt_inet.h:
echo "#define INET 1" > ${.TARGET}
@@ -52,10 +53,11 @@ opt_ipx.h:
echo "#define IPX 1" > ${.TARGET}
.endif
-opt_netsmb.h:
- echo "#define NETSMB 1" > ${.TARGET}
+# XXX netsmb should be a separate module
.if defined(NETSMBCRYPTO)
- echo "#define NETSMBCRYPTO 1" >> ${.TARGET}
+opt_netsmb.h:
+ echo "#define NETSMBCRYPTO 1" > ${.TARGET}
+.endif
.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/snc/Makefile b/sys/modules/snc/Makefile
index b8623726fed5..6c71146252a7 100644
--- a/sys/modules/snc/Makefile
+++ b/sys/modules/snc/Makefile
@@ -6,7 +6,9 @@ KMOD= if_snc
SRCS= if_snc.c if_snc_cbus.c if_snc_pccard.c dp83932.c dp83932subr.c
SRCS+= opt_inet.h device_if.h bus_if.h isa_if.h
+.if !defined(KERNBUILDDIR)
opt_inet.h:
echo "#define INET 1" > ${.TARGET}
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/sppp/Makefile b/sys/modules/sppp/Makefile
index 030f843e5f42..0976210a21a3 100644
--- a/sys/modules/sppp/Makefile
+++ b/sys/modules/sppp/Makefile
@@ -15,6 +15,7 @@ EXPORT_SYMS= sppp_attach \
sppp_isempty \
sppp_flush
+.if !defined(KERNBUILDDIR)
opt_inet.h:
echo "#define INET 1" > opt_inet.h
@@ -23,5 +24,6 @@ opt_inet6.h:
opt_ipx.h:
echo "#define IPX 1" > opt_ipx.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/sr/Makefile b/sys/modules/sr/Makefile
index b49d21edbdbe..22bfc4bb5483 100644
--- a/sys/modules/sr/Makefile
+++ b/sys/modules/sr/Makefile
@@ -5,13 +5,13 @@ KMOD = if_sr
SRCS = if_sr.c if_sr_isa.c if_sr_pci.c
SRCS += device_if.h bus_if.h pci_if.h isa_if.h opt_netgraph.h
+.if !defined(KERNBUILDDIR)
NETGRAPH?= 0
-opt_netgraph.h:
.if ${NETGRAPH} != 0
+opt_netgraph.h:
echo "#define NETGRAPH ${NETGRAPH}" > opt_netgraph.h
-.else
- echo "" > opt_netgraph.h
+.endif
.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/svr4/Makefile b/sys/modules/svr4/Makefile
index 25345e750c60..df17758fafa6 100644
--- a/sys/modules/svr4/Makefile
+++ b/sys/modules/svr4/Makefile
@@ -26,6 +26,7 @@ svr4_locore.o: svr4_locore.s svr4_assym.h
svr4_genassym.o: svr4_genassym.c svr4.h @ machine
${CC} -c ${CFLAGS:N-fno-common} ${.IMPSRC}
+.if !defined(KERNBUILDDIR)
opt_compat.h:
echo "#define COMPAT_43 1" > opt_compat.h
@@ -33,5 +34,6 @@ opt_compat.h:
opt_svr4.h:
echo "#define DEBUG_SVR4 1" > opt_svr4.h
.endif
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/trm/Makefile b/sys/modules/trm/Makefile
index f984794b3070..beb1ab474980 100644
--- a/sys/modules/trm/Makefile
+++ b/sys/modules/trm/Makefile
@@ -6,7 +6,9 @@ KMOD= trm
SRCS= trm.c trm.h opt_cam.h device_if.h bus_if.h \
opt_scsi.h pci_if.h
+.if !defined(KERNBUILDDIR)
opt_scsi.h:
echo "#define SCSI_DELAY 15000" > opt_scsi.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/ubsec/Makefile b/sys/modules/ubsec/Makefile
index 8b6799af4e7b..661d33ec6336 100644
--- a/sys/modules/ubsec/Makefile
+++ b/sys/modules/ubsec/Makefile
@@ -6,7 +6,9 @@ SRCS = ubsec.c opt_ubsec.h
SRCS += device_if.h bus_if.h pci_if.h
SRCS += opt_bus.h crypto_if.h
+.if !defined(KERNBUILDDIR)
opt_ubsec.h:
echo "#define UBSEC_DEBUG 1" > opt_ubsec.h
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/ukbd/Makefile b/sys/modules/ukbd/Makefile
index 3c55896e6088..80d29052d715 100644
--- a/sys/modules/ukbd/Makefile
+++ b/sys/modules/ukbd/Makefile
@@ -5,7 +5,9 @@
KMOD= ukbd
SRCS= bus_if.h device_if.h opt_usb.h opt_kbd.h opt_ukbd.h usbdevs.h ukbd.c
+.if !defined(KERNBUILDDIR)
opt_kbd.h:
echo "#define KBD_INSTALL_CDEV 1" > ${.TARGET}
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/vkbd/Makefile b/sys/modules/vkbd/Makefile
index b16ce414b4de..29591dc37efa 100644
--- a/sys/modules/vkbd/Makefile
+++ b/sys/modules/vkbd/Makefile
@@ -6,7 +6,9 @@
KMOD= vkbd
SRCS= vkbd.c opt_kbd.h
+.if !defined(KERNBUILDDIR)
opt_kbd.h:
echo "#define KBD_INSTALL_CDEV 1" > ${.TARGET}
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/wi/Makefile b/sys/modules/wi/Makefile
index ee577e8bd4ac..20fc1a209e56 100644
--- a/sys/modules/wi/Makefile
+++ b/sys/modules/wi/Makefile
@@ -6,7 +6,9 @@ KMOD= if_wi
SRCS= opt_wi.h if_wi.c if_wi_pccard.c if_wi_pci.c \
card_if.h device_if.h bus_if.h pci_if.h pccarddevs.h
+.if !defined(KERNBUILDDIR)
opt_wi.h:
echo "#define WI_SYMBOL_FIRMWARE 1" > ${.TARGET}
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/wlan/Makefile b/sys/modules/wlan/Makefile
index f37ba4420e01..4389c5a30f18 100644
--- a/sys/modules/wlan/Makefile
+++ b/sys/modules/wlan/Makefile
@@ -8,10 +8,12 @@ SRCS= ieee80211.c ieee80211_crypto.c ieee80211_crypto_none.c \
ieee80211_node.c ieee80211_output.c ieee80211_proto.c
SRCS+= bus_if.h device_if.h opt_inet.h opt_ipx.h
+.if !defined(KERNBUILDDIR)
opt_inet.h:
echo "#define INET 1" > opt_inet.h
opt_ipx.h:
echo "#define IPX 1" > opt_ipx.h
+.endif
.include <bsd.kmod.mk>