From 8f09f1ecff14a54470048d6e42719adacc0f0c45 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Tue, 25 Nov 2014 07:12:32 +0000 Subject: [PATCH 01/64] Don't create symlinks for nls/openssl unless the respective options are set --- etc/Makefile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/etc/Makefile b/etc/Makefile index ff70cc12ad0b..92b6629b3698 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -376,23 +376,29 @@ distrib-dirs: ${MTREES:N/*} ${INSTALL_SYMLINK} ../$$mandir \ ${DESTDIR}/usr/share/man/en.UTF-8/; \ done +.if ${MK_OPENSSL} != "no" cd ${DESTDIR}/usr/share/openssl/man; \ for mandir in man*; do \ ${INSTALL_SYMLINK} ../$$mandir \ ${DESTDIR}/usr/share/openssl/man/en.ISO8859-1/; \ done +.endif set - `grep "^[a-zA-Z]" ${.CURDIR}/man.alias`; \ while [ $$# -gt 0 ] ; do \ ${INSTALL_SYMLINK} "$$2" "${DESTDIR}/usr/share/man/$$1"; \ - ${INSTALL_SYMLINK} "$$2" \ - "${DESTDIR}/usr/share/openssl/man/$$1"; \ - shift; shift; \ + if [ "${MK_OPENSSL}" != "no" ]; then \ + ${INSTALL_SYMLINK} "$$2" \ + "${DESTDIR}/usr/share/openssl/man/$$1"; \ + shift; shift; \ + fi; \ done +.if ${MK_NLS} != "no" set - `grep "^[a-zA-Z]" ${.CURDIR}/nls.alias`; \ while [ $$# -gt 0 ] ; do \ ${INSTALL_SYMLINK} "$$2" "${DESTDIR}/usr/share/nls/$$1"; \ shift; shift; \ done +.endif etc-examples: cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \ From c1479b76dc5a6747f769b8cfd9bf5cc3c4c579be Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Tue, 25 Nov 2014 07:14:16 +0000 Subject: [PATCH 02/64] The shift; shift needs to be moved outside the .if ${MK_OPENSSL} conditional --- etc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/Makefile b/etc/Makefile index 92b6629b3698..431474b68c5a 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -389,8 +389,8 @@ distrib-dirs: ${MTREES:N/*} if [ "${MK_OPENSSL}" != "no" ]; then \ ${INSTALL_SYMLINK} "$$2" \ "${DESTDIR}/usr/share/openssl/man/$$1"; \ - shift; shift; \ fi; \ + shift; shift; \ done .if ${MK_NLS} != "no" set - `grep "^[a-zA-Z]" ${.CURDIR}/nls.alias`; \ From 41e0727670a602645137315e07c0357cc282995c Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Tue, 25 Nov 2014 07:30:26 +0000 Subject: [PATCH 03/64] Make bsdinstall(8) and sade(8) optional components via MK_BSDINSTALL=yes --- share/mk/src.opts.mk | 1 + tools/build/mk/OptionalObsoleteFiles.inc | 33 ++++++++++++++++++++++++ tools/build/options/WITHOUT_BSDINSTALL | 5 ++++ usr.sbin/Makefile | 5 +++- 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tools/build/options/WITHOUT_BSDINSTALL diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index 87c0f9998cd7..af546c725a04 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -57,6 +57,7 @@ __DEFAULT_YES_OPTIONS = \ BLUETOOTH \ BOOT \ BSD_CPIO \ + BSDINSTALL \ BSNMP \ BZIP2 \ CALENDAR \ diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index fa643a80916b..68e85c3851d3 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -274,6 +274,39 @@ OLD_FILES+=usr/share/man/man8/sdpd.8.gz # to be filled in #.endif +.if ${MK_BSDINSTALL} == no +OLD_FILES+=usr/libexec/bsdinstall/adduser +OLD_FILES+=usr/libexec/bsdinstall/auto +OLD_FILES+=usr/libexec/bsdinstall/autopart +OLD_FILES+=usr/libexec/bsdinstall/checksum +OLD_FILES+=usr/libexec/bsdinstall/config +OLD_FILES+=usr/libexec/bsdinstall/distextract +OLD_FILES+=usr/libexec/bsdinstall/distfetch +OLD_FILES+=usr/libexec/bsdinstall/docsinstall +OLD_FILES+=usr/libexec/bsdinstall/entropy +OLD_FILES+=usr/libexec/bsdinstall/hostname +OLD_FILES+=usr/libexec/bsdinstall/jail +OLD_FILES+=usr/libexec/bsdinstall/keymap +OLD_FILES+=usr/libexec/bsdinstall/mirrorselect +OLD_FILES+=usr/libexec/bsdinstall/mount +OLD_FILES+=usr/libexec/bsdinstall/netconfig +OLD_FILES+=usr/libexec/bsdinstall/netconfig_ipv4 +OLD_FILES+=usr/libexec/bsdinstall/netconfig_ipv6 +OLD_FILES+=usr/libexec/bsdinstall/partedit +OLD_FILES+=usr/libexec/bsdinstall/rootpass +OLD_FILES+=usr/libexec/bsdinstall/script +OLD_FILES+=usr/libexec/bsdinstall/scriptedpart +OLD_FILES+=usr/libexec/bsdinstall/services +OLD_FILES+=usr/libexec/bsdinstall/time +OLD_FILES+=usr/libexec/bsdinstall/umount +OLD_FILES+=usr/libexec/bsdinstall/wlanconfig +OLD_FILES+=usr/libexec/bsdinstall/zfsboot +OLD_FILES+=usr/sbin/bsdinstall +OLD_FILES+=usr/share/man/man8/bsdinstall.8.gz +OLD_FILES+=usr/share/man/man8/sade.8.gz +OLD_DIRS+=usr/libexec/bsdinstall +.endif + .if ${MK_CALENDAR} == no OLD_FILES+=etc/periodic/daily/300.calendar OLD_FILES+=usr/bin/calendar diff --git a/tools/build/options/WITHOUT_BSDINSTALL b/tools/build/options/WITHOUT_BSDINSTALL new file mode 100644 index 000000000000..8aaf2a6544ed --- /dev/null +++ b/tools/build/options/WITHOUT_BSDINSTALL @@ -0,0 +1,5 @@ +.\" $FreeBSD$ +Set to not build +.Xr bsdinstall 8 , +.Xr sade 8 , +and related programs. diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile index df9f8674793d..1f45385fa527 100644 --- a/usr.sbin/Makefile +++ b/usr.sbin/Makefile @@ -9,7 +9,6 @@ SUBDIR= adduser \ binmiscctl \ bootparamd \ bsdconfig \ - bsdinstall \ cdcontrol \ chkgrp \ chown \ @@ -128,6 +127,10 @@ SUBDIR+= authpf SUBDIR+= bluetooth .endif +.if ${MK_BSDINSTALL} != "no" +SUBDIR+= bsdinstall +.endif + .if ${MK_BSNMP} != "no" SUBDIR+= bsnmpd .endif From 8bbfb3bbe93c1cebc15d26e77f9130960d0e8240 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Tue, 25 Nov 2014 08:04:32 +0000 Subject: [PATCH 04/64] Don't install othermta unless MK_MAIL == yes --- etc/rc.d/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile index f26c190fe9dd..e3a38b03eedd 100644 --- a/etc/rc.d/Makefile +++ b/etc/rc.d/Makefile @@ -107,7 +107,7 @@ FILES= DAEMON \ ntpd \ ntpdate \ ${_opensm} \ - othermta \ + ${_othermta} \ pf \ pflog \ pfsync \ @@ -186,6 +186,10 @@ _kfd= kfd _kpasswdd= kpasswdd .endif +.if ${MK_MAIL} != "no" +_othermta= othermta +.endif + .if ${MK_OFED} != "no" _opensm= opensm .endif From 05bc3dd6c00f584ef8a49f8a91eb6adc70d19cd1 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Tue, 25 Nov 2014 08:39:46 +0000 Subject: [PATCH 05/64] Make inetd optional via MK_INETD --- etc/Makefile | 5 ++++- etc/rc.d/Makefile | 6 +++++- share/mk/src.opts.mk | 1 + tools/build/mk/OptionalObsoleteFiles.inc | 7 +++++++ tools/build/options/WITHOUT_INETD | 3 +++ usr.sbin/Makefile | 5 ++++- 6 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 tools/build/options/WITHOUT_INETD diff --git a/etc/Makefile b/etc/Makefile index 431474b68c5a..d8d1f72b5adf 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -25,7 +25,6 @@ BIN1= auto_master \ hosts \ hosts.allow \ hosts.equiv \ - inetd.conf \ libalias.conf \ libmap.conf \ login.access \ @@ -95,6 +94,10 @@ BIN1+= snmpd.config BIN1+= freebsd-update.conf .endif +.if ${MK_INETD} != "no" +BIN1+= inetd.conf +.endif + .if ${MK_LOCATE} != "no" BIN1+= ${.CURDIR}/../usr.bin/locate/locate/locate.rc .endif diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile index e3a38b03eedd..d90fc8350266 100644 --- a/etc/rc.d/Makefile +++ b/etc/rc.d/Makefile @@ -56,7 +56,7 @@ FILES= DAEMON \ hostid \ hostid_save \ hostname \ - inetd \ + ${_inetd} \ ip6addrctl \ ipfilter \ ipfs \ @@ -175,6 +175,10 @@ _ubthidhci= ubthidhci _casperd= casperd .endif +.if ${MK_INETD} != "no" +_inetd= inetd +.endif + .if ${MK_NS_CACHING} != "no" _nscd= nscd .endif diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index af546c725a04..b9b6687dac9b 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -95,6 +95,7 @@ __DEFAULT_YES_OPTIONS = \ ICONV \ INET \ INET6 \ + INETD \ IPFILTER \ IPFW \ JAIL \ diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index 68e85c3851d3..cefaab22c645 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -2013,6 +2013,13 @@ OLD_FILES+=usr/share/man/man8/traceroute6.8.gz OLD_FILES+=rescue/ping6 .endif +.if ${MK_INETD} == no +OLD_FILES+=etc/rc.d/inetd +OLD_FILES+=usr/sbin/inetd +OLD_FILES+=usr/share/man/man5/inetd.conf.5.gz +OLD_FILES+=usr/share/man/man8/inetd.8.gz +.endif + .if ${MK_INFO} == no OLD_FILES+=usr/bin/info OLD_FILES+=usr/bin/infokey diff --git a/tools/build/options/WITHOUT_INETD b/tools/build/options/WITHOUT_INETD new file mode 100644 index 000000000000..b4fe5dce7b30 --- /dev/null +++ b/tools/build/options/WITHOUT_INETD @@ -0,0 +1,3 @@ +.\" $FreeBSD$ +Set to not build +.Xr inetd 8 . diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile index 1f45385fa527..dd29a0d49a28 100644 --- a/usr.sbin/Makefile +++ b/usr.sbin/Makefile @@ -34,7 +34,6 @@ SUBDIR= adduser \ gstat \ i2c \ ifmcstat \ - inetd \ iostat \ iscsid \ kldxref \ @@ -175,6 +174,10 @@ SUBDIR+= rtsold SUBDIR+= traceroute6 .endif +.if ${MK_INETD} != "no" +SUBDIR+= inetd +.endif + .if ${MK_IPFW} != "no" SUBDIR+= ipfwpcap .endif From 1bdede93d8fc7416168c2bd1bae922e34638d23a Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Tue, 25 Nov 2014 19:01:49 +0000 Subject: [PATCH 06/64] Make src.opts.mk the source of truth for whether or not to build hyperv In particular, according to several Makefiles it can only be built/run on amd64 and i386/i386. It isn't supported on i386/pc98 --- share/mk/src.opts.mk | 8 +++++++- usr.sbin/Makefile.i386 | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index b9b6687dac9b..0a469280f9d1 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -91,7 +91,6 @@ __DEFAULT_YES_OPTIONS = \ GPL_DTC \ GROFF \ HTML \ - HYPERV \ ICONV \ INET \ INET6 \ @@ -213,6 +212,13 @@ __DEFAULT_NO_OPTIONS+=CLANG_IS_CC CLANG CLANG_BOOTSTRAP __DEFAULT_YES_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX .endif +# hyperv is only supported on amd64 and i386/i386 +.if ${__T} == "amd64" || (${__T} == "i386" && ${__TT} == "i386") +__DEFAULT_YES_OPTIONS+=HYPERV +.else +MK_HYPERV:= no +.endif + .include # diff --git a/usr.sbin/Makefile.i386 b/usr.sbin/Makefile.i386 index 772c11d02058..de7bb464f581 100644 --- a/usr.sbin/Makefile.i386 +++ b/usr.sbin/Makefile.i386 @@ -9,6 +9,9 @@ SUBDIR+= asf SUBDIR+= btxld .endif SUBDIR+= cpucontrol +.if ${MK_HYPERV} != "no" +SUBDIR+= hyperv +.endif SUBDIR+= kgmon SUBDIR+= kgzip SUBDIR+= lptcontrol @@ -28,9 +31,6 @@ SUBDIR+= zzz SUBDIR+= acpi .endif SUBDIR+= boot0cfg -.if ${MK_HYPERV} != "no" -SUBDIR+= hyperv -.endif .if ${MK_WIRELESS} != "no" SUBDIR+= wlconfig .endif From c341279404d2f175b9169d13bcafe6b9bf6e7975 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Tue, 25 Nov 2014 19:17:12 +0000 Subject: [PATCH 07/64] Add an additional src.conf doc snippet for WITH_HYPERV --- tools/build/options/WITH_HYPERV | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 tools/build/options/WITH_HYPERV diff --git a/tools/build/options/WITH_HYPERV b/tools/build/options/WITH_HYPERV new file mode 100644 index 000000000000..a6bdf72ff3e3 --- /dev/null +++ b/tools/build/options/WITH_HYPERV @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Set to build and install HyperV utilities. From 4be1ca354c7cf79c8a9d28f71782c7241332ee9f Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Tue, 25 Nov 2014 19:20:25 +0000 Subject: [PATCH 08/64] Make building/installing bhyve optional via MK_BHYVE on amd64 Disable building/installing bhyve from src.opts.mk on unsupported architectures (!amd64) --- share/examples/Makefile | 7 +++++-- share/man/man4/Makefile | 5 ++++- share/mk/src.opts.mk | 7 +++++++ tools/build/mk/OptionalObsoleteFiles.inc | 8 ++++++++ tools/build/options/WITHOUT_BHYVE | 4 ++++ tools/build/options/WITH_BHYVE | 4 ++++ usr.sbin/Makefile.amd64 | 2 ++ 7 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 tools/build/options/WITHOUT_BHYVE create mode 100644 tools/build/options/WITH_BHYVE diff --git a/share/examples/Makefile b/share/examples/Makefile index 79de48eb3129..609344f66e2d 100644 --- a/share/examples/Makefile +++ b/share/examples/Makefile @@ -7,7 +7,6 @@ LDIRS= BSD_daemon \ FreeBSD_version \ IPv6 \ - bhyve \ bootforth \ csh \ diskless \ @@ -42,7 +41,6 @@ XFILES= BSD_daemon/FreeBSD.pfa \ FreeBSD_version/Makefile \ FreeBSD_version/README \ IPv6/USAGE \ - bhyve/vmrun.sh \ bootforth/README \ bootforth/boot.4th \ bootforth/frames.4th \ @@ -207,6 +205,11 @@ NO_OBJ= # in environments where it's not possible to keep /sys publicly readable) SHARED?= copies +.if ${MK_BHYVE} != "no" +LDIRS+= bhyve +XFILES+= bhyve/vmrun.sh +.endif + beforeinstall: ${SHARED} etc-examples .ORDER: ${SHARED} etc-examples diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index 76b3d55c2c61..1aefe7a4f130 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -835,7 +835,6 @@ _xnb.4= xnb.4 .endif .if ${MACHINE_CPUARCH} == "amd64" -_bhyve.4= bhyve.4 _if_ntb.4= if_ntb.4 _ntb.4= ntb.4 _ntb_hw.4= ntb_hw.4 @@ -858,6 +857,10 @@ _nvram2env.4= nvram2env.4 SUBDIR= man4.${MACHINE_CPUARCH} .endif +.if ${MK_BHYVE} != "no" +_bhyve.4= bhyve.4 +.endif + .if ${MK_TESTS} != "no" ATF= ${.CURDIR}/../../../contrib/atf .PATH: ${ATF}/doc diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index 0a469280f9d1..87af499a12d8 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -212,6 +212,13 @@ __DEFAULT_NO_OPTIONS+=CLANG_IS_CC CLANG CLANG_BOOTSTRAP __DEFAULT_YES_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX .endif +# bhyve is only supported on amd64 +.if ${__T} == "amd64" +__DEFAULT_YES_OPTIONS+=BHYVE +.else +MK_BHYVE:= no +.endif + # hyperv is only supported on amd64 and i386/i386 .if ${__T} == "amd64" || (${__T} == "i386" && ${__TT} == "i386") __DEFAULT_YES_OPTIONS+=HYPERV diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index cefaab22c645..60f2551ffe5e 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -144,6 +144,14 @@ OLD_FILES+=usr/share/man/man8/authpf.8.gz OLD_FILES+=usr/share/man/man8/authpf-noip.8.gz .endif +.if ${MK_BHYVE} == no +OLD_FILES+=usr/sbin/bhyve +OLD_FILES+=usr/sbin/bhyvectl +OLD_FILES+=usr/sbin/bhyveload +OLD_FILES+=usr/share/man/man8/bhyve.8.gz +OLD_FILES+=usr/share/man/man8/bhyveload.8.gz +.endif + .if ${MK_BLUETOOTH} == no OLD_FILES+=etc/bluetooth/hcsecd.conf OLD_FILES+=etc/bluetooth/hosts diff --git a/tools/build/options/WITHOUT_BHYVE b/tools/build/options/WITHOUT_BHYVE new file mode 100644 index 000000000000..f60fd17ddba7 --- /dev/null +++ b/tools/build/options/WITHOUT_BHYVE @@ -0,0 +1,4 @@ +.\" $FreeBSD$ +Set to not build or install +.Xr bhyve 8 , +associated utilities, and examples. diff --git a/tools/build/options/WITH_BHYVE b/tools/build/options/WITH_BHYVE new file mode 100644 index 000000000000..b136928c1287 --- /dev/null +++ b/tools/build/options/WITH_BHYVE @@ -0,0 +1,4 @@ +.\" $FreeBSD$ +Set to build and install +.Xr bhyve 8 , +associated utilities, and examples. diff --git a/usr.sbin/Makefile.amd64 b/usr.sbin/Makefile.amd64 index 2d1a3e8daadd..3f40974c7a0d 100644 --- a/usr.sbin/Makefile.amd64 +++ b/usr.sbin/Makefile.amd64 @@ -10,9 +10,11 @@ SUBDIR+= acpi SUBDIR+= apm .endif SUBDIR+= asf +.if ${MK_BHYVE} != "no" SUBDIR+= bhyve SUBDIR+= bhyvectl SUBDIR+= bhyveload +.endif SUBDIR+= boot0cfg .if ${MK_TOOLCHAIN} != "no" SUBDIR+= btxld From 05d9930e0f44d7c4a65df1493776b4b479df719e Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Tue, 25 Nov 2014 19:37:55 +0000 Subject: [PATCH 09/64] Only install etc/rc.d/bsnmpd if MK_BSNMP == yes --- etc/rc.d/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile index d90fc8350266..0bd1a96a6165 100644 --- a/etc/rc.d/Makefile +++ b/etc/rc.d/Makefile @@ -27,7 +27,7 @@ FILES= DAEMON \ ${_bluetooth} \ bootparams \ bridge \ - bsnmpd \ + ${_bsnmpd} \ ${_bthidd} \ ${_casperd} \ ccd \ @@ -171,6 +171,10 @@ _hcsecd= hcsecd _ubthidhci= ubthidhci .endif +.if ${MK_BSNMP} != "no" +_bsnmpd= bsnmpd +.endif + .if ${MK_CASPER} != "no" _casperd= casperd .endif From 6d94729e30e4ba3502ff862939843656adcb7616 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Tue, 25 Nov 2014 19:38:23 +0000 Subject: [PATCH 10/64] Fill in entries for MK_BSNMP == no --- tools/build/mk/OptionalObsoleteFiles.inc | 82 ++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index 60f2551ffe5e..33f39c322ffa 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -315,6 +315,88 @@ OLD_FILES+=usr/share/man/man8/sade.8.gz OLD_DIRS+=usr/libexec/bsdinstall .endif +.if ${MK_BSNMP} == no +OLD_FILES+=etc/rc.d/bsnmpd +OLD_FILES+=usr/bin/bsnmpget +OLD_FILES+=usr/bin/bsnmpset +OLD_FILES+=usr/bin/bsnmpwalk +OLD_FILES+=usr/include/bsnmp/asn1.h +OLD_FILES+=usr/include/bsnmp/bridge_snmp.h +OLD_FILES+=usr/include/bsnmp/snmp.h +OLD_FILES+=usr/include/bsnmp/snmp_mibII.h +OLD_FILES+=usr/include/bsnmp/snmp_netgraph.h +OLD_FILES+=usr/include/bsnmp/snmpagent.h +OLD_FILES+=usr/include/bsnmp/snmpclient.h +OLD_FILES+=usr/include/bsnmp/snmpmod.h +OLD_FILES+=usr/lib/libbsnmp.a +OLD_FILES+=usr/lib/libbsnmp.so.6 +OLD_FILES+=usr/lib/libbsnmptools.a +OLD_FILES+=usr/lib/libbsnmptools.so.0 +OLD_FILES+=usr/lib/snmp_bridge.so.6 +OLD_FILES+=usr/lib/snmp_hast.so.6 +OLD_FILES+=usr/lib/snmp_hostres.so.6 +OLD_FILES+=usr/lib/snmp_lm75.so.6 +OLD_FILES+=usr/lib/snmp_mibII.so.6 +OLD_FILES+=usr/lib/snmp_netgraph.so.6 +OLD_FILES+=usr/lib/snmp_target.so.6 +OLD_FILES+=usr/lib/snmp_usm.so.6 +OLD_FILES+=usr/lib/snmp_vacm.so.6 +OLD_FILES+=usr/lib/snmp_wlan.so.6 +OLD_FILES+=usr/sbin/bsnmpd +OLD_FILES+=usr/sbin/gensnmptree +OLD_FILES+=usr/share/man/man1/bsnmpd.1.gz +OLD_FILES+=usr/share/man/man1/bsnmpget.1.gz +OLD_FILES+=usr/share/man/man1/bsnmpset.1.gz +OLD_FILES+=usr/share/man/man1/bsnmpwalk.1.gz +OLD_FILES+=usr/share/man/man1/gensnmptree.1.gz +OLD_FILES+=usr/share/man/man3/asn1.3.gz +OLD_FILES+=usr/share/man/man3/bsnmpagent.3.gz +OLD_FILES+=usr/share/man/man3/bsnmpclient.3.gz +OLD_FILES+=usr/share/man/man3/bsnmplib.3.gz +OLD_FILES+=usr/share/man/man3/snmp_bridge.3.gz +OLD_FILES+=usr/share/man/man3/snmp_hast.3.gz +OLD_FILES+=usr/share/man/man3/snmp_hostres.3.gz +OLD_FILES+=usr/share/man/man3/snmp_lm75.3.gz +OLD_FILES+=usr/share/man/man3/snmp_mibII.3.gz +OLD_FILES+=usr/share/man/man3/snmp_netgraph.3.gz +OLD_FILES+=usr/share/man/man3/snmp_target.3.gz +OLD_FILES+=usr/share/man/man3/snmp_usm.3.gz +OLD_FILES+=usr/share/man/man3/snmp_vacm.3.gz +OLD_FILES+=usr/share/man/man3/snmp_wlan.3.gz +OLD_FILES+=usr/share/man/man3/snmpmod.3.gz +OLD_FILES+=usr/share/snmp/defs/bridge_tree.def +OLD_FILES+=usr/share/snmp/defs/hast_tree.def +OLD_FILES+=usr/share/snmp/defs/hostres_tree.def +OLD_FILES+=usr/share/snmp/defs/lm75_tree.def +OLD_FILES+=usr/share/snmp/defs/mibII_tree.def +OLD_FILES+=usr/share/snmp/defs/netgraph_tree.def +OLD_FILES+=usr/share/snmp/defs/pf_tree.def +OLD_FILES+=usr/share/snmp/defs/target_tree.def +OLD_FILES+=usr/share/snmp/defs/tree.def +OLD_FILES+=usr/share/snmp/defs/usm_tree.def +OLD_FILES+=usr/share/snmp/defs/vacm_tree.def +OLD_FILES+=usr/share/snmp/defs/wlan_tree.def +OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-BRIDGE-MIB.txt +OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-HAST-MIB.txt +OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-HOSTRES-MIB.txt +OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-IP-MIB.txt +OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-LM75-MIB.txt +OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-MIB.txt +OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-MIB2-MIB.txt +OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-PF-MIB.txt +OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-NETGRAPH.txt +OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-SNMPD.txt +OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-WIRELESS-MIB.txt +OLD_FILES+=usr/share/snmp/mibs/BRIDGE-MIB.txt +OLD_FILES+=usr/share/snmp/mibs/FREEBSD-MIB.txt +OLD_FILES+=usr/share/snmp/mibs/FOKUS-MIB.txt +OLD_FILES+=usr/share/snmp/mibs/RSTP-MIB.txt +OLD_DIRS+=usr/include/bsnmp +OLD_DIRS+=usr/share/snmp +OLD_DIRS+=usr/share/snmp/defs +OLD_DIRS+=usr/share/snmp/mibs +.endif + .if ${MK_CALENDAR} == no OLD_FILES+=etc/periodic/daily/300.calendar OLD_FILES+=usr/bin/calendar From 9a2c263854da01e1ef7cddf83df0a43ccca15979 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Tue, 25 Nov 2014 19:45:28 +0000 Subject: [PATCH 11/64] Don't build/install lib/libvmmapi if MK_BHYVE == no Suggested by: grehan --- lib/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Makefile b/lib/Makefile index a5d0df52a76d..af5fb6255712 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -167,6 +167,10 @@ _csu=csu _libngatm= libngatm .endif +.if ${MK_BHYVE} != "no" +_libvmmapi= libvmmapi +.endif + .if ${MK_BLUETOOTH} != "no" _libbluetooth= libbluetooth _libsdp= libsdp @@ -242,10 +246,6 @@ _libproc= libproc _librtld_db= librtld_db .endif -.if ${MACHINE_CPUARCH} == "amd64" -_libvmmapi= libvmmapi -.endif - .if ${MACHINE_CPUARCH} == "mips" _libproc= libproc _librtld_db= librtld_db From 88585cd46c468c46b9f2622fd546e7b66c175013 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Tue, 25 Nov 2014 22:38:16 +0000 Subject: [PATCH 12/64] Add more MK_BSNMP == no entries for things not caught due to custom settings in $SRCCONF --- tools/build/mk/OptionalObsoleteFiles.inc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index 33f39c322ffa..63e0fb6cde28 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -323,6 +323,7 @@ OLD_FILES+=usr/bin/bsnmpwalk OLD_FILES+=usr/include/bsnmp/asn1.h OLD_FILES+=usr/include/bsnmp/bridge_snmp.h OLD_FILES+=usr/include/bsnmp/snmp.h +OLD_FILES+=usr/include/bsnmp/snmp_atm.h OLD_FILES+=usr/include/bsnmp/snmp_mibII.h OLD_FILES+=usr/include/bsnmp/snmp_netgraph.h OLD_FILES+=usr/include/bsnmp/snmpagent.h @@ -330,14 +331,18 @@ OLD_FILES+=usr/include/bsnmp/snmpclient.h OLD_FILES+=usr/include/bsnmp/snmpmod.h OLD_FILES+=usr/lib/libbsnmp.a OLD_FILES+=usr/lib/libbsnmp.so.6 +OLD_FILES+=usr/lib/libbsnmp_p.a OLD_FILES+=usr/lib/libbsnmptools.a OLD_FILES+=usr/lib/libbsnmptools.so.0 +OLD_FILES+=usr/lib/libbsnmptools_p.a +OLD_FILES+=usr/lib/snmp_atm.so.6 OLD_FILES+=usr/lib/snmp_bridge.so.6 OLD_FILES+=usr/lib/snmp_hast.so.6 OLD_FILES+=usr/lib/snmp_hostres.so.6 OLD_FILES+=usr/lib/snmp_lm75.so.6 OLD_FILES+=usr/lib/snmp_mibII.so.6 OLD_FILES+=usr/lib/snmp_netgraph.so.6 +OLD_FILES+=usr/lib/snmp_pf.so.6 OLD_FILES+=usr/lib/snmp_target.so.6 OLD_FILES+=usr/lib/snmp_usm.so.6 OLD_FILES+=usr/lib/snmp_vacm.so.6 @@ -353,6 +358,7 @@ OLD_FILES+=usr/share/man/man3/asn1.3.gz OLD_FILES+=usr/share/man/man3/bsnmpagent.3.gz OLD_FILES+=usr/share/man/man3/bsnmpclient.3.gz OLD_FILES+=usr/share/man/man3/bsnmplib.3.gz +OLD_FILES+=usr/share/man/man3/snmp_atm.3.gz OLD_FILES+=usr/share/man/man3/snmp_bridge.3.gz OLD_FILES+=usr/share/man/man3/snmp_hast.3.gz OLD_FILES+=usr/share/man/man3/snmp_hostres.3.gz @@ -364,6 +370,8 @@ OLD_FILES+=usr/share/man/man3/snmp_usm.3.gz OLD_FILES+=usr/share/man/man3/snmp_vacm.3.gz OLD_FILES+=usr/share/man/man3/snmp_wlan.3.gz OLD_FILES+=usr/share/man/man3/snmpmod.3.gz +OLD_FILES+=usr/share/snmp/defs/atm_freebsd.def +OLD_FILES+=usr/share/snmp/defs/atm_tree.def OLD_FILES+=usr/share/snmp/defs/bridge_tree.def OLD_FILES+=usr/share/snmp/defs/hast_tree.def OLD_FILES+=usr/share/snmp/defs/hostres_tree.def @@ -376,6 +384,8 @@ OLD_FILES+=usr/share/snmp/defs/tree.def OLD_FILES+=usr/share/snmp/defs/usm_tree.def OLD_FILES+=usr/share/snmp/defs/vacm_tree.def OLD_FILES+=usr/share/snmp/defs/wlan_tree.def +OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-ATM-FREEBSD-MIB.txt +OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-ATM.txt OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-BRIDGE-MIB.txt OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-HAST-MIB.txt OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-HOSTRES-MIB.txt @@ -383,13 +393,13 @@ OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-IP-MIB.txt OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-LM75-MIB.txt OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-MIB.txt OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-MIB2-MIB.txt -OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-PF-MIB.txt OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-NETGRAPH.txt +OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-PF-MIB.txt OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-SNMPD.txt OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-WIRELESS-MIB.txt OLD_FILES+=usr/share/snmp/mibs/BRIDGE-MIB.txt -OLD_FILES+=usr/share/snmp/mibs/FREEBSD-MIB.txt OLD_FILES+=usr/share/snmp/mibs/FOKUS-MIB.txt +OLD_FILES+=usr/share/snmp/mibs/FREEBSD-MIB.txt OLD_FILES+=usr/share/snmp/mibs/RSTP-MIB.txt OLD_DIRS+=usr/include/bsnmp OLD_DIRS+=usr/share/snmp From fe4c66a4f806597044d37ba70c6de6706de00bfa Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Tue, 25 Nov 2014 23:01:01 +0000 Subject: [PATCH 13/64] Add script I'm using to add entries to OptionalObsoleteFiles.inc --- tools/add-optional-obsolete-files-entries.sh | 49 ++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 tools/add-optional-obsolete-files-entries.sh diff --git a/tools/add-optional-obsolete-files-entries.sh b/tools/add-optional-obsolete-files-entries.sh new file mode 100755 index 000000000000..1c6de8c02066 --- /dev/null +++ b/tools/add-optional-obsolete-files-entries.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# +# Simple script for enumerating installed files for a list of directories +# +# usage: add-optional-obsolete-files-entries.sh directory .. +# +# $FreeBSD$ + +: ${TMPDIR=/tmp} + +DESTDIR=$(mktemp -d $TMPDIR/tmp.XXXXXX) || exit +trap "rm -Rf $DESTDIR" EXIT INT TERM + +# Don't pollute the output with +: ${SRCCONF=/dev/null} +: ${__MAKE_CONF=/dev/null} + +if [ $# -gt 0 ] +then + directories=$* +else + directories=. +fi + +export __MAKE_CONF DESTDIR SRCCONF + +SRCTOP=$(cd $(make -V'${.MAKE.MAKEFILES:M*/share/mk/sys.mk:H:H:H}'); pwd) + +# Don't install the manpage symlinks +(cd $SRCTOP; make hier INSTALL_SYMLINK=true MK_MAN=no >/dev/null) + +for directory in $directories +do + (cd $directory && make install >/dev/null) || exit +done +# Prune empty directories +# XXX: is [ -n ... ] call necessary? +while empty_dirs=$(find $DESTDIR -type d -and -empty) && [ -n "$empty_dirs" ] +do + rmdir $empty_dirs +done + +# Enumerate all of the installed files/directories +(cd $DESTDIR; + find -s . -type f -mindepth 1 | sed -e 's,^,OLD_FILES+=,'; + find -s . -type d -mindepth 1 -and \! -empty | \ + egrep -v '^\./(s*bin|libexec|usr|usr/include|usr/lib|usr/libexec|usr/s*bin|usr/share|usr/share/man|usr/share/man/man[0-9])$' | \ + sed -e 's,^,OLD_DIRS+=,' +) | sed -e 's,+=\./,+=,' From 3802be032310340c9f9a42e986de34b42bf18dfa Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Wed, 26 Nov 2014 00:13:51 +0000 Subject: [PATCH 14/64] Remove deadcode --- libexec/rpc.rusersd/Makefile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/libexec/rpc.rusersd/Makefile b/libexec/rpc.rusersd/Makefile index df2be379d086..7801a0cdcb0c 100644 --- a/libexec/rpc.rusersd/Makefile +++ b/libexec/rpc.rusersd/Makefile @@ -7,9 +7,4 @@ MAN = rpc.rusersd.8 DPADD= ${LIBRPCSVC} ${LIBUTIL} LDADD= -lrpcsvc -lutil -#.if exists(/usr/X11R6/include/X11/extensions/xidle.h) -#CFLAGS+= -DXIDLE -#LDADD+= -L/usr/X11R6/lib -lXext -lX11 -#.endif - .include From bdf492a3ac3d6d35ee2694d1de48d5c0eb57b88b Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Wed, 26 Nov 2014 02:37:00 +0000 Subject: [PATCH 15/64] Missed the bsnmp config file --- tools/build/mk/OptionalObsoleteFiles.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index 63e0fb6cde28..25b62fbe0510 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -316,6 +316,7 @@ OLD_DIRS+=usr/libexec/bsdinstall .endif .if ${MK_BSNMP} == no +OLD_FILES+=etc/snmpd.config OLD_FILES+=etc/rc.d/bsnmpd OLD_FILES+=usr/bin/bsnmpget OLD_FILES+=usr/bin/bsnmpset From 4bbfcad58016bd10bdedf239a4471dbe1bf4a360 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Wed, 26 Nov 2014 02:46:48 +0000 Subject: [PATCH 16/64] Only install the accounting/apm rc scripts for MK_ACCT/MK_APM if the relevant knobs are set --- etc/rc.d/Makefile | 12 +++++++++--- tools/build/mk/OptionalObsoleteFiles.inc | 3 +++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile index 0bd1a96a6165..ef15d53b9f8c 100644 --- a/etc/rc.d/Makefile +++ b/etc/rc.d/Makefile @@ -8,12 +8,9 @@ FILES= DAEMON \ NETWORKING \ SERVERS \ abi \ - accounting \ addswap \ adjkerntz \ amd \ - apm \ - apmd \ archdep \ atm1 \ atm2 \ @@ -164,6 +161,15 @@ FILES= DAEMON \ zfs \ zvol +.if ${MK_ACCT} != "no" +FILES+= accounting +.endif + +.if ${MK_APM} != "no" +FILES+= apm +FILES+= apmd +.endif + .if ${MK_BLUETOOTH} != "no" _bluetooth= bluetooth _bthidd= bthidd diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index 25b62fbe0510..d302898b9f78 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -6,6 +6,7 @@ # .if ${MK_ACCT} == no +OLD_FILES+=etc/rc.d/accounting OLD_FILES+=etc/periodic/daily/310.accounting OLD_FILES+=usr/sbin/accton OLD_FILES+=usr/sbin/sa @@ -48,6 +49,8 @@ OLD_FILES+=usr/share/man/man8/wire-test.8.gz .endif .if ${MK_APM} == no +OLD_FILES+=etc/rc.d/apm +OLD_FILES+=etc/rc.d/apmd OLD_FILES+=etc/apmd.conf OLD_FILES+=usr/sbin/apm OLD_FILES+=usr/share/examples/etc/apmd.conf From 961281fa16d3670c592ac27d5c8462f0e0f12fd1 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Wed, 26 Nov 2014 02:59:37 +0000 Subject: [PATCH 17/64] Don't install the rsh and telnetd pam.d files if MK_RCMDS == no or MK_TELNET == no, respectively --- etc/pam.d/Makefile | 12 ++++++++++-- tools/build/mk/OptionalObsoleteFiles.inc | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/etc/pam.d/Makefile b/etc/pam.d/Makefile index 7369022cc8b6..2d3356a8fca9 100644 --- a/etc/pam.d/Makefile +++ b/etc/pam.d/Makefile @@ -2,6 +2,8 @@ NO_OBJ= +.include + FILES= README \ atrun \ cron \ @@ -10,11 +12,17 @@ FILES= README \ login \ other \ passwd pop3 \ - rsh \ sshd su system \ - telnetd \ xdm +.if ${MK_RCMDS} != "no" +FILES+= rsh +.endif + +.if ${MK_TELNET} != "no" +FILES+= telnetd +.endif + FILESDIR= /etc/pam.d FILESMODE= 644 FILESMODE_README= 444 diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index d302898b9f78..ea74c320323a 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -3913,6 +3913,7 @@ OLD_FILES+=usr/lib/private/libssh_p.a .if ${MK_RCMDS} == no OLD_FILES+=bin/rcp +OLD_FILES+=etc/pam.d/rsh OLD_FILES+=etc/rc.d/rwho OLD_FILES+=etc/periodic/daily/140.clean-rwho OLD_FILES+=etc/periodic/daily/430.status-rwho @@ -4279,6 +4280,7 @@ OLD_FILES+=usr/share/nls/uk_UA.UTF-8/tcsh.cat .endif .if ${MK_TELNET} == no +OLD_FILES+=etc/pam.d/telnetd OLD_FILES+=usr/bin/telnet OLD_FILES+=usr/libexec/telnetd OLD_FILES+=usr/share/man/man1/telnet.1.gz From fb624adcf88f0ead58d6be7c03c84e036580f0e1 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Wed, 26 Nov 2014 03:38:12 +0000 Subject: [PATCH 18/64] MK_HYPERV: Sort OLD_FILES and add /usr/libexec/hyperv to OLD_DIRS --- tools/build/mk/OptionalObsoleteFiles.inc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index ea74c320323a..e44ab9134ec1 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -4925,9 +4925,10 @@ OLD_FILES+=usr/share/examples/dma/mailer.conf .if ${MK_HYPERV} == no OLD_FILES+=etc/devd/hyperv.conf -OLD_FILES+=usr/libexec/hyperv/hv_set_ifconfig -OLD_FILES+=usr/libexec/hyperv/hv_get_dns_info OLD_FILES+=usr/libexec/hyperv/hv_get_dhcp_info +OLD_FILES+=usr/libexec/hyperv/hv_get_dns_info +OLD_FILES+=usr/libexec/hyperv/hv_set_ifconfig OLD_FILES+=usr/sbin/hv_kvp_daemon OLD_FILES+=usr/share/man/man8/hv_kvp_daemon.8.gz +OLD_DIRS+=usr/libexec/hyperv .endif From 7e57795a34b906cdc7bf3356d968422bb453dd04 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Wed, 26 Nov 2014 06:54:17 +0000 Subject: [PATCH 19/64] Don't try and build 32-bit versions of hyperv / bhyve --- Makefile.inc1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.inc1 b/Makefile.inc1 index 7d828ec9d081..f54b3138cc38 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -433,7 +433,7 @@ LIB32WMAKEFLAGS+= CC="${XCC} ${LIB32FLAGS}" \ MK_TESTS=no LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \ - MK_MAN=no MK_INFO=no MK_HTML=no + MK_MAN=no MK_INFO=no MK_HTML=no MK_HYPERV=no MK_BHYVE=no LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} \ MK_TOOLCHAIN=no ${IMAKE_INSTALL} .endif From 466046ec0d4dec84ee133aa1b6b22f9eaf6defa5 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Wed, 26 Nov 2014 08:44:05 +0000 Subject: [PATCH 20/64] Conditionalize a number of components in the tree - bootparamd - bootpd - finger/fingerd - ftp/ftpd - hastctl/hastd - iscsid, et al - rbootd - talk/talkd - tcpd, et al - tftp/tftpd Add src.conf entries for the various components and do a best effort at adding components to tools/build/mk/OptionalObsoleteFiles.inc --- etc/Makefile | 5 +- etc/rc.d/Makefile | 22 ++++-- include/protocols/Makefile | 8 +- libexec/Makefile | 35 +++++++-- sbin/Makefile | 12 ++- share/examples/Makefile | 15 ++-- share/man/man4/Makefile | 7 +- share/mk/src.opts.mk | 10 +++ tools/build/mk/OptionalObsoleteFiles.inc | 97 ++++++++++++++++++++++++ tools/build/options/WITHOUT_BOOTPARAMD | 3 + tools/build/options/WITHOUT_BOOTPD | 3 + tools/build/options/WITHOUT_FINGER | 5 ++ tools/build/options/WITHOUT_FTP | 5 ++ tools/build/options/WITHOUT_HAST | 4 + tools/build/options/WITHOUT_ISCSI | 4 + tools/build/options/WITHOUT_RBOOTD | 3 + tools/build/options/WITHOUT_TALK | 5 ++ tools/build/options/WITHOUT_TCP_WRAPPERS | 4 + tools/build/options/WITHOUT_TFTP | 5 ++ usr.bin/Makefile | 25 ++++-- usr.sbin/Makefile | 17 ++++- 21 files changed, 260 insertions(+), 34 deletions(-) create mode 100644 tools/build/options/WITHOUT_BOOTPARAMD create mode 100644 tools/build/options/WITHOUT_BOOTPD create mode 100644 tools/build/options/WITHOUT_FINGER create mode 100644 tools/build/options/WITHOUT_FTP create mode 100644 tools/build/options/WITHOUT_HAST create mode 100644 tools/build/options/WITHOUT_ISCSI create mode 100644 tools/build/options/WITHOUT_RBOOTD create mode 100644 tools/build/options/WITHOUT_TALK create mode 100644 tools/build/options/WITHOUT_TCP_WRAPPERS create mode 100644 tools/build/options/WITHOUT_TFTP diff --git a/etc/Makefile b/etc/Makefile index d8d1f72b5adf..466bc7c92391 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -19,7 +19,6 @@ BIN1= auto_master \ dhclient.conf \ disktab \ fbtab \ - ftpusers \ gettytab \ group \ hosts \ @@ -94,6 +93,10 @@ BIN1+= snmpd.config BIN1+= freebsd-update.conf .endif +.if ${MK_FTP} != "no" +BIN1+= ftpusers +.endif + .if ${MK_INETD} != "no" BIN1+= inetd.conf .endif diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile index ef15d53b9f8c..855abcb71405 100644 --- a/etc/rc.d/Makefile +++ b/etc/rc.d/Makefile @@ -22,7 +22,6 @@ FILES= DAEMON \ autounmountd \ bgfsck \ ${_bluetooth} \ - bootparams \ bridge \ ${_bsnmpd} \ ${_bthidd} \ @@ -40,14 +39,12 @@ FILES= DAEMON \ dmesg \ dumpon \ fsck \ - ftpd \ gbde \ geli \ geli2 \ gptboot \ growfs \ gssd \ - hastd \ ${_hcsecd} \ hostapd \ hostid \ @@ -63,8 +60,6 @@ FILES= DAEMON \ ipropd_master \ ipropd_slave \ ipsec \ - iscsictl \ - iscsid \ jail \ ${_kadmind} \ ${_kdc} \ @@ -177,6 +172,10 @@ _hcsecd= hcsecd _ubthidhci= ubthidhci .endif +.if ${MK_BOOTPARAMD} != "no" +FILES+= bootparams +.endif + .if ${MK_BSNMP} != "no" _bsnmpd= bsnmpd .endif @@ -185,10 +184,23 @@ _bsnmpd= bsnmpd _casperd= casperd .endif +.if ${MK_FTP} != "no" +FILES+= ftpd +.endif + +.if ${MK_HAST} != "no" +FILES+= hastd +.endif + .if ${MK_INETD} != "no" _inetd= inetd .endif +.if ${MK_ISCSI} != "no" +FILES+= iscsictl +FILES+= iscsid +.endif + .if ${MK_NS_CACHING} != "no" _nscd= nscd .endif diff --git a/include/protocols/Makefile b/include/protocols/Makefile index ddd8f21dc912..a9c82dbb25cb 100644 --- a/include/protocols/Makefile +++ b/include/protocols/Makefile @@ -1,7 +1,13 @@ # $FreeBSD$ +.include + NO_OBJ= -INCS= dumprestore.h routed.h rwhod.h talkd.h timed.h +INCS= dumprestore.h routed.h rwhod.h timed.h INCSDIR=${INCLUDEDIR}/protocols +.if ${MK_TALK} == "no" +INCS+= talkd.h +.endif + .include diff --git a/libexec/Makefile b/libexec/Makefile index 7d1c1f8ddae4..27d245e5e070 100644 --- a/libexec/Makefile +++ b/libexec/Makefile @@ -5,18 +5,14 @@ SUBDIR= ${_atf} \ ${_atrun} \ - bootpd \ ${_casper} \ ${_comsat} \ ${_dma} \ ${_dma-mbox-create} \ - fingerd \ - ftpd \ getty \ ${_mail.local} \ ${_mknetid} \ ${_pppoed} \ - rbootd \ revnetgroup \ ${_rlogind} \ rpc.rquotad \ @@ -28,11 +24,8 @@ SUBDIR= ${_atf} \ ${_rtld-elf} \ save-entropy \ ${_smrsh} \ - talkd \ - tcpd \ ${_telnetd} \ ${_tests} \ - tftpd \ ${_tftp-proxy} \ ulog-helper \ ${_ypxfr} @@ -41,10 +34,22 @@ SUBDIR= ${_atf} \ _atrun= atrun .endif +.if ${MK_BOOTPD} != "no" +SUBDIR+= bootpd +.endif + .if ${MK_CASPER} != "no" _casper= casper .endif +.if ${MK_FINGER} != "no" +SUBDIR+= fingerd +.endif + +.if ${MK_FTP} != "no" +SUBDIR+= ftpd +.endif + .if ${MK_MAIL} != "no" _comsat= comsat .endif @@ -71,6 +76,10 @@ _tftp-proxy= tftp-proxy _rtld-elf= rtld-elf .endif +.if ${MK_RBOOTD} != "no" +SUBDIR+= rbootd +.endif + .if ${MK_RCMDS} != "no" _rlogind= rlogind _rshd= rshd @@ -81,10 +90,22 @@ _mail.local= mail.local _smrsh= smrsh .endif +.if ${MK_TALK} != "no" +SUBDIR+= talkd +.endif + +.if ${MK_TCP_WRAPPERS} != "no" +SUBDIR+= tcpd +.endif + .if ${MK_TELNET} != "no" _telnetd= telnetd .endif +.if ${MK_TFTP} != "no" +SUBDIR+= tftpd +.endif + .if ${MK_TESTS} != "no" _atf= atf _tests= tests diff --git a/sbin/Makefile b/sbin/Makefile index 3725270c4c3f..7adaa929dee2 100644 --- a/sbin/Makefile +++ b/sbin/Makefile @@ -31,11 +31,8 @@ SUBDIR=adjkerntz \ ggate \ growfs \ gvinum \ - hastctl \ - hastd \ ifconfig \ init \ - iscontrol \ kldconfig \ kldload \ kldstat \ @@ -86,6 +83,11 @@ SUBDIR+= casperd SUBDIR+= devd .endif +.if ${MK_HAST} != "no" +SUBDIR+= hastctl +SUBDIR+= hastd +.endif + .if ${MK_IPFILTER} != "no" SUBDIR+= ipf .endif @@ -95,6 +97,10 @@ SUBDIR+= ipfw SUBDIR+= natd .endif +.if ${MK_ISCSI} != "no" +SUBDIR+= iscontrol +.endif + .if ${MK_NAND} != "no" SUBDIR+= nandfs SUBDIR+= newfs_nandfs diff --git a/share/examples/Makefile b/share/examples/Makefile index 609344f66e2d..7fd8723aa30c 100644 --- a/share/examples/Makefile +++ b/share/examples/Makefile @@ -13,7 +13,6 @@ LDIRS= BSD_daemon \ drivers \ etc \ find_interface \ - hast \ ibcs2 \ indent \ ipfw \ @@ -62,11 +61,6 @@ XFILES= BSD_daemon/FreeBSD.pfa \ find_interface/Makefile \ find_interface/README \ find_interface/find_interface.c \ - hast/ucarp.sh \ - hast/ucarp_down.sh \ - hast/ucarp_up.sh \ - hast/vip-down.sh \ - hast/vip-up.sh \ ibcs2/README \ ibcs2/hello.uu \ indent/indent.pro \ @@ -210,6 +204,15 @@ LDIRS+= bhyve XFILES+= bhyve/vmrun.sh .endif +.if ${MK_HAST} != "no" +LDIRS+= hast +XFILES+= hast/ucarp.sh \ + hast/ucarp_down.sh \ + hast/ucarp_up.sh \ + hast/vip-down.sh \ + hast/vip-up.sh +.endif + beforeinstall: ${SHARED} etc-examples .ORDER: ${SHARED} etc-examples diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index 1aefe7a4f130..7fa6dea4a672 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -206,8 +206,6 @@ MAN= aac.4 \ ipw.4 \ ipwfw.4 \ isci.4 \ - iscsi.4 \ - iscsi_initiator.4 \ ismt.4 \ isp.4 \ ispfw.4 \ @@ -861,6 +859,11 @@ SUBDIR= man4.${MACHINE_CPUARCH} _bhyve.4= bhyve.4 .endif +.if ${MK_ISCSI} != "no" +MAN+= iscsi.4 +MAN+= iscsi_initiator.4 +.endif + .if ${MK_TESTS} != "no" ATF= ${.CURDIR}/../../../contrib/atf .PATH: ${ATF}/doc diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index 87af499a12d8..9132d23ed27c 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -56,6 +56,8 @@ __DEFAULT_YES_OPTIONS = \ BINUTILS_BOOTSTRAP \ BLUETOOTH \ BOOT \ + BOOTPD \ + BOOTPARAMD \ BSD_CPIO \ BSDINSTALL \ BSNMP \ @@ -76,11 +78,13 @@ __DEFAULT_YES_OPTIONS = \ ED_CRYPTO \ EXAMPLES \ FDT \ + FINGER \ FLOPPY \ FMTREE \ FORTH \ FP_LIBC \ FREEBSD_UPDATE \ + FTP \ GAMES \ GCOV \ GDB \ @@ -90,6 +94,7 @@ __DEFAULT_YES_OPTIONS = \ GPIO \ GPL_DTC \ GROFF \ + HAST \ HTML \ ICONV \ INET \ @@ -97,6 +102,7 @@ __DEFAULT_YES_OPTIONS = \ INETD \ IPFILTER \ IPFW \ + ISCSI \ JAIL \ KDUMP \ KVM \ @@ -130,6 +136,7 @@ __DEFAULT_YES_OPTIONS = \ PPP \ QUOTAS \ RCMDS \ + RBOOTD \ RCS \ RESCUE \ ROUTED \ @@ -143,10 +150,13 @@ __DEFAULT_YES_OPTIONS = \ SYSCALL_COMPAT \ SYSCONS \ SYSINSTALL \ + TALK \ + TCP_WRAPPERS \ TCSH \ TELNET \ TESTS \ TEXTPROC \ + TFTP \ UNBOUND \ USB \ UTMPX \ diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index e44ab9134ec1..c1ddf1cd2de3 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -285,6 +285,26 @@ OLD_FILES+=usr/share/man/man8/sdpd.8.gz # to be filled in #.endif +.if ${MK_BOOTPARAMD} == no +OLD_FILES+=rc.d/bootparams +OLD_FILES+=usr/sbin/bootparamd +OLD_FILES+=usr/sbin/callbootd +OLD_FILES+=usr/share/man/man5/bootparams.5.gz +OLD_FILES+=usr/share/man/man8/bootparamd.8.gz +.endif + +.if ${MK_BOOTPD} == no +OLD_FILES+=usr/libexec/bootpd +OLD_FILES+=usr/libexec/bootpgw +OLD_FILES+=usr/sbin/bootpef +OLD_FILES+=usr/sbin/bootptest +OLD_FILES+=usr/share/man/man5/bootptab.5.gz +OLD_FILES+=usr/share/man/man8/bootpd.8.gz +OLD_FILES+=usr/share/man/man8/bootpef.8.gz +OLD_FILES+=usr/share/man/man8/bootpgw.8.gz +OLD_FILES+=usr/share/man/man8/bootptest.8.gz +.endif + .if ${MK_BSDINSTALL} == no OLD_FILES+=usr/libexec/bsdinstall/adduser OLD_FILES+=usr/libexec/bsdinstall/auto @@ -742,6 +762,14 @@ OLD_FILES+=usr/share/man/man1/gperf.1.gz .endif .endif +.if ${MK_FINGER} == no +OLD_FILES+=usr/bin/finger +OLD_FILES+=usr/libexec/fingerd +OLD_FILES+=usr/share/man/man1/finger.1.gz +OLD_FILES+=usr/share/man/man5/finger.conf.5.gz +OLD_FILES+=usr/share/man/man8/fingerd.8.gz +.endif + .if ${MK_FMTREE} == no OLD_FILES+=usr/sbin/fmtree OLD_FILES+=usr/share/man/man8/fmtree.8.gz @@ -1358,6 +1386,18 @@ OLD_FILES+=usr/share/man/man5/freebsd-update.conf.5.gz OLD_FILES+=usr/share/man/man8/freebsd-update.8.gz .endif +.if ${MK_FTP} == no +OLD_FILES+=usr/bin/ftp +OLD_FILES+=usr/bin/gate-ftp +OLD_FILES+=usr/bin/pftp +OLD_FILES+=usr/libexec/ftpd +OLD_FILES+=usr/share/man/man1/ftp.1.gz +OLD_FILES+=usr/share/man/man1/gate-ftp.1.gz +OLD_FILES+=usr/share/man/man1/pftp.1.gz +OLD_FILES+=usr/share/man/man5/ftpchroot.5.gz +OLD_FILES+=usr/share/man/man8/ftpd.8.gz +.endif + .if ${MK_GAMES} == no OLD_FILES+=usr/games/bcd OLD_FILES+=usr/games/caesar @@ -2053,6 +2093,20 @@ OLD_FILES+=usr/share/man/man5/qop.5.gz OLD_FILES+=usr/share/man/man8/gssd.8.gz .endif +.if ${MK_HAST} == no +OLD_FILES+=sbin/hastctl +OLD_FILES+=sbin/hastd +OLD_FILES+=usr/share/examples/hast/ucarp.sh +OLD_FILES+=usr/share/examples/hast/ucarp_down.sh +OLD_FILES+=usr/share/examples/hast/ucarp_up.sh +OLD_FILES+=usr/share/examples/hast/vip-down.sh +OLD_FILES+=usr/share/examples/hast/vip-up.sh +OLD_FILES+=usr/share/man/man5/hast.conf.5.gz +OLD_FILES+=usr/share/man/man8/hastctl.8.gz +OLD_FILES+=usr/share/man/man8/hastd.8.gz +OLD_DIRS+=usr/share/examples/hast +.endif + .if ${MK_HESIOD} == no OLD_FILES+=usr/bin/hesinfo OLD_FILES+=usr/include/hesiod.h @@ -2252,6 +2306,20 @@ OLD_FILES+=usr/share/man/man8/ipfwpcap.8.gz OLD_FILES+=usr/share/man/man8/natd.8.gz .endif +.if ${MK_ISCSI} == no +OLD_FILES+=etc/rc.d/iscsictl +OLD_FILES+=etc/rc.d/iscsid +OLD_FILES+=sbin/iscontrol +OLD_FILES+=usr/bin/iscsictl +OLD_FILES+=usr/sbin/iscsid +OLD_FILES+=usr/share/man/man4/iscsi.4.gz +OLD_FILES+=usr/share/man/man4/iscsi_initiator.4.gz +OLD_FILES+=usr/share/man/man5/iscsi.conf.5.gz +OLD_FILES+=usr/share/man/man8/iscontrol.8.gz +OLD_FILES+=usr/share/man/man8/iscsictl.8.gz +OLD_FILES+=usr/share/man/man8/iscsid.8.gz +.endif + .if ${MK_JAIL} == no OLD_FILES+=usr/sbin/jail OLD_FILES+=usr/sbin/jexec @@ -3911,6 +3979,11 @@ OLD_FILES+=usr/lib/private/libldns_p.a OLD_FILES+=usr/lib/private/libssh_p.a .endif +.if ${MK_RBOOTD} == no +OLD_FILES+=usr/libexec/rbootd +OLD_FILES+=usr/share/man/man8/rbootd.8.gz +.endif + .if ${MK_RCMDS} == no OLD_FILES+=bin/rcp OLD_FILES+=etc/pam.d/rsh @@ -4219,6 +4292,23 @@ OLD_DIRS+=usr/share/doc/pjdfstest # to be filled in #.endif +.if ${MK_TALK} == no +OLD_FILES+=usr/bin/talk +OLD_FILES+=usr/include/protocols/talkd.h +OLD_FILES+=usr/libexec/ntalkd +OLD_FILES+=usr/share/man/man1/talk.1.gz +OLD_FILES+=usr/share/man/man8/talkd.8.gz +.endif + +.if ${MK_TCP_WRAPPERS} == no +OLD_FILES+=usr/libexec/tcpd +OLD_FILES+=usr/sbin/tcpdchk +OLD_FILES+=usr/sbin/tcpdmatch +OLD_FILES+=usr/share/man/man8/tcpd.8.gz +OLD_FILES+=usr/share/man/man8/tcpdchk.8.gz +OLD_FILES+=usr/share/man/man8/tcpdmatch.8.gz +.endif + .if ${MK_TCSH} == no OLD_FILES+=bin/csh OLD_FILES+=bin/tcsh @@ -4287,6 +4377,13 @@ OLD_FILES+=usr/share/man/man1/telnet.1.gz OLD_FILES+=usr/share/man/man8/telnetd.8.gz .endif +.if ${MK_TFTP} == no +OLD_FILES+=usr/bin/tftp +OLD_FILES+=usr/libexec/tftpd +OLD_FILES+=usr/share/man/man1/tftp.1.gz +OLD_FILES+=usr/share/man/man8/tftpd.8.gz +.endif + .if ${MK_TESTS} == yes OLD_FILES+=usr/bin/atf-sh OLD_FILES+=usr/include/atf-c++/config.hpp diff --git a/tools/build/options/WITHOUT_BOOTPARAMD b/tools/build/options/WITHOUT_BOOTPARAMD new file mode 100644 index 000000000000..f9960830fd24 --- /dev/null +++ b/tools/build/options/WITHOUT_BOOTPARAMD @@ -0,0 +1,3 @@ +.\" $FreeBSD$ +Set to not build or install +.Xr bootparamd 8 . diff --git a/tools/build/options/WITHOUT_BOOTPD b/tools/build/options/WITHOUT_BOOTPD new file mode 100644 index 000000000000..6733d5a7b839 --- /dev/null +++ b/tools/build/options/WITHOUT_BOOTPD @@ -0,0 +1,3 @@ +.\" $FreeBSD$ +Set to not build or install +.Xr bootpd 8 . diff --git a/tools/build/options/WITHOUT_FINGER b/tools/build/options/WITHOUT_FINGER new file mode 100644 index 000000000000..7f654083a3c4 --- /dev/null +++ b/tools/build/options/WITHOUT_FINGER @@ -0,0 +1,5 @@ +.\" $FreeBSD$ +Set to not build or install +.Xr finger 1 +and +.Xr fingerd 8 . diff --git a/tools/build/options/WITHOUT_FTP b/tools/build/options/WITHOUT_FTP new file mode 100644 index 000000000000..5e0fc8eedc19 --- /dev/null +++ b/tools/build/options/WITHOUT_FTP @@ -0,0 +1,5 @@ +.\" $FreeBSD$ +Set to not build or install +.Xr ftp 1 +and +.Xr ftpd 8 . diff --git a/tools/build/options/WITHOUT_HAST b/tools/build/options/WITHOUT_HAST new file mode 100644 index 000000000000..0c31b8c3d0ca --- /dev/null +++ b/tools/build/options/WITHOUT_HAST @@ -0,0 +1,4 @@ +.\" $FreeBSD$ +Set to not build +.Xr hastd 8 +and related utilities. diff --git a/tools/build/options/WITHOUT_ISCSI b/tools/build/options/WITHOUT_ISCSI new file mode 100644 index 000000000000..83f3d7467ba6 --- /dev/null +++ b/tools/build/options/WITHOUT_ISCSI @@ -0,0 +1,4 @@ +.\" $FreeBSD$ +Set to not build +.Xr iscid 8 +and related utilities. diff --git a/tools/build/options/WITHOUT_RBOOTD b/tools/build/options/WITHOUT_RBOOTD new file mode 100644 index 000000000000..f7c33e194c8c --- /dev/null +++ b/tools/build/options/WITHOUT_RBOOTD @@ -0,0 +1,3 @@ +.\" $FreeBSD$ +Set to not build or install +.Xr rbootd 8 . diff --git a/tools/build/options/WITHOUT_TALK b/tools/build/options/WITHOUT_TALK new file mode 100644 index 000000000000..33d41675000b --- /dev/null +++ b/tools/build/options/WITHOUT_TALK @@ -0,0 +1,5 @@ +.\" $FreeBSD$ +Set to not build or install +.Xr talk 1 +and +.Xr talkd 8 . diff --git a/tools/build/options/WITHOUT_TCP_WRAPPERS b/tools/build/options/WITHOUT_TCP_WRAPPERS new file mode 100644 index 000000000000..7c41198308b5 --- /dev/null +++ b/tools/build/options/WITHOUT_TCP_WRAPPERS @@ -0,0 +1,4 @@ +.\" $FreeBSD$ +Set to not build or install +.Xr tcpd 8 , +and related utilities. diff --git a/tools/build/options/WITHOUT_TFTP b/tools/build/options/WITHOUT_TFTP new file mode 100644 index 000000000000..bdb51ac7cfa6 --- /dev/null +++ b/tools/build/options/WITHOUT_TFTP @@ -0,0 +1,5 @@ +.\" $FreeBSD$ +Set to not build or install +.Xr tftp 1 +and +.Xr tftpd 8 . diff --git a/usr.bin/Makefile b/usr.bin/Makefile index 298903e5e5b9..879cedaeba50 100644 --- a/usr.bin/Makefile +++ b/usr.bin/Makefile @@ -49,12 +49,10 @@ SUBDIR= alias \ fetch \ file \ find \ - finger \ fmt \ fold \ fstat \ fsync \ - ftp \ gcore \ gencat \ getconf \ @@ -68,7 +66,6 @@ SUBDIR= alias \ id \ ipcrm \ ipcs \ - iscsictl \ join \ jot \ ${_kdump} \ @@ -160,12 +157,10 @@ SUBDIR= alias \ systat \ tabs \ tail \ - talk \ tar \ tcopy \ tee \ ${_tests} \ - tftp \ time \ timeout \ tip \ @@ -236,10 +231,18 @@ SUBDIR+= calendar _clang= clang .endif +.if ${MK_FINGER} != "no" +SUBDIR+= finger +.endif + .if ${MK_FMAKE} != "no" SUBDIR+= make .endif +.if ${MK_FTP} != "no" +SUBDIR+= ftp +.endif + .if ${MK_GPL_DTC} != "yes" SUBDIR+= dtc .endif @@ -258,6 +261,10 @@ _mkcsmapper= mkcsmapper _mkesdb= mkesdb .endif +.if ${MK_ISCSI} != "no" +SUBDIR+= iscsictl +.endif + .if ${MK_KDUMP} != "no" SUBDIR+= kdump SUBDIR+= truss @@ -330,6 +337,10 @@ SUBDIR+= rwho SUBDIR+= vacation .endif +.if ${MK_TALK} != "no" +SUBDIR+= talk +.endif + .if ${MK_TELNET} != "no" SUBDIR+= telnet .endif @@ -344,6 +355,10 @@ SUBDIR+= colcrt SUBDIR+= ul .endif +.if ${MK_TFTP} != "no" +SUBDIR+= tftp +.endif + .if ${MK_TOOLCHAIN} != "no" SUBDIR+= ar SUBDIR+= c89 diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile index dd29a0d49a28..cc686d07e387 100644 --- a/usr.sbin/Makefile +++ b/usr.sbin/Makefile @@ -7,7 +7,6 @@ SUBDIR= adduser \ arp \ autofs \ binmiscctl \ - bootparamd \ bsdconfig \ cdcontrol \ chkgrp \ @@ -35,7 +34,6 @@ SUBDIR= adduser \ i2c \ ifmcstat \ iostat \ - iscsid \ kldxref \ mailwrapper \ makefs \ @@ -82,8 +80,6 @@ SUBDIR= adduser \ spray \ syslogd \ sysrc \ - tcpdchk \ - tcpdmatch \ tcpdrop \ tcpdump \ timed \ @@ -126,6 +122,10 @@ SUBDIR+= authpf SUBDIR+= bluetooth .endif +.if ${MK_BOOTPARAMD} != "no" +SUBDIR+= bootparamd +.endif + .if ${MK_BSDINSTALL} != "no" SUBDIR+= bsdinstall .endif @@ -182,6 +182,10 @@ SUBDIR+= inetd SUBDIR+= ipfwpcap .endif +.if ${MK_ISCSI} != "no" +SUBDIR+= iscsid +.endif + .if ${MK_JAIL} != "no" SUBDIR+= jail SUBDIR+= jexec @@ -294,6 +298,11 @@ SUBDIR+= praliases SUBDIR+= sendmail .endif +.if ${MK_TCP_WRAPPERS} != "no" +SUBDIR+= tcpdchk +SUBDIR+= tcpdmatch +.endif + .if ${MK_TESTS} != "no" SUBDIR+= tests .endif From 12de3059d049b66cc1ca95509c253dc1359b2816 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Wed, 26 Nov 2014 12:49:37 +0000 Subject: [PATCH 21/64] Fix some accidentally inverted logic --- include/protocols/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/protocols/Makefile b/include/protocols/Makefile index a9c82dbb25cb..0008c76fb875 100644 --- a/include/protocols/Makefile +++ b/include/protocols/Makefile @@ -6,7 +6,7 @@ NO_OBJ= INCS= dumprestore.h routed.h rwhod.h timed.h INCSDIR=${INCLUDEDIR}/protocols -.if ${MK_TALK} == "no" +.if ${MK_TALK} != "no" INCS+= talkd.h .endif From 046cc7b93efb079e02456dad8172f924009c8c48 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Wed, 26 Nov 2014 12:54:58 +0000 Subject: [PATCH 22/64] Account for /usr/include/protocols/r{outed,whod}.h with their respective build knobs --- include/protocols/Makefile | 10 +++++++++- tools/build/mk/OptionalObsoleteFiles.inc | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/protocols/Makefile b/include/protocols/Makefile index 0008c76fb875..c39002ef9598 100644 --- a/include/protocols/Makefile +++ b/include/protocols/Makefile @@ -3,9 +3,17 @@ .include NO_OBJ= -INCS= dumprestore.h routed.h rwhod.h timed.h +INCS= dumprestore.h timed.h INCSDIR=${INCLUDEDIR}/protocols +.if ${MK_RCMDS} != "no" +INCS+= rwhod.h +.endif + +.if ${MK_ROUTED} != "no" +INCS+= routed.h +.endif + .if ${MK_TALK} != "no" INCS+= talkd.h .endif diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index c1ddf1cd2de3..98dd39c7da72 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -3985,6 +3985,7 @@ OLD_FILES+=usr/share/man/man8/rbootd.8.gz .endif .if ${MK_RCMDS} == no +OLD_FILES+=usr/include/protocols/rwhod.h OLD_FILES+=bin/rcp OLD_FILES+=etc/pam.d/rsh OLD_FILES+=etc/rc.d/rwho @@ -4040,6 +4041,7 @@ OLD_FILES+=usr/share/man/man8/etcupdate.8.gz #.endif .if ${MK_ROUTED} == no +OLD_FILES+=usr/include/protocols/routed.h OLD_FILES+=sbin/routed OLD_FILES+=sbin/rtquery OLD_FILES+=usr/share/man/man8/routed.8.gz From a3f5edf093c370c21ef6a0496c073c1b0194cfd3 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Wed, 26 Nov 2014 13:25:09 +0000 Subject: [PATCH 23/64] Add MK_TIMED option for optionally building usr.sbin/timed, et al --- etc/rc.d/Makefile | 5 ++++- share/mk/src.opts.mk | 1 + tools/build/mk/OptionalObsoleteFiles.inc | 8 ++++++++ tools/build/options/WITHOUT_TIMED | 3 +++ usr.sbin/Makefile | 5 ++++- 5 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 tools/build/options/WITHOUT_TIMED diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile index 855abcb71405..427cb7545e7b 100644 --- a/etc/rc.d/Makefile +++ b/etc/rc.d/Makefile @@ -137,7 +137,6 @@ FILES= DAEMON \ syscons \ sysctl \ syslogd \ - timed \ tmp \ ${_ubthidhci} \ ugidfw \ @@ -236,6 +235,10 @@ FILES+= ftp-proxy FILES+= rwho .endif +.if ${MK_TIMED} != "no" +FILES+= timed +.endif + .if ${MK_UNBOUND} != "no" _unbound= local_unbound .endif diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index 9132d23ed27c..a18e1a1308e3 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -157,6 +157,7 @@ __DEFAULT_YES_OPTIONS = \ TESTS \ TEXTPROC \ TFTP \ + TIMED \ UNBOUND \ USB \ UTMPX \ diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index 98dd39c7da72..e7fa7f657e0c 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -4911,6 +4911,14 @@ OLD_FILES+=${TESTS_FILES} . endif .endif # Test suite. +.if ${MK_TIMED} == no +OLD_FILES+=etc/rc.d/timed +OLD_FILES+=usr/sbin/timed +OLD_FILES+=usr/sbin/timedc +OLD_FILES+=usr/share/man/man8/timed.8.gz +OLD_FILES+=usr/share/man/man8/timedc.8.gz +.endif + #.if ${MK_TOOLCHAIN} == no # to be filled in #.endif diff --git a/tools/build/options/WITHOUT_TIMED b/tools/build/options/WITHOUT_TIMED new file mode 100644 index 000000000000..a1f4c6859a3d --- /dev/null +++ b/tools/build/options/WITHOUT_TIMED @@ -0,0 +1,3 @@ +.\" $FreeBSD$ +Set to not build or install +.Xr timed 8 . diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile index cc686d07e387..2b6cb1b62d8a 100644 --- a/usr.sbin/Makefile +++ b/usr.sbin/Makefile @@ -82,7 +82,6 @@ SUBDIR= adduser \ sysrc \ tcpdrop \ tcpdump \ - timed \ traceroute \ trpt \ tzsetup \ @@ -307,6 +306,10 @@ SUBDIR+= tcpdmatch SUBDIR+= tests .endif +.if ${MK_TIMED} != "no" +SUBDIR+= timed +.endif + .if ${MK_TOOLCHAIN} != "no" SUBDIR+= config SUBDIR+= crunch From 24dce9ffb7d197f6a574cba1960195c4aa79bd67 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Wed, 26 Nov 2014 13:26:12 +0000 Subject: [PATCH 24/64] Ignore LIBPRIVATEDIR when suggesting directories to prune --- tools/add-optional-obsolete-files-entries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/add-optional-obsolete-files-entries.sh b/tools/add-optional-obsolete-files-entries.sh index 1c6de8c02066..7776780a4d41 100755 --- a/tools/add-optional-obsolete-files-entries.sh +++ b/tools/add-optional-obsolete-files-entries.sh @@ -44,6 +44,6 @@ done (cd $DESTDIR; find -s . -type f -mindepth 1 | sed -e 's,^,OLD_FILES+=,'; find -s . -type d -mindepth 1 -and \! -empty | \ - egrep -v '^\./(s*bin|libexec|usr|usr/include|usr/lib|usr/libexec|usr/s*bin|usr/share|usr/share/man|usr/share/man/man[0-9])$' | \ + egrep -v '^\./(s*bin|libexec|usr|usr/include|usr/lib|usr/lib/private|usr/libexec|usr/s*bin|usr/share|usr/share/man|usr/share/man/man[0-9])$' | \ sed -e 's,^,OLD_DIRS+=,' ) | sed -e 's,+=\./,+=,' From ece34a4f2de9d58100ff37c2a149ba5b6bb4b97b Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Wed, 26 Nov 2014 14:01:27 +0000 Subject: [PATCH 25/64] Fix use of OLD_FILES and OLD_LIBS for MK_BSNMP and MK_TESTS Convention in the file is that .a files be added to OLD_FILES and versioned .so's be added to OLD_LIBS --- tools/build/mk/OptionalObsoleteFiles.inc | 40 ++++++++++++------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index e7fa7f657e0c..f74b099262a3 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -354,23 +354,23 @@ OLD_FILES+=usr/include/bsnmp/snmpagent.h OLD_FILES+=usr/include/bsnmp/snmpclient.h OLD_FILES+=usr/include/bsnmp/snmpmod.h OLD_FILES+=usr/lib/libbsnmp.a -OLD_FILES+=usr/lib/libbsnmp.so.6 +OLD_LIBS+=usr/lib/libbsnmp.so.6 OLD_FILES+=usr/lib/libbsnmp_p.a OLD_FILES+=usr/lib/libbsnmptools.a -OLD_FILES+=usr/lib/libbsnmptools.so.0 +OLD_LIBS+=usr/lib/libbsnmptools.so.0 OLD_FILES+=usr/lib/libbsnmptools_p.a -OLD_FILES+=usr/lib/snmp_atm.so.6 -OLD_FILES+=usr/lib/snmp_bridge.so.6 -OLD_FILES+=usr/lib/snmp_hast.so.6 -OLD_FILES+=usr/lib/snmp_hostres.so.6 -OLD_FILES+=usr/lib/snmp_lm75.so.6 -OLD_FILES+=usr/lib/snmp_mibII.so.6 -OLD_FILES+=usr/lib/snmp_netgraph.so.6 -OLD_FILES+=usr/lib/snmp_pf.so.6 -OLD_FILES+=usr/lib/snmp_target.so.6 -OLD_FILES+=usr/lib/snmp_usm.so.6 -OLD_FILES+=usr/lib/snmp_vacm.so.6 -OLD_FILES+=usr/lib/snmp_wlan.so.6 +OLD_LIBS+=usr/lib/snmp_atm.so.6 +OLD_LIBS+=usr/lib/snmp_bridge.so.6 +OLD_LIBS+=usr/lib/snmp_hast.so.6 +OLD_LIBS+=usr/lib/snmp_hostres.so.6 +OLD_LIBS+=usr/lib/snmp_lm75.so.6 +OLD_LIBS+=usr/lib/snmp_mibII.so.6 +OLD_LIBS+=usr/lib/snmp_netgraph.so.6 +OLD_LIBS+=usr/lib/snmp_pf.so.6 +OLD_LIBS+=usr/lib/snmp_target.so.6 +OLD_LIBS+=usr/lib/snmp_usm.so.6 +OLD_LIBS+=usr/lib/snmp_vacm.so.6 +OLD_LIBS+=usr/lib/snmp_wlan.so.6 OLD_FILES+=usr/sbin/bsnmpd OLD_FILES+=usr/sbin/gensnmptree OLD_FILES+=usr/share/man/man1/bsnmpd.1.gz @@ -4390,15 +4390,15 @@ OLD_FILES+=usr/share/man/man8/tftpd.8.gz OLD_FILES+=usr/bin/atf-sh OLD_FILES+=usr/include/atf-c++/config.hpp OLD_FILES+=usr/include/atf-c/config.h -OLD_LIBS+=usr/lib/libatf-c++.a +OLD_FILES+=usr/lib/libatf-c++.a OLD_LIBS+=usr/lib/libatf-c++.so OLD_LIBS+=usr/lib/libatf-c++.so.1 OLD_LIBS+=usr/lib/libatf-c++.so.2 -OLD_LIBS+=usr/lib/libatf-c++_p.a -OLD_LIBS+=usr/lib/libatf-c.a +OLD_FILES+=usr/lib/libatf-c++_p.a +OLD_FILES+=usr/lib/libatf-c.a OLD_LIBS+=usr/lib/libatf-c.so OLD_LIBS+=usr/lib/libatf-c.so.1 -OLD_LIBS+=usr/lib/libatf-c_p.a +OLD_FILES+=usr/lib/libatf-c_p.a OLD_LIBS+=usr/lib/private/libatf-c.so.0 OLD_LIBS+=usr/lib/private/libatf-c++.so.1 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64" @@ -4878,11 +4878,11 @@ OLD_FILES+=usr/include/atf-c++/tests.hpp OLD_FILES+=usr/include/atf-c++/utils.hpp OLD_FILES+=usr/include/atf-c++.hpp OLD_FILES+=usr/lib/libatf-c_p.a -OLD_FILES+=usr/lib/libatf-c.so.1 +OLD_LIBS+=usr/lib/libatf-c.so.1 OLD_FILES+=usr/lib/libatf-c.so OLD_FILES+=usr/lib/libatf-c++.a OLD_FILES+=usr/lib/libatf-c++_p.a -OLD_FILES+=usr/lib/libatf-c++.so.1 +OLD_LIBS+=usr/lib/libatf-c++.so.1 OLD_FILES+=usr/lib/libatf-c++.so OLD_FILES+=usr/lib/libatf-c.a OLD_FILES+=usr/libexec/atf-check From 38082ac9aed3bbef5c81dfee18880c1c3fec4b06 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Wed, 26 Nov 2014 21:17:32 +0000 Subject: [PATCH 26/64] - Handle OLD_LIBS properly by looking for versioned .so's - Filter out /usr/libdata and /usr/libdata/pkgconfig from OLD_DIRS --- tools/add-optional-obsolete-files-entries.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/add-optional-obsolete-files-entries.sh b/tools/add-optional-obsolete-files-entries.sh index 7776780a4d41..f4c5ed69b8f7 100755 --- a/tools/add-optional-obsolete-files-entries.sh +++ b/tools/add-optional-obsolete-files-entries.sh @@ -42,8 +42,10 @@ done # Enumerate all of the installed files/directories (cd $DESTDIR; - find -s . -type f -mindepth 1 | sed -e 's,^,OLD_FILES+=,'; + find -s . -type f -mindepth 1 | \ + sed -e 's,^,OLD_FILES+=,' \ + -e '/lib\/.*\.so\.[0-9]\.*/s/OLD_FILES+=/OLD_LIBS+=/g'; find -s . -type d -mindepth 1 -and \! -empty | \ - egrep -v '^\./(s*bin|libexec|usr|usr/include|usr/lib|usr/lib/private|usr/libexec|usr/s*bin|usr/share|usr/share/man|usr/share/man/man[0-9])$' | \ + grep -v '^\./(s*bin|libexec|usr|usr/include|usr/lib(data)?|usr/libdata/pkgconfig|usr/lib/private|usr/libexec|usr/s*bin|usr/share(/(examples|man))?|usr/share/man/man[0-9])$' | \ sed -e 's,^,OLD_DIRS+=,' ) | sed -e 's,+=\./,+=,' From 0341ccf22728f358d39b1f696786e7a34ce23669 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Wed, 26 Nov 2014 21:18:52 +0000 Subject: [PATCH 27/64] Clean up more usb related files when MK_USB == no when dealing with manpages, libraries, and binaries --- include/Makefile | 6 +- share/examples/Makefile | 17 +- share/man/man4/Makefile | 119 ++++---- share/man/man9/Makefile | 7 +- share/misc/Makefile | 9 +- tools/build/mk/OptionalObsoleteFiles.inc | 371 +++++++++++++++++++++++ 6 files changed, 462 insertions(+), 67 deletions(-) diff --git a/include/Makefile b/include/Makefile index fe62e5e26d49..6003e2683bb8 100644 --- a/include/Makefile +++ b/include/Makefile @@ -44,7 +44,7 @@ LSUBDIRS= cam/ata cam/scsi \ dev/hwpmc \ dev/ic dev/iicbus ${_dev_ieee488} dev/io dev/lmc dev/mfi dev/nvme \ dev/ofw dev/pbio dev/pci ${_dev_powermac_nvram} dev/ppbus dev/smbus \ - dev/speaker dev/usb dev/utopia dev/vkbd dev/wi \ + dev/speaker dev/utopia dev/vkbd dev/wi \ fs/cuse \ fs/devfs fs/fdescfs fs/msdosfs fs/nandfs fs/nfs fs/nullfs \ fs/procfs fs/smbfs fs/udf fs/unionfs \ @@ -57,6 +57,10 @@ LSUBDIRS= cam/ata cam/scsi \ security/mac_mls security/mac_partition \ ufs/ffs ufs/ufs +.if ${MK_USB} != "no" +LSUBDIRS+= dev/usb +.endif + LSUBSUBDIRS= dev/mpt/mpilib .if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpc64" diff --git a/share/examples/Makefile b/share/examples/Makefile index 7fd8723aa30c..6d8eceba130f 100644 --- a/share/examples/Makefile +++ b/share/examples/Makefile @@ -18,7 +18,6 @@ LDIRS= BSD_daemon \ ipfw \ jails \ kld \ - libusb20 \ libvgl \ mdoc \ netgraph \ @@ -92,12 +91,6 @@ XFILES= BSD_daemon/FreeBSD.pfa \ kld/syscall/module/syscall.c \ kld/syscall/test/Makefile \ kld/syscall/test/call.c \ - libusb20/Makefile \ - libusb20/README \ - libusb20/util.c \ - libusb20/util.h \ - libusb20/bulk.c \ - libusb20/control.c \ libvgl/Makefile \ libvgl/demo.c \ mdoc/POSIX-copyright \ @@ -213,6 +206,16 @@ XFILES+= hast/ucarp.sh \ hast/vip-up.sh .endif +.if ${MK_USB} != "no" +LDIRS+= libusb20 +XFILES+= libusb20/Makefile \ + libusb20/README \ + libusb20/util.c \ + libusb20/util.h \ + libusb20/bulk.c \ + libusb20/control.c +.endif + beforeinstall: ${SHARED} etc-examples .ORDER: ${SHARED} etc-examples diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index 7fa6dea4a672..ad8e622cc005 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -503,56 +503,6 @@ MAN= aac.4 \ tws.4 \ tx.4 \ txp.4 \ - u3g.4 \ - uark.4 \ - uart.4 \ - uath.4 \ - ubsa.4 \ - ubsec.4 \ - ubser.4 \ - ubtbcmfw.4 \ - uchcom.4 \ - ucom.4 \ - ucycom.4 \ - udav.4 \ - udbp.4 \ - udp.4 \ - udplite.4 \ - uep.4 \ - ufm.4 \ - ufoma.4 \ - uftdi.4 \ - ugen.4 \ - uhci.4 \ - uhid.4 \ - uhso.4 \ - uipaq.4 \ - ukbd.4 \ - uled.4 \ - ulpt.4 \ - umass.4 \ - umcs.4 \ - umct.4 \ - umodem.4 \ - umoscom.4 \ - ums.4 \ - unix.4 \ - upgt.4 \ - uplcom.4 \ - ural.4 \ - urio.4 \ - urndis.4 \ - ${_urtw.4} \ - urtwn.4 \ - urtwnfw.4 \ - usb.4 \ - usb_template.4 \ - usb_quirk.4 \ - uslcom.4 \ - usfs.4 \ - utopia.4 \ - uvisor.4 \ - uvscom.4 \ vale.4 \ vga.4 \ vge.4 \ @@ -733,13 +683,6 @@ MLINKS+=tl.4 if_tl.4 MLINKS+=tun.4 if_tun.4 MLINKS+=tx.4 if_tx.4 MLINKS+=txp.4 if_txp.4 -MLINKS+=u3g.4 u3gstub.4 -MLINKS+=uath.4 if_uath.4 -MLINKS+=udav.4 if_udav.4 -MLINKS+=upgt.4 if_upgt.4 -MLINKS+=ural.4 if_ural.4 -MLINKS+=urndis.4 if_urndis.4 -MLINKS+=${_urtw.4} ${_if_urtw.4} MLINKS+=vge.4 if_vge.4 MLINKS+=vlan.4 if_vlan.4 MLINKS+=vxlan.4 if_vxlan.4 @@ -876,4 +819,66 @@ _pflog.4= pflog.4 _pfsync.4= pfsync.4 .endif +.if ${MK_USB} != "no" +MAN+= \ + u3g.4 \ + uark.4 \ + uart.4 \ + uath.4 \ + ubsa.4 \ + ubsec.4 \ + ubser.4 \ + ubtbcmfw.4 \ + uchcom.4 \ + ucom.4 \ + ucycom.4 \ + udav.4 \ + udbp.4 \ + udp.4 \ + udplite.4 \ + uep.4 \ + ufm.4 \ + ufoma.4 \ + uftdi.4 \ + ugen.4 \ + uhci.4 \ + uhid.4 \ + uhso.4 \ + uipaq.4 \ + ukbd.4 \ + uled.4 \ + ulpt.4 \ + umass.4 \ + umcs.4 \ + umct.4 \ + umodem.4 \ + umoscom.4 \ + ums.4 \ + unix.4 \ + upgt.4 \ + uplcom.4 \ + ural.4 \ + urio.4 \ + urndis.4 \ + ${_urtw.4} \ + urtwn.4 \ + urtwnfw.4 \ + usb.4 \ + usb_quirk.4 \ + usb_template.4 \ + usfs.4 \ + uslcom.4 + utopia.4 \ + uvisor.4 \ + uvscom.4 \ + +MLINKS+=u3g.4 u3gstub.4 +MLINKS+=uath.4 if_uath.4 +MLINKS+=udav.4 if_udav.4 +MLINKS+=upgt.4 if_upgt.4 +MLINKS+=ural.4 if_ural.4 +MLINKS+=urndis.4 if_urndis.4 +MLINKS+=${_urtw.4} ${_if_urtw.4} +.endif + .include diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index 6b6ee16165c5..eef10fcbf95f 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -1,5 +1,7 @@ # $FreeBSD$ +.include + MAN= accept_filter.9 \ accf_data.9 \ accf_dns.9 \ @@ -272,7 +274,6 @@ MAN= accept_filter.9 \ uidinfo.9 \ uio.9 \ unr.9 \ - usbdi.9 \ utopia.9 \ vaccess.9 \ vaccess_acl_nfs4.9 \ @@ -1600,6 +1601,9 @@ MLINKS+=uidinfo.9 uifind.9 \ uidinfo.9 uihold.9 MLINKS+=uio.9 uiomove.9 \ uio.9 uiomove_nofault.9 + +.if ${MK_USB} != "no" +MAN+= usbdi.9 MLINKS+=usbdi.9 usbd_do_request.9 \ usbdi.9 usbd_do_request_flags.9 \ usbdi.9 usbd_errstr.9 \ @@ -1651,6 +1655,7 @@ MLINKS+=usbdi.9 usbd_do_request.9 \ usbdi.9 usb_fifo_reset.9 \ usbdi.9 usb_fifo_softc.9 \ usbdi.9 usb_fifo_wakeup.9 +.endif MLINKS+=vcount.9 count_dev.9 MLINKS+=vfsconf.9 vfs_modevent.9 \ vfsconf.9 vfs_register.9 \ diff --git a/share/misc/Makefile b/share/misc/Makefile index 3e2afc43125f..16f803c2b27d 100644 --- a/share/misc/Makefile +++ b/share/misc/Makefile @@ -1,15 +1,22 @@ # From: @(#)Makefile 8.1 (Berkeley) 6/8/93 # $FreeBSD$ +.include + .PATH: ${.CURDIR}/../../sys/dev/usb FILES= ascii birthtoken bsd-family-tree committers-doc.dot committers-ports.dot \ committers-src.dot eqnchar flowers init.ee \ iso3166 iso639 latin1 man.template mdoc.template operator pci_vendors \ - scsi_modes usb_hid_usages usbdevs \ + scsi_modes \ organization.dot NO_OBJ= FILESDIR= ${BINDIR}/misc +.if ${MK_USB} != "no" +FILES+= usb_hid_usages +FILES+= usbdevs +.endif + .include diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index f74b099262a3..08d722c213b9 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -4946,6 +4946,377 @@ OLD_FILES+=usr/sbin/unbound-control-setup .if ${MK_USB} == no OLD_FILES+=etc/devd/uauth.conf OLD_FILES+=etc/devd/usb.conf +OLD_FILES+=usr/bin/usbhidaction +OLD_FILES+=usr/bin/usbhidctl +OLD_FILES+=usr/include/dev/usb/ufm_ioctl.h +OLD_FILES+=usr/include/dev/usb/uftdiio.h +OLD_FILES+=usr/include/dev/usb/uled_ioctl.h +OLD_FILES+=usr/include/dev/usb/usb.h +OLD_FILES+=usr/include/dev/usb/usb_bus.h +OLD_FILES+=usr/include/dev/usb/usb_busdma.h +OLD_FILES+=usr/include/dev/usb/usb_cdc.h +OLD_FILES+=usr/include/dev/usb/usb_compat_linux.h +OLD_FILES+=usr/include/dev/usb/usb_controller.h +OLD_FILES+=usr/include/dev/usb/usb_core.h +OLD_FILES+=usr/include/dev/usb/usb_debug.h +OLD_FILES+=usr/include/dev/usb/usb_dev.h +OLD_FILES+=usr/include/dev/usb/usb_device.h +OLD_FILES+=usr/include/dev/usb/usb_dynamic.h +OLD_FILES+=usr/include/dev/usb/usb_endian.h +OLD_FILES+=usr/include/dev/usb/usb_freebsd.h +OLD_FILES+=usr/include/dev/usb/usb_freebsd_loader.h +OLD_FILES+=usr/include/dev/usb/usb_generic.h +OLD_FILES+=usr/include/dev/usb/usb_hub.h +OLD_FILES+=usr/include/dev/usb/usb_ioctl.h +OLD_FILES+=usr/include/dev/usb/usb_mbuf.h +OLD_FILES+=usr/include/dev/usb/usb_msctest.h +OLD_FILES+=usr/include/dev/usb/usb_pci.h +OLD_FILES+=usr/include/dev/usb/usb_pf.h +OLD_FILES+=usr/include/dev/usb/usb_process.h +OLD_FILES+=usr/include/dev/usb/usb_request.h +OLD_FILES+=usr/include/dev/usb/usb_transfer.h +OLD_FILES+=usr/include/dev/usb/usb_util.h +OLD_FILES+=usr/include/dev/usb/usbdi.h +OLD_FILES+=usr/include/dev/usb/usbdi_util.h +OLD_FILES+=usr/include/dev/usb/usbhid.h +OLD_DIRS+=usr/include/dev/usb +OLD_FILES+=usr/include/libusb.h +OLD_FILES+=usr/include/libusb20.h +OLD_FILES+=usr/include/libusb20_desc.h +OLD_FILES+=usr/include/usb.h +OLD_FILES+=usr/include/usbhid.h +OLD_FILES+=usr/lib/libusb.a +OLD_LIBS+=usr/lib/libusb.so.3 +OLD_FILES+=usr/lib/libusb_p.a +OLD_FILES+=usr/lib/libusbhid.a +OLD_LIBS+=usr/lib/libusbhid.so.4 +OLD_FILES+=usr/lib/libusbhid_p.a +.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64" +OLD_FILES+=usr/lib32/libusb.a +OLD_LIBS+=usr/lib32/libusb.so.3 +OLD_FILES+=usr/lib32/libusbhid.a +OLD_LIBS+=usr/lib32/libusbhid.so.4 +.endif +OLD_FILES+=usr/libdata/pkgconfig/libusb-0.1.pc +OLD_FILES+=usr/libdata/pkgconfig/libusb-1.0.pc +OLD_FILES+=usr/libdata/pkgconfig/libusb-2.0.pc +OLD_FILES+=usr/sbin/usbconfig +OLD_FILES+=usr/sbin/usbdump +OLD_FILES+=usr/share/examples/libusb20/Makefile +OLD_FILES+=usr/share/examples/libusb20/README +OLD_FILES+=usr/share/examples/libusb20/bulk.c +OLD_FILES+=usr/share/examples/libusb20/control.c +OLD_FILES+=usr/share/examples/libusb20/util.c +OLD_FILES+=usr/share/examples/libusb20/util.h +OLD_DIRS+=usr/share/examples/libusb20 +OLD_FILES+=usr/share/man/man1/usbhidaction.1.gz +OLD_FILES+=usr/share/man/man1/usbhidctl.1.gz +OLD_FILES+=usr/share/man/man3/hid_dispose_report_desc.3.gz +OLD_FILES+=usr/share/man/man3/hid_end_parse.3.gz +OLD_FILES+=usr/share/man/man3/hid_get_data.3.gz +OLD_FILES+=usr/share/man/man3/hid_get_item.3.gz +OLD_FILES+=usr/share/man/man3/hid_get_report_desc.3.gz +OLD_FILES+=usr/share/man/man3/hid_init.3.gz +OLD_FILES+=usr/share/man/man3/hid_locate.3.gz +OLD_FILES+=usr/share/man/man3/hid_report_size.3.gz +OLD_FILES+=usr/share/man/man3/hid_set_data.3.gz +OLD_FILES+=usr/share/man/man3/hid_start_parse.3.gz +OLD_FILES+=usr/share/man/man3/hid_usage_in_page.3.gz +OLD_FILES+=usr/share/man/man3/hid_usage_page.3.gz +OLD_FILES+=usr/share/man/man3/libusb.3.gz +OLD_FILES+=usr/share/man/man3/libusb20.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_be_add_dev_quirk.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_be_alloc_default.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_be_dequeue_device.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_be_device_foreach.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_be_enqueue_device.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_be_free.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_be_get_dev_quirk.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_be_get_quirk_name.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_be_get_template.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_be_remove_dev_quirk.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_be_set_template.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_desc_foreach.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_alloc.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_alloc_config.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_check_connected.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_close.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_detach_kernel_driver.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_free.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_get_address.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_get_backend_name.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_get_bus_number.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_get_config_index.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_get_debug.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_get_desc.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_get_device_desc.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_get_fd.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_get_iface_desc.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_get_info.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_get_mode.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_get_parent_address.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_get_parent_port.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_get_port_path.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_get_power_mode.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_get_power_usage.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_get_speed.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_kernel_driver_active.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_open.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_process.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_req_string_simple_sync.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_req_string_sync.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_request_sync.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_reset.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_set_alt_index.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_set_config_index.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_set_debug.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_set_power_mode.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_dev_wait_process.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_error_name.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_me_decode.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_me_encode.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_me_get_1.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_me_get_2.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_strerror.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_bulk_intr_sync.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_callback_wrapper.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_clear_stall_sync.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_close.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_drain.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_get_actual_frames.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_get_actual_length.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_get_length.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_get_max_frames.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_get_max_packet_length.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_get_max_total_length.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_get_pointer.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_get_priv_sc0.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_get_priv_sc1.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_get_status.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_get_time_complete.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_open.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_pending.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_set_buffer.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_set_callback.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_set_flags.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_set_length.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_set_priv_sc0.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_set_priv_sc1.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_set_timeout.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_set_total_frames.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_setup_bulk.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_setup_control.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_setup_intr.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_setup_isoc.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_start.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_stop.3.gz +OLD_FILES+=usr/share/man/man3/libusb20_tr_submit.3.gz +OLD_FILES+=usr/share/man/man3/libusb_alloc_transfer.3.gz +OLD_FILES+=usr/share/man/man3/libusb_attach_kernel_driver.3.gz +OLD_FILES+=usr/share/man/man3/libusb_bulk_transfer.3.gz +OLD_FILES+=usr/share/man/man3/libusb_cancel_transfer.3.gz +OLD_FILES+=usr/share/man/man3/libusb_check_connected.3.gz +OLD_FILES+=usr/share/man/man3/libusb_claim_interface.3.gz +OLD_FILES+=usr/share/man/man3/libusb_clear_halt.3.gz +OLD_FILES+=usr/share/man/man3/libusb_close.3.gz +OLD_FILES+=usr/share/man/man3/libusb_control_transfer.3.gz +OLD_FILES+=usr/share/man/man3/libusb_detach_kernel_driver.3.gz +OLD_FILES+=usr/share/man/man3/libusb_detach_kernel_driver_np.3.gz +OLD_FILES+=usr/share/man/man3/libusb_error_name.3.gz +OLD_FILES+=usr/share/man/man3/libusb_event_handler_active.3.gz +OLD_FILES+=usr/share/man/man3/libusb_event_handling_ok.3.gz +OLD_FILES+=usr/share/man/man3/libusb_exit.3.gz +OLD_FILES+=usr/share/man/man3/libusb_free_bos_descriptor.3.gz +OLD_FILES+=usr/share/man/man3/libusb_free_config_descriptor.3.gz +OLD_FILES+=usr/share/man/man3/libusb_free_device_list.3.gz +OLD_FILES+=usr/share/man/man3/libusb_free_ss_endpoint_comp.3.gz +OLD_FILES+=usr/share/man/man3/libusb_free_transfer.3.gz +OLD_FILES+=usr/share/man/man3/libusb_get_active_config_descriptor.3.gz +OLD_FILES+=usr/share/man/man3/libusb_get_bus_number.3.gz +OLD_FILES+=usr/share/man/man3/libusb_get_config_descriptor.3.gz +OLD_FILES+=usr/share/man/man3/libusb_get_config_descriptor_by_value.3.gz +OLD_FILES+=usr/share/man/man3/libusb_get_configuration.3.gz +OLD_FILES+=usr/share/man/man3/libusb_get_device.3.gz +OLD_FILES+=usr/share/man/man3/libusb_get_device_address.3.gz +OLD_FILES+=usr/share/man/man3/libusb_get_device_descriptor.3.gz +OLD_FILES+=usr/share/man/man3/libusb_get_device_list.3.gz +OLD_FILES+=usr/share/man/man3/libusb_get_device_speed.3.gz +OLD_FILES+=usr/share/man/man3/libusb_get_driver.3.gz +OLD_FILES+=usr/share/man/man3/libusb_get_driver_np.3.gz +OLD_FILES+=usr/share/man/man3/libusb_get_max_iso_packet_size.3.gz +OLD_FILES+=usr/share/man/man3/libusb_get_max_packet_size.3.gz +OLD_FILES+=usr/share/man/man3/libusb_get_next_timeout.3.gz +OLD_FILES+=usr/share/man/man3/libusb_get_pollfds.3.gz +OLD_FILES+=usr/share/man/man3/libusb_get_string_descriptor.3.gz +OLD_FILES+=usr/share/man/man3/libusb_get_string_descriptor_ascii.3.gz +OLD_FILES+=usr/share/man/man3/libusb_handle_events.3.gz +OLD_FILES+=usr/share/man/man3/libusb_handle_events_completed.3.gz +OLD_FILES+=usr/share/man/man3/libusb_handle_events_locked.3.gz +OLD_FILES+=usr/share/man/man3/libusb_handle_events_timeout.3.gz +OLD_FILES+=usr/share/man/man3/libusb_handle_events_timeout_completed.3.gz +OLD_FILES+=usr/share/man/man3/libusb_init.3.gz +OLD_FILES+=usr/share/man/man3/libusb_interrupt_transfer.3.gz +OLD_FILES+=usr/share/man/man3/libusb_kernel_driver_active.3.gz +OLD_FILES+=usr/share/man/man3/libusb_lock_event_waiters.3.gz +OLD_FILES+=usr/share/man/man3/libusb_lock_events.3.gz +OLD_FILES+=usr/share/man/man3/libusb_open.3.gz +OLD_FILES+=usr/share/man/man3/libusb_open_device_with_vid_pid.3.gz +OLD_FILES+=usr/share/man/man3/libusb_parse_bos_descriptor.3.gz +OLD_FILES+=usr/share/man/man3/libusb_parse_ss_endpoint_comp.3.gz +OLD_FILES+=usr/share/man/man3/libusb_ref_device.3.gz +OLD_FILES+=usr/share/man/man3/libusb_release_interface.3.gz +OLD_FILES+=usr/share/man/man3/libusb_reset_device.3.gz +OLD_FILES+=usr/share/man/man3/libusb_set_configuration.3.gz +OLD_FILES+=usr/share/man/man3/libusb_set_debug.3.gz +OLD_FILES+=usr/share/man/man3/libusb_set_interface_alt_setting.3.gz +OLD_FILES+=usr/share/man/man3/libusb_set_pollfd_notifiers.3.gz +OLD_FILES+=usr/share/man/man3/libusb_strerror.3.gz +OLD_FILES+=usr/share/man/man3/libusb_submit_transfer.3.gz +OLD_FILES+=usr/share/man/man3/libusb_try_lock_events.3.gz +OLD_FILES+=usr/share/man/man3/libusb_unlock_event_waiters.3.gz +OLD_FILES+=usr/share/man/man3/libusb_unlock_events.3.gz +OLD_FILES+=usr/share/man/man3/libusb_unref_device.3.gz +OLD_FILES+=usr/share/man/man3/libusb_wait_for_event.3.gz +OLD_FILES+=usr/share/man/man3/libusbhid.3.gz +OLD_FILES+=usr/share/man/man3/usb.3.gz +OLD_FILES+=usr/share/man/man3/usb_bulk_read.3.gz +OLD_FILES+=usr/share/man/man3/usb_bulk_write.3.gz +OLD_FILES+=usr/share/man/man3/usb_check_connected.3.gz +OLD_FILES+=usr/share/man/man3/usb_claim_interface.3.gz +OLD_FILES+=usr/share/man/man3/usb_clear_halt.3.gz +OLD_FILES+=usr/share/man/man3/usb_close.3.gz +OLD_FILES+=usr/share/man/man3/usb_control_msg.3.gz +OLD_FILES+=usr/share/man/man3/usb_destroy_configuration.3.gz +OLD_FILES+=usr/share/man/man3/usb_device.3.gz +OLD_FILES+=usr/share/man/man3/usb_fetch_and_parse_descriptors.3.gz +OLD_FILES+=usr/share/man/man3/usb_find_busses.3.gz +OLD_FILES+=usr/share/man/man3/usb_find_devices.3.gz +OLD_FILES+=usr/share/man/man3/usb_get_busses.3.gz +OLD_FILES+=usr/share/man/man3/usb_get_descriptor.3.gz +OLD_FILES+=usr/share/man/man3/usb_get_descriptor_by_endpoint.3.gz +OLD_FILES+=usr/share/man/man3/usb_get_string.3.gz +OLD_FILES+=usr/share/man/man3/usb_get_string_simple.3.gz +OLD_FILES+=usr/share/man/man3/usb_init.3.gz +OLD_FILES+=usr/share/man/man3/usb_interrupt_read.3.gz +OLD_FILES+=usr/share/man/man3/usb_interrupt_write.3.gz +OLD_FILES+=usr/share/man/man3/usb_open.3.gz +OLD_FILES+=usr/share/man/man3/usb_parse_configuration.3.gz +OLD_FILES+=usr/share/man/man3/usb_parse_descriptor.3.gz +OLD_FILES+=usr/share/man/man3/usb_release_interface.3.gz +OLD_FILES+=usr/share/man/man3/usb_reset.3.gz +OLD_FILES+=usr/share/man/man3/usb_resetep.3.gz +OLD_FILES+=usr/share/man/man3/usb_set_altinterface.3.gz +OLD_FILES+=usr/share/man/man3/usb_set_configuration.3.gz +OLD_FILES+=usr/share/man/man3/usb_set_debug.3.gz +OLD_FILES+=usr/share/man/man3/usb_strerror.3.gz +OLD_FILES+=usr/share/man/man3/usbhid.3.gz +OLD_FILES+=usr/share/man/man4/u3g.4.gz +OLD_FILES+=usr/share/man/man4/u3gstub.4.gz +OLD_FILES+=usr/share/man/man4/uark.4.gz +OLD_FILES+=usr/share/man/man4/uart.4.gz +OLD_FILES+=usr/share/man/man4/uath.4.gz +OLD_FILES+=usr/share/man/man4/ubsa.4.gz +OLD_FILES+=usr/share/man/man4/ubsec.4.gz +OLD_FILES+=usr/share/man/man4/ubser.4.gz +OLD_FILES+=usr/share/man/man4/ubtbcmfw.4.gz +OLD_FILES+=usr/share/man/man4/uchcom.4.gz +OLD_FILES+=usr/share/man/man4/ucom.4.gz +OLD_FILES+=usr/share/man/man4/ucycom.4.gz +OLD_FILES+=usr/share/man/man4/udav.4.gz +OLD_FILES+=usr/share/man/man4/udbp.4.gz +OLD_FILES+=usr/share/man/man4/udp.4.gz +OLD_FILES+=usr/share/man/man4/udplite.4.gz +OLD_FILES+=usr/share/man/man4/uep.4.gz +OLD_FILES+=usr/share/man/man4/ufm.4.gz +OLD_FILES+=usr/share/man/man4/ufoma.4.gz +OLD_FILES+=usr/share/man/man4/uftdi.4.gz +OLD_FILES+=usr/share/man/man4/ugen.4.gz +OLD_FILES+=usr/share/man/man4/uhci.4.gz +OLD_FILES+=usr/share/man/man4/uhid.4.gz +OLD_FILES+=usr/share/man/man4/uhso.4.gz +OLD_FILES+=usr/share/man/man4/uipaq.4.gz +OLD_FILES+=usr/share/man/man4/ukbd.4.gz +OLD_FILES+=usr/share/man/man4/uled.4.gz +OLD_FILES+=usr/share/man/man4/ulpt.4.gz +OLD_FILES+=usr/share/man/man4/umass.4.gz +OLD_FILES+=usr/share/man/man4/umcs.4.gz +OLD_FILES+=usr/share/man/man4/umct.4.gz +OLD_FILES+=usr/share/man/man4/umodem.4.gz +OLD_FILES+=usr/share/man/man4/umoscom.4.gz +OLD_FILES+=usr/share/man/man4/ums.4.gz +OLD_FILES+=usr/share/man/man4/unix.4.gz +OLD_FILES+=usr/share/man/man4/upgt.4.gz +OLD_FILES+=usr/share/man/man4/uplcom.4.gz +OLD_FILES+=usr/share/man/man4/ural.4.gz +OLD_FILES+=usr/share/man/man4/urio.4.gz +OLD_FILES+=usr/share/man/man4/urndis.4.gz +OLD_FILES+=usr/share/man/man4/urtw.4.gz +OLD_FILES+=usr/share/man/man4/urtwn.4.gz +OLD_FILES+=usr/share/man/man4/urtwnfw.4.gz +OLD_FILES+=usr/share/man/man4/usb.4.gz +OLD_FILES+=usr/share/man/man4/usb_quirk.4.gz +OLD_FILES+=usr/share/man/man4/usb_template.4.gz +OLD_FILES+=usr/share/man/man4/usfs.4.gz +OLD_FILES+=usr/share/man/man4/uslcom.4.gz +OLD_FILES+=usr/share/man/man4/utopia.4.gz +OLD_FILES+=usr/share/man/man4/uvisor.4.gz +OLD_FILES+=usr/share/man/man4/uvscom.4.gz +OLD_FILES+=usr/share/man/man8/usbconfig.8.gz +OLD_FILES+=usr/share/man/man8/usbdump.8.gz +OLD_FILES+=usr/share/man/man9/usb_fifo_alloc_buffer.9.gz +OLD_FILES+=usr/share/man/man9/usb_fifo_attach.9.gz +OLD_FILES+=usr/share/man/man9/usb_fifo_detach.9.gz +OLD_FILES+=usr/share/man/man9/usb_fifo_free_buffer.9.gz +OLD_FILES+=usr/share/man/man9/usb_fifo_get_data.9.gz +OLD_FILES+=usr/share/man/man9/usb_fifo_get_data_buffer.9.gz +OLD_FILES+=usr/share/man/man9/usb_fifo_get_data_error.9.gz +OLD_FILES+=usr/share/man/man9/usb_fifo_get_data_linear.9.gz +OLD_FILES+=usr/share/man/man9/usb_fifo_put_bytes_max.9.gz +OLD_FILES+=usr/share/man/man9/usb_fifo_put_data.9.gz +OLD_FILES+=usr/share/man/man9/usb_fifo_put_data_buffer.9.gz +OLD_FILES+=usr/share/man/man9/usb_fifo_put_data_error.9.gz +OLD_FILES+=usr/share/man/man9/usb_fifo_put_data_linear.9.gz +OLD_FILES+=usr/share/man/man9/usb_fifo_reset.9.gz +OLD_FILES+=usr/share/man/man9/usb_fifo_softc.9.gz +OLD_FILES+=usr/share/man/man9/usb_fifo_wakeup.9.gz +OLD_FILES+=usr/share/man/man9/usbd_do_request.9.gz +OLD_FILES+=usr/share/man/man9/usbd_do_request_flags.9.gz +OLD_FILES+=usr/share/man/man9/usbd_errstr.9.gz +OLD_FILES+=usr/share/man/man9/usbd_lookup_id_by_info.9.gz +OLD_FILES+=usr/share/man/man9/usbd_lookup_id_by_uaa.9.gz +OLD_FILES+=usr/share/man/man9/usbd_transfer_clear_stall.9.gz +OLD_FILES+=usr/share/man/man9/usbd_transfer_drain.9.gz +OLD_FILES+=usr/share/man/man9/usbd_transfer_pending.9.gz +OLD_FILES+=usr/share/man/man9/usbd_transfer_poll.9.gz +OLD_FILES+=usr/share/man/man9/usbd_transfer_setup.9.gz +OLD_FILES+=usr/share/man/man9/usbd_transfer_start.9.gz +OLD_FILES+=usr/share/man/man9/usbd_transfer_stop.9.gz +OLD_FILES+=usr/share/man/man9/usbd_transfer_submit.9.gz +OLD_FILES+=usr/share/man/man9/usbd_transfer_unsetup.9.gz +OLD_FILES+=usr/share/man/man9/usbd_xfer_clr_flag.9.gz +OLD_FILES+=usr/share/man/man9/usbd_xfer_frame_data.9.gz +OLD_FILES+=usr/share/man/man9/usbd_xfer_frame_len.9.gz +OLD_FILES+=usr/share/man/man9/usbd_xfer_get_frame.9.gz +OLD_FILES+=usr/share/man/man9/usbd_xfer_get_priv.9.gz +OLD_FILES+=usr/share/man/man9/usbd_xfer_is_stalled.9.gz +OLD_FILES+=usr/share/man/man9/usbd_xfer_max_framelen.9.gz +OLD_FILES+=usr/share/man/man9/usbd_xfer_max_frames.9.gz +OLD_FILES+=usr/share/man/man9/usbd_xfer_max_len.9.gz +OLD_FILES+=usr/share/man/man9/usbd_xfer_set_flag.9.gz +OLD_FILES+=usr/share/man/man9/usbd_xfer_set_frame_data.9.gz +OLD_FILES+=usr/share/man/man9/usbd_xfer_set_frame_len.9.gz +OLD_FILES+=usr/share/man/man9/usbd_xfer_set_frame_offset.9.gz +OLD_FILES+=usr/share/man/man9/usbd_xfer_set_frames.9.gz +OLD_FILES+=usr/share/man/man9/usbd_xfer_set_interval.9.gz +OLD_FILES+=usr/share/man/man9/usbd_xfer_set_priv.9.gz +OLD_FILES+=usr/share/man/man9/usbd_xfer_set_stall.9.gz +OLD_FILES+=usr/share/man/man9/usbd_xfer_set_timeout.9.gz +OLD_FILES+=usr/share/man/man9/usbd_xfer_softc.9.gz +OLD_FILES+=usr/share/man/man9/usbd_xfer_state.9.gz +OLD_FILES+=usr/share/man/man9/usbd_xfer_status.9.gz +OLD_FILES+=usr/share/man/man9/usbdi.9.gz +OLD_FILES+=usr/share/misc/usb_hid_usages +OLD_FILES+=usr/share/misc/usbdevs .endif .if ${MK_UTMPX} == no From f8a682df154a6ea03a3476a3b987e023be481613 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Wed, 26 Nov 2014 21:32:12 +0000 Subject: [PATCH 28/64] Add missing line continuation --- share/man/man4/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index ad8e622cc005..a1e020a6ea56 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -867,7 +867,7 @@ MAN+= \ usb_quirk.4 \ usb_template.4 \ usfs.4 \ - uslcom.4 + uslcom.4 \ utopia.4 \ uvisor.4 \ uvscom.4 \ From f5ce9d6be99139b8787f55cf9c579c00c0bfe016 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Wed, 26 Nov 2014 21:53:53 +0000 Subject: [PATCH 29/64] Installing zzz(8) doesn't make sense when both ACPI and APM are disabled --- tools/build/mk/OptionalObsoleteFiles.inc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index 08d722c213b9..028555156ac3 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -58,6 +58,11 @@ OLD_FILES+=usr/share/man/man8/amd64/apm.8.gz OLD_FILES+=usr/share/man/man8/amd64/apmconf.8.gz .endif +.if ${MK_APM} == no && ${MK_ACPI} == no +OLD_FILES+=usr/sbin/zzz +OLD_FILES+=usr/share/man/man8/zzz.8.gz +.endif + .if ${MK_AT} == no OLD_FILES+=usr/bin/at OLD_FILES+=usr/bin/atq From c1399c63ec419aaae204c3e4da308c9e4abdac5a Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Wed, 26 Nov 2014 22:26:22 +0000 Subject: [PATCH 30/64] - Fix egrep -> grep typo introduced in previous commit - Do depth-first search on OLD_DIRS so the list is logically sorted --- tools/add-optional-obsolete-files-entries.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/add-optional-obsolete-files-entries.sh b/tools/add-optional-obsolete-files-entries.sh index f4c5ed69b8f7..d9095cec5943 100755 --- a/tools/add-optional-obsolete-files-entries.sh +++ b/tools/add-optional-obsolete-files-entries.sh @@ -45,7 +45,7 @@ done find -s . -type f -mindepth 1 | \ sed -e 's,^,OLD_FILES+=,' \ -e '/lib\/.*\.so\.[0-9]\.*/s/OLD_FILES+=/OLD_LIBS+=/g'; - find -s . -type d -mindepth 1 -and \! -empty | \ - grep -v '^\./(s*bin|libexec|usr|usr/include|usr/lib(data)?|usr/libdata/pkgconfig|usr/lib/private|usr/libexec|usr/s*bin|usr/share(/(examples|man))?|usr/share/man/man[0-9])$' | \ + find -d -s . -type d -mindepth 1 -and \! -empty | \ + egrep -v '^\./(s*bin|libexec|usr|usr/include|usr/lib(data)?|usr/libdata/pkgconfig|usr/lib/private|usr/libexec|usr/s*bin|usr/share|usr/share/(examples|man)|usr/share/man/man[0-9])$' | \ sed -e 's,^,OLD_DIRS+=,' ) | sed -e 's,+=\./,+=,' From 238fb74d5c0752456590f4ac831e7b9007084369 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Wed, 26 Nov 2014 22:27:31 +0000 Subject: [PATCH 31/64] Followup to r275144 -- don't traverse down usr.sbin/zzz if ACPI/APM are disabled --- usr.sbin/Makefile.amd64 | 2 ++ usr.sbin/Makefile.i386 | 2 ++ 2 files changed, 4 insertions(+) diff --git a/usr.sbin/Makefile.amd64 b/usr.sbin/Makefile.amd64 index 3f40974c7a0d..d821510d89f7 100644 --- a/usr.sbin/Makefile.amd64 +++ b/usr.sbin/Makefile.amd64 @@ -32,4 +32,6 @@ SUBDIR+= ndiscvt .endif SUBDIR+= sicontrol SUBDIR+= spkrtest +.if ${MK_ACPI} != "no" || ${MK_APM} != "no" SUBDIR+= zzz +.endif diff --git a/usr.sbin/Makefile.i386 b/usr.sbin/Makefile.i386 index de7bb464f581..70e4ef5a3916 100644 --- a/usr.sbin/Makefile.i386 +++ b/usr.sbin/Makefile.i386 @@ -23,7 +23,9 @@ SUBDIR+= ndiscvt SUBDIR+= pnpinfo SUBDIR+= sicontrol SUBDIR+= spkrtest +.if ${MK_ACPI} != "no" || ${MK_APM} != "no" SUBDIR+= zzz +.endif # Differentiate between FreeBSD/i386 and FreeBSD/pc98 .if ${MACHINE} == "i386" From d96b818e7360a3891664235ba412af35db268c4e Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Wed, 26 Nov 2014 22:41:51 +0000 Subject: [PATCH 32/64] - Fill in MK_LEGACY_CONSOLE == no and SYSCONS == no - Don't install syscons(4) - Don't install the moused or syscons rc.d scripts if MK_LEGACY_CONSOLE == no --- etc/rc.d/Makefile | 7 +- share/man/man4/Makefile | 5 +- tools/build/mk/OptionalObsoleteFiles.inc | 209 ++++++++++++++++++++++- 3 files changed, 215 insertions(+), 6 deletions(-) diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile index 427cb7545e7b..634895d6350b 100644 --- a/etc/rc.d/Makefile +++ b/etc/rc.d/Makefile @@ -80,7 +80,6 @@ FILES= DAEMON \ mdconfig \ mdconfig2 \ mountd \ - moused \ mroute6d \ mrouted \ msgs \ @@ -134,7 +133,6 @@ FILES= DAEMON \ stf \ swap \ swaplate \ - syscons \ sysctl \ syslogd \ tmp \ @@ -200,6 +198,11 @@ FILES+= iscsictl FILES+= iscsid .endif +.if ${MK_LEGACY_CONSOLE} != "no" +FILES+= moused +FILES+= syscons +.endif + .if ${MK_NS_CACHING} != "no" _nscd= nscd .endif diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index a1e020a6ea56..2df7bdbc9587 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -481,7 +481,6 @@ MAN= aac.4 \ sym.4 \ syncache.4 \ syncer.4 \ - syscons.4 \ sysmouse.4 \ tap.4 \ targ.4 \ @@ -819,6 +818,10 @@ _pflog.4= pflog.4 _pfsync.4= pfsync.4 .endif +.if ${MK_SYSCONS} != "no" +MAN+= syscons.4 +.endif + .if ${MK_USB} != "no" MAN+= \ u3g.4 \ diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index 028555156ac3..b5bfd33f0d28 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -3328,6 +3328,23 @@ OLD_FILES+=usr/bin/host OLD_FILES+=usr/share/man/man1/host.1.gz .endif +.if ${MK_LEGACY_CONSOLE} == no +OLD_FILES+=etc/rc.d/moused +OLD_FILES+=etc/rc.d/syscons +OLD_FILES+=usr/sbin/kbdcontrol +OLD_FILES+=usr/sbin/kbdmap +OLD_FILES+=usr/sbin/moused +OLD_FILES+=usr/sbin/vidcontrol +OLD_FILES+=usr/sbin/vidfont +OLD_FILES+=usr/share/man/man1/kbdcontrol.1.gz +OLD_FILES+=usr/share/man/man1/kbdmap.1.gz +OLD_FILES+=usr/share/man/man1/vidcontrol.1.gz +OLD_FILES+=usr/share/man/man1/vidfont.1.gz +OLD_FILES+=usr/share/man/man5/kbdmap.5.gz +OLD_FILES+=usr/share/man/man5/keymap.5.gz +OLD_FILES+=usr/share/man/man8/moused.8.g +.endif + #.if ${MK_LIB32} == no # to be filled in #.endif @@ -4295,9 +4312,195 @@ OLD_FILES+=usr/share/doc/pjdfstest/README OLD_DIRS+=usr/share/doc/pjdfstest .endif -#.if ${MK_SYSCONS} == no -# to be filled in -#.endif +.if ${MK_SYSCONS} == no +OLD_FILES+=usr/share/man/man4/syscons.4.gz +OLD_FILES+=usr/share/syscons/fonts/INDEX.fonts +OLD_FILES+=usr/share/syscons/fonts/armscii8-8x14.fnt +OLD_FILES+=usr/share/syscons/fonts/armscii8-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/armscii8-8x8.fnt +OLD_FILES+=usr/share/syscons/fonts/cp1251-8x14.fnt +OLD_FILES+=usr/share/syscons/fonts/cp1251-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/cp1251-8x8.fnt +OLD_FILES+=usr/share/syscons/fonts/cp437-8x14.fnt +OLD_FILES+=usr/share/syscons/fonts/cp437-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/cp437-8x8.fnt +OLD_FILES+=usr/share/syscons/fonts/cp437-thin-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/cp437-thin-8x8.fnt +OLD_FILES+=usr/share/syscons/fonts/cp850-8x14.fnt +OLD_FILES+=usr/share/syscons/fonts/cp850-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/cp850-8x8.fnt +OLD_FILES+=usr/share/syscons/fonts/cp850-thin-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/cp850-thin-8x8.fnt +OLD_FILES+=usr/share/syscons/fonts/cp865-8x14.fnt +OLD_FILES+=usr/share/syscons/fonts/cp865-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/cp865-8x8.fnt +OLD_FILES+=usr/share/syscons/fonts/cp865-thin-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/cp865-thin-8x8.fnt +OLD_FILES+=usr/share/syscons/fonts/cp866-8x14.fnt +OLD_FILES+=usr/share/syscons/fonts/cp866-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/cp866-8x8.fnt +OLD_FILES+=usr/share/syscons/fonts/cp866b-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/cp866c-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/cp866u-8x14.fnt +OLD_FILES+=usr/share/syscons/fonts/cp866u-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/cp866u-8x8.fnt +OLD_FILES+=usr/share/syscons/fonts/haik8-8x14.fnt +OLD_FILES+=usr/share/syscons/fonts/haik8-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/haik8-8x8.fnt +OLD_FILES+=usr/share/syscons/fonts/iso-8x14.fnt +OLD_FILES+=usr/share/syscons/fonts/iso-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/iso-8x8.fnt +OLD_FILES+=usr/share/syscons/fonts/iso-thin-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/iso02-8x14.fnt +OLD_FILES+=usr/share/syscons/fonts/iso02-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/iso02-8x8.fnt +OLD_FILES+=usr/share/syscons/fonts/iso04-8x14.fnt +OLD_FILES+=usr/share/syscons/fonts/iso04-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/iso04-8x8.fnt +OLD_FILES+=usr/share/syscons/fonts/iso04-vga9-8x14.fnt +OLD_FILES+=usr/share/syscons/fonts/iso04-vga9-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/iso04-vga9-8x8.fnt +OLD_FILES+=usr/share/syscons/fonts/iso04-vga9-wide-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/iso04-wide-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/iso05-8x14.fnt +OLD_FILES+=usr/share/syscons/fonts/iso05-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/iso05-8x8.fnt +OLD_FILES+=usr/share/syscons/fonts/iso07-8x14.fnt +OLD_FILES+=usr/share/syscons/fonts/iso07-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/iso07-8x8.fnt +OLD_FILES+=usr/share/syscons/fonts/iso08-8x14.fnt +OLD_FILES+=usr/share/syscons/fonts/iso08-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/iso08-8x8.fnt +OLD_FILES+=usr/share/syscons/fonts/iso09-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/iso15-8x14.fnt +OLD_FILES+=usr/share/syscons/fonts/iso15-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/iso15-8x8.fnt +OLD_FILES+=usr/share/syscons/fonts/iso15-thin-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/koi8-r-8x14.fnt +OLD_FILES+=usr/share/syscons/fonts/koi8-r-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/koi8-r-8x8.fnt +OLD_FILES+=usr/share/syscons/fonts/koi8-rb-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/koi8-rc-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/koi8-u-8x14.fnt +OLD_FILES+=usr/share/syscons/fonts/koi8-u-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/koi8-u-8x8.fnt +OLD_FILES+=usr/share/syscons/fonts/swiss-1131-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/swiss-1251-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/swiss-8x14.fnt +OLD_FILES+=usr/share/syscons/fonts/swiss-8x16.fnt +OLD_FILES+=usr/share/syscons/fonts/swiss-8x8.fnt +OLD_FILES+=usr/share/syscons/keymaps/INDEX.keymaps +OLD_FILES+=usr/share/syscons/keymaps/be.iso.acc.kbd +OLD_FILES+=usr/share/syscons/keymaps/be.iso.kbd +OLD_FILES+=usr/share/syscons/keymaps/bg.bds.ctrlcaps.kbd +OLD_FILES+=usr/share/syscons/keymaps/bg.phonetic.ctrlcaps.kbd +OLD_FILES+=usr/share/syscons/keymaps/br275.cp850.kbd +OLD_FILES+=usr/share/syscons/keymaps/br275.iso.acc.kbd +OLD_FILES+=usr/share/syscons/keymaps/br275.iso.kbd +OLD_FILES+=usr/share/syscons/keymaps/by.cp1131.kbd +OLD_FILES+=usr/share/syscons/keymaps/by.cp1251.kbd +OLD_FILES+=usr/share/syscons/keymaps/by.iso5.kbd +OLD_FILES+=usr/share/syscons/keymaps/ce.iso2.kbd +OLD_FILES+=usr/share/syscons/keymaps/colemak.iso15.acc.kbd +OLD_FILES+=usr/share/syscons/keymaps/cs.latin2.qwertz.kbd +OLD_FILES+=usr/share/syscons/keymaps/cz.iso2.kbd +OLD_FILES+=usr/share/syscons/keymaps/danish.cp865.kbd +OLD_FILES+=usr/share/syscons/keymaps/danish.iso.acc.kbd +OLD_FILES+=usr/share/syscons/keymaps/danish.iso.kbd +OLD_FILES+=usr/share/syscons/keymaps/danish.iso.macbook.kbd +OLD_FILES+=usr/share/syscons/keymaps/dutch.iso.acc.kbd +OLD_FILES+=usr/share/syscons/keymaps/eee_nordic.kbd +OLD_FILES+=usr/share/syscons/keymaps/el.iso07.kbd +OLD_FILES+=usr/share/syscons/keymaps/estonian.cp850.kbd +OLD_FILES+=usr/share/syscons/keymaps/estonian.iso.kbd +OLD_FILES+=usr/share/syscons/keymaps/estonian.iso15.kbd +OLD_FILES+=usr/share/syscons/keymaps/finnish.cp850.kbd +OLD_FILES+=usr/share/syscons/keymaps/finnish.iso.kbd +OLD_FILES+=usr/share/syscons/keymaps/fr.dvorak.acc.kbd +OLD_FILES+=usr/share/syscons/keymaps/fr.dvorak.kbd +OLD_FILES+=usr/share/syscons/keymaps/fr.iso.acc.kbd +OLD_FILES+=usr/share/syscons/keymaps/fr.iso.kbd +OLD_FILES+=usr/share/syscons/keymaps/fr.macbook.acc.kbd +OLD_FILES+=usr/share/syscons/keymaps/fr_CA.iso.acc.kbd +OLD_FILES+=usr/share/syscons/keymaps/german.cp850.kbd +OLD_FILES+=usr/share/syscons/keymaps/german.iso.acc.kbd +OLD_FILES+=usr/share/syscons/keymaps/german.iso.kbd +OLD_FILES+=usr/share/syscons/keymaps/gr.elot.acc.kbd +OLD_FILES+=usr/share/syscons/keymaps/gr.us101.acc.kbd +OLD_FILES+=usr/share/syscons/keymaps/hr.iso.kbd +OLD_FILES+=usr/share/syscons/keymaps/hu.iso2.101keys.kbd +OLD_FILES+=usr/share/syscons/keymaps/hu.iso2.102keys.kbd +OLD_FILES+=usr/share/syscons/keymaps/hy.armscii-8.kbd +OLD_FILES+=usr/share/syscons/keymaps/icelandic.iso.acc.kbd +OLD_FILES+=usr/share/syscons/keymaps/icelandic.iso.kbd +OLD_FILES+=usr/share/syscons/keymaps/it.iso.kbd +OLD_FILES+=usr/share/syscons/keymaps/iw.iso8.kbd +OLD_FILES+=usr/share/syscons/keymaps/jp.106.kbd +OLD_FILES+=usr/share/syscons/keymaps/jp.106x.kbd +OLD_FILES+=usr/share/syscons/keymaps/jp.pc98.iso.kbd +OLD_FILES+=usr/share/syscons/keymaps/jp.pc98.kbd +OLD_FILES+=usr/share/syscons/keymaps/kk.pt154.io.kbd +OLD_FILES+=usr/share/syscons/keymaps/kk.pt154.kst.kbd +OLD_FILES+=usr/share/syscons/keymaps/latinamerican.iso.acc.kbd +OLD_FILES+=usr/share/syscons/keymaps/latinamerican.kbd +OLD_FILES+=usr/share/syscons/keymaps/lt.iso4.kbd +OLD_FILES+=usr/share/syscons/keymaps/norwegian.dvorak.kbd +OLD_FILES+=usr/share/syscons/keymaps/norwegian.iso.kbd +OLD_FILES+=usr/share/syscons/keymaps/pl_PL.ISO8859-2.kbd +OLD_FILES+=usr/share/syscons/keymaps/pl_PL.dvorak.kbd +OLD_FILES+=usr/share/syscons/keymaps/pt.iso.acc.kbd +OLD_FILES+=usr/share/syscons/keymaps/pt.iso.kbd +OLD_FILES+=usr/share/syscons/keymaps/ru.cp866.kbd +OLD_FILES+=usr/share/syscons/keymaps/ru.iso5.kbd +OLD_FILES+=usr/share/syscons/keymaps/ru.koi8-r.kbd +OLD_FILES+=usr/share/syscons/keymaps/ru.koi8-r.shift.kbd +OLD_FILES+=usr/share/syscons/keymaps/ru.koi8-r.win.kbd +OLD_FILES+=usr/share/syscons/keymaps/si.iso.kbd +OLD_FILES+=usr/share/syscons/keymaps/sk.iso2.kbd +OLD_FILES+=usr/share/syscons/keymaps/spanish.dvorak.kbd +OLD_FILES+=usr/share/syscons/keymaps/spanish.iso.acc.kbd +OLD_FILES+=usr/share/syscons/keymaps/spanish.iso.kbd +OLD_FILES+=usr/share/syscons/keymaps/spanish.iso15.acc.kbd +OLD_FILES+=usr/share/syscons/keymaps/swedish.cp850.kbd +OLD_FILES+=usr/share/syscons/keymaps/swedish.iso.kbd +OLD_FILES+=usr/share/syscons/keymaps/swissfrench.cp850.kbd +OLD_FILES+=usr/share/syscons/keymaps/swissfrench.iso.acc.kbd +OLD_FILES+=usr/share/syscons/keymaps/swissfrench.iso.kbd +OLD_FILES+=usr/share/syscons/keymaps/swissgerman.cp850.kbd +OLD_FILES+=usr/share/syscons/keymaps/swissgerman.iso.acc.kbd +OLD_FILES+=usr/share/syscons/keymaps/swissgerman.iso.kbd +OLD_FILES+=usr/share/syscons/keymaps/swissgerman.macbook.acc.kbd +OLD_FILES+=usr/share/syscons/keymaps/tr.iso9.q.kbd +OLD_FILES+=usr/share/syscons/keymaps/ua.iso5.kbd +OLD_FILES+=usr/share/syscons/keymaps/ua.koi8-u.kbd +OLD_FILES+=usr/share/syscons/keymaps/ua.koi8-u.shift.alt.kbd +OLD_FILES+=usr/share/syscons/keymaps/uk.cp850-ctrl.kbd +OLD_FILES+=usr/share/syscons/keymaps/uk.cp850.kbd +OLD_FILES+=usr/share/syscons/keymaps/uk.dvorak.kbd +OLD_FILES+=usr/share/syscons/keymaps/uk.iso-ctrl.kbd +OLD_FILES+=usr/share/syscons/keymaps/uk.iso.kbd +OLD_FILES+=usr/share/syscons/keymaps/us.dvorak.kbd +OLD_FILES+=usr/share/syscons/keymaps/us.dvorakl.kbd +OLD_FILES+=usr/share/syscons/keymaps/us.dvorakp.kbd +OLD_FILES+=usr/share/syscons/keymaps/us.dvorakr.kbd +OLD_FILES+=usr/share/syscons/keymaps/us.dvorakx.kbd +OLD_FILES+=usr/share/syscons/keymaps/us.emacs.kbd +OLD_FILES+=usr/share/syscons/keymaps/us.iso.acc.kbd +OLD_FILES+=usr/share/syscons/keymaps/us.iso.kbd +OLD_FILES+=usr/share/syscons/keymaps/us.pc-ctrl.kbd +OLD_FILES+=usr/share/syscons/keymaps/us.unix.kbd +OLD_FILES+=usr/share/syscons/scrnmaps/armscii8-2haik8.scm +OLD_FILES+=usr/share/syscons/scrnmaps/iso-8859-1_to_cp437.scm +OLD_FILES+=usr/share/syscons/scrnmaps/iso-8859-4_for_vga9.scm +OLD_FILES+=usr/share/syscons/scrnmaps/iso-8859-7_to_cp437.scm +OLD_FILES+=usr/share/syscons/scrnmaps/koi8-r2cp866.scm +OLD_FILES+=usr/share/syscons/scrnmaps/koi8-u2cp866u.scm +OLD_FILES+=usr/share/syscons/scrnmaps/us-ascii_to_cp437.scm +OLD_DIRS+=usr/share/syscons/fonts +OLD_DIRS+=usr/share/syscons/keymaps +OLD_DIRS+=usr/share/syscons/scrnmaps +OLD_DIRS+=usr/share/syscons +.endif .if ${MK_TALK} == no OLD_FILES+=usr/bin/talk From bb9096f6cac86645886d7bd8049404d1445b26e5 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Wed, 26 Nov 2014 23:07:54 +0000 Subject: [PATCH 33/64] Move hyperv/vmm under MK_HYPERV/MK_BHYVE, respectively --- sys/modules/Makefile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/modules/Makefile b/sys/modules/Makefile index fedc92e362c4..fe083910fd95 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -389,6 +389,10 @@ SUBDIR= \ ${_zfs} \ zlib +.if ${MK_BHYVE} != "no" || defined(ALL_MODULES) +_vmm= vmm +.endif + .if ${MK_CRYPT} != "no" || defined(ALL_MODULES) .if exists(${.CURDIR}/../opencrypto) _crypto= crypto @@ -399,6 +403,10 @@ _random= random .endif .endif +.if ${MK_HYPERV} != "no" || defined(ALL_MODULES) +_hyperv= hyperv +.endif + .if (${MK_INET_SUPPORT} != "no" || ${MK_INET6_SUPPORT} != "no") || \ defined(ALL_MODULES) _carp= carp @@ -550,7 +558,6 @@ _hptmv= hptmv _hptnr= hptnr _hptrr= hptrr .endif -_hyperv= hyperv _ichwd= ichwd _ida= ida _iir= iir @@ -612,7 +619,6 @@ _qlxge= qlxge _qlxgb= qlxgb _qlxgbe= qlxgbe _sfxge= sfxge -_vmm= vmm .endif .if ${MACHINE_CPUARCH} == "i386" From 49a61f07c165a756949f854b49b2ead881eaa956 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Thu, 27 Nov 2014 00:02:42 +0000 Subject: [PATCH 34/64] Only build iscsi/iscsi_initiator if MK_ISCSI != no --- sys/modules/Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/modules/Makefile b/sys/modules/Makefile index fe083910fd95..f66d6c2a2fb7 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -171,8 +171,6 @@ SUBDIR= \ ${_ipw} \ ${_ipwfw} \ ${_isci} \ - iscsi \ - iscsi_initiator \ isp \ ${_ispfw} \ ${_iwi} \ @@ -425,6 +423,11 @@ _ipfw= ipfw _ipfilter= ipfilter .endif +.if ${MK_ISCSI} != "no" || defined(ALL_MODULES) +SUBDIR+= iscsi +SUBDIR+= iscsi_initiator +.endif + .if ${MK_NAND} != "no" || defined(ALL_MODULES) _nandfs= nandfs _nandsim= nandsim From e26856d614b4c610d0bb4592351167d330b718a4 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Thu, 27 Nov 2014 00:10:16 +0000 Subject: [PATCH 35/64] Honor MK_NETGRAPH for netgraph components --- share/examples/Makefile | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/share/examples/Makefile b/share/examples/Makefile index 6d8eceba130f..a0bd647c19ea 100644 --- a/share/examples/Makefile +++ b/share/examples/Makefile @@ -20,7 +20,6 @@ LDIRS= BSD_daemon \ kld \ libvgl \ mdoc \ - netgraph \ perfmon \ ppi \ ppp \ @@ -99,13 +98,6 @@ XFILES= BSD_daemon/FreeBSD.pfa \ mdoc/example.3 \ mdoc/example.4 \ mdoc/example.9 \ - netgraph/ether.bridge \ - netgraph/frame_relay \ - netgraph/ngctl \ - netgraph/raw \ - netgraph/udp.tunnel \ - netgraph/virtual.chain \ - netgraph/virtual.lan \ perfmon/Makefile \ perfmon/README \ perfmon/perfmon.c \ @@ -206,6 +198,17 @@ XFILES+= hast/ucarp.sh \ hast/vip-up.sh .endif +.if ${MK_NETGRAPH} != "no" +LDIRS+= netgraph +XFILES+= netgraph/ether.bridge \ + netgraph/frame_relay \ + netgraph/ngctl \ + netgraph/raw \ + netgraph/udp.tunnel \ + netgraph/virtual.chain \ + netgraph/virtual.lan +.endif + .if ${MK_USB} != "no" LDIRS+= libusb20 XFILES+= libusb20/Makefile \ From 44834b8f270ea2cec7ce73954183cd2073948ccf Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Thu, 27 Nov 2014 00:10:59 +0000 Subject: [PATCH 36/64] Honor MK_NETGRAPH for netgraph manpages --- share/man/man4/Makefile | 120 +++++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 58 deletions(-) diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index 2df7bdbc9587..0fcdda2e93a7 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -290,65 +290,7 @@ MAN= aac.4 \ netmap.4 \ ${_nfe.4} \ ${_nfsmb.4} \ - ng_async.4 \ - ng_atm.4 \ - ngatmbase.4 \ - ng_atmllc.4 \ - ng_bluetooth.4 \ - ng_bpf.4 \ - ng_bridge.4 \ - ng_bt3c.4 \ - ng_btsocket.4 \ - ng_car.4 \ - ng_ccatm.4 \ - ng_cisco.4 \ - ng_deflate.4 \ - ng_device.4 \ nge.4 \ - ng_echo.4 \ - ng_eiface.4 \ - ng_etf.4 \ - ng_ether.4 \ - ng_ether_echo.4 \ - ng_frame_relay.4 \ - ng_gif.4 \ - ng_gif_demux.4 \ - ng_h4.4 \ - ng_hci.4 \ - ng_hole.4 \ - ng_hub.4 \ - ng_iface.4 \ - ng_ipfw.4 \ - ng_ip_input.4 \ - ng_ksocket.4 \ - ng_l2cap.4 \ - ng_l2tp.4 \ - ng_lmi.4 \ - ng_mppc.4 \ - ng_nat.4 \ - ng_netflow.4 \ - ng_one2many.4 \ - ng_patch.4 \ - ng_ppp.4 \ - ng_pppoe.4 \ - ng_pptpgre.4 \ - ng_pred1.4 \ - ng_rfc1490.4 \ - ng_socket.4 \ - ng_source.4 \ - ng_split.4 \ - ng_sppp.4 \ - ng_sscfu.4 \ - ng_sscop.4 \ - ng_tag.4 \ - ng_tcpmss.4 \ - ng_tee.4 \ - ng_tty.4 \ - ng_ubt.4 \ - ng_UI.4 \ - ng_uni.4 \ - ng_vjc.4 \ - ng_vlan.4 \ nmdm.4 \ nsp.4 \ ${_ntb.4} \ @@ -806,6 +748,68 @@ MAN+= iscsi.4 MAN+= iscsi_initiator.4 .endif +.if ${MK_NETGRAPH} != "no" +MAN+= \ + ng_async.4 \ + ng_atm.4 \ + ngatmbase.4 \ + ng_atmllc.4 \ + ng_bluetooth.4 \ + ng_bpf.4 \ + ng_bridge.4 \ + ng_bt3c.4 \ + ng_btsocket.4 \ + ng_car.4 \ + ng_ccatm.4 \ + ng_cisco.4 \ + ng_deflate.4 \ + ng_device.4 \ + ng_echo.4 \ + ng_eiface.4 \ + ng_etf.4 \ + ng_ether.4 \ + ng_ether_echo.4 \ + ng_frame_relay.4 \ + ng_gif.4 \ + ng_gif_demux.4 \ + ng_h4.4 \ + ng_hci.4 \ + ng_hole.4 \ + ng_hub.4 \ + ng_iface.4 \ + ng_ipfw.4 \ + ng_ip_input.4 \ + ng_ksocket.4 \ + ng_l2cap.4 \ + ng_l2tp.4 \ + ng_lmi.4 \ + ng_mppc.4 \ + ng_nat.4 \ + ng_netflow.4 \ + ng_one2many.4 \ + ng_patch.4 \ + ng_ppp.4 \ + ng_pppoe.4 \ + ng_pptpgre.4 \ + ng_pred1.4 \ + ng_rfc1490.4 \ + ng_socket.4 \ + ng_source.4 \ + ng_split.4 \ + ng_sppp.4 \ + ng_sscfu.4 \ + ng_sscop.4 \ + ng_tag.4 \ + ng_tcpmss.4 \ + ng_tee.4 \ + ng_tty.4 \ + ng_ubt.4 \ + ng_UI.4 \ + ng_uni.4 \ + ng_vjc.4 \ + ng_vlan.4 +.endif + .if ${MK_TESTS} != "no" ATF= ${.CURDIR}/../../../contrib/atf .PATH: ${ATF}/doc From 9f325b1e411b4f788818dc4cf358e332004304b7 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Thu, 27 Nov 2014 03:59:57 +0000 Subject: [PATCH 37/64] Implement knobs for MK_NETGRAPH_SUPPORT --- share/mk/src.opts.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index a18e1a1308e3..c99286879a0d 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -123,6 +123,7 @@ __DEFAULT_YES_OPTIONS = \ NDIS \ NETCAT \ NETGRAPH \ + NETGRAPH_SUPPORT \ NLS_CATALOGS \ NS_CACHING \ NTP \ @@ -306,6 +307,7 @@ MK_DMAGENT:= no .if ${MK_NETGRAPH} == "no" MK_ATM:= no MK_BLUETOOTH:= no +MK_NETGRAPH_SUPPORT:= no .endif .if ${MK_OPENSSL} == "no" From ebb7b8dbb0aa21804c13c3216863adddda7b82e6 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Thu, 27 Nov 2014 04:01:39 +0000 Subject: [PATCH 38/64] Honor MK_ATM, MK_CUSE, and MK_NETGRAPH_SUPPORT Shuffle around conditionals so they're better sorted --- include/Makefile | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/include/Makefile b/include/Makefile index 6003e2683bb8..c13dba2ea08c 100644 --- a/include/Makefile +++ b/include/Makefile @@ -36,8 +36,8 @@ PHDRS= sched.h _semaphore.h LHDRS= aio.h errno.h fcntl.h linker_set.h poll.h stdatomic.h stdint.h \ syslog.h ucontext.h -LDIRS= bsm cam geom net net80211 netgraph netinet netinet6 \ - netipsec netnatm netsmb nfs nfsclient nfsserver sys vm +LDIRS= bsm cam geom net net80211 netinet netinet6 \ + netipsec netsmb nfs nfsclient nfsserver sys vm LSUBDIRS= cam/ata cam/scsi \ dev/acpica dev/agp dev/an dev/bktr dev/ciss dev/filemon dev/firewire \ @@ -45,24 +45,40 @@ LSUBDIRS= cam/ata cam/scsi \ dev/ic dev/iicbus ${_dev_ieee488} dev/io dev/lmc dev/mfi dev/nvme \ dev/ofw dev/pbio dev/pci ${_dev_powermac_nvram} dev/ppbus dev/smbus \ dev/speaker dev/utopia dev/vkbd dev/wi \ - fs/cuse \ fs/devfs fs/fdescfs fs/msdosfs fs/nandfs fs/nfs fs/nullfs \ fs/procfs fs/smbfs fs/udf fs/unionfs \ geom/cache geom/concat geom/eli geom/gate geom/journal geom/label \ geom/mirror geom/mountver geom/multipath geom/nop \ geom/raid geom/raid3 geom/shsec geom/stripe geom/virstor \ - netgraph/atm netgraph/netflow \ security/audit \ security/mac_biba security/mac_bsdextended security/mac_lomac \ security/mac_mls security/mac_partition \ ufs/ffs ufs/ufs +LSUBSUBDIRS= dev/mpt/mpilib + +.if ${MK_ATM} != "no" +LDIRS+= netnatm +LSUBDIRS+= netgraph/atm +.endif + +.if ${MK_BLUETOOTH} != "no" +LSUBSUBDIRS+= netgraph/bluetooth/include +.endif + +.if ${MK_CUSE} != "no" +LSUBDIRS+= fs/cuse +.endif + +.if ${MK_NETGRAPH_SUPPORT} != "no" +LDIRS+= netgraph +LSUBDIRS+= netgraph/netflow +.endif + .if ${MK_USB} != "no" LSUBDIRS+= dev/usb .endif -LSUBSUBDIRS= dev/mpt/mpilib - .if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpc64" _dev_powermac_nvram= dev/powermac_nvram .endif @@ -80,10 +96,6 @@ INCS+= gssapi.h INCS+= hesiod.h .endif -.if ${MK_BLUETOOTH} != "no" -LSUBSUBDIRS+= netgraph/bluetooth/include -.endif - # Handle the #define aliases for libiconv .if ${MK_ICONV} == "yes" INCS+= iconv.h From f541dd9b519891eb8fb2a8f1737d2b9b59a71488 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Thu, 27 Nov 2014 04:16:47 +0000 Subject: [PATCH 39/64] Implement MK_RADIUS_SUPPORT to make libradius and assorted support optional --- Makefile.inc1 | 6 +++++- lib/Makefile | 8 ++++++-- lib/libpam/modules/modules.inc | 4 ++++ share/mk/src.opts.mk | 5 +++++ tools/build/options/WITHOUT_RADIUS_SUPPORT | 5 +++++ 5 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 tools/build/options/WITHOUT_RADIUS_SUPPORT diff --git a/Makefile.inc1 b/Makefile.inc1 index f54b3138cc38..49577a573267 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -1605,7 +1605,7 @@ _prebuild_libs= ${_kerberos5_lib_libasn1} \ ${_lib_libcapsicum} \ lib/ncurses/ncurses lib/ncurses/ncursesw \ lib/libopie lib/libpam ${_lib_libthr} \ - lib/libradius lib/libsbuf lib/libtacplus \ + ${_lib_libradius} lib/libsbuf lib/libtacplus \ lib/libgeom \ ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \ ${_cddl_lib_libuutil} \ @@ -1628,6 +1628,10 @@ lib/libgeom__L: lib/libexpat__L _lib_libthr= lib/libthr .endif +.if ${MK_RADIUS_SUPPORT} != "no" +_lib_libradius= lib/libradius +.endif + .if ${MK_OFED} != "no" _ofed_lib= contrib/ofed/usr.lib/ .endif diff --git a/lib/Makefile b/lib/Makefile index af5fb6255712..064587e2b523 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -80,7 +80,7 @@ SUBDIR= ${SUBDIR_ORDERED} \ ${_libpmc} \ ${_libproc} \ libprocstat \ - libradius \ + ${_libradius} \ librpcsvc \ librt \ ${_librtld_db} \ @@ -140,7 +140,7 @@ SUBDIR_DEPEND_liblibrpcsec_gss= libgssapi SUBDIR_DEPEND_libmagic= libz SUBDIR_DEPEND_libmemstat= libkvm SUBDIR_DEPEND_libopie= libmd -SUBDIR_DEPEND_libpam= libcrypt libopie libradius librpcsvc libtacplus libutil ${_libypclnt} ${_libcom_err} +SUBDIR_DEPEND_libpam= libcrypt libopie ${_libradius} librpcsvc libtacplus libutil ${_libypclnt} ${_libcom_err} SUBDIR_DEPEND_libpjdlog= libutil SUBDIR_DEPEND_libprocstat= libkvm libutil SUBDIR_DEPEND_libradius= libmd @@ -269,6 +269,10 @@ _libmp= libmp _libpmc= libpmc .endif +.if ${MK_RADIUS} != "no" +_libradius= libradius +.endif + .if ${MK_SENDMAIL} != "no" _libmilter= libmilter _libsm= libsm diff --git a/lib/libpam/modules/modules.inc b/lib/libpam/modules/modules.inc index 66fc63c89dc9..1582931962cc 100644 --- a/lib/libpam/modules/modules.inc +++ b/lib/libpam/modules/modules.inc @@ -7,7 +7,9 @@ MODULES += pam_chroot MODULES += pam_deny MODULES += pam_echo MODULES += pam_exec +.if ${MK_FTP} != "no" MODULES += pam_ftpusers +.endif MODULES += pam_group MODULES += pam_guest .if ${MK_KERBEROS} != "no" @@ -21,7 +23,9 @@ MODULES += pam_opie MODULES += pam_opieaccess MODULES += pam_passwdqc MODULES += pam_permit +.if ${MK_RADIUS} != "no MODULES += pam_radius +.endif MODULES += pam_rhosts MODULES += pam_rootok MODULES += pam_securetty diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index c99286879a0d..de5a8e140cd6 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -136,6 +136,7 @@ __DEFAULT_YES_OPTIONS = \ PORTSNAP \ PPP \ QUOTAS \ + RADIUS_SUPPORT \ RCMDS \ RBOOTD \ RCS \ @@ -310,6 +311,10 @@ MK_BLUETOOTH:= no MK_NETGRAPH_SUPPORT:= no .endif +.if ${MK_NETGRAPH_SUPPORT} == "no" +MK_RADIUS_SUPPORT:= no +.endif + .if ${MK_OPENSSL} == "no" MK_OPENSSH:= no MK_KERBEROS:= no diff --git a/tools/build/options/WITHOUT_RADIUS_SUPPORT b/tools/build/options/WITHOUT_RADIUS_SUPPORT new file mode 100644 index 000000000000..31f5aab012b7 --- /dev/null +++ b/tools/build/options/WITHOUT_RADIUS_SUPPORT @@ -0,0 +1,5 @@ +.\" $FreeBSD$ +Set to not build radius support into various applications, like +.Xr pam_radius 8 +and +.Xr ppp 8 . From 7a818dff67aa585b89e6f065194b55e1894b698d Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Thu, 27 Nov 2014 04:19:01 +0000 Subject: [PATCH 40/64] Populate MK_CUSE, MK_NETGRAPH, MK_NETGRAPH_SUPPORT, and MK_RADIUS_SUPPORT --- tools/build/mk/OptionalObsoleteFiles.inc | 222 +++++++++++++++++++++++ 1 file changed, 222 insertions(+) diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index b5bfd33f0d28..a8134b860f9c 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -753,6 +753,43 @@ OLD_FILES+=usr/share/man/man1/ctm_smail.1.gz OLD_FILES+=usr/share/man/man5/ctm.5.gz .endif +.if ${MK_CUSE} == no +OLD_FILES+=usr/include/fs/cuse/cuse_defs.h +OLD_FILES+=usr/include/fs/cuse/cuse_ioctl.h +OLD_FILES+=usr/include/cuse.h +OLD_FILES+=usr/lib/libcuse.a +OLD_LIBS+=usr/lib/libcuse.so.1 +OLD_FILES+=usr/lib/libcuse_p.a +OLD_FILES+=usr/share/man/man3/cuse.3.gz +OLD_FILES+=usr/share/man/man3/cuse_alloc_unit_number.3.gz +OLD_FILES+=usr/share/man/man3/cuse_alloc_unit_number_by_id.3.gz +OLD_FILES+=usr/share/man/man3/cuse_copy_in.3.gz +OLD_FILES+=usr/share/man/man3/cuse_copy_out.3.gz +OLD_FILES+=usr/share/man/man3/cuse_dev_create.3.gz +OLD_FILES+=usr/share/man/man3/cuse_dev_destroy.3.gz +OLD_FILES+=usr/share/man/man3/cuse_dev_get_current.3.gz +OLD_FILES+=usr/share/man/man3/cuse_dev_get_per_file_handle.3.gz +OLD_FILES+=usr/share/man/man3/cuse_dev_get_priv0.3.gz +OLD_FILES+=usr/share/man/man3/cuse_dev_get_priv1.3.gz +OLD_FILES+=usr/share/man/man3/cuse_dev_set_per_file_handle.3.gz +OLD_FILES+=usr/share/man/man3/cuse_dev_set_priv0.3.gz +OLD_FILES+=usr/share/man/man3/cuse_dev_set_priv1.3.gz +OLD_FILES+=usr/share/man/man3/cuse_free_unit_number.3.gz +OLD_FILES+=usr/share/man/man3/cuse_free_unit_number_by_id.3.gz +OLD_FILES+=usr/share/man/man3/cuse_get_local.3.gz +OLD_FILES+=usr/share/man/man3/cuse_got_peer_signal.3.gz +OLD_FILES+=usr/share/man/man3/cuse_init.3.gz +OLD_FILES+=usr/share/man/man3/cuse_is_vmalloc_addr.3.gz +OLD_FILES+=usr/share/man/man3/cuse_poll_wakeup.3.gz +OLD_FILES+=usr/share/man/man3/cuse_set_local.3.gz +OLD_FILES+=usr/share/man/man3/cuse_uninit.3.gz +OLD_FILES+=usr/share/man/man3/cuse_vmalloc.3.gz +OLD_FILES+=usr/share/man/man3/cuse_vmfree.3.gz +OLD_FILES+=usr/share/man/man3/cuse_vmoffset.3.gz +OLD_FILES+=usr/share/man/man3/cuse_wait_and_process.3.gz +OLD_DIRS+=usr/include/fs/cuse +.endif + # devd(8) not listed here on purpose .if ${MK_CXX} == no OLD_FILES+=usr/bin/CC @@ -1395,12 +1432,14 @@ OLD_FILES+=usr/share/man/man8/freebsd-update.8.gz OLD_FILES+=usr/bin/ftp OLD_FILES+=usr/bin/gate-ftp OLD_FILES+=usr/bin/pftp +OLD_LIBS+=usr/lib/pam_ftpusers.so.5 OLD_FILES+=usr/libexec/ftpd OLD_FILES+=usr/share/man/man1/ftp.1.gz OLD_FILES+=usr/share/man/man1/gate-ftp.1.gz OLD_FILES+=usr/share/man/man1/pftp.1.gz OLD_FILES+=usr/share/man/man5/ftpchroot.5.gz OLD_FILES+=usr/share/man/man8/ftpd.8.gz +OLD_FILES+=usr/share/man/man8/pam_ftpusers.8.gz .endif .if ${MK_GAMES} == no @@ -3570,6 +3609,143 @@ OLD_FILES+=usr/bin/nc OLD_FILES+=usr/share/man/man1/nc.1.gz .endif +.if ${MK_NETGRAPH} == no +OLD_FILES+=usr/sbin/ngctl +OLD_FILES+=usr/sbin/nghook +OLD_FILES+=usr/share/examples/netgraph/ether.bridge +OLD_FILES+=usr/share/examples/netgraph/frame_relay +OLD_FILES+=usr/share/examples/netgraph/ngctl +OLD_FILES+=usr/share/examples/netgraph/raw +OLD_FILES+=usr/share/examples/netgraph/udp.tunnel +OLD_FILES+=usr/share/examples/netgraph/virtual.chain +OLD_FILES+=usr/share/examples/netgraph/virtual.lan +OLD_FILES+=usr/share/man/man4/ng_UI.4.gz +OLD_FILES+=usr/share/man/man4/ng_async.4.gz +OLD_FILES+=usr/share/man/man4/ng_atm.4.gz +OLD_FILES+=usr/share/man/man4/ng_atmllc.4.gz +OLD_FILES+=usr/share/man/man4/ng_bluetooth.4.gz +OLD_FILES+=usr/share/man/man4/ng_bpf.4.gz +OLD_FILES+=usr/share/man/man4/ng_bridge.4.gz +OLD_FILES+=usr/share/man/man4/ng_bt3c.4.gz +OLD_FILES+=usr/share/man/man4/ng_btsocket.4.gz +OLD_FILES+=usr/share/man/man4/ng_car.4.gz +OLD_FILES+=usr/share/man/man4/ng_ccatm.4.gz +OLD_FILES+=usr/share/man/man4/ng_cisco.4.gz +OLD_FILES+=usr/share/man/man4/ng_deflate.4.gz +OLD_FILES+=usr/share/man/man4/ng_device.4.gz +OLD_FILES+=usr/share/man/man4/ng_echo.4.gz +OLD_FILES+=usr/share/man/man4/ng_eiface.4.gz +OLD_FILES+=usr/share/man/man4/ng_etf.4.gz +OLD_FILES+=usr/share/man/man4/ng_ether.4.gz +OLD_FILES+=usr/share/man/man4/ng_ether_echo.4.gz +OLD_FILES+=usr/share/man/man4/ng_frame_relay.4.gz +OLD_FILES+=usr/share/man/man4/ng_gif.4.gz +OLD_FILES+=usr/share/man/man4/ng_gif_demux.4.gz +OLD_FILES+=usr/share/man/man4/ng_h4.4.gz +OLD_FILES+=usr/share/man/man4/ng_hci.4.gz +OLD_FILES+=usr/share/man/man4/ng_hole.4.gz +OLD_FILES+=usr/share/man/man4/ng_hub.4.gz +OLD_FILES+=usr/share/man/man4/ng_iface.4.gz +OLD_FILES+=usr/share/man/man4/ng_ip_input.4.gz +OLD_FILES+=usr/share/man/man4/ng_ipfw.4.gz +OLD_FILES+=usr/share/man/man4/ng_ksocket.4.gz +OLD_FILES+=usr/share/man/man4/ng_l2cap.4.gz +OLD_FILES+=usr/share/man/man4/ng_l2tp.4.gz +OLD_FILES+=usr/share/man/man4/ng_lmi.4.gz +OLD_FILES+=usr/share/man/man4/ng_mppc.4.gz +OLD_FILES+=usr/share/man/man4/ng_nat.4.gz +OLD_FILES+=usr/share/man/man4/ng_netflow.4.gz +OLD_FILES+=usr/share/man/man4/ng_one2many.4.gz +OLD_FILES+=usr/share/man/man4/ng_patch.4.gz +OLD_FILES+=usr/share/man/man4/ng_ppp.4.gz +OLD_FILES+=usr/share/man/man4/ng_pppoe.4.gz +OLD_FILES+=usr/share/man/man4/ng_pptpgre.4.gz +OLD_FILES+=usr/share/man/man4/ng_pred1.4.gz +OLD_FILES+=usr/share/man/man4/ng_rfc1490.4.gz +OLD_FILES+=usr/share/man/man4/ng_socket.4.gz +OLD_FILES+=usr/share/man/man4/ng_source.4.gz +OLD_FILES+=usr/share/man/man4/ng_split.4.gz +OLD_FILES+=usr/share/man/man4/ng_sppp.4.gz +OLD_FILES+=usr/share/man/man4/ng_sscfu.4.gz +OLD_FILES+=usr/share/man/man4/ng_sscop.4.gz +OLD_FILES+=usr/share/man/man4/ng_tag.4.gz +OLD_FILES+=usr/share/man/man4/ng_tcpmss.4.gz +OLD_FILES+=usr/share/man/man4/ng_tee.4.gz +OLD_FILES+=usr/share/man/man4/ng_tty.4.gz +OLD_FILES+=usr/share/man/man4/ng_ubt.4.gz +OLD_FILES+=usr/share/man/man4/ng_uni.4.gz +OLD_FILES+=usr/share/man/man4/ng_vjc.4.gz +OLD_FILES+=usr/share/man/man4/ng_vlan.4.gz +OLD_FILES+=usr/share/man/man8/ngctl.8.gz +OLD_FILES+=usr/share/man/man8/nghook.8.gz +OLD_DIRS+=usr/share/examples/netgraph +.endif + +.if ${MK_NETGRAPH_SUPPORT} == no +OLD_FILES+=usr/include/netgraph/atm/ng_atm.h +OLD_FILES+=usr/include/netgraph/atm/ng_ccatm.h +OLD_FILES+=usr/include/netgraph/atm/ng_sscfu.h +OLD_FILES+=usr/include/netgraph/atm/ng_sscop.h +OLD_FILES+=usr/include/netgraph/atm/ng_uni.h +OLD_FILES+=usr/include/netgraph/atm/ngatmbase.h +OLD_FILES+=usr/include/netgraph/netflow/netflow.h +OLD_FILES+=usr/include/netgraph/netflow/netflow_v9.h +OLD_FILES+=usr/include/netgraph/netflow/ng_netflow.h +OLD_FILES+=usr/include/netgraph/netgraph.h +OLD_FILES+=usr/include/netgraph/ng_UI.h +OLD_FILES+=usr/include/netgraph/ng_async.h +OLD_FILES+=usr/include/netgraph/ng_atmllc.h +OLD_FILES+=usr/include/netgraph/ng_bpf.h +OLD_FILES+=usr/include/netgraph/ng_bridge.h +OLD_FILES+=usr/include/netgraph/ng_car.h +OLD_FILES+=usr/include/netgraph/ng_cisco.h +OLD_FILES+=usr/include/netgraph/ng_deflate.h +OLD_FILES+=usr/include/netgraph/ng_device.h +OLD_FILES+=usr/include/netgraph/ng_echo.h +OLD_FILES+=usr/include/netgraph/ng_eiface.h +OLD_FILES+=usr/include/netgraph/ng_etf.h +OLD_FILES+=usr/include/netgraph/ng_ether.h +OLD_FILES+=usr/include/netgraph/ng_ether_echo.h +OLD_FILES+=usr/include/netgraph/ng_frame_relay.h +OLD_FILES+=usr/include/netgraph/ng_gif.h +OLD_FILES+=usr/include/netgraph/ng_gif_demux.h +OLD_FILES+=usr/include/netgraph/ng_hole.h +OLD_FILES+=usr/include/netgraph/ng_hub.h +OLD_FILES+=usr/include/netgraph/ng_iface.h +OLD_FILES+=usr/include/netgraph/ng_ip_input.h +OLD_FILES+=usr/include/netgraph/ng_ipfw.h +OLD_FILES+=usr/include/netgraph/ng_ksocket.h +OLD_FILES+=usr/include/netgraph/ng_l2tp.h +OLD_FILES+=usr/include/netgraph/ng_lmi.h +OLD_FILES+=usr/include/netgraph/ng_message.h +OLD_FILES+=usr/include/netgraph/ng_mppc.h +OLD_FILES+=usr/include/netgraph/ng_nat.h +OLD_FILES+=usr/include/netgraph/ng_one2many.h +OLD_FILES+=usr/include/netgraph/ng_parse.h +OLD_FILES+=usr/include/netgraph/ng_patch.h +OLD_FILES+=usr/include/netgraph/ng_pipe.h +OLD_FILES+=usr/include/netgraph/ng_ppp.h +OLD_FILES+=usr/include/netgraph/ng_pppoe.h +OLD_FILES+=usr/include/netgraph/ng_pptpgre.h +OLD_FILES+=usr/include/netgraph/ng_pred1.h +OLD_FILES+=usr/include/netgraph/ng_rfc1490.h +OLD_FILES+=usr/include/netgraph/ng_sample.h +OLD_FILES+=usr/include/netgraph/ng_socket.h +OLD_FILES+=usr/include/netgraph/ng_socketvar.h +OLD_FILES+=usr/include/netgraph/ng_source.h +OLD_FILES+=usr/include/netgraph/ng_split.h +OLD_FILES+=usr/include/netgraph/ng_sppp.h +OLD_FILES+=usr/include/netgraph/ng_tag.h +OLD_FILES+=usr/include/netgraph/ng_tcpmss.h +OLD_FILES+=usr/include/netgraph/ng_tee.h +OLD_FILES+=usr/include/netgraph/ng_tty.h +OLD_FILES+=usr/include/netgraph/ng_vjc.h +OLD_FILES+=usr/include/netgraph/ng_vlan.h +OLD_DIRS+=usr/include/netgraph/atm +OLD_DIRS+=usr/include/netgraph/netflow +OLD_DIRS+=usr/include/netgraph +.endif + .if ${MK_NIS} == no OLD_FILES+=usr/bin/ypcat OLD_FILES+=usr/bin/ypchfn @@ -4001,6 +4177,52 @@ OLD_FILES+=usr/lib/private/libldns_p.a OLD_FILES+=usr/lib/private/libssh_p.a .endif +.if ${MK_RADIUS_SUPPORT} == no +OLD_FILES+=usr/include/radlib.h +OLD_FILES+=usr/include/radlib_vs.h +OLD_FILES+=usr/lib/libradius.a +OLD_LIBS+=usr/lib/libradius.so.4 +OLD_LIBS+=usr/lib/pam_radius.so.5 +OLD_FILES+=usr/lib/libradius_p.a +OLD_FILES+=usr/share/man/man3/libradius.3.gz +OLD_FILES+=usr/share/man/man3/rad_acct_open.3.gz +OLD_FILES+=usr/share/man/man3/rad_add_server.3.gz +OLD_FILES+=usr/share/man/man3/rad_add_server_ex.3.gz +OLD_FILES+=usr/share/man/man3/rad_auth_open.3.gz +OLD_FILES+=usr/share/man/man3/rad_bind_to.3.gz +OLD_FILES+=usr/share/man/man3/rad_close.3.gz +OLD_FILES+=usr/share/man/man3/rad_config.3.gz +OLD_FILES+=usr/share/man/man3/rad_continue_send_request.3.gz +OLD_FILES+=usr/share/man/man3/rad_create_request.3.gz +OLD_FILES+=usr/share/man/man3/rad_create_response.3.gz +OLD_FILES+=usr/share/man/man3/rad_cvt_addr.3.gz +OLD_FILES+=usr/share/man/man3/rad_cvt_int.3.gz +OLD_FILES+=usr/share/man/man3/rad_cvt_string.3.gz +OLD_FILES+=usr/share/man/man3/rad_demangle.3.gz +OLD_FILES+=usr/share/man/man3/rad_demangle_mppe_key.3.gz +OLD_FILES+=usr/share/man/man3/rad_get_attr.3.gz +OLD_FILES+=usr/share/man/man3/rad_get_vendor_attr.3.gz +OLD_FILES+=usr/share/man/man3/rad_init_send_request.3.gz +OLD_FILES+=usr/share/man/man3/rad_put_addr.3.gz +OLD_FILES+=usr/share/man/man3/rad_put_attr.3.gz +OLD_FILES+=usr/share/man/man3/rad_put_int.3.gz +OLD_FILES+=usr/share/man/man3/rad_put_message_authentic.3.gz +OLD_FILES+=usr/share/man/man3/rad_put_string.3.gz +OLD_FILES+=usr/share/man/man3/rad_put_vendor_addr.3.gz +OLD_FILES+=usr/share/man/man3/rad_put_vendor_attr.3.gz +OLD_FILES+=usr/share/man/man3/rad_put_vendor_int.3.gz +OLD_FILES+=usr/share/man/man3/rad_put_vendor_string.3.gz +OLD_FILES+=usr/share/man/man3/rad_receive_request.3.gz +OLD_FILES+=usr/share/man/man3/rad_request_authenticator.3.gz +OLD_FILES+=usr/share/man/man3/rad_send_request.3.gz +OLD_FILES+=usr/share/man/man3/rad_send_response.3.gz +OLD_FILES+=usr/share/man/man3/rad_server_open.3.gz +OLD_FILES+=usr/share/man/man3/rad_server_secret.3.gz +OLD_FILES+=usr/share/man/man3/rad_strerror.3.gz +OLD_FILES+=usr/share/man/man5/radius.conf.5.gz +OLD_FILES+=usr/share/man/man8/pam_radius.8.gz +.endif + .if ${MK_RBOOTD} == no OLD_FILES+=usr/libexec/rbootd OLD_FILES+=usr/share/man/man8/rbootd.8.gz From 254aaed7cf21504ca627d8b865de2583e7d9ae2c Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Thu, 27 Nov 2014 04:23:00 +0000 Subject: [PATCH 41/64] Fix typos: MK_RADIUS -> MK_RADIUS_SUPPORT --- lib/Makefile | 2 +- lib/libpam/modules/modules.inc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Makefile b/lib/Makefile index 064587e2b523..958721d37bb1 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -269,7 +269,7 @@ _libmp= libmp _libpmc= libpmc .endif -.if ${MK_RADIUS} != "no" +.if ${MK_RADIUS_SUPPORT} != "no" _libradius= libradius .endif diff --git a/lib/libpam/modules/modules.inc b/lib/libpam/modules/modules.inc index 1582931962cc..a4bd282ed48f 100644 --- a/lib/libpam/modules/modules.inc +++ b/lib/libpam/modules/modules.inc @@ -23,7 +23,7 @@ MODULES += pam_opie MODULES += pam_opieaccess MODULES += pam_passwdqc MODULES += pam_permit -.if ${MK_RADIUS} != "no +.if ${MK_RADIUS_SUPPORT} != "no MODULES += pam_radius .endif MODULES += pam_rhosts From b13f4f90e483dbfd72f6ce6d1ba872bea45b5897 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Thu, 27 Nov 2014 07:17:32 +0000 Subject: [PATCH 42/64] Fill in MK_BOOT for amd64 --- tools/build/mk/OptionalObsoleteFiles.inc | 64 ++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index a8134b860f9c..471ea27e082a 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -156,8 +156,10 @@ OLD_FILES+=usr/share/man/man8/authpf-noip.8.gz OLD_FILES+=usr/sbin/bhyve OLD_FILES+=usr/sbin/bhyvectl OLD_FILES+=usr/sbin/bhyveload +OLD_FILES+=usr/share/examples/bhyve/vmrun.sh OLD_FILES+=usr/share/man/man8/bhyve.8.gz OLD_FILES+=usr/share/man/man8/bhyveload.8.gz +OLD_DIRS+=usr/share/examples/bhyve .endif .if ${MK_BLUETOOTH} == no @@ -286,9 +288,65 @@ OLD_FILES+=usr/share/man/man8/sdpcontrol.8.gz OLD_FILES+=usr/share/man/man8/sdpd.8.gz .endif -#.if ${MK_BOOT} == no -# to be filled in -#.endif +.if ${MK_BOOT} == no +OLD_FILES+=boot/beastie.4th +OLD_FILES+=boot/boot +OLD_FILES+=boot/boot0 +OLD_FILES+=boot/boot0sio +OLD_FILES+=boot/boot1 +OLD_FILES+=boot/boot1.efi +OLD_FILES+=boot/boot1.efifat +OLD_FILES+=boot/boot2 +OLD_FILES+=boot/brand.4th +OLD_FILES+=boot/cdboot +OLD_FILES+=boot/check-password.4th +OLD_FILES+=boot/color.4th +OLD_FILES+=boot/defaults/loader.conf +OLD_FILES+=boot/delay.4th +OLD_FILES+=boot/device.hints +OLD_FILES+=boot/frames.4th +OLD_FILES+=boot/gptboot +OLD_FILES+=boot/gptzfsboot +OLD_FILES+=boot/loader +OLD_FILES+=boot/loader.4th +OLD_FILES+=boot/loader.efi +OLD_FILES+=boot/loader.help +OLD_FILES+=boot/loader.rc +OLD_FILES+=boot/mbr +OLD_FILES+=boot/menu-commands.4th +OLD_FILES+=boot/menu.4th +OLD_FILES+=boot/menu.rc +OLD_FILES+=boot/menusets.4th +OLD_FILES+=boot/pcibios.4th +OLD_FILES+=boot/pmbr +OLD_FILES+=boot/pxeboot +OLD_FILES+=boot/screen.4th +OLD_FILES+=boot/shortcuts.4th +OLD_FILES+=boot/support.4th +OLD_FILES+=boot/userboot.so +OLD_FILES+=boot/version.4th +OLD_FILES+=boot/zfsboot +OLD_FILES+=boot/zfsloader +OLD_FILES+=usr/lib/kgzldr.o +OLD_FILES+=usr/share/man/man5/loader.conf.5.gz +OLD_FILES+=usr/share/man/man8/beastie.4th.8.gz +OLD_FILES+=usr/share/man/man8/brand.4th.8.gz +OLD_FILES+=usr/share/man/man8/check-password.4th.8.gz +OLD_FILES+=usr/share/man/man8/color.4th.8.gz +OLD_FILES+=usr/share/man/man8/delay.4th.8.gz +OLD_FILES+=usr/share/man/man8/gptboot.8.gz +OLD_FILES+=usr/share/man/man8/gptzfsboot.8.gz +OLD_FILES+=usr/share/man/man8/loader.4th.8.gz +OLD_FILES+=usr/share/man/man8/loader.8.gz +OLD_FILES+=usr/share/man/man8/menu.4th.8.gz +OLD_FILES+=usr/share/man/man8/menusets.4th.8.gz +OLD_FILES+=usr/share/man/man8/pxeboot.8.gz +OLD_FILES+=usr/share/man/man8/version.4th.8.gz +OLD_FILES+=usr/share/man/man8/zfsboot.8.gz +OLD_FILES+=usr/share/man/man8/zfsloader.8.gz +OLD_DIRS+=boot/defaults +OLD_DIRS+=boot +.endif .if ${MK_BOOTPARAMD} == no OLD_FILES+=rc.d/bootparams From eaf49814e9ce20c9c846a7eaecca80da069b2874 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Thu, 27 Nov 2014 07:19:36 +0000 Subject: [PATCH 43/64] Ignore boot and remove from MK_BOOT additions done in previous commit --- tools/add-optional-obsolete-files-entries.sh | 2 +- tools/build/mk/OptionalObsoleteFiles.inc | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/add-optional-obsolete-files-entries.sh b/tools/add-optional-obsolete-files-entries.sh index d9095cec5943..1aafdf316a81 100755 --- a/tools/add-optional-obsolete-files-entries.sh +++ b/tools/add-optional-obsolete-files-entries.sh @@ -46,6 +46,6 @@ done sed -e 's,^,OLD_FILES+=,' \ -e '/lib\/.*\.so\.[0-9]\.*/s/OLD_FILES+=/OLD_LIBS+=/g'; find -d -s . -type d -mindepth 1 -and \! -empty | \ - egrep -v '^\./(s*bin|libexec|usr|usr/include|usr/lib(data)?|usr/libdata/pkgconfig|usr/lib/private|usr/libexec|usr/s*bin|usr/share|usr/share/(examples|man)|usr/share/man/man[0-9])$' | \ + egrep -v '^\./(boot|s*bin|libexec|usr|usr/include|usr/lib(data)?|usr/libdata/pkgconfig|usr/lib/private|usr/libexec|usr/s*bin|usr/share|usr/share/(examples|man)|usr/share/man/man[0-9])$' | \ sed -e 's,^,OLD_DIRS+=,' ) | sed -e 's,+=\./,+=,' diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index 471ea27e082a..62716212b12c 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -345,7 +345,6 @@ OLD_FILES+=usr/share/man/man8/version.4th.8.gz OLD_FILES+=usr/share/man/man8/zfsboot.8.gz OLD_FILES+=usr/share/man/man8/zfsloader.8.gz OLD_DIRS+=boot/defaults -OLD_DIRS+=boot .endif .if ${MK_BOOTPARAMD} == no From 7e8bf5690fc906df8992eea68d0d602361d8030f Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Thu, 27 Nov 2014 07:26:20 +0000 Subject: [PATCH 44/64] Remove /etc/X11 entry from BSD.root.dist - FreeBSD hasn't packaged X11 with the distro since 8.x - X.org hasn't required xorg.conf [in /etc/X11] for some time now - X.org should work with ${LOCALBASE}/etc/X11 - This path should be included in the X.org package manifest --- etc/mtree/BSD.root.dist | 2 -- 1 file changed, 2 deletions(-) diff --git a/etc/mtree/BSD.root.dist b/etc/mtree/BSD.root.dist index af2f6a9add09..5eb8c01a4f0f 100644 --- a/etc/mtree/BSD.root.dist +++ b/etc/mtree/BSD.root.dist @@ -24,8 +24,6 @@ dev mode=0555 .. etc - X11 - .. autofs .. bluetooth From ee0d2af8e2a311fb27b87e7a999e705933aef064 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Thu, 27 Nov 2014 07:33:50 +0000 Subject: [PATCH 45/64] Until I teach bsd.*.mk to accept NO_ROOT, make this script only accept root users --- tools/add-optional-obsolete-files-entries.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/add-optional-obsolete-files-entries.sh b/tools/add-optional-obsolete-files-entries.sh index 1aafdf316a81..9eeab4e16681 100755 --- a/tools/add-optional-obsolete-files-entries.sh +++ b/tools/add-optional-obsolete-files-entries.sh @@ -6,6 +6,12 @@ # # $FreeBSD$ +# NO_ROOT doesn't seem to work at a non-installworld, etc level yet +if [ $(id -u) -ne 0 ]; then + echo "${0##*/}: ERROR: this script must be run as root" + exit 1 +fi + : ${TMPDIR=/tmp} DESTDIR=$(mktemp -d $TMPDIR/tmp.XXXXXX) || exit From 899d8a5bd5e797ffbdb51e1b6b68b34d4f7b1a0f Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Thu, 27 Nov 2014 07:49:25 +0000 Subject: [PATCH 46/64] Only install libmap32.conf if MK_LIB32 != no --- etc/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/etc/Makefile b/etc/Makefile index 466bc7c92391..a9073f5db407 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -53,10 +53,6 @@ BIN1= auto_master \ syslog.conf \ termcap.small -.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "powerpc64" -BIN1+= libmap32.conf -.endif - .if exists(${.CURDIR}/etc.${MACHINE}/ttys) BIN1+= etc.${MACHINE}/ttys .elif exists(${.CURDIR}/etc.${MACHINE_ARCH}/ttys) @@ -105,6 +101,10 @@ BIN1+= inetd.conf BIN1+= ${.CURDIR}/../usr.bin/locate/locate/locate.rc .endif +.if ${MK_LIB32} != "no" +BIN1+= libmap32.conf +.endif + .if ${MK_LPR} != "no" BIN1+= hosts.lpd printcap .endif From 0a579cc7074bae0ce20acc31f592776980d0c0e3 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Thu, 27 Nov 2014 07:56:28 +0000 Subject: [PATCH 47/64] Handle MK_RADIUS_SUPPORT in usr.sbin/ppp --- usr.sbin/ppp/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/usr.sbin/ppp/Makefile b/usr.sbin/ppp/Makefile index dda493e4534c..7783f42909b3 100644 --- a/usr.sbin/ppp/Makefile +++ b/usr.sbin/ppp/Makefile @@ -31,6 +31,9 @@ PPP_NO_NETGRAPH= .if ${MK_PAM_SUPPORT} == "no" PPP_NO_PAM= .endif +.if ${MK_RADIUS_SUPPORT} == "no" +PPP_NO_RADIUS= +.endif .if defined(PPP_NO_SUID) BINMODE=554 From caedb5eb290137a4d2c8ff78e23d02c22dcaca39 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Thu, 27 Nov 2014 08:31:20 +0000 Subject: [PATCH 48/64] Honor MK_EXAMPLES --- usr.sbin/bsdconfig/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/usr.sbin/bsdconfig/Makefile b/usr.sbin/bsdconfig/Makefile index 1f1ec9e6ca44..bfccce9be4bf 100644 --- a/usr.sbin/bsdconfig/Makefile +++ b/usr.sbin/bsdconfig/Makefile @@ -1,10 +1,11 @@ # $FreeBSD$ +.include + SUBDIR= console \ diskmgmt \ docsinstall \ dot \ - examples \ include \ includes \ mouse \ @@ -25,4 +26,8 @@ SCRIPTS= bsdconfig MAN= bsdconfig.8 +.if ${MK_EXAMPLES} != "no" +SUBDIR+= examples +.endif + .include From b7c1742fa82fc3295d2c43258e2b801f406aada3 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Thu, 27 Nov 2014 09:40:36 +0000 Subject: [PATCH 49/64] Filter out /lib, /usr/lib32, and fold the /usr/lib* checks into one expression --- tools/add-optional-obsolete-files-entries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/add-optional-obsolete-files-entries.sh b/tools/add-optional-obsolete-files-entries.sh index 9eeab4e16681..8384b31a8ef4 100755 --- a/tools/add-optional-obsolete-files-entries.sh +++ b/tools/add-optional-obsolete-files-entries.sh @@ -52,6 +52,6 @@ done sed -e 's,^,OLD_FILES+=,' \ -e '/lib\/.*\.so\.[0-9]\.*/s/OLD_FILES+=/OLD_LIBS+=/g'; find -d -s . -type d -mindepth 1 -and \! -empty | \ - egrep -v '^\./(boot|s*bin|libexec|usr|usr/include|usr/lib(data)?|usr/libdata/pkgconfig|usr/lib/private|usr/libexec|usr/s*bin|usr/share|usr/share/(examples|man)|usr/share/man/man[0-9])$' | \ + egrep -v '^\./(boot|s*bin|lib|libexec|usr|usr/include|usr/lib(32|data|exec)?|usr/libdata/pkgconfig|usr/lib/private|usr/s*bin|usr/share|usr/share/(examples|man)|usr/share/man/man[0-9])$' | \ sed -e 's,^,OLD_DIRS+=,' ) | sed -e 's,+=\./,+=,' From a8b303ad4d16cae08e9da613228639ffb8889ab4 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Thu, 27 Nov 2014 09:42:40 +0000 Subject: [PATCH 50/64] Add WITHOUT_AUTOFS and WITHOUT_BSDCONFIG --- etc/Makefile | 9 +++++++-- etc/rc.d/Makefile | 9 ++++++--- share/Makefile | 6 +++++- share/man/man5/Makefile | 5 ++++- share/mk/src.opts.mk | 2 ++ tools/build/options/WITHOUT_AUTOFS | 4 ++++ tools/build/options/WITHOUT_BSDCONFIG | 5 +++++ usr.sbin/Makefile | 12 +++++++++--- 8 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 tools/build/options/WITHOUT_AUTOFS create mode 100644 tools/build/options/WITHOUT_BSDCONFIG diff --git a/etc/Makefile b/etc/Makefile index a9073f5db407..8aa64e5f7f0d 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -11,8 +11,7 @@ SUBDIR= sendmail SUBDIR+=tests .endif -BIN1= auto_master \ - crontab \ +BIN1= crontab \ devd.conf \ devfs.conf \ ddb.conf \ @@ -81,6 +80,10 @@ BIN1+= amd.map BIN1+= apmd.conf .endif +.if ${MK_AUTOFS} != "no" +BIN1+= auto_master +.endif + .if ${MK_BSNMP} != "no" BIN1+= snmpd.config .endif @@ -232,7 +235,9 @@ distribution: echo "./etc/spwd.db type=file mode=0600 uname=root gname=wheel"; \ ) | ${METALOG.add} .endif +.if ${MK_AUTOFS} != "no" ${_+_}cd ${.CURDIR}/autofs; ${MAKE} install +.endif .if ${MK_BLUETOOTH} != "no" ${_+_}cd ${.CURDIR}/bluetooth; ${MAKE} install .endif diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile index 634895d6350b..91b94e90c064 100644 --- a/etc/rc.d/Makefile +++ b/etc/rc.d/Makefile @@ -17,9 +17,6 @@ FILES= DAEMON \ atm3 \ auditd \ auditdistd \ - automount \ - automountd \ - autounmountd \ bgfsck \ ${_bluetooth} \ bridge \ @@ -162,6 +159,12 @@ FILES+= apm FILES+= apmd .endif +.if ${MK_AUTOFS} != "no" +FILES+= automount +FILES+= automountd +FILES+= autounmountd +.endif + .if ${MK_BLUETOOTH} != "no" _bluetooth= bluetooth _bthidd= bthidd diff --git a/share/Makefile b/share/Makefile index 63c18bb6464a..97d1dac540ca 100644 --- a/share/Makefile +++ b/share/Makefile @@ -8,7 +8,7 @@ SUBDIR= ${_colldef} \ ${_dict} \ ${_doc} \ - dtrace \ + ${_dtrace} \ ${_examples} \ ${_i18n} \ keys \ @@ -37,6 +37,10 @@ SUBDIR= ${_colldef} \ _snmp= snmp .endif +.if ${MK_CDDL} != "no" +_dtrace= dtrace +.endif + .if ${MK_DICT} != "no" _dict= dict .endif diff --git a/share/man/man5/Makefile b/share/man/man5/Makefile index e8483355926d..15056f3395ea 100644 --- a/share/man/man5/Makefile +++ b/share/man/man5/Makefile @@ -7,7 +7,6 @@ MAN= acct.5 \ ar.5 \ a.out.5 \ - autofs.5 \ bluetooth.device.conf.5 \ bluetooth.hosts.5 \ bluetooth.protocols.5 \ @@ -80,6 +79,10 @@ MLINKS+=quota.user.5 quota.group.5 MLINKS+=rc.conf.5 rc.conf.local.5 MLINKS+=resolver.5 resolv.conf.5 +.if ${MK_AUTOFS} != "no" +MAN+= autofs.5 +.endif + .if ${MK_FREEBSD_UPDATE} != "no" MAN+= freebsd-update.conf.5 .endif diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index de5a8e140cd6..97e162adff63 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -52,6 +52,7 @@ __DEFAULT_YES_OPTIONS = \ ATM \ AUDIT \ AUTHPF \ + AUTOFS \ BINUTILS \ BINUTILS_BOOTSTRAP \ BLUETOOTH \ @@ -59,6 +60,7 @@ __DEFAULT_YES_OPTIONS = \ BOOTPD \ BOOTPARAMD \ BSD_CPIO \ + BSDCONFIG \ BSDINSTALL \ BSNMP \ BZIP2 \ diff --git a/tools/build/options/WITHOUT_AUTOFS b/tools/build/options/WITHOUT_AUTOFS new file mode 100644 index 000000000000..f9c5c2ce5a1f --- /dev/null +++ b/tools/build/options/WITHOUT_AUTOFS @@ -0,0 +1,4 @@ +.\" $FreeBSD$ +Set to not build +.Xr autofs 4 +related programs, libraries, and kernel modules. diff --git a/tools/build/options/WITHOUT_BSDCONFIG b/tools/build/options/WITHOUT_BSDCONFIG new file mode 100644 index 000000000000..10d8b6e5f44b --- /dev/null +++ b/tools/build/options/WITHOUT_BSDCONFIG @@ -0,0 +1,5 @@ +.\" $FreeBSD$ +Set to not build +.Xr bsdconfig 8 , +.Xr sysrc 8 , +and related programs. diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile index 2b6cb1b62d8a..c412682f4dcc 100644 --- a/usr.sbin/Makefile +++ b/usr.sbin/Makefile @@ -5,9 +5,7 @@ SUBDIR= adduser \ arp \ - autofs \ binmiscctl \ - bsdconfig \ cdcontrol \ chkgrp \ chown \ @@ -79,7 +77,6 @@ SUBDIR= adduser \ snapinfo \ spray \ syslogd \ - sysrc \ tcpdrop \ tcpdump \ traceroute \ @@ -117,6 +114,10 @@ SUBDIR+= praudit SUBDIR+= authpf .endif +.if ${MK_AUTOFS} != "no" +SUBDIR+= autofs +.endif + .if ${MK_BLUETOOTH} != "no" SUBDIR+= bluetooth .endif @@ -125,6 +126,11 @@ SUBDIR+= bluetooth SUBDIR+= bootparamd .endif +.if ${MK_BSDCONFIG} != "no" +SUBDIR+= bsdconfig +SUBDIR+= sysrc +.endif + .if ${MK_BSDINSTALL} != "no" SUBDIR+= bsdinstall .endif From 92e0655db4e102be7c519d2177698f5b74086832 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Thu, 27 Nov 2014 09:50:12 +0000 Subject: [PATCH 51/64] Honor MK_AUTOFS --- sys/modules/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/modules/Makefile b/sys/modules/Makefile index f66d6c2a2fb7..34a66ff20eba 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -48,7 +48,7 @@ SUBDIR= \ ata \ ath \ ath_pci \ - autofs \ + ${_autofs} \ ${_auxio} \ ${_bce} \ bfe \ @@ -387,6 +387,10 @@ SUBDIR= \ ${_zfs} \ zlib +.if ${MK_AUTOFS} != "no" || defined(ALL_MODULES) +_autofs= autofs +.endif + .if ${MK_BHYVE} != "no" || defined(ALL_MODULES) _vmm= vmm .endif From 68b259bdd5a6c88f01a4966c83442dea20763473 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Thu, 27 Nov 2014 09:53:17 +0000 Subject: [PATCH 52/64] Populate MK_AUTOFS and MK_BSDCONFIG; add more dtrace bits to MK_CDDL; add minimal bits to MK_LIB32 --- tools/build/mk/OptionalObsoleteFiles.inc | 234 ++++++++++++++++++++++- 1 file changed, 229 insertions(+), 5 deletions(-) diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index 62716212b12c..a23637bb15c2 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -152,6 +152,22 @@ OLD_FILES+=usr/share/man/man8/authpf.8.gz OLD_FILES+=usr/share/man/man8/authpf-noip.8.gz .endif +.if ${MK_AUTOFS} == no +OLD_FILES+=etc/autofs/include_ldap +OLD_FILES+=etc/autofs/special_hosts +OLD_FILES+=etc/autofs/special_null +OLD_FILES+=etc/auto_master +OLD_FILES+=usr/sbin/automount +OLD_FILES+=usr/sbin/automountd +OLD_FILES+=usr/sbin/autounmountd +OLD_FILES+=usr/share/man/man5/autofs.5.gz +OLD_FILES+=usr/share/man/man5/auto_master.5.gz +OLD_FILES+=usr/share/man/man8/automount.8.gz +OLD_FILES+=usr/share/man/man8/automountd.8.gz +OLD_FILES+=usr/share/man/man8/autounmountd.8.gz +OLD_DIRS+=etc/autofs +.endif + .if ${MK_BHYVE} == no OLD_FILES+=usr/sbin/bhyve OLD_FILES+=usr/sbin/bhyvectl @@ -367,6 +383,201 @@ OLD_FILES+=usr/share/man/man8/bootpgw.8.gz OLD_FILES+=usr/share/man/man8/bootptest.8.gz .endif +.if ${MK_BSDCONFIG} == no +OLD_FILES+=usr/libexec/bsdconfig/020.docsinstall/INDEX +OLD_FILES+=usr/libexec/bsdconfig/020.docsinstall/USAGE +OLD_FILES+=usr/libexec/bsdconfig/020.docsinstall/docsinstall +OLD_FILES+=usr/libexec/bsdconfig/020.docsinstall/include/messages.subr +OLD_FILES+=usr/libexec/bsdconfig/030.packages/INDEX +OLD_FILES+=usr/libexec/bsdconfig/030.packages/USAGE +OLD_FILES+=usr/libexec/bsdconfig/030.packages/include/messages.subr +OLD_FILES+=usr/libexec/bsdconfig/030.packages/packages +OLD_FILES+=usr/libexec/bsdconfig/040.password/INDEX +OLD_FILES+=usr/libexec/bsdconfig/040.password/USAGE +OLD_FILES+=usr/libexec/bsdconfig/040.password/include/messages.subr +OLD_FILES+=usr/libexec/bsdconfig/040.password/password +OLD_FILES+=usr/libexec/bsdconfig/050.diskmgmt/INDEX +OLD_FILES+=usr/libexec/bsdconfig/050.diskmgmt/USAGE +OLD_FILES+=usr/libexec/bsdconfig/050.diskmgmt/diskmgmt +OLD_FILES+=usr/libexec/bsdconfig/050.diskmgmt/include/messages.subr +OLD_FILES+=usr/libexec/bsdconfig/070.usermgmt/INDEX +OLD_FILES+=usr/libexec/bsdconfig/070.usermgmt/USAGE +OLD_FILES+=usr/libexec/bsdconfig/070.usermgmt/groupadd +OLD_FILES+=usr/libexec/bsdconfig/070.usermgmt/groupdel +OLD_FILES+=usr/libexec/bsdconfig/070.usermgmt/groupedit +OLD_FILES+=usr/libexec/bsdconfig/070.usermgmt/include/messages.subr +OLD_FILES+=usr/libexec/bsdconfig/070.usermgmt/include/usermgmt.hlp +OLD_FILES+=usr/libexec/bsdconfig/070.usermgmt/useradd +OLD_FILES+=usr/libexec/bsdconfig/070.usermgmt/userdel +OLD_FILES+=usr/libexec/bsdconfig/070.usermgmt/useredit +OLD_FILES+=usr/libexec/bsdconfig/070.usermgmt/usermgmt +OLD_FILES+=usr/libexec/bsdconfig/080.console/INDEX +OLD_FILES+=usr/libexec/bsdconfig/080.console/USAGE +OLD_FILES+=usr/libexec/bsdconfig/080.console/console +OLD_FILES+=usr/libexec/bsdconfig/080.console/font +OLD_FILES+=usr/libexec/bsdconfig/080.console/include/messages.subr +OLD_FILES+=usr/libexec/bsdconfig/080.console/keymap +OLD_FILES+=usr/libexec/bsdconfig/080.console/repeat +OLD_FILES+=usr/libexec/bsdconfig/080.console/saver +OLD_FILES+=usr/libexec/bsdconfig/080.console/screenmap +OLD_FILES+=usr/libexec/bsdconfig/080.console/ttys +OLD_FILES+=usr/libexec/bsdconfig/090.timezone/INDEX +OLD_FILES+=usr/libexec/bsdconfig/090.timezone/USAGE +OLD_FILES+=usr/libexec/bsdconfig/090.timezone/include/messages.subr +OLD_FILES+=usr/libexec/bsdconfig/090.timezone/timezone +OLD_FILES+=usr/libexec/bsdconfig/110.mouse/INDEX +OLD_FILES+=usr/libexec/bsdconfig/110.mouse/USAGE +OLD_FILES+=usr/libexec/bsdconfig/110.mouse/disable +OLD_FILES+=usr/libexec/bsdconfig/110.mouse/enable +OLD_FILES+=usr/libexec/bsdconfig/110.mouse/flags +OLD_FILES+=usr/libexec/bsdconfig/110.mouse/include/messages.subr +OLD_FILES+=usr/libexec/bsdconfig/110.mouse/mouse +OLD_FILES+=usr/libexec/bsdconfig/110.mouse/port +OLD_FILES+=usr/libexec/bsdconfig/110.mouse/type +OLD_FILES+=usr/libexec/bsdconfig/120.networking/INDEX +OLD_FILES+=usr/libexec/bsdconfig/120.networking/USAGE +OLD_FILES+=usr/libexec/bsdconfig/120.networking/defaultrouter +OLD_FILES+=usr/libexec/bsdconfig/120.networking/devices +OLD_FILES+=usr/libexec/bsdconfig/120.networking/hostname +OLD_FILES+=usr/libexec/bsdconfig/120.networking/include/messages.subr +OLD_FILES+=usr/libexec/bsdconfig/120.networking/nameservers +OLD_FILES+=usr/libexec/bsdconfig/120.networking/networking +OLD_FILES+=usr/libexec/bsdconfig/130.security/INDEX +OLD_FILES+=usr/libexec/bsdconfig/130.security/USAGE +OLD_FILES+=usr/libexec/bsdconfig/130.security/include/messages.subr +OLD_FILES+=usr/libexec/bsdconfig/130.security/include/securelevel.hlp +OLD_FILES+=usr/libexec/bsdconfig/130.security/kern_securelevel +OLD_FILES+=usr/libexec/bsdconfig/130.security/security +OLD_FILES+=usr/libexec/bsdconfig/140.startup/INDEX +OLD_FILES+=usr/libexec/bsdconfig/140.startup/USAGE +OLD_FILES+=usr/libexec/bsdconfig/140.startup/include/messages.subr +OLD_FILES+=usr/libexec/bsdconfig/140.startup/misc +OLD_FILES+=usr/libexec/bsdconfig/140.startup/rcadd +OLD_FILES+=usr/libexec/bsdconfig/140.startup/rcconf +OLD_FILES+=usr/libexec/bsdconfig/140.startup/rcdelete +OLD_FILES+=usr/libexec/bsdconfig/140.startup/rcedit +OLD_FILES+=usr/libexec/bsdconfig/140.startup/rcvar +OLD_FILES+=usr/libexec/bsdconfig/140.startup/startup +OLD_FILES+=usr/libexec/bsdconfig/150.ttys/INDEX +OLD_FILES+=usr/libexec/bsdconfig/150.ttys/USAGE +OLD_FILES+=usr/libexec/bsdconfig/150.ttys/include/messages.subr +OLD_FILES+=usr/libexec/bsdconfig/150.ttys/ttys +OLD_FILES+=usr/libexec/bsdconfig/USAGE +OLD_FILES+=usr/libexec/bsdconfig/dot/INDEX +OLD_FILES+=usr/libexec/bsdconfig/dot/USAGE +OLD_FILES+=usr/libexec/bsdconfig/dot/dot +OLD_FILES+=usr/libexec/bsdconfig/dot/include/messages.subr +OLD_FILES+=usr/libexec/bsdconfig/include/bsdconfig.hlp +OLD_FILES+=usr/libexec/bsdconfig/include/media.hlp +OLD_FILES+=usr/libexec/bsdconfig/include/messages.subr +OLD_FILES+=usr/libexec/bsdconfig/include/network_device.hlp +OLD_FILES+=usr/libexec/bsdconfig/include/options.hlp +OLD_FILES+=usr/libexec/bsdconfig/include/tcp.hlp +OLD_FILES+=usr/libexec/bsdconfig/include/usage.hlp +OLD_FILES+=usr/libexec/bsdconfig/includes/INDEX +OLD_FILES+=usr/libexec/bsdconfig/includes/USAGE +OLD_FILES+=usr/libexec/bsdconfig/includes/include/messages.subr +OLD_FILES+=usr/libexec/bsdconfig/includes/includes +OLD_FILES+=usr/sbin/bsdconfig +OLD_FILES+=usr/sbin/sysrc +OLD_FILES+=usr/share/bsdconfig/common.subr +OLD_FILES+=usr/share/bsdconfig/device.subr +OLD_FILES+=usr/share/bsdconfig/dialog.subr +OLD_FILES+=usr/share/bsdconfig/geom.subr +OLD_FILES+=usr/share/bsdconfig/keymap.subr +OLD_FILES+=usr/share/bsdconfig/media/any.subr +OLD_FILES+=usr/share/bsdconfig/media/cdrom.subr +OLD_FILES+=usr/share/bsdconfig/media/common.subr +OLD_FILES+=usr/share/bsdconfig/media/directory.subr +OLD_FILES+=usr/share/bsdconfig/media/dos.subr +OLD_FILES+=usr/share/bsdconfig/media/floppy.subr +OLD_FILES+=usr/share/bsdconfig/media/ftp.subr +OLD_FILES+=usr/share/bsdconfig/media/http.subr +OLD_FILES+=usr/share/bsdconfig/media/httpproxy.subr +OLD_FILES+=usr/share/bsdconfig/media/network.subr +OLD_FILES+=usr/share/bsdconfig/media/nfs.subr +OLD_FILES+=usr/share/bsdconfig/media/options.subr +OLD_FILES+=usr/share/bsdconfig/media/tcpip.subr +OLD_FILES+=usr/share/bsdconfig/media/ufs.subr +OLD_FILES+=usr/share/bsdconfig/media/usb.subr +OLD_FILES+=usr/share/bsdconfig/mustberoot.subr +OLD_FILES+=usr/share/bsdconfig/networking/common.subr +OLD_FILES+=usr/share/bsdconfig/networking/device.subr +OLD_FILES+=usr/share/bsdconfig/networking/hostname.subr +OLD_FILES+=usr/share/bsdconfig/networking/ipaddr.subr +OLD_FILES+=usr/share/bsdconfig/networking/media.subr +OLD_FILES+=usr/share/bsdconfig/networking/netmask.subr +OLD_FILES+=usr/share/bsdconfig/networking/resolv.subr +OLD_FILES+=usr/share/bsdconfig/networking/routing.subr +OLD_FILES+=usr/share/bsdconfig/networking/services.subr +OLD_FILES+=usr/share/bsdconfig/packages/categories.subr +OLD_FILES+=usr/share/bsdconfig/packages/index.subr +OLD_FILES+=usr/share/bsdconfig/packages/musthavepkg.subr +OLD_FILES+=usr/share/bsdconfig/packages/packages.subr +OLD_FILES+=usr/share/bsdconfig/password/password.subr +OLD_FILES+=usr/share/bsdconfig/script.subr +OLD_FILES+=usr/share/bsdconfig/startup/rcconf.subr +OLD_FILES+=usr/share/bsdconfig/startup/rcedit.subr +OLD_FILES+=usr/share/bsdconfig/startup/rcvar.subr +OLD_FILES+=usr/share/bsdconfig/strings.subr +OLD_FILES+=usr/share/bsdconfig/struct.subr +OLD_FILES+=usr/share/bsdconfig/sysrc.subr +OLD_FILES+=usr/share/bsdconfig/timezone/continents.subr +OLD_FILES+=usr/share/bsdconfig/timezone/countries.subr +OLD_FILES+=usr/share/bsdconfig/timezone/iso3166.subr +OLD_FILES+=usr/share/bsdconfig/timezone/menus.subr +OLD_FILES+=usr/share/bsdconfig/timezone/zones.subr +OLD_FILES+=usr/share/bsdconfig/usermgmt/group.subr +OLD_FILES+=usr/share/bsdconfig/usermgmt/group_input.subr +OLD_FILES+=usr/share/bsdconfig/usermgmt/user.subr +OLD_FILES+=usr/share/bsdconfig/usermgmt/user_input.subr +OLD_FILES+=usr/share/bsdconfig/variable.subr +OLD_FILES+=usr/share/examples/bsdconfig/add_some_packages.sh +OLD_FILES+=usr/share/examples/bsdconfig/browse_packages_http.sh +OLD_FILES+=usr/share/examples/bsdconfig/bsdconfigrc +OLD_FILES+=usr/share/man/man8/bsdconfig.8.gz +OLD_FILES+=usr/share/man/man8/sysrc.8.gz +OLD_DIRS+=usr/libexec/bsdconfig/020.docsinstall/include +OLD_DIRS+=usr/libexec/bsdconfig/020.docsinstall +OLD_DIRS+=usr/libexec/bsdconfig/030.packages/include +OLD_DIRS+=usr/libexec/bsdconfig/030.packages +OLD_DIRS+=usr/libexec/bsdconfig/040.password/include +OLD_DIRS+=usr/libexec/bsdconfig/040.password +OLD_DIRS+=usr/libexec/bsdconfig/050.diskmgmt/include +OLD_DIRS+=usr/libexec/bsdconfig/050.diskmgmt +OLD_DIRS+=usr/libexec/bsdconfig/070.usermgmt/include +OLD_DIRS+=usr/libexec/bsdconfig/070.usermgmt +OLD_DIRS+=usr/libexec/bsdconfig/080.console/include +OLD_DIRS+=usr/libexec/bsdconfig/080.console +OLD_DIRS+=usr/libexec/bsdconfig/090.timezone/include +OLD_DIRS+=usr/libexec/bsdconfig/090.timezone +OLD_DIRS+=usr/libexec/bsdconfig/110.mouse/include +OLD_DIRS+=usr/libexec/bsdconfig/110.mouse +OLD_DIRS+=usr/libexec/bsdconfig/120.networking/include +OLD_DIRS+=usr/libexec/bsdconfig/120.networking +OLD_DIRS+=usr/libexec/bsdconfig/130.security/include +OLD_DIRS+=usr/libexec/bsdconfig/130.security +OLD_DIRS+=usr/libexec/bsdconfig/140.startup/include +OLD_DIRS+=usr/libexec/bsdconfig/140.startup +OLD_DIRS+=usr/libexec/bsdconfig/150.ttys/include +OLD_DIRS+=usr/libexec/bsdconfig/150.ttys +OLD_DIRS+=usr/libexec/bsdconfig/dot/include +OLD_DIRS+=usr/libexec/bsdconfig/dot +OLD_DIRS+=usr/libexec/bsdconfig/include +OLD_DIRS+=usr/libexec/bsdconfig/includes/include +OLD_DIRS+=usr/libexec/bsdconfig/includes +OLD_DIRS+=usr/libexec/bsdconfig +OLD_DIRS+=usr/share/bsdconfig/media +OLD_DIRS+=usr/share/bsdconfig/networking +OLD_DIRS+=usr/share/bsdconfig/packages +OLD_DIRS+=usr/share/bsdconfig/password +OLD_DIRS+=usr/share/bsdconfig/startup +OLD_DIRS+=usr/share/bsdconfig/timezone +OLD_DIRS+=usr/share/bsdconfig/usermgmt +OLD_DIRS+=usr/share/bsdconfig +OLD_DIRS+=usr/share/examples/bsdconfig +.endif + .if ${MK_BSDINSTALL} == no OLD_FILES+=usr/libexec/bsdinstall/adduser OLD_FILES+=usr/libexec/bsdinstall/auto @@ -607,7 +818,6 @@ OLD_FILES+=usr/lib/dtrace/signal.d OLD_FILES+=usr/lib/dtrace/tcp.d OLD_FILES+=usr/lib/dtrace/udp.d OLD_FILES+=usr/lib/dtrace/unistd.d -OLD_DIRS+=usr/lib/dtrace OLD_FILES+=usr/lib/libavl.a OLD_FILES+=usr/lib/libavl.so OLD_FILES+=usr/lib/libavl_p.a @@ -628,7 +838,6 @@ OLD_FILES+=usr/lib/libuutil.so OLD_FILES+=usr/lib/libuutil_p.a .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64" OLD_FILES+=usr/lib32/dtrace/drti.o -OLD_DIRS+=usr/lib32/dtrace OLD_FILES+=usr/lib32/libavl.a OLD_FILES+=usr/lib32/libavl.so OLD_LIBS+=usr/lib32/libavl.so.2 @@ -654,9 +863,24 @@ OLD_FILES+=usr/lib32/libuutil.so OLD_LIBS+=usr/lib32/libuutil.so.2 OLD_FILES+=usr/lib32/libuutil_p.a .endif +OLD_LIBS+=lib/libdtrace.so.2 OLD_FILES+=usr/sbin/dtrace OLD_FILES+=usr/sbin/lockstat OLD_FILES+=usr/share/man/man1/dtrace.1.gz +OLD_FILES+=usr/share/dtrace/disklatency +OLD_FILES+=usr/share/dtrace/disklatencycmd +OLD_FILES+=usr/share/dtrace/hotopen +OLD_FILES+=usr/share/dtrace/nfsclienttime +OLD_FILES+=usr/share/dtrace/toolkit/execsnoop +OLD_FILES+=usr/share/dtrace/toolkit/hotkernel +OLD_FILES+=usr/share/dtrace/toolkit/hotuser +OLD_FILES+=usr/share/dtrace/toolkit/opensnoop +OLD_FILES+=usr/share/dtrace/toolkit/procsystime +OLD_FILES+=usr/share/man/man1/dtrace.1.gz +OLD_DIRS+=usr/lib/dtrace +OLD_DIRS+=usr/lib32/dtrace +OLD_DIRS+=usr/share/dtrace/toolkit +OLD_DIRS+=usr/share/dtrace .endif .if ${MK_ZFS} == no @@ -3441,9 +3665,9 @@ OLD_FILES+=usr/share/man/man5/keymap.5.gz OLD_FILES+=usr/share/man/man8/moused.8.g .endif -#.if ${MK_LIB32} == no -# to be filled in -#.endif +.if ${MK_LIB32} == no +OLD_FILES+=etc/libmap32.conf +.endif .if ${MK_LIBCPLUSPLUS} == no OLD_LIBS+=lib/libcxxrt.so.1 From 2d561fcbcf5643baa7759f7479af312cb5247229 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Thu, 27 Nov 2014 23:42:32 +0000 Subject: [PATCH 53/64] Use ${.TARGET} instead of hardcoding the name in the dump build rule --- usr.bin/vi/catalog/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/vi/catalog/Makefile b/usr.bin/vi/catalog/Makefile index bd9db9f22e30..4e21298a095e 100644 --- a/usr.bin/vi/catalog/Makefile +++ b/usr.bin/vi/catalog/Makefile @@ -101,7 +101,7 @@ english.base: dump ${SCAN} #Makefile dump: dump.c - ${CC} -o dump ${.ALLSRC} + ${CC} -o ${.TARGET} ${.ALLSRC} CLEANFILES+= dump ${CAT} english.base *.check __ck1 __ck2 From 2c3774c183a9b9736d5e27aa757a922fbaf8eb5d Mon Sep 17 00:00:00 2001 From: "Bjoern A. Zeeb" Date: Fri, 28 Nov 2014 14:51:49 +0000 Subject: [PATCH 54/64] After r275196 unbreak NOIP and NOINET kernels by hiding an otherwise unused varibale under the proper #ifdef. --- sys/net/if_arcsubr.c | 2 ++ sys/net/if_fddisubr.c | 2 ++ sys/net/if_fwsubr.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/sys/net/if_arcsubr.c b/sys/net/if_arcsubr.c index d9a6cab129e7..46fbf5b6232d 100644 --- a/sys/net/if_arcsubr.c +++ b/sys/net/if_arcsubr.c @@ -103,7 +103,9 @@ arc_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, u_int8_t atype, adst; int loop_copy = 0; int isphds; +#ifdef INET int is_gw; +#endif if (!((ifp->if_flags & IFF_UP) && (ifp->if_drv_flags & IFF_DRV_RUNNING))) diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c index 91b26e538dd8..9066c0d3cd63 100644 --- a/sys/net/if_fddisubr.c +++ b/sys/net/if_fddisubr.c @@ -101,7 +101,9 @@ fddi_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, int loop_copy = 0, error = 0, hdrcmplt = 0; u_char esrc[FDDI_ADDR_LEN], edst[FDDI_ADDR_LEN]; struct fddi_header *fh; +#ifdef INET int is_gw; +#endif #ifdef MAC error = mac_ifnet_check_transmit(ifp, m); diff --git a/sys/net/if_fwsubr.c b/sys/net/if_fwsubr.c index fd4851ed621b..5bb12f9ee3aa 100644 --- a/sys/net/if_fwsubr.c +++ b/sys/net/if_fwsubr.c @@ -89,7 +89,9 @@ firewire_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, struct mbuf *mtail; int unicast, dgl, foff; static int next_dgl; +#ifdef INET int is_gw; +#endif #ifdef MAC error = mac_ifnet_check_transmit(ifp, m); From a7f8c4eb4cbddfb882774651c2bc62ca38925859 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Fri, 28 Nov 2014 22:03:35 +0000 Subject: [PATCH 55/64] Readd Makefile.inc that were used to include upper level Makefile.inc and set (among other things) the destination where the binary should be installed --- usr.sbin/cron/Makefile.inc | 3 +++ usr.sbin/fifolog/Makefile.inc | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 usr.sbin/cron/Makefile.inc create mode 100644 usr.sbin/fifolog/Makefile.inc diff --git a/usr.sbin/cron/Makefile.inc b/usr.sbin/cron/Makefile.inc new file mode 100644 index 000000000000..265f86d1ed55 --- /dev/null +++ b/usr.sbin/cron/Makefile.inc @@ -0,0 +1,3 @@ +# $FreeBSD$ + +.include "../Makefile.inc" diff --git a/usr.sbin/fifolog/Makefile.inc b/usr.sbin/fifolog/Makefile.inc new file mode 100644 index 000000000000..265f86d1ed55 --- /dev/null +++ b/usr.sbin/fifolog/Makefile.inc @@ -0,0 +1,3 @@ +# $FreeBSD$ + +.include "../Makefile.inc" From 1eea90048f8f0e6360171d254c1f60f41a090814 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sat, 29 Nov 2014 00:33:10 +0000 Subject: [PATCH 56/64] Update libucl to latest version --- COPYING | 23 + ChangeLog.md | 16 + Makefile.am | 6 +- Makefile.w32 | 7 +- README.md | 58 +- cmake/CMakeLists.txt | 18 +- configure.ac | 29 +- doc/lua_api.md | 194 +++++++ include/lua_ucl.h | 69 +++ include/ucl.h | 187 ++++-- libucl.pc.in | 2 +- lua/Makefile.am | 26 + lua/libucl.rockspec.in | 26 + lua/lua_ucl.c | 820 +++++++++++++++++++++++++++ lua/test.lua | 48 ++ m4/.gitignore | 4 + m4/ax_lua.m4 | 606 ++++++++++++++++++++ src/ucl_emitter.c | 64 ++- src/ucl_emitter_streamline.c | 3 +- src/ucl_emitter_utils.c | 58 +- src/ucl_hash.c | 15 + src/ucl_hash.h | 6 + src/ucl_internal.h | 40 +- src/ucl_parser.c | 434 ++++++++++---- src/ucl_util.c | 581 ++++++++++++++++--- tests/Makefile.am | 2 +- tests/basic/12.in | 2 + tests/basic/12.res | 3 + tests/basic/13.in | 9 + tests/basic/13.res | 8 + tests/basic/4.res | 22 +- tests/basic/comments.in | 25 + tests/basic/comments.res | 7 + tests/basic/include_dir/invalid.conf | 1 + tests/basic/include_dir/pri1.conf | 2 + tests/basic/include_dir/pri2.conf | 2 + tests/basic/include_dir/test1.conf | 1 + tests/basic/include_dir/test2.conf | 1 + tests/basic/include_dir/test3.conf | 1 + tests/generate.res | 1 + tests/test_basic.c | 4 +- tests/test_generate.c | 7 + tests/test_schema.c | 2 +- utils/objdump.c | 1 + 44 files changed, 3169 insertions(+), 272 deletions(-) create mode 100644 COPYING create mode 100644 doc/lua_api.md create mode 100644 include/lua_ucl.h create mode 100644 lua/Makefile.am create mode 100644 lua/libucl.rockspec.in create mode 100644 lua/lua_ucl.c create mode 100644 lua/test.lua create mode 100644 m4/.gitignore create mode 100644 m4/ax_lua.m4 create mode 100644 tests/basic/12.in create mode 100644 tests/basic/12.res create mode 100644 tests/basic/13.in create mode 100644 tests/basic/13.res create mode 100644 tests/basic/comments.in create mode 100644 tests/basic/comments.res create mode 100644 tests/basic/include_dir/invalid.conf create mode 100644 tests/basic/include_dir/pri1.conf create mode 100644 tests/basic/include_dir/pri2.conf create mode 100644 tests/basic/include_dir/test1.conf create mode 100644 tests/basic/include_dir/test2.conf create mode 100644 tests/basic/include_dir/test3.conf diff --git a/COPYING b/COPYING new file mode 100644 index 000000000000..33048e1b8b97 --- /dev/null +++ b/COPYING @@ -0,0 +1,23 @@ +Copyright (c) 2013-2014, Vsevolod Stakhov +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* 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. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. diff --git a/ChangeLog.md b/ChangeLog.md index 09c331f4c6d1..0df5e072222e 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -4,3 +4,19 @@ - Streamline emitter has been added, so it is now possible to output partial `ucl` objects - Emitter now is more flexible due to emitter_context structure + +### 0.5.1 +- Fixed number of bugs and memory leaks + +### 0.5.2 + +- Allow userdata objects to be emitted and destructed +- Use userdata objects to store lua function references + +### Libucl 0.6 + +- Reworked macro interface + +### Libucl 0.6.1 + +- Various utilities fixes diff --git a/Makefile.am b/Makefile.am index 4668b3681849..ece5b97df488 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,4 +4,8 @@ EXTRA_DIST = uthash README.md pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libucl.pc -SUBDIRS = src tests utils doc \ No newline at end of file +if LUA_SUB + LUA_SUBDIR = lua +endif + +SUBDIRS = src tests utils doc $(LUA_SUBDIR) \ No newline at end of file diff --git a/Makefile.w32 b/Makefile.w32 index 62ff14a3a296..0e61274ff59c 100644 --- a/Makefile.w32 +++ b/Makefile.w32 @@ -33,6 +33,7 @@ OBJECTS = $(OBJDIR)/ucl_hash.o \ $(OBJDIR)/ucl_util.o \ $(OBJDIR)/ucl_parser.o \ $(OBJDIR)/ucl_emitter.o \ + $(OBJDIR)/ucl_emitter_utils.o \ $(OBJDIR)/ucl_schema.o \ $(OBJDIR)/xxhash.o @@ -51,6 +52,8 @@ $(OBJDIR)/ucl_parser.o: $(SRCDIR)/ucl_parser.c $(HDEPS) $(CC) -o $(OBJDIR)/ucl_parser.o $(CPPFLAGS) $(COPT_FLAGS) $(CFLAGS) $(C_COMMON_FLAGS) $(SSL_CFLAGS) $(FETCH_FLAGS) -c $(SRCDIR)/ucl_parser.c $(OBJDIR)/ucl_emitter.o: $(SRCDIR)/ucl_emitter.c $(HDEPS) $(CC) -o $(OBJDIR)/ucl_emitter.o $(CPPFLAGS) $(COPT_FLAGS) $(CFLAGS) $(C_COMMON_FLAGS) $(SSL_CFLAGS) $(FETCH_FLAGS) -c $(SRCDIR)/ucl_emitter.c +$(OBJDIR)/ucl_emitter_utils.o: $(SRCDIR)/ucl_emitter_utils.c $(HDEPS) + $(CC) -o $(OBJDIR)/ucl_emitter_utils.o $(CPPFLAGS) $(COPT_FLAGS) $(CFLAGS) $(C_COMMON_FLAGS) $(SSL_CFLAGS) $(FETCH_FLAGS) -c $(SRCDIR)/ucl_emitter_utils.c $(OBJDIR)/ucl_hash.o: $(SRCDIR)/ucl_hash.c $(HDEPS) $(CC) -o $(OBJDIR)/ucl_hash.o $(CPPFLAGS) $(COPT_FLAGS) $(CFLAGS) $(C_COMMON_FLAGS) $(SSL_CFLAGS) $(FETCH_FLAGS) -c $(SRCDIR)/ucl_hash.c $(OBJDIR)/ucl_schema.o: $(SRCDIR)/ucl_schema.c $(HDEPS) @@ -61,7 +64,7 @@ $(OBJDIR)/xxhash.o: $(SRCDIR)/xxhash.c $(HDEPS) clean: $(RM) $(OBJDIR)/*.o $(OBJDIR)/$(SONAME) $(OBJDIR)/$(SONAME) $(OBJDIR)/chargen $(OBJDIR)/test_basic $(OBJDIR)/test_speed $(OBJDIR)/objdump $(OBJDIR)/test_generate $(RMDIR) $(OBJDIR) - + # Utils chargen: utils/chargen.c $(OBJDIR)/$(SONAME) @@ -75,7 +78,7 @@ test: $(OBJDIR) $(OBJDIR)/$(SONAME) $(OBJDIR)/test_basic $(OBJDIR)/test_speed $( run-test: test TEST_DIR=$(TESTDIR) $(TESTDIR)/run_tests.sh $(OBJDIR)/test_basic $(OBJDIR)/test_speed $(OBJDIR)/test_generate - + $(OBJDIR)/test_basic: $(TESTDIR)/test_basic.c $(OBJDIR)/$(SONAME) $(CC) -o $(OBJDIR)/test_basic $(CPPFLAGS) $(COPT_FLAGS) $(CFLAGS) $(C_COMMON_FLAGS) $(SSL_CFLAGS) $(FETCH_FLAGS) $(LDFLAGS) $(TESTDIR)/test_basic.c $(LD_UCL_FLAGS) $(OBJDIR)/test_speed: $(TESTDIR)/test_speed.c $(OBJDIR)/$(SONAME) diff --git a/README.md b/README.md index b6353d10ae27..235cfb6595df 100644 --- a/README.md +++ b/README.md @@ -223,15 +223,57 @@ UCL supports external macros both multiline and single line ones: .... }; ``` -There are two internal macros provided by UCL: -* `include` - read a file `/path/to/file` or an url `http://example.com/file` and include it to the current place of -UCL configuration; -* `try\_include` - try to read a file or url and include it but do not create a fatal error if a file or url is not accessible; -* `includes` - read a file or an url like the previous macro, but fetch and check the signature file (which is obtained -by `.sig` suffix appending). +Moreover, each macro can accept an optional list of arguments in braces. These +arguments themselves are the UCL object that is parsed and passed to a macro as +options: -Public keys which are used for the last command are specified by the concrete UCL user. +```nginx +.macro(param=value) "something"; +.macro(param={key=value}) "something"; +.macro(.include "params.conf") "something"; +.macro(#this is multiline macro +param = [value1, value2]) "something"; +.macro(key="()") "something"; +``` + +UCL also provide a convenient `include` macro to load content from another files +to the current UCL object. This macro accepts either path to file: + +```nginx +.include "/full/path.conf" +.include "./relative/path.conf" +.include "${CURDIR}/path.conf" +``` + +or URL (if ucl is built with url support provided by either `libcurl` or `libfetch`): + + .include "http://example.com/file.conf" + +`.include` macro supports a set of options: + +* `try` (default: **false**) - if this option is `true` than UCL treats errors on loading of +this file as non-fatal. For example, such a file can be absent but it won't stop the parsing +of the top-level document. +* `sign` (default: **false**) - if this option is `true` UCL loads and checks the signature for +a file from path named `.sig`. Trusted public keys should be provided for UCL API after +parser is created but before any configurations are parsed. +* `glob` (default: **false**) - if this option is `true` UCL treats the filename as GLOB pattern and load +all files that matches the specified pattern (normally the format of patterns is defined in `glob` manual page +for your operating system). This option is meaningless for URL includes. +* `url` (default: **true**) - allow URL includes. +* `priority` (default: 0) - specify priority for the include (see below). + +Priorities are used by UCL parser to manage the policy of objects rewriting during including other files +as following: + +* If we have two objects with the same priority then we form an implicit array +* If a new object has bigger priority then we overwrite an old one +* If a new object has lower priority then we ignore it + +By default, the priority of top-level object is set to zero (lowest priority). Currently, +you can define up to 16 priorities (from 0 to 15). Includes with bigger priorities will +rewrite keys from the objects with lower priorities as specified by the policy. ### Variables support @@ -317,7 +359,7 @@ ucl: emitted compact json in 0.0991 seconds ucl: emitted yaml in 0.1354 seconds ``` -You can do your own benchmarks by running `make test` in libucl top directory. +You can do your own benchmarks by running `make check` in libucl top directory. ## Conclusion diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 4551966135ea..3c57db53784a 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -1,8 +1,8 @@ PROJECT(libucl C) SET(LIBUCL_VERSION_MAJOR 0) -SET(LIBUCL_VERSION_MINOR 2) -SET(LIBUCL_VERSION_PATCH 9) +SET(LIBUCL_VERSION_MINOR 5) +SET(LIBUCL_VERSION_PATCH 0) SET(LIBUCL_VERSION "${LIBUCL_VERSION_MAJOR}.${LIBUCL_VERSION_MINOR}.${LIBUCL_VERSION_PATCH}") @@ -86,6 +86,8 @@ INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/../uthash") SET(UCLSRC ../src/ucl_util.c ../src/ucl_parser.c ../src/ucl_emitter.c + ../src/ucl_emitter_streamline.c + ../src/ucl_emitter_utils.c ../src/ucl_hash.c ../src/ucl_schema.c ../src/xxhash.c) @@ -98,6 +100,18 @@ ENDIF (BUILD_SHARED_LIBS) ADD_LIBRARY(ucl ${LIB_TYPE} ${UCLSRC}) SET_TARGET_PROPERTIES(ucl PROPERTIES VERSION ${LIBUCL_VERSION} SOVERSION ${LIBUCL_VERSION_MAJOR}) +IF(WITH_LUA) + SET(UCL_LUA_SRC ../lua/lua_ucl.c) + ADD_LIBRARY(lua-ucl ${LIB_TYPE} ${UCL_LUA_SRC}) + IF(ENABLE_LUAJIT MATCHES "ON") + TARGET_LINK_LIBRARIES(lua-ucl "${LUAJIT_LIBRARY}") + ELSE(ENABLE_LUAJIT MATCHES "ON") + TARGET_LINK_LIBRARIES(lua-ucl "${LUA_LIBRARY}") + ENDIF(ENABLE_LUAJIT MATCHES "ON") + TARGET_LINK_LIBRARIES(lua-ucl ucl) + SET_TARGET_PROPERTIES(lua-ucl PROPERTIES VERSION ${LIBUCL_VERSION} SOVERSION ${LIBUCL_VERSION_MAJOR}) +ENDIF(WITH_LUA) + IF(HAVE_FETCH_H) TARGET_LINK_LIBRARIES(ucl fetch) ELSE(HAVE_FETCH_H) diff --git a/configure.ac b/configure.ac index 2d612f6236e8..32db73ad0fdd 100644 --- a/configure.ac +++ b/configure.ac @@ -1,12 +1,13 @@ m4_define([maj_ver], [0]) -m4_define([med_ver], [5]) -m4_define([min_ver], [0]) -m4_define([so_version], [2:0:0]) +m4_define([med_ver], [6]) +m4_define([min_ver], [1]) +m4_define([so_version], [3:0:1]) m4_define([ucl_version], [maj_ver.med_ver.min_ver]) AC_INIT([libucl],[ucl_version],[https://github.com/vstakhov/libucl],[libucl]) AC_CONFIG_SRCDIR([configure.ac]) -AM_INIT_AUTOMAKE([1.11 foreign silent-rules -Wall -Wportability no-dist-gzip dist-xz]) +AM_INIT_AUTOMAKE([1.11 foreign -Wall -Wportability no-dist-gzip dist-xz]) +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) UCL_VERSION=ucl_version SO_VERSION=so_version @@ -57,6 +58,9 @@ AC_ARG_ENABLE([regex], AS_HELP_STRING([--enable-regex], AC_ARG_ENABLE([signatures], AS_HELP_STRING([--enable-signatures], [Enable signatures check (requires openssl) @<:@default=no@:>@]), [], [enable_signatures=no]) +AC_ARG_ENABLE([lua], AS_HELP_STRING([--enable-lua], + [Enable lua API build (requires lua libraries and headers) @<:@default=no@:>@]), [], + [enable_lua=no]) AC_ARG_ENABLE([utils], AS_HELP_STRING([--enable-utils], [Build and install utils @<:@default=no@:>@]), [case "${enableval}" in @@ -99,6 +103,21 @@ AS_IF([test "x$enable_regex" = "xyes"], [ ]) AC_SUBST(LIBREGEX_LIB) +AS_IF([test "x$enable_lua" = "xyes"], [ + AX_PROG_LUA([5.1], [], [ + AX_LUA_HEADERS([ + AX_LUA_LIBS([ + AC_DEFINE(HAVE_LUA, 1, [Define to 1 for lua support.]) + with_lua="yes" + ], [AC_MSG_ERROR([unable to find the lua libraries]) + ]) + ], [AC_MSG_ERROR([unable to find the lua header files]) + ]) + ], [AC_MSG_ERROR([unable to find the lua interpreter])]) +], [with_lua="no"]) + +AM_CONDITIONAL([LUA_SUB], [test "$with_lua" = "yes"]) + AS_IF([test "x$enable_urls" = "xyes"], [ AC_CHECK_HEADER([fetch.h], [ AC_DEFINE(HAVE_FETCH_H, 1, [Define to 1 if you have the header file.]) @@ -155,9 +174,11 @@ AC_LINK_IFELSE([ AC_CONFIG_FILES(Makefile \ src/Makefile \ + lua/Makefile tests/Makefile \ utils/Makefile \ doc/Makefile \ + lua/libucl.rockspec \ libucl.pc) AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h]) AC_OUTPUT diff --git a/doc/lua_api.md b/doc/lua_api.md new file mode 100644 index 000000000000..a53353b3c57e --- /dev/null +++ b/doc/lua_api.md @@ -0,0 +1,194 @@ +## Module `ucl` + +This lua module allows to parse objects from strings and to store data into +ucl objects. It uses `libucl` C library to parse and manipulate with ucl objects. + +Example: + +~~~lua +local ucl = require("ucl") + +local parser = ucl.parser() +local res,err = parser:parse_string('{key=value}') + +if not res then + print('parser error: ' .. err) +else + local obj = parser:get_object() + local got = ucl.to_format(obj, 'json') +endif + +local table = { + str = 'value', + num = 100500, + null = ucl.null, + func = function () + return 'huh' + end + + +print(ucl.to_format(table, 'ucl')) +-- Output: +--[[ +num = 100500; +str = "value"; +null = null; +func = "huh"; +--]] +~~~ + +###Brief content: + +**Functions**: + +> [`ucl_object_push_lua(L, obj, allow_array)`](#function-ucl_object_push_lual-obj-allow_array) + +> [`ucl.to_format(var, format)`](#function-uclto_formatvar-format) + + + +**Methods**: + +> [`parser:parse_file(name)`](#method-parserparse_filename) + +> [`parser:parse_string(input)`](#method-parserparse_stringinput) + +> [`parser:get_object()`](#method-parserget_object) + + +## Functions + +The module `ucl` defines the following functions. + +### Function `ucl_object_push_lua(L, obj, allow_array)` + +This is a `C` function to push `UCL` object as lua variable. This function +converts `obj` to lua representation using the following conversions: + +- *scalar* values are directly presented by lua objects +- *userdata* values are converted to lua function objects using `LUA_REGISTRYINDEX`, +this can be used to pass functions from lua to c and vice-versa +- *arrays* are converted to lua tables with numeric indicies suitable for `ipairs` iterations +- *objects* are converted to lua tables with string indicies + +**Parameters:** + +- `L {lua_State}`: lua state pointer +- `obj {ucl_object_t}`: object to push +- `allow_array {bool}`: expand implicit arrays (should be true for all but partial arrays) + +**Returns:** + +- `{int}`: `1` if an object is pushed to lua + +Back to [module description](#module-ucl). + +### Function `ucl.to_format(var, format)` + +Converts lua variable `var` to the specified `format`. Formats supported are: + +- `json` - fine printed json +- `json-compact` - compacted json +- `config` - fine printed configuration +- `ucl` - same as `config` +- `yaml` - embedded yaml + +If `var` contains function, they are called during output formatting and if +they return string value, then this value is used for ouptut. + +**Parameters:** + +- `var {variant}`: any sort of lua variable (if userdata then metafield `__to_ucl` is searched for output) +- `format {string}`: any available format + +**Returns:** + +- `{string}`: string representation of `var` in the specific `format`. + +Example: + +~~~lua +local table = { + str = 'value', + num = 100500, + null = ucl.null, + func = function () + return 'huh' + end + + +print(ucl.to_format(table, 'ucl')) +-- Output: +--[[ +num = 100500; +str = "value"; +null = null; +func = "huh"; +--]] +~~~ + +Back to [module description](#module-ucl). + + +## Methods + +The module `ucl` defines the following methods. + +### Method `parser:parse_file(name)` + +Parse UCL object from file. + +**Parameters:** + +- `name {string}`: filename to parse + +**Returns:** + +- `{bool[, string]}`: if res is `true` then file has been parsed successfully, otherwise an error string is also returned + +Example: + +~~~lua +local parser = ucl.parser() +local res,err = parser:parse_file('/some/file.conf') + +if not res then + print('parser error: ' .. err) +else + -- Do something with object +end +~~~ + +Back to [module description](#module-ucl). + +### Method `parser:parse_string(input)` + +Parse UCL object from file. + +**Parameters:** + +- `input {string}`: string to parse + +**Returns:** + +- `{bool[, string]}`: if res is `true` then file has been parsed successfully, otherwise an error string is also returned + +Back to [module description](#module-ucl). + +### Method `parser:get_object()` + +Get top object from parser and export it to lua representation. + +**Parameters:** + + nothing + +**Returns:** + +- `{variant or nil}`: ucl object as lua native variable + +Back to [module description](#module-ucl). + + +Back to [top](#). + diff --git a/include/lua_ucl.h b/include/lua_ucl.h new file mode 100644 index 000000000000..38e74d3f619d --- /dev/null +++ b/include/lua_ucl.h @@ -0,0 +1,69 @@ +/* Copyright (c) 2014, Vsevolod Stakhov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * + * THIS SOFTWARE IS PROVIDED ''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 AUTHOR 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. + */ +#ifndef LUA_UCL_H_ +#define LUA_UCL_H_ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include "ucl.h" + +/** + * Closure structure for lua function storing inside UCL + */ +struct ucl_lua_funcdata { + lua_State *L; + int idx; + char *ret; +}; + +/** + * Initialize lua UCL API + */ +UCL_EXTERN int luaopen_ucl (lua_State *L); + +/** + * Import UCL object from lua state + * @param L lua state + * @param idx index of object at the lua stack to convert to UCL + * @return new UCL object or NULL, the caller should unref object after using + */ +UCL_EXTERN ucl_object_t* ucl_object_lua_import (lua_State *L, int idx); + +/** + * Push an object to lua + * @param L lua state + * @param obj object to push + * @param allow_array traverse over implicit arrays + */ +UCL_EXTERN int ucl_object_push_lua (lua_State *L, + const ucl_object_t *obj, bool allow_array); + +UCL_EXTERN struct ucl_lua_funcdata* ucl_object_toclosure ( + const ucl_object_t *obj); + +#endif /* LUA_UCL_H_ */ diff --git a/include/ucl.h b/include/ucl.h index b40f11322508..1aac6a25332c 100644 --- a/include/ucl.h +++ b/include/ucl.h @@ -147,7 +147,8 @@ typedef enum ucl_emitter { typedef enum ucl_parser_flags { UCL_PARSER_KEY_LOWERCASE = 0x1, /**< Convert all keys to lower case */ UCL_PARSER_ZEROCOPY = 0x2, /**< Parse input in zero-copy mode if possible */ - UCL_PARSER_NO_TIME = 0x4 /**< Do not parse time and treat time values as strings */ + UCL_PARSER_NO_TIME = 0x4, /**< Do not parse time and treat time values as strings */ + UCL_PARSER_NO_IMPLICIT_ARRAYS = 0x8 /** Create explicit arrays instead of implicit ones */ } ucl_parser_flags_t; /** @@ -171,9 +172,12 @@ typedef enum ucl_string_flags { * Basic flags for an object */ typedef enum ucl_object_flags { - UCL_OBJECT_ALLOCATED_KEY = 1, /**< An object has key allocated internally */ - UCL_OBJECT_ALLOCATED_VALUE = 2, /**< An object has a string value allocated internally */ - UCL_OBJECT_NEED_KEY_ESCAPE = 4 /**< The key of an object need to be escaped on output */ + UCL_OBJECT_ALLOCATED_KEY = 0x1, /**< An object has key allocated internally */ + UCL_OBJECT_ALLOCATED_VALUE = 0x2, /**< An object has a string value allocated internally */ + UCL_OBJECT_NEED_KEY_ESCAPE = 0x4, /**< The key of an object need to be escaped on output */ + UCL_OBJECT_EPHEMERAL = 0x8, /**< Temporary object that does not need to be freed really */ + UCL_OBJECT_MULTILINE = 0x10, /**< String should be displayed as multiline string */ + UCL_OBJECT_MULTIVALUE = 0x20 /**< Object is a key with multiple values */ } ucl_object_flags_t; /** @@ -195,14 +199,21 @@ typedef struct ucl_object_s { const char *key; /**< Key of an object */ struct ucl_object_s *next; /**< Array handle */ struct ucl_object_s *prev; /**< Array handle */ - unsigned char* trash_stack[2]; /**< Pointer to allocated chunks */ - unsigned keylen; /**< Lenght of a key */ - unsigned len; /**< Size of an object */ - enum ucl_type type; /**< Real type */ - uint16_t ref; /**< Reference count */ + uint32_t keylen; /**< Lenght of a key */ + uint32_t len; /**< Size of an object */ + uint32_t ref; /**< Reference count */ uint16_t flags; /**< Object flags */ + uint16_t type; /**< Real type */ + unsigned char* trash_stack[2]; /**< Pointer to allocated chunks */ } ucl_object_t; +/** + * Destructor type for userdata objects + * @param ud user specified data pointer + */ +typedef void (*ucl_userdata_dtor)(void *ud); +typedef const char* (*ucl_userdata_emitter)(void *ud); + /** @} */ /** @@ -238,6 +249,31 @@ UCL_EXTERN ucl_object_t* ucl_object_new (void) UCL_WARN_UNUSED_RESULT; */ UCL_EXTERN ucl_object_t* ucl_object_typed_new (ucl_type_t type) UCL_WARN_UNUSED_RESULT; +/** + * Create new object with type and priority specified + * @param type type of a new object + * @param priority priority of an object + * @return new object + */ +UCL_EXTERN ucl_object_t* ucl_object_new_full (ucl_type_t type, unsigned priority) + UCL_WARN_UNUSED_RESULT; + +/** + * Create new object with userdata dtor + * @param dtor destructor function + * @return new object + */ +UCL_EXTERN ucl_object_t* ucl_object_new_userdata (ucl_userdata_dtor dtor, + ucl_userdata_emitter emitter) UCL_WARN_UNUSED_RESULT; + +/** + * Perform deep copy of an object copying everything + * @param other object to copy + * @return new object with refcount equal to 1 + */ +UCL_EXTERN ucl_object_t * ucl_object_copy (const ucl_object_t *other) + UCL_WARN_UNUSED_RESULT; + /** * Return the type of an object * @return the object type @@ -293,7 +329,7 @@ UCL_EXTERN ucl_object_t* ucl_object_frombool (bool bv) UCL_WARN_UNUSED_RESULT; /** * Insert a object 'elt' to the hash 'top' and associate it with key 'key' - * @param top destination object (will be created automatically if top is NULL) + * @param top destination object (must be of type UCL_OBJECT) * @param elt element to insert (must NOT be NULL) * @param key key to associate with this object (either const or preallocated) * @param keylen length of the key (or 0 for NULL terminated keys) @@ -306,7 +342,7 @@ UCL_EXTERN bool ucl_object_insert_key (ucl_object_t *top, ucl_object_t *elt, /** * Replace a object 'elt' to the hash 'top' and associate it with key 'key', old object will be unrefed, * if no object has been found this function works like ucl_object_insert_key() - * @param top destination object (will be created automatically if top is NULL) + * @param top destination object (must be of type UCL_OBJECT) * @param elt element to insert (must NOT be NULL) * @param key key to associate with this object (either const or preallocated) * @param keylen length of the key (or 0 for NULL terminated keys) @@ -316,6 +352,15 @@ UCL_EXTERN bool ucl_object_insert_key (ucl_object_t *top, ucl_object_t *elt, UCL_EXTERN bool ucl_object_replace_key (ucl_object_t *top, ucl_object_t *elt, const char *key, size_t keylen, bool copy_key); +/** + * Merge the keys from one object to another object. Overwrite on conflict + * @param top destination object (must be of type UCL_OBJECT) + * @param elt element to insert (must be of type UCL_OBJECT) + * @param copy copy rather than reference the elements + * @return true if all keys have been merged + */ +UCL_EXTERN bool ucl_object_merge (ucl_object_t *top, ucl_object_t *elt, bool copy); + /** * Delete a object associated with key 'key', old object will be unrefered, * @param top object @@ -335,8 +380,9 @@ UCL_EXTERN bool ucl_object_delete_key (ucl_object_t *top, /** - * Delete key from `top` object returning the object deleted. This object is not - * released + * Removes `key` from `top` object, returning the object that was removed. This + * object is not released, caller must unref the returned object when it is no + * longer needed. * @param top object * @param key key to remove * @param keylen length of the key (or 0 for NULL terminated keys) @@ -346,8 +392,9 @@ UCL_EXTERN ucl_object_t* ucl_object_pop_keyl (ucl_object_t *top, const char *key size_t keylen) UCL_WARN_UNUSED_RESULT; /** - * Delete key from `top` object returning the object deleted. This object is not - * released + * Removes `key` from `top` object returning the object that was removed. This + * object is not released, caller must unref the returned object when it is no + * longer needed. * @param top object * @param key key to remove * @return removed object or NULL if object has not been found @@ -356,9 +403,9 @@ UCL_EXTERN ucl_object_t* ucl_object_pop_key (ucl_object_t *top, const char *key) UCL_WARN_UNUSED_RESULT; /** - * Insert a object 'elt' to the hash 'top' and associate it with key 'key', if the specified key exist, - * try to merge its content - * @param top destination object (will be created automatically if top is NULL) + * Insert a object 'elt' to the hash 'top' and associate it with key 'key', if + * the specified key exist, try to merge its content + * @param top destination object (must be of type UCL_OBJECT) * @param elt element to insert (must NOT be NULL) * @param key key to associate with this object (either const or preallocated) * @param keylen length of the key (or 0 for NULL terminated keys) @@ -369,8 +416,8 @@ UCL_EXTERN bool ucl_object_insert_key_merged (ucl_object_t *top, ucl_object_t *e const char *key, size_t keylen, bool copy_key); /** - * Append an element to the front of array object - * @param top destination object (will be created automatically if top is NULL) + * Append an element to the end of array object + * @param top destination object (must NOT be NULL) * @param elt element to append (must NOT be NULL) * @return true if value has been inserted */ @@ -379,7 +426,7 @@ UCL_EXTERN bool ucl_array_append (ucl_object_t *top, /** * Append an element to the start of array object - * @param top destination object (will be created automatically if top is NULL) + * @param top destination object (must NOT be NULL) * @param elt element to append (must NOT be NULL) * @return true if value has been inserted */ @@ -387,8 +434,19 @@ UCL_EXTERN bool ucl_array_prepend (ucl_object_t *top, ucl_object_t *elt); /** - * Removes an element `elt` from the array `top`. Caller must unref the returned object when it is not - * needed. + * Merge all elements of second array into the first array + * @param top destination array (must be of type UCL_ARRAY) + * @param elt array to copy elements from (must be of type UCL_ARRAY) + * @param copy copy elements instead of referencing them + * @return true if arrays were merged + */ +UCL_EXTERN bool ucl_array_merge (ucl_object_t *top, ucl_object_t *elt, + bool copy); + +/** + * Removes an element `elt` from the array `top`, returning the object that was + * removed. This object is not released, caller must unref the returned object + * when it is no longer needed. * @param top array ucl object * @param elt element to remove * @return removed element or NULL if `top` is NULL or not an array @@ -411,35 +469,50 @@ UCL_EXTERN const ucl_object_t* ucl_array_head (const ucl_object_t *top); UCL_EXTERN const ucl_object_t* ucl_array_tail (const ucl_object_t *top); /** - * Removes the last element from the array `top`. Caller must unref the returned object when it is not - * needed. + * Removes the last element from the array `top`, returning the object that was + * removed. This object is not released, caller must unref the returned object + * when it is no longer needed. * @param top array ucl object * @return removed element or NULL if `top` is NULL or not an array */ UCL_EXTERN ucl_object_t* ucl_array_pop_last (ucl_object_t *top); /** - * Return object identified by an index of the array `top` - * @param obj object to get a key from (must be of type UCL_ARRAY) - * @param index index to return - * @return object at the specified index or NULL if index is not found - */ -UCL_EXTERN const ucl_object_t* ucl_array_find_index (const ucl_object_t *top, - unsigned int index); - -/** - * Removes the first element from the array `top`. Caller must unref the returned object when it is not - * needed. + * Removes the first element from the array `top`, returning the object that was + * removed. This object is not released, caller must unref the returned object + * when it is no longer needed. * @param top array ucl object * @return removed element or NULL if `top` is NULL or not an array */ UCL_EXTERN ucl_object_t* ucl_array_pop_first (ucl_object_t *top); +/** + * Return object identified by index of the array `top` + * @param top object to get a key from (must be of type UCL_ARRAY) + * @param index array index to return + * @return object at the specified index or NULL if index is not found + */ +UCL_EXTERN const ucl_object_t* ucl_array_find_index (const ucl_object_t *top, + unsigned int index); + +/** + * Replace an element in an array with a different element, returning the object + * that was replaced. This object is not released, caller must unref the + * returned object when it is no longer needed. + * @param top destination object (must be of type UCL_ARRAY) + * @param elt element to append (must NOT be NULL) + * @param index array index in destination to overwrite with elt + * @return object that was replaced or NULL if index is not found + */ +ucl_object_t * +ucl_array_replace_index (ucl_object_t *top, ucl_object_t *elt, + unsigned int index); + /** * Append a element to another element forming an implicit array * @param head head to append (may be NULL) * @param elt new element - * @return true if element has been inserted + * @return the new implicit array */ UCL_EXTERN ucl_object_t * ucl_elt_append (ucl_object_t *head, ucl_object_t *elt); @@ -533,7 +606,7 @@ UCL_EXTERN const char* ucl_object_tolstring (const ucl_object_t *obj, size_t *tl * Return object identified by a key in the specified object * @param obj object to get a key from (must be of type UCL_OBJECT) * @param key key to search - * @return object matched the specified key or NULL if key is not found + * @return object matching the specified key or NULL if key was not found */ UCL_EXTERN const ucl_object_t* ucl_object_find_key (const ucl_object_t *obj, const char *key); @@ -543,7 +616,7 @@ UCL_EXTERN const ucl_object_t* ucl_object_find_key (const ucl_object_t *obj, * @param obj object to get a key from (must be of type UCL_OBJECT) * @param key key to search * @param klen length of a key - * @return object matched the specified key or NULL if key is not found + * @return object matching the specified key or NULL if key was not found */ UCL_EXTERN const ucl_object_t* ucl_object_find_keyl (const ucl_object_t *obj, const char *key, size_t klen); @@ -575,6 +648,7 @@ UCL_EXTERN const char* ucl_object_keyl (const ucl_object_t *obj, size_t *len); /** * Increase reference count for an object * @param obj object to ref + * @return the referenced object */ UCL_EXTERN ucl_object_t* ucl_object_ref (const ucl_object_t *obj); @@ -611,6 +685,21 @@ UCL_EXTERN int ucl_object_compare (const ucl_object_t *o1, UCL_EXTERN void ucl_object_array_sort (ucl_object_t *ar, int (*cmp)(const ucl_object_t *o1, const ucl_object_t *o2)); +/** + * Get the priority for specific UCL object + * @param obj any ucl object + * @return priority of an object + */ +UCL_EXTERN unsigned int ucl_object_get_priority (const ucl_object_t *obj); + +/** + * Set explicit priority of an object. + * @param obj any ucl object + * @param priority new priroity value (only 4 least significant bits are considred) + */ +UCL_EXTERN void ucl_object_set_priority (ucl_object_t *obj, + unsigned int priority); + /** * Opaque iterator object */ @@ -640,11 +729,14 @@ UCL_EXTERN const ucl_object_t* ucl_iterate_object (const ucl_object_t *obj, * Macro handler for a parser * @param data the content of macro * @param len the length of content + * @param arguments arguments object * @param ud opaque user data * @param err error pointer * @return true if macro has been parsed */ -typedef bool (*ucl_macro_handler) (const unsigned char *data, size_t len, void* ud); +typedef bool (*ucl_macro_handler) (const unsigned char *data, size_t len, + const ucl_object_t *arguments, + void* ud); /* Opaque parser */ struct ucl_parser; @@ -702,12 +794,23 @@ UCL_EXTERN void ucl_parser_set_variables_handler (struct ucl_parser *parser, * @param parser parser structure * @param data the pointer to the beginning of a chunk * @param len the length of a chunk - * @param err if *err is NULL it is set to parser error * @return true if chunk has been added and false in case of error */ UCL_EXTERN bool ucl_parser_add_chunk (struct ucl_parser *parser, const unsigned char *data, size_t len); +/** + * Load new chunk to a parser with the specified priority + * @param parser parser structure + * @param data the pointer to the beginning of a chunk + * @param len the length of a chunk + * @param priority the desired priority of a chunk (only 4 least significant bits + * are considered for this parameter) + * @return true if chunk has been added and false in case of error + */ +UCL_EXTERN bool ucl_parser_add_chunk_priority (struct ucl_parser *parser, + const unsigned char *data, size_t len, unsigned priority); + /** * Load ucl object from a string * @param parser parser structure @@ -835,7 +938,7 @@ struct ucl_emitter_context { /** A set of output operations */ const struct ucl_emitter_operations *ops; /** Current amount of indent tabs */ - unsigned int ident; + unsigned int indent; /** Top level object */ const ucl_object_t *top; /** The rest of context */ diff --git a/libucl.pc.in b/libucl.pc.in index 975462d21fdc..3433fa9d8b1c 100644 --- a/libucl.pc.in +++ b/libucl.pc.in @@ -7,5 +7,5 @@ Name: LibUCL Description: Universal configuration library Version: @UCL_VERSION@ Libs: -L${libdir} -lucl -Libs.private: @LIBS_EXTRA@ +Libs.private: @LIBS_EXTRA@ @LUA_LIB@ Cflags: -I${includedir}/ diff --git a/lua/Makefile.am b/lua/Makefile.am new file mode 100644 index 000000000000..95beafbfc94e --- /dev/null +++ b/lua/Makefile.am @@ -0,0 +1,26 @@ +ucl_common_cflags= -I$(top_srcdir)/src \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/uthash \ + -Wall -W -Wno-unused-parameter -Wno-pointer-sign +luaexec_LTLIBRARIES= ucl.la +ucl_la_SOURCES= lua_ucl.c +ucl_la_CFLAGS= $(ucl_common_cflags) \ + @LUA_INCLUDE@ +ucl_la_LDFLAGS = -module -export-dynamic -avoid-version +ucl_la_LIBADD= $(top_srcdir)/src/libucl.la \ + @LIBFETCH_LIBS@ \ + @LIBCRYPTO_LIB@ \ + @LIBREGEX_LIB@ \ + @CURL_LIBS@ \ + @LUA_LIB@ + +include_HEADERS= $(top_srcdir)/include/lua_ucl.h + +ROCKSPEC = $(PACKAGE)-$(VERSION)-1.rockspec +EXTRA_DIST = $(PACKAGE).rockspec.in \ + test.lua +DISTCLEANFILES = $(PACKAGE).rockspec + +$(ROCKSPEC): $(PACKAGE).rockspec dist + sed -e 's/@MD5@/'`$(MD5SUM) $(distdir).tar.gz | \ + cut -d " " -f 1`'/g' < $(PACKAGE).rockspec > $@ \ No newline at end of file diff --git a/lua/libucl.rockspec.in b/lua/libucl.rockspec.in new file mode 100644 index 000000000000..52f39176a7bd --- /dev/null +++ b/lua/libucl.rockspec.in @@ -0,0 +1,26 @@ +package="@PACKAGE@" +version="@VERSION@-1" +source = { + url = "https://github.com/downloads/vstakhov/@PACKAGE@/@PACKAGE@-@VERSION@.tar.gz", + md5 = "@MD5@", + dir = "@PACKAGE@-@VERSION@" +} +description = { + summary = "UCL - json like configuration language", + detailed = [[ + UCL is heavily infused by nginx configuration as the example + of a convenient configuration system. + However, UCL is fully compatible with JSON format and is able + to parse json files. + ]], + homepage = "http://github.com/vstakhov/@PACKAGE@/", + license = "" +} +dependencies = { + "lua >= 5.1" +} +build = { + type = "command", + build_command = "LUA=$(LUA) CPPFLAGS=-I$(LUA_INCDIR) ./configure --prefix=$(PREFIX) --libdir=$(LIBDIR) --datadir=$(LUADIR) && make clean && make", + install_command = "make install" +} diff --git a/lua/lua_ucl.c b/lua/lua_ucl.c new file mode 100644 index 000000000000..682b0b559fd3 --- /dev/null +++ b/lua/lua_ucl.c @@ -0,0 +1,820 @@ +/* Copyright (c) 2014, Vsevolod Stakhov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * + * THIS SOFTWARE IS PROVIDED ''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 AUTHOR 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. + */ + +/** + * @file lua ucl bindings + */ + +#include "ucl.h" +#include "ucl_internal.h" +#include "lua_ucl.h" +#include + +/*** + * @module ucl + * This lua module allows to parse objects from strings and to store data into + * ucl objects. It uses `libucl` C library to parse and manipulate with ucl objects. + * @example +local ucl = require("ucl") + +local parser = ucl.parser() +local res,err = parser:parse_string('{key=value}') + +if not res then + print('parser error: ' .. err) +else + local obj = parser:get_object() + local got = ucl.to_format(obj, 'json') +endif + +local table = { + str = 'value', + num = 100500, + null = ucl.null, + func = function () + return 'huh' + end +} + +print(ucl.to_format(table, 'ucl')) +-- Output: +--[[ +num = 100500; +str = "value"; +null = null; +func = "huh"; +--]] + */ + +#define PARSER_META "ucl.parser.meta" +#define EMITTER_META "ucl.emitter.meta" +#define NULL_META "null.emitter.meta" + +static int ucl_object_lua_push_array (lua_State *L, const ucl_object_t *obj); +static int ucl_object_lua_push_scalar (lua_State *L, const ucl_object_t *obj, bool allow_array); +static ucl_object_t* ucl_object_lua_fromtable (lua_State *L, int idx); +static ucl_object_t* ucl_object_lua_fromelt (lua_State *L, int idx); + +static void *ucl_null; + +/** + * Push a single element of an object to lua + * @param L + * @param key + * @param obj + */ +static void +ucl_object_lua_push_element (lua_State *L, const char *key, + const ucl_object_t *obj) +{ + lua_pushstring (L, key); + ucl_object_push_lua (L, obj, true); + lua_settable (L, -3); +} + +static void +lua_ucl_userdata_dtor (void *ud) +{ + struct ucl_lua_funcdata *fd = (struct ucl_lua_funcdata *)ud; + + luaL_unref (fd->L, LUA_REGISTRYINDEX, fd->idx); + if (fd->ret != NULL) { + free (fd->ret); + } + free (fd); +} + +static const char * +lua_ucl_userdata_emitter (void *ud) +{ + struct ucl_lua_funcdata *fd = (struct ucl_lua_funcdata *)ud; + const char *out = ""; + + lua_rawgeti (fd->L, LUA_REGISTRYINDEX, fd->idx); + + lua_pcall (fd->L, 0, 1, 0); + out = lua_tostring (fd->L, -1); + + if (out != NULL) { + /* We need to store temporary string in a more appropriate place */ + if (fd->ret) { + free (fd->ret); + } + fd->ret = strdup (out); + } + + lua_settop (fd->L, 0); + + return fd->ret; +} + +/** + * Push a single object to lua + * @param L + * @param obj + * @return + */ +static int +ucl_object_lua_push_object (lua_State *L, const ucl_object_t *obj, + bool allow_array) +{ + const ucl_object_t *cur; + ucl_object_iter_t it = NULL; + int nelt = 0; + + if (allow_array && obj->next != NULL) { + /* Actually we need to push this as an array */ + return ucl_object_lua_push_array (L, obj); + } + + /* Optimize allocation by preallocation of table */ + while (ucl_iterate_object (obj, &it, true) != NULL) { + nelt ++; + } + + lua_createtable (L, 0, nelt); + it = NULL; + + while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) { + ucl_object_lua_push_element (L, ucl_object_key (cur), cur); + } + + return 1; +} + +/** + * Push an array to lua as table indexed by integers + * @param L + * @param obj + * @return + */ +static int +ucl_object_lua_push_array (lua_State *L, const ucl_object_t *obj) +{ + const ucl_object_t *cur; + int i = 1, nelt = 0; + + /* Optimize allocation by preallocation of table */ + LL_FOREACH (obj, cur) { + nelt ++; + } + + lua_createtable (L, nelt, 0); + + LL_FOREACH (obj, cur) { + ucl_object_push_lua (L, cur, false); + lua_rawseti (L, -2, i); + i ++; + } + + return 1; +} + +/** + * Push a simple object to lua depending on its actual type + */ +static int +ucl_object_lua_push_scalar (lua_State *L, const ucl_object_t *obj, + bool allow_array) +{ + struct ucl_lua_funcdata *fd; + + if (allow_array && obj->next != NULL) { + /* Actually we need to push this as an array */ + return ucl_object_lua_push_array (L, obj); + } + + switch (obj->type) { + case UCL_BOOLEAN: + lua_pushboolean (L, ucl_obj_toboolean (obj)); + break; + case UCL_STRING: + lua_pushstring (L, ucl_obj_tostring (obj)); + break; + case UCL_INT: +#if LUA_VERSION_NUM >= 501 + lua_pushinteger (L, ucl_obj_toint (obj)); +#else + lua_pushnumber (L, ucl_obj_toint (obj)); +#endif + break; + case UCL_FLOAT: + case UCL_TIME: + lua_pushnumber (L, ucl_obj_todouble (obj)); + break; + case UCL_NULL: + lua_getfield (L, LUA_REGISTRYINDEX, "ucl.null"); + break; + case UCL_USERDATA: + fd = (struct ucl_lua_funcdata *)obj->value.ud; + lua_rawgeti (L, LUA_REGISTRYINDEX, fd->idx); + break; + default: + lua_pushnil (L); + break; + } + + return 1; +} + +/*** + * @function ucl_object_push_lua(L, obj, allow_array) + * This is a `C` function to push `UCL` object as lua variable. This function + * converts `obj` to lua representation using the following conversions: + * + * - *scalar* values are directly presented by lua objects + * - *userdata* values are converted to lua function objects using `LUA_REGISTRYINDEX`, + * this can be used to pass functions from lua to c and vice-versa + * - *arrays* are converted to lua tables with numeric indicies suitable for `ipairs` iterations + * - *objects* are converted to lua tables with string indicies + * @param {lua_State} L lua state pointer + * @param {ucl_object_t} obj object to push + * @param {bool} allow_array expand implicit arrays (should be true for all but partial arrays) + * @return {int} `1` if an object is pushed to lua + */ +int +ucl_object_push_lua (lua_State *L, const ucl_object_t *obj, bool allow_array) +{ + switch (obj->type) { + case UCL_OBJECT: + return ucl_object_lua_push_object (L, obj, allow_array); + case UCL_ARRAY: + return ucl_object_lua_push_array (L, obj->value.av); + default: + return ucl_object_lua_push_scalar (L, obj, allow_array); + } +} + +/** + * Parse lua table into object top + * @param L + * @param top + * @param idx + */ +static ucl_object_t * +ucl_object_lua_fromtable (lua_State *L, int idx) +{ + ucl_object_t *obj, *top = NULL; + size_t keylen; + const char *k; + bool is_array = true; + int max = INT_MIN; + + if (idx < 0) { + /* For negative indicies we want to invert them */ + idx = lua_gettop (L) + idx + 1; + } + /* Check for array */ + lua_pushnil (L); + while (lua_next (L, idx) != 0) { + if (lua_type (L, -2) == LUA_TNUMBER) { + double num = lua_tonumber (L, -2); + if (num == (int)num) { + if (num > max) { + max = num; + } + } + else { + /* Keys are not integer */ + lua_pop (L, 2); + is_array = false; + break; + } + } + else { + /* Keys are not numeric */ + lua_pop (L, 2); + is_array = false; + break; + } + lua_pop (L, 1); + } + + /* Table iterate */ + if (is_array) { + int i; + + top = ucl_object_typed_new (UCL_ARRAY); + for (i = 1; i <= max; i ++) { + lua_pushinteger (L, i); + lua_gettable (L, idx); + obj = ucl_object_lua_fromelt (L, lua_gettop (L)); + if (obj != NULL) { + ucl_array_append (top, obj); + } + } + } + else { + lua_pushnil (L); + top = ucl_object_typed_new (UCL_OBJECT); + while (lua_next (L, idx) != 0) { + /* copy key to avoid modifications */ + k = lua_tolstring (L, -2, &keylen); + obj = ucl_object_lua_fromelt (L, lua_gettop (L)); + + if (obj != NULL) { + ucl_object_insert_key (top, obj, k, keylen, true); + } + lua_pop (L, 1); + } + } + + return top; +} + +/** + * Get a single element from lua to object obj + * @param L + * @param obj + * @param idx + */ +static ucl_object_t * +ucl_object_lua_fromelt (lua_State *L, int idx) +{ + int type; + double num; + ucl_object_t *obj = NULL; + struct ucl_lua_funcdata *fd; + + type = lua_type (L, idx); + + switch (type) { + case LUA_TSTRING: + obj = ucl_object_fromstring_common (lua_tostring (L, idx), 0, 0); + break; + case LUA_TNUMBER: + num = lua_tonumber (L, idx); + if (num == (int64_t)num) { + obj = ucl_object_fromint (num); + } + else { + obj = ucl_object_fromdouble (num); + } + break; + case LUA_TBOOLEAN: + obj = ucl_object_frombool (lua_toboolean (L, idx)); + break; + case LUA_TUSERDATA: + if (lua_topointer (L, idx) == ucl_null) { + obj = ucl_object_typed_new (UCL_NULL); + } + break; + case LUA_TTABLE: + case LUA_TFUNCTION: + case LUA_TTHREAD: + if (luaL_getmetafield (L, idx, "__gen_ucl")) { + if (lua_isfunction (L, -1)) { + lua_settop (L, 3); /* gen, obj, func */ + lua_insert (L, 1); /* func, gen, obj */ + lua_insert (L, 2); /* func, obj, gen */ + lua_call(L, 2, 1); + obj = ucl_object_lua_fromelt (L, 1); + } + lua_pop (L, 2); + } + else { + if (type == LUA_TTABLE) { + obj = ucl_object_lua_fromtable (L, idx); + } + else if (type == LUA_TFUNCTION) { + fd = malloc (sizeof (*fd)); + if (fd != NULL) { + lua_pushvalue (L, idx); + fd->L = L; + fd->ret = NULL; + fd->idx = luaL_ref (L, LUA_REGISTRYINDEX); + + obj = ucl_object_new_userdata (lua_ucl_userdata_dtor, + lua_ucl_userdata_emitter); + obj->type = UCL_USERDATA; + obj->value.ud = (void *)fd; + } + } + } + break; + } + + return obj; +} + +/** + * @function ucl_object_lua_import(L, idx) + * Extracts ucl object from lua variable at `idx` position, + * @see ucl_object_push_lua for conversion definitions + * @param {lua_state} L lua state machine pointer + * @param {int} idx index where the source variable is placed + * @return {ucl_object_t} new ucl object extracted from lua variable. Reference count of this object is 1, + * this object thus needs to be unref'ed after usage. + */ +ucl_object_t * +ucl_object_lua_import (lua_State *L, int idx) +{ + ucl_object_t *obj; + int t; + + t = lua_type (L, idx); + switch (t) { + case LUA_TTABLE: + obj = ucl_object_lua_fromtable (L, idx); + break; + default: + obj = ucl_object_lua_fromelt (L, idx); + break; + } + + return obj; +} + +static int +lua_ucl_parser_init (lua_State *L) +{ + struct ucl_parser *parser, **pparser; + int flags = 0; + + if (lua_gettop (L) >= 1) { + flags = lua_tonumber (L, 1); + } + + parser = ucl_parser_new (flags); + if (parser == NULL) { + lua_pushnil (L); + } + + pparser = lua_newuserdata (L, sizeof (parser)); + *pparser = parser; + luaL_getmetatable (L, PARSER_META); + lua_setmetatable (L, -2); + + return 1; +} + +static struct ucl_parser * +lua_ucl_parser_get (lua_State *L, int index) +{ + return *((struct ucl_parser **) luaL_checkudata(L, index, PARSER_META)); +} + +/*** + * @method parser:parse_file(name) + * Parse UCL object from file. + * @param {string} name filename to parse + * @return {bool[, string]} if res is `true` then file has been parsed successfully, otherwise an error string is also returned +@example +local parser = ucl.parser() +local res,err = parser:parse_file('/some/file.conf') + +if not res then + print('parser error: ' .. err) +else + -- Do something with object +end + */ +static int +lua_ucl_parser_parse_file (lua_State *L) +{ + struct ucl_parser *parser; + const char *file; + int ret = 2; + + parser = lua_ucl_parser_get (L, 1); + file = luaL_checkstring (L, 2); + + if (parser != NULL && file != NULL) { + if (ucl_parser_add_file (parser, file)) { + lua_pushboolean (L, true); + ret = 1; + } + else { + lua_pushboolean (L, false); + lua_pushstring (L, ucl_parser_get_error (parser)); + } + } + else { + lua_pushboolean (L, false); + lua_pushstring (L, "invalid arguments"); + } + + return ret; +} + +/*** + * @method parser:parse_string(input) + * Parse UCL object from file. + * @param {string} input string to parse + * @return {bool[, string]} if res is `true` then file has been parsed successfully, otherwise an error string is also returned + */ +static int +lua_ucl_parser_parse_string (lua_State *L) +{ + struct ucl_parser *parser; + const char *string; + size_t llen; + int ret = 2; + + parser = lua_ucl_parser_get (L, 1); + string = luaL_checklstring (L, 2, &llen); + + if (parser != NULL && string != NULL) { + if (ucl_parser_add_chunk (parser, (const unsigned char *)string, llen)) { + lua_pushboolean (L, true); + ret = 1; + } + else { + lua_pushboolean (L, false); + lua_pushstring (L, ucl_parser_get_error (parser)); + } + } + else { + lua_pushboolean (L, false); + lua_pushstring (L, "invalid arguments"); + } + + return ret; +} + +/*** + * @method parser:get_object() + * Get top object from parser and export it to lua representation. + * @return {variant or nil} ucl object as lua native variable + */ +static int +lua_ucl_parser_get_object (lua_State *L) +{ + struct ucl_parser *parser; + ucl_object_t *obj; + int ret = 1; + + parser = lua_ucl_parser_get (L, 1); + obj = ucl_parser_get_object (parser); + + if (obj != NULL) { + ret = ucl_object_push_lua (L, obj, false); + /* no need to keep reference */ + ucl_object_unref (obj); + } + else { + lua_pushnil (L); + } + + return ret; +} + +static int +lua_ucl_parser_gc (lua_State *L) +{ + struct ucl_parser *parser; + + parser = lua_ucl_parser_get (L, 1); + ucl_parser_free (parser); + + return 0; +} + +static void +lua_ucl_parser_mt (lua_State *L) +{ + luaL_newmetatable (L, PARSER_META); + + lua_pushvalue(L, -1); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction (L, lua_ucl_parser_gc); + lua_setfield (L, -2, "__gc"); + + lua_pushcfunction (L, lua_ucl_parser_parse_file); + lua_setfield (L, -2, "parse_file"); + + lua_pushcfunction (L, lua_ucl_parser_parse_string); + lua_setfield (L, -2, "parse_string"); + + lua_pushcfunction (L, lua_ucl_parser_get_object); + lua_setfield (L, -2, "get_object"); + + lua_pop (L, 1); +} + +static int +lua_ucl_to_string (lua_State *L, const ucl_object_t *obj, enum ucl_emitter type) +{ + unsigned char *result; + + result = ucl_object_emit (obj, type); + + if (result != NULL) { + lua_pushstring (L, (const char *)result); + free (result); + } + else { + lua_pushnil (L); + } + + return 1; +} + +static int +lua_ucl_to_json (lua_State *L) +{ + ucl_object_t *obj; + int format = UCL_EMIT_JSON; + + if (lua_gettop (L) > 1) { + if (lua_toboolean (L, 2)) { + format = UCL_EMIT_JSON_COMPACT; + } + } + + obj = ucl_object_lua_import (L, 1); + if (obj != NULL) { + lua_ucl_to_string (L, obj, format); + ucl_object_unref (obj); + } + else { + lua_pushnil (L); + } + + return 1; +} + +static int +lua_ucl_to_config (lua_State *L) +{ + ucl_object_t *obj; + + obj = ucl_object_lua_import (L, 1); + if (obj != NULL) { + lua_ucl_to_string (L, obj, UCL_EMIT_CONFIG); + ucl_object_unref (obj); + } + else { + lua_pushnil (L); + } + + return 1; +} + +/*** + * @function ucl.to_format(var, format) + * Converts lua variable `var` to the specified `format`. Formats supported are: + * + * - `json` - fine printed json + * - `json-compact` - compacted json + * - `config` - fine printed configuration + * - `ucl` - same as `config` + * - `yaml` - embedded yaml + * + * If `var` contains function, they are called during output formatting and if + * they return string value, then this value is used for ouptut. + * @param {variant} var any sort of lua variable (if userdata then metafield `__to_ucl` is searched for output) + * @param {string} format any available format + * @return {string} string representation of `var` in the specific `format`. + * @example +local table = { + str = 'value', + num = 100500, + null = ucl.null, + func = function () + return 'huh' + end +} + +print(ucl.to_format(table, 'ucl')) +-- Output: +--[[ +num = 100500; +str = "value"; +null = null; +func = "huh"; +--]] + */ +static int +lua_ucl_to_format (lua_State *L) +{ + ucl_object_t *obj; + int format = UCL_EMIT_JSON; + + if (lua_gettop (L) > 1) { + if (lua_type (L, 2) == LUA_TNUMBER) { + format = lua_tonumber (L, 2); + if (format < 0 || format >= UCL_EMIT_YAML) { + lua_pushnil (L); + return 1; + } + } + else if (lua_type (L, 2) == LUA_TSTRING) { + const char *strtype = lua_tostring (L, 2); + + if (strcasecmp (strtype, "json") == 0) { + format = UCL_EMIT_JSON; + } + else if (strcasecmp (strtype, "json-compact") == 0) { + format = UCL_EMIT_JSON_COMPACT; + } + else if (strcasecmp (strtype, "yaml") == 0) { + format = UCL_EMIT_YAML; + } + else if (strcasecmp (strtype, "config") == 0 || + strcasecmp (strtype, "ucl") == 0) { + format = UCL_EMIT_CONFIG; + } + } + } + + obj = ucl_object_lua_import (L, 1); + if (obj != NULL) { + lua_ucl_to_string (L, obj, format); + ucl_object_unref (obj); + } + else { + lua_pushnil (L); + } + + return 1; +} + +static int +lua_ucl_null_tostring (lua_State* L) +{ + lua_pushstring (L, "null"); + return 1; +} + +static void +lua_ucl_null_mt (lua_State *L) +{ + luaL_newmetatable (L, NULL_META); + + lua_pushcfunction (L, lua_ucl_null_tostring); + lua_setfield (L, -2, "__tostring"); + + lua_pop (L, 1); +} + +int +luaopen_ucl (lua_State *L) +{ + lua_ucl_parser_mt (L); + lua_ucl_null_mt (L); + + /* Create the refs weak table: */ + lua_createtable (L, 0, 2); + lua_pushliteral (L, "v"); /* tbl, "v" */ + lua_setfield (L, -2, "__mode"); + lua_pushvalue (L, -1); /* tbl, tbl */ + lua_setmetatable (L, -2); /* tbl */ + lua_setfield (L, LUA_REGISTRYINDEX, "ucl.refs"); + + lua_newtable (L); + + lua_pushcfunction (L, lua_ucl_parser_init); + lua_setfield (L, -2, "parser"); + + lua_pushcfunction (L, lua_ucl_to_json); + lua_setfield (L, -2, "to_json"); + + lua_pushcfunction (L, lua_ucl_to_config); + lua_setfield (L, -2, "to_config"); + + lua_pushcfunction (L, lua_ucl_to_format); + lua_setfield (L, -2, "to_format"); + + ucl_null = lua_newuserdata (L, 0); + luaL_getmetatable (L, NULL_META); + lua_setmetatable (L, -2); + + lua_pushvalue (L, -1); + lua_setfield (L, LUA_REGISTRYINDEX, "ucl.null"); + + lua_setfield (L, -2, "null"); + + return 1; +} + +struct ucl_lua_funcdata* +ucl_object_toclosure (const ucl_object_t *obj) +{ + if (obj == NULL || obj->type != UCL_USERDATA) { + return NULL; + } + + return (struct ucl_lua_funcdata*)obj->value.ud; +} diff --git a/lua/test.lua b/lua/test.lua new file mode 100644 index 000000000000..1e7b3b3e0bdb --- /dev/null +++ b/lua/test.lua @@ -0,0 +1,48 @@ +local ucl = require("ucl") + +function test_simple() + local expect = + '['.. + '"float",1.5,'.. + '"integer",5,'.. + '"true",true,'.. + '"false",false,'.. + '"null",null,'.. + '"string","hello",'.. + '"array",[1,2],'.. + '"object",{"key":"value"}'.. + ']' + + -- Input to to_value matches the output of to_string: + local parser = ucl.parser() + local res,err = parser:parse_string(expect) + if not res then + print('parser error: ' .. err) + return 1 + end + + local obj = parser:get_object() + local got = ucl.to_json(obj, true) + if expect == got then + return 0 + else + print(expect .. " == " .. tostring(got)) + return 1 + end +end + +test_simple() + +local table = { + str = 'value', + num = 100500, + null = ucl.null, + func = function () + return 'huh' + end, + badfunc = function() + print("I'm bad") + end +} + +print(ucl.to_format(table, 'ucl')) diff --git a/m4/.gitignore b/m4/.gitignore new file mode 100644 index 000000000000..5e7d2734cfc6 --- /dev/null +++ b/m4/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/m4/ax_lua.m4 b/m4/ax_lua.m4 new file mode 100644 index 000000000000..7662f4f22d1b --- /dev/null +++ b/m4/ax_lua.m4 @@ -0,0 +1,606 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_lua.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_LUA[([MINIMUM-VERSION], [TOO-BIG-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])] +# AX_LUA_HEADERS[([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])] +# AX_LUA_LIBS[([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])] +# AX_LUA_READLINE[([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])] +# +# DESCRIPTION +# +# Detect a Lua interpreter, optionally specifying a minimum and maximum +# version number. Set up important Lua paths, such as the directories in +# which to install scripts and modules (shared libraries). +# +# Also detect Lua headers and libraries. The Lua version contained in the +# header is checked to match the Lua interpreter version exactly. When +# searching for Lua libraries, the version number is used as a suffix. +# This is done with the goal of supporting multiple Lua installs (5.1 and +# 5.2 side-by-side). +# +# A note on compatibility with previous versions: This file has been +# mostly rewritten for serial 18. Most developers should be able to use +# these macros without needing to modify configure.ac. Care has been taken +# to preserve each macro's behavior, but there are some differences: +# +# 1) AX_WITH_LUA is deprecated; it now expands to the exact same thing as +# AX_PROG_LUA with no arguments. +# +# 2) AX_LUA_HEADERS now checks that the version number defined in lua.h +# matches the interpreter version. AX_LUA_HEADERS_VERSION is therefore +# unnecessary, so it is deprecated and does not expand to anything. +# +# 3) The configure flag --with-lua-suffix no longer exists; the user +# should instead specify the LUA precious variable on the command line. +# See the AX_PROG_LUA description for details. +# +# Please read the macro descriptions below for more information. +# +# This file was inspired by Andrew Dalke's and James Henstridge's +# python.m4 and Tom Payne's, Matthieu Moy's, and Reuben Thomas's ax_lua.m4 +# (serial 17). Basically, this file is a mash-up of those two files. I +# like to think it combines the best of the two! +# +# AX_PROG_LUA: Search for the Lua interpreter, and set up important Lua +# paths. Adds precious variable LUA, which may contain the path of the Lua +# interpreter. If LUA is blank, the user's path is searched for an +# suitable interpreter. +# +# If MINIMUM-VERSION is supplied, then only Lua interpreters with a +# version number greater or equal to MINIMUM-VERSION will be accepted. If +# TOO-BIG- VERSION is also supplied, then only Lua interpreters with a +# version number greater or equal to MINIMUM-VERSION and less than +# TOO-BIG-VERSION will be accepted. +# +# The Lua version number, LUA_VERSION, is found from the interpreter, and +# substituted. LUA_PLATFORM is also found, but not currently supported (no +# standard representation). +# +# Finally, the macro finds four paths: +# +# luadir Directory to install Lua scripts. +# pkgluadir $luadir/$PACKAGE +# luaexecdir Directory to install Lua modules. +# pkgluaexecdir $luaexecdir/$PACKAGE +# +# These paths a found based on $prefix, $exec_prefix, Lua's package.path, +# and package.cpath. The first path of package.path beginning with $prefix +# is selected as luadir. The first path of package.cpath beginning with +# $exec_prefix is used as luaexecdir. This should work on all reasonable +# Lua installations. If a path cannot be determined, a default path is +# used. Of course, the user can override these later when invoking make. +# +# luadir Default: $prefix/share/lua/$LUA_VERSION +# luaexecdir Default: $exec_prefix/lib/lua/$LUA_VERSION +# +# These directories can be used by Automake as install destinations. The +# variable name minus 'dir' needs to be used as a prefix to the +# appropriate Automake primary, e.g. lua_SCRIPS or luaexec_LIBRARIES. +# +# If an acceptable Lua interpreter is found, then ACTION-IF-FOUND is +# performed, otherwise ACTION-IF-NOT-FOUND is preformed. If ACTION-IF-NOT- +# FOUND is blank, then it will default to printing an error. To prevent +# the default behavior, give ':' as an action. +# +# AX_LUA_HEADERS: Search for Lua headers. Requires that AX_PROG_LUA be +# expanded before this macro. Adds precious variable LUA_INCLUDE, which +# may contain Lua specific include flags, e.g. -I/usr/include/lua5.1. If +# LUA_INCLUDE is blank, then this macro will attempt to find suitable +# flags. +# +# LUA_INCLUDE can be used by Automake to compile Lua modules or +# executables with embedded interpreters. The *_CPPFLAGS variables should +# be used for this purpose, e.g. myprog_CPPFLAGS = $(LUA_INCLUDE). +# +# This macro searches for the header lua.h (and others). The search is +# performed with a combination of CPPFLAGS, CPATH, etc, and LUA_INCLUDE. +# If the search is unsuccessful, then some common directories are tried. +# If the headers are then found, then LUA_INCLUDE is set accordingly. +# +# The paths automatically searched are: +# +# * /usr/include/luaX.Y +# * /usr/include/lua/X.Y +# * /usr/include/luaXY +# * /usr/local/include/luaX.Y +# * /usr/local/include/lua-X.Y +# * /usr/local/include/lua/X.Y +# * /usr/local/include/luaXY +# +# (Where X.Y is the Lua version number, e.g. 5.1.) +# +# The Lua version number found in the headers is always checked to match +# the Lua interpreter's version number. Lua headers with mismatched +# version numbers are not accepted. +# +# If headers are found, then ACTION-IF-FOUND is performed, otherwise +# ACTION-IF-NOT-FOUND is performed. If ACTION-IF-NOT-FOUND is blank, then +# it will default to printing an error. To prevent the default behavior, +# set the action to ':'. +# +# AX_LUA_LIBS: Search for Lua libraries. Requires that AX_PROG_LUA be +# expanded before this macro. Adds precious variable LUA_LIB, which may +# contain Lua specific linker flags, e.g. -llua5.1. If LUA_LIB is blank, +# then this macro will attempt to find suitable flags. +# +# LUA_LIB can be used by Automake to link Lua modules or executables with +# embedded interpreters. The *_LIBADD and *_LDADD variables should be used +# for this purpose, e.g. mymod_LIBADD = $(LUA_LIB). +# +# This macro searches for the Lua library. More technically, it searches +# for a library containing the function lua_load. The search is performed +# with a combination of LIBS, LIBRARY_PATH, and LUA_LIB. +# +# If the search determines that some linker flags are missing, then those +# flags will be added to LUA_LIB. +# +# If libraries are found, then ACTION-IF-FOUND is performed, otherwise +# ACTION-IF-NOT-FOUND is performed. If ACTION-IF-NOT-FOUND is blank, then +# it will default to printing an error. To prevent the default behavior, +# set the action to ':'. +# +# AX_LUA_READLINE: Search for readline headers and libraries. Requires the +# AX_LIB_READLINE macro, which is provided by ax_lib_readline.m4 from the +# Autoconf Archive. +# +# If a readline compatible library is found, then ACTION-IF-FOUND is +# performed, otherwise ACTION-IF-NOT-FOUND is performed. +# +# LICENSE +# +# Copyright (c) 2014 Reuben Thomas +# Copyright (c) 2013 Tim Perkins +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 23 + +dnl ========================================================================= +dnl AX_PROG_LUA([MINIMUM-VERSION], [TOO-BIG-VERSION], +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ========================================================================= +AC_DEFUN([AX_PROG_LUA], +[ + dnl Make LUA a precious variable. + AC_ARG_VAR([LUA], [The Lua interpreter, e.g. /usr/bin/lua5.1]) + + dnl Find a Lua interpreter. + m4_define_default([_AX_LUA_INTERPRETER_LIST], + [lua lua5.2 lua52 lua5.1 lua51 lua50]) + + m4_if([$1], [], + [ dnl No version check is needed. Find any Lua interpreter. + AS_IF([test "x$LUA" = 'x'], + [AC_PATH_PROGS([LUA], [_AX_LUA_INTERPRETER_LIST], [:])]) + ax_display_LUA='lua' + + dnl At least check if this is a Lua interpreter. + AC_MSG_CHECKING([if $LUA is a Lua interpreter]) + _AX_LUA_CHK_IS_INTRP([$LUA], + [AC_MSG_RESULT([yes])], + [ AC_MSG_RESULT([no]) + AC_MSG_ERROR([not a Lua interpreter]) + ]) + ], + [ dnl A version check is needed. + AS_IF([test "x$LUA" != 'x'], + [ dnl Check if this is a Lua interpreter. + AC_MSG_CHECKING([if $LUA is a Lua interpreter]) + _AX_LUA_CHK_IS_INTRP([$LUA], + [AC_MSG_RESULT([yes])], + [ AC_MSG_RESULT([no]) + AC_MSG_ERROR([not a Lua interpreter]) + ]) + dnl Check the version. + m4_if([$2], [], + [_ax_check_text="whether $LUA version >= $1"], + [_ax_check_text="whether $LUA version >= $1, < $2"]) + AC_MSG_CHECKING([$_ax_check_text]) + _AX_LUA_CHK_VER([$LUA], [$1], [$2], + [AC_MSG_RESULT([yes])], + [ AC_MSG_RESULT([no]) + AC_MSG_ERROR([version is out of range for specified LUA])]) + ax_display_LUA=$LUA + ], + [ dnl Try each interpreter until we find one that satisfies VERSION. + m4_if([$2], [], + [_ax_check_text="for a Lua interpreter with version >= $1"], + [_ax_check_text="for a Lua interpreter with version >= $1, < $2"]) + AC_CACHE_CHECK([$_ax_check_text], + [ax_cv_pathless_LUA], + [ for ax_cv_pathless_LUA in _AX_LUA_INTERPRETER_LIST none; do + test "x$ax_cv_pathless_LUA" = 'xnone' && break + _AX_LUA_CHK_IS_INTRP([$ax_cv_pathless_LUA], [], [continue]) + _AX_LUA_CHK_VER([$ax_cv_pathless_LUA], [$1], [$2], [break]) + done + ]) + dnl Set $LUA to the absolute path of $ax_cv_pathless_LUA. + AS_IF([test "x$ax_cv_pathless_LUA" = 'xnone'], + [LUA=':'], + [AC_PATH_PROG([LUA], [$ax_cv_pathless_LUA])]) + ax_display_LUA=$ax_cv_pathless_LUA + ]) + ]) + + AS_IF([test "x$LUA" = 'x:'], + [ dnl Run any user-specified action, or abort. + m4_default([$4], [AC_MSG_ERROR([cannot find suitable Lua interpreter])]) + ], + [ dnl Query Lua for its version number. + AC_CACHE_CHECK([for $ax_display_LUA version], [ax_cv_lua_version], + [ ax_cv_lua_version=`$LUA -e 'print(_VERSION:match "(%d+%.%d+)")'` ]) + AS_IF([test "x$ax_cv_lua_version" = 'x'], + [AC_MSG_ERROR([invalid Lua version number])]) + AC_SUBST([LUA_VERSION], [$ax_cv_lua_version]) + AC_SUBST([LUA_SHORT_VERSION], [`echo "$LUA_VERSION" | sed 's|\.||'`]) + + dnl The following check is not supported: + dnl At times (like when building shared libraries) you may want to know + dnl which OS platform Lua thinks this is. + AC_CACHE_CHECK([for $ax_display_LUA platform], [ax_cv_lua_platform], + [ax_cv_lua_platform=`$LUA -e "print('unknown')"`]) + AC_SUBST([LUA_PLATFORM], [$ax_cv_lua_platform]) + + dnl Use the values of $prefix and $exec_prefix for the corresponding + dnl values of LUA_PREFIX and LUA_EXEC_PREFIX. These are made distinct + dnl variables so they can be overridden if need be. However, the general + dnl consensus is that you shouldn't need this ability. + AC_SUBST([LUA_PREFIX], ['${prefix}']) + AC_SUBST([LUA_EXEC_PREFIX], ['${exec_prefix}']) + + dnl Lua provides no way to query the script directory, and instead + dnl provides LUA_PATH. However, we should be able to make a safe educated + dnl guess. If the built-in search path contains a directory which is + dnl prefixed by $prefix, then we can store scripts there. The first + dnl matching path will be used. + AC_CACHE_CHECK([for $ax_display_LUA script directory], + [ax_cv_lua_luadir], + [ AS_IF([test "x$prefix" = 'xNONE'], + [ax_lua_prefix=$ac_default_prefix], + [ax_lua_prefix=$prefix]) + + dnl Initialize to the default path. + ax_cv_lua_luadir="$LUA_PREFIX/share/lua/$LUA_VERSION" + + dnl Try to find a path with the prefix. + _AX_LUA_FND_PRFX_PTH([$LUA], [$ax_lua_prefix], [package.path]) + AS_IF([test "x$ax_lua_prefixed_path" != 'x'], + [ dnl Fix the prefix. + _ax_strip_prefix=`echo "$ax_lua_prefix" | sed 's|.|.|g'` + ax_cv_lua_luadir=`echo "$ax_lua_prefixed_path" | \ + sed "s,^$_ax_strip_prefix,$LUA_PREFIX,"` + ]) + ]) + AC_SUBST([luadir], [$ax_cv_lua_luadir]) + AC_SUBST([pkgluadir], [\${luadir}/$PACKAGE]) + + dnl Lua provides no way to query the module directory, and instead + dnl provides LUA_PATH. However, we should be able to make a safe educated + dnl guess. If the built-in search path contains a directory which is + dnl prefixed by $exec_prefix, then we can store modules there. The first + dnl matching path will be used. + AC_CACHE_CHECK([for $ax_display_LUA module directory], + [ax_cv_lua_luaexecdir], + [ AS_IF([test "x$exec_prefix" = 'xNONE'], + [ax_lua_exec_prefix=$ax_lua_prefix], + [ax_lua_exec_prefix=$exec_prefix]) + + dnl Initialize to the default path. + ax_cv_lua_luaexecdir="$LUA_EXEC_PREFIX/lib/lua/$LUA_VERSION" + + dnl Try to find a path with the prefix. + _AX_LUA_FND_PRFX_PTH([$LUA], + [$ax_lua_exec_prefix], [package.cpathd]) + AS_IF([test "x$ax_lua_prefixed_path" != 'x'], + [ dnl Fix the prefix. + _ax_strip_prefix=`echo "$ax_lua_exec_prefix" | sed 's|.|.|g'` + ax_cv_lua_luaexecdir=`echo "$ax_lua_prefixed_path" | \ + sed "s,^$_ax_strip_prefix,$LUA_EXEC_PREFIX,"` + ]) + ]) + AC_SUBST([luaexecdir], [$ax_cv_lua_luaexecdir]) + AC_SUBST([pkgluaexecdir], [\${luaexecdir}/$PACKAGE]) + + dnl Run any user specified action. + $3 + ]) +]) + +dnl AX_WITH_LUA is now the same thing as AX_PROG_LUA. +AC_DEFUN([AX_WITH_LUA], +[ + AC_MSG_WARN([[$0 is deprecated, please use AX_PROG_LUA]]) + AX_PROG_LUA +]) + + +dnl ========================================================================= +dnl _AX_LUA_CHK_IS_INTRP(PROG, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) +dnl ========================================================================= +AC_DEFUN([_AX_LUA_CHK_IS_INTRP], +[ + dnl Just print _VERSION because all Lua interpreters have this global. + AS_IF([$1 -e "print('Hello ' .. _VERSION .. '!')" &>/dev/null], + [$2], [$3]) +]) + + +dnl ========================================================================= +dnl _AX_LUA_CHK_VER(PROG, MINIMUM-VERSION, [TOO-BIG-VERSION], +dnl [ACTION-IF-TRUE], [ACTION-IF-FALSE]) +dnl ========================================================================= +AC_DEFUN([_AX_LUA_CHK_VER], +[ + AS_IF([$1 2>/dev/null -e ' + function norm (v) i,j=v:match "(%d+)%.(%d+)" return 100 * i + j end + v=norm (_VERSION) + os.exit ((v >= norm ("$2") and ("$3" == "" or v < norm ("$3"))) and 0 or 1)'], + [$4], [$5]) +]) + + +dnl ========================================================================= +dnl _AX_LUA_FND_PRFX_PTH(PROG, PREFIX, LUA-PATH-VARIABLE) +dnl ========================================================================= +AC_DEFUN([_AX_LUA_FND_PRFX_PTH], +[ + dnl Invokes the Lua interpreter PROG to print the path variable + dnl LUA-PATH-VARIABLE, usually package.path or package.cpath. Paths are + dnl then matched against PREFIX. The first path to begin with PREFIX is set + dnl to ax_lua_prefixed_path. + + ax_lua_prefixed_path='' + _ax_package_paths=`$1 -e 'print($3)' 2>/dev/null | sed 's|;|\n|g'` + dnl Try the paths in order, looking for the prefix. + for _ax_package_path in $_ax_package_paths; do + dnl Copy the path, up to the use of a Lua wildcard. + _ax_path_parts=`echo "$_ax_package_path" | sed 's|/|\n|g'` + _ax_reassembled='' + for _ax_path_part in $_ax_path_parts; do + echo "$_ax_path_part" | grep '\?' >/dev/null && break + _ax_reassembled="$_ax_reassembled/$_ax_path_part" + done + dnl Check the path against the prefix. + _ax_package_path=$_ax_reassembled + if echo "$_ax_package_path" | grep "^$2" >/dev/null; then + dnl Found it. + ax_lua_prefixed_path=$_ax_package_path + break + fi + done +]) + + +dnl ========================================================================= +dnl AX_LUA_HEADERS([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ========================================================================= +AC_DEFUN([AX_LUA_HEADERS], +[ + dnl Check for LUA_VERSION. + AC_MSG_CHECKING([if LUA_VERSION is defined]) + AS_IF([test "x$LUA_VERSION" != 'x'], + [AC_MSG_RESULT([yes])], + [ AC_MSG_RESULT([no]) + AC_MSG_ERROR([cannot check Lua headers without knowing LUA_VERSION]) + ]) + + dnl Make LUA_INCLUDE a precious variable. + AC_ARG_VAR([LUA_INCLUDE], [The Lua includes, e.g. -I/usr/include/lua5.1]) + + dnl Some default directories to search. + LUA_SHORT_VERSION=`echo "$LUA_VERSION" | sed 's|\.||'` + m4_define_default([_AX_LUA_INCLUDE_LIST], + [ /usr/include/lua$LUA_VERSION \ + /usr/include/lua/$LUA_VERSION \ + /usr/include/lua$LUA_SHORT_VERSION \ + /usr/local/include/lua$LUA_VERSION \ + /usr/local/include/lua-$LUA_VERSION \ + /usr/local/include/lua/$LUA_VERSION \ + /usr/local/include/lua$LUA_SHORT_VERSION \ + ]) + + dnl Try to find the headers. + _ax_lua_saved_cppflags=$CPPFLAGS + CPPFLAGS="$CPPFLAGS $LUA_INCLUDE" + AC_CHECK_HEADERS([lua.h lualib.h lauxlib.h luaconf.h]) + CPPFLAGS=$_ax_lua_saved_cppflags + + dnl Try some other directories if LUA_INCLUDE was not set. + AS_IF([test "x$LUA_INCLUDE" = 'x' && + test "x$ac_cv_header_lua_h" != 'xyes'], + [ dnl Try some common include paths. + for _ax_include_path in _AX_LUA_INCLUDE_LIST; do + test ! -d "$_ax_include_path" && continue + + AC_MSG_CHECKING([for Lua headers in]) + AC_MSG_RESULT([$_ax_include_path]) + + AS_UNSET([ac_cv_header_lua_h]) + AS_UNSET([ac_cv_header_lualib_h]) + AS_UNSET([ac_cv_header_lauxlib_h]) + AS_UNSET([ac_cv_header_luaconf_h]) + + _ax_lua_saved_cppflags=$CPPFLAGS + CPPFLAGS="$CPPFLAGS -I$_ax_include_path" + AC_CHECK_HEADERS([lua.h lualib.h lauxlib.h luaconf.h]) + CPPFLAGS=$_ax_lua_saved_cppflags + + AS_IF([test "x$ac_cv_header_lua_h" = 'xyes'], + [ LUA_INCLUDE="-I$_ax_include_path" + break + ]) + done + ]) + + AS_IF([test "x$ac_cv_header_lua_h" = 'xyes' && test "x$cross_compiling" != 'xyes'], + [ dnl Make a program to print LUA_VERSION defined in the header. + dnl TODO This probably shouldn't be a runtime test. + + AC_CACHE_CHECK([for Lua header version], + [ax_cv_lua_header_version], + [ _ax_lua_saved_cppflags=$CPPFLAGS + CPPFLAGS="$CPPFLAGS $LUA_INCLUDE" + AC_RUN_IFELSE( + [ AC_LANG_SOURCE([[ +#include +#include +#include +int main(int argc, char ** argv) +{ + if(argc > 1) printf("%s", LUA_VERSION); + exit(EXIT_SUCCESS); +} +]]) + ], + [ ax_cv_lua_header_version=`./conftest$EXEEXT p | \ + sed "s|^Lua \(.*\)|\1|" | \ + grep -o "^@<:@0-9@:>@\+\\.@<:@0-9@:>@\+"` + ], + [ax_cv_lua_header_version='unknown']) + CPPFLAGS=$_ax_lua_saved_cppflags + ]) + + dnl Compare this to the previously found LUA_VERSION. + AC_MSG_CHECKING([if Lua header version matches $LUA_VERSION]) + AS_IF([test "x$ax_cv_lua_header_version" = "x$LUA_VERSION"], + [ AC_MSG_RESULT([yes]) + ax_header_version_match='yes' + ], + [ AC_MSG_RESULT([no]) + ax_header_version_match='no' + ]) + ], + [ + ax_header_version_match='yes' + ]) + + dnl Was LUA_INCLUDE specified? + AS_IF([test "x$ax_header_version_match" != 'xyes' && + test "x$LUA_INCLUDE" != 'x'], + [AC_MSG_ERROR([cannot find headers for specified LUA_INCLUDE])]) + + dnl Test the final result and run user code. + AS_IF([test "x$ax_header_version_match" = 'xyes'], [$1], + [m4_default([$2], [AC_MSG_ERROR([cannot find Lua includes])])]) +]) + +dnl AX_LUA_HEADERS_VERSION no longer exists, use AX_LUA_HEADERS. +AC_DEFUN([AX_LUA_HEADERS_VERSION], +[ + AC_MSG_WARN([[$0 is deprecated, please use AX_LUA_HEADERS]]) +]) + + +dnl ========================================================================= +dnl AX_LUA_LIBS([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ========================================================================= +AC_DEFUN([AX_LUA_LIBS], +[ + dnl TODO Should this macro also check various -L flags? + + dnl Check for LUA_VERSION. + AC_MSG_CHECKING([if LUA_VERSION is defined]) + AS_IF([test "x$LUA_VERSION" != 'x'], + [AC_MSG_RESULT([yes])], + [ AC_MSG_RESULT([no]) + AC_MSG_ERROR([cannot check Lua libs without knowing LUA_VERSION]) + ]) + + dnl Make LUA_LIB a precious variable. + AC_ARG_VAR([LUA_LIB], [The Lua library, e.g. -llua5.1]) + + AS_IF([test "x$LUA_LIB" != 'x'], + [ dnl Check that LUA_LIBS works. + _ax_lua_saved_libs=$LIBS + LIBS="$LIBS $LUA_LIB" + AC_SEARCH_LIBS([lua_load], [], + [_ax_found_lua_libs='yes'], + [_ax_found_lua_libs='no']) + LIBS=$_ax_lua_saved_libs + + dnl Check the result. + AS_IF([test "x$_ax_found_lua_libs" != 'xyes'], + [AC_MSG_ERROR([cannot find libs for specified LUA_LIB])]) + ], + [ dnl First search for extra libs. + _ax_lua_extra_libs='' + + _ax_lua_saved_libs=$LIBS + LIBS="$LIBS $LUA_LIB" + AC_SEARCH_LIBS([exp], [m]) + AC_SEARCH_LIBS([dlopen], [dl]) + LIBS=$_ax_lua_saved_libs + + AS_IF([test "x$ac_cv_search_exp" != 'xno' && + test "x$ac_cv_search_exp" != 'xnone required'], + [_ax_lua_extra_libs="$_ax_lua_extra_libs $ac_cv_search_exp"]) + + AS_IF([test "x$ac_cv_search_dlopen" != 'xno' && + test "x$ac_cv_search_dlopen" != 'xnone required'], + [_ax_lua_extra_libs="$_ax_lua_extra_libs $ac_cv_search_dlopen"]) + + dnl Try to find the Lua libs. + _ax_lua_saved_libs=$LIBS + LIBS="$LIBS $LUA_LIB" + AC_SEARCH_LIBS([lua_load], + [ lua$LUA_VERSION \ + lua$LUA_SHORT_VERSION \ + lua-$LUA_VERSION \ + lua-$LUA_SHORT_VERSION \ + lua], + [_ax_found_lua_libs='yes'], + [_ax_found_lua_libs='no'], + [$_ax_lua_extra_libs]) + LIBS=$_ax_lua_saved_libs + + AS_IF([test "x$ac_cv_search_lua_load" != 'xno' && + test "x$ac_cv_search_lua_load" != 'xnone required'], + [LUA_LIB="$ac_cv_search_lua_load $_ax_lua_extra_libs"]) + ]) + + dnl Test the result and run user code. + AS_IF([test "x$_ax_found_lua_libs" = 'xyes'], [$1], + [m4_default([$2], [AC_MSG_ERROR([cannot find Lua libs])])]) +]) + + +dnl ========================================================================= +dnl AX_LUA_READLINE([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ========================================================================= +AC_DEFUN([AX_LUA_READLINE], +[ + AX_LIB_READLINE + AS_IF([test "x$ac_cv_header_readline_readline_h" != 'x' && + test "x$ac_cv_header_readline_history_h" != 'x'], + [ LUA_LIBS_CFLAGS="-DLUA_USE_READLINE $LUA_LIBS_CFLAGS" + $1 + ], + [$2]) +]) diff --git a/src/ucl_emitter.c b/src/ucl_emitter.c index 11fe50c00602..8134d09c1a65 100644 --- a/src/ucl_emitter.c +++ b/src/ucl_emitter.c @@ -130,6 +130,19 @@ ucl_emitter_print_key (bool print_key, struct ucl_emitter_context *ctx, func->ucl_emitter_append_character (' ', 1, func->ud); } } + else if (ctx->id == UCL_EMIT_YAML) { + if (obj->keylen > 0 && (obj->flags & UCL_OBJECT_NEED_KEY_ESCAPE)) { + ucl_elt_string_write_json (obj->key, obj->keylen, ctx); + } + else if (obj->keylen > 0) { + func->ucl_emitter_append_len (obj->key, obj->keylen, func->ud); + } + else { + func->ucl_emitter_append_len ("null", 4, func->ud); + } + + func->ucl_emitter_append_len (": ", 2, func->ud); + } else { if (obj->keylen > 0) { ucl_elt_string_write_json (obj->key, obj->keylen, ctx); @@ -182,7 +195,7 @@ ucl_emitter_common_end_object (struct ucl_emitter_context *ctx, const struct ucl_emitter_functions *func = ctx->func; if (UCL_EMIT_IDENT_TOP_OBJ(ctx, obj)) { - ctx->ident --; + ctx->indent --; if (compact) { func->ucl_emitter_append_character ('}', 1, func->ud); } @@ -191,7 +204,7 @@ ucl_emitter_common_end_object (struct ucl_emitter_context *ctx, /* newline is already added for this format */ func->ucl_emitter_append_character ('\n', 1, func->ud); } - ucl_add_tabs (func, ctx->ident, compact); + ucl_add_tabs (func, ctx->indent, compact); func->ucl_emitter_append_character ('}', 1, func->ud); } } @@ -210,7 +223,7 @@ ucl_emitter_common_end_array (struct ucl_emitter_context *ctx, { const struct ucl_emitter_functions *func = ctx->func; - ctx->ident --; + ctx->indent --; if (compact) { func->ucl_emitter_append_character (']', 1, func->ud); } @@ -219,7 +232,7 @@ ucl_emitter_common_end_array (struct ucl_emitter_context *ctx, /* newline is already added for this format */ func->ucl_emitter_append_character ('\n', 1, func->ud); } - ucl_add_tabs (func, ctx->ident, compact); + ucl_add_tabs (func, ctx->indent, compact); func->ucl_emitter_append_character (']', 1, func->ud); } @@ -249,7 +262,7 @@ ucl_emitter_common_start_array (struct ucl_emitter_context *ctx, func->ucl_emitter_append_len ("[\n", 2, func->ud); } - ctx->ident ++; + ctx->indent ++; if (obj->type == UCL_ARRAY) { /* explicit array */ @@ -294,7 +307,7 @@ ucl_emitter_common_start_object (struct ucl_emitter_context *ctx, else { func->ucl_emitter_append_len ("{\n", 2, func->ud); } - ctx->ident ++; + ctx->indent ++; } while ((cur = ucl_hash_iterate (obj->value.ov, &it))) { @@ -315,7 +328,7 @@ ucl_emitter_common_start_object (struct ucl_emitter_context *ctx, func->ucl_emitter_append_len (",\n", 2, func->ud); } } - ucl_add_tabs (func, ctx->ident, compact); + ucl_add_tabs (func, ctx->indent, compact); ucl_emitter_common_start_array (ctx, cur, true, compact); ucl_emitter_common_end_array (ctx, cur, compact); } @@ -342,17 +355,23 @@ ucl_emitter_common_elt (struct ucl_emitter_context *ctx, { const struct ucl_emitter_functions *func = ctx->func; bool flag; + struct ucl_object_userdata *ud; + const char *ud_out = ""; if (ctx->id != UCL_EMIT_CONFIG && !first) { if (compact) { func->ucl_emitter_append_character (',', 1, func->ud); } else { - func->ucl_emitter_append_len (",\n", 2, func->ud); + if (ctx->id == UCL_EMIT_YAML && ctx->indent == 0) { + func->ucl_emitter_append_len ("\n", 1, func->ud); + } else { + func->ucl_emitter_append_len (",\n", 2, func->ud); + } } } - ucl_add_tabs (func, ctx->ident, compact); + ucl_add_tabs (func, ctx->indent, compact); switch (obj->type) { case UCL_INT: @@ -379,7 +398,12 @@ ucl_emitter_common_elt (struct ucl_emitter_context *ctx, break; case UCL_STRING: ucl_emitter_print_key (print_key, ctx, obj, compact); - ucl_elt_string_write_json (obj->value.sv, obj->len, ctx); + if (ctx->id == UCL_EMIT_CONFIG && ucl_maybe_long_string (obj)) { + ucl_elt_string_write_multiline (obj->value.sv, obj->len, ctx); + } + else { + ucl_elt_string_write_json (obj->value.sv, obj->len, ctx); + } ucl_emitter_finish_object (ctx, obj, compact, !print_key); break; case UCL_NULL: @@ -396,6 +420,16 @@ ucl_emitter_common_elt (struct ucl_emitter_context *ctx, ucl_emitter_common_end_array (ctx, obj, compact); break; case UCL_USERDATA: + ud = (struct ucl_object_userdata *)obj; + ucl_emitter_print_key (print_key, ctx, obj, compact); + if (ud->emitter) { + ud_out = ud->emitter (obj->value.ud); + if (ud_out == NULL) { + ud_out = "null"; + } + } + ucl_elt_string_write_json (ud_out, strlen (ud_out), ctx); + ucl_emitter_finish_object (ctx, obj, compact, !print_key); break; } } @@ -425,10 +459,10 @@ ucl_emitter_common_elt (struct ucl_emitter_context *ctx, ucl_emitter_common_end_array (ctx, obj, (compact)); \ } -UCL_EMIT_TYPE_IMPL(json, false); -UCL_EMIT_TYPE_IMPL(json_compact, true); -UCL_EMIT_TYPE_IMPL(config, false); -UCL_EMIT_TYPE_IMPL(yaml, false); +UCL_EMIT_TYPE_IMPL(json, false) +UCL_EMIT_TYPE_IMPL(json_compact, true) +UCL_EMIT_TYPE_IMPL(config, false) +UCL_EMIT_TYPE_IMPL(yaml, false) unsigned char * ucl_object_emit (const ucl_object_t *obj, enum ucl_emitter emit_type) @@ -461,7 +495,7 @@ ucl_object_emit_full (const ucl_object_t *obj, enum ucl_emitter emit_type, if (ctx != NULL) { memcpy (&my_ctx, ctx, sizeof (my_ctx)); my_ctx.func = emitter; - my_ctx.ident = 0; + my_ctx.indent = 0; my_ctx.top = obj; my_ctx.ops->ucl_emitter_write_elt (&my_ctx, obj, true, false); diff --git a/src/ucl_emitter_streamline.c b/src/ucl_emitter_streamline.c index acf4a305a46e..ff27c88244a5 100644 --- a/src/ucl_emitter_streamline.c +++ b/src/ucl_emitter_streamline.c @@ -108,9 +108,8 @@ ucl_object_emit_streamline_start_container (struct ucl_emitter_context *ctx, st->is_array = false; sctx->ops->ucl_emitter_start_object (ctx, obj, print_key); } + LL_PREPEND (sctx->containers, st); } - - LL_PREPEND (sctx->containers, st); } void diff --git a/src/ucl_emitter_utils.c b/src/ucl_emitter_utils.c index c619ab9df15e..da412097ffbc 100644 --- a/src/ucl_emitter_utils.c +++ b/src/ucl_emitter_utils.c @@ -93,9 +93,7 @@ ucl_elt_string_write_json (const char *str, size_t size, size_t len = 0; const struct ucl_emitter_functions *func = ctx->func; - if (ctx->id != UCL_EMIT_YAML) { - func->ucl_emitter_append_character ('"', 1, func->ud); - } + func->ucl_emitter_append_character ('"', 1, func->ud); while (size) { if (ucl_test_character (*p, UCL_CHARACTER_JSON_UNSAFE)) { @@ -137,9 +135,18 @@ ucl_elt_string_write_json (const char *str, size_t size, if (len > 0) { func->ucl_emitter_append_len (c, len, func->ud); } - if (ctx->id != UCL_EMIT_YAML) { - func->ucl_emitter_append_character ('"', 1, func->ud); - } + func->ucl_emitter_append_character ('"', 1, func->ud); +} + +void +ucl_elt_string_write_multiline (const char *str, size_t size, + struct ucl_emitter_context *ctx) +{ + const struct ucl_emitter_functions *func = ctx->func; + + func->ucl_emitter_append_len ("<ud); + func->ucl_emitter_append_len (str, size, func->ud); + func->ucl_emitter_append_len ("\nEOD", sizeof ("\nEOD") - 1, func->ud); } /* @@ -154,7 +161,7 @@ ucl_utstring_append_character (unsigned char c, size_t len, void *ud) utstring_append_c (buf, c); } else { - utstring_reserve (buf, len); + utstring_reserve (buf, len + 1); memset (&buf->d[buf->i], c, len); buf->i += len; buf->d[buf->i] = '\0'; @@ -267,19 +274,23 @@ ucl_fd_append_character (unsigned char c, size_t len, void *ud) unsigned char *buf; if (len == 1) { - write (fd, &c, 1); + return write (fd, &c, 1); } else { buf = malloc (len); if (buf == NULL) { /* Fallback */ while (len --) { - write (fd, &c, 1); + if (write (fd, &c, 1) == -1) { + return -1; + } } } else { memset (buf, c, len); - write (fd, buf, len); + if (write (fd, buf, len) == -1) { + return -1; + } free (buf); } } @@ -292,9 +303,7 @@ ucl_fd_append_len (const unsigned char *str, size_t len, void *ud) { int fd = *(int *)ud; - write (fd, str, len); - - return 0; + return write (fd, str, len); } static int @@ -304,9 +313,7 @@ ucl_fd_append_int (int64_t val, void *ud) char intbuf[64]; snprintf (intbuf, sizeof (intbuf), "%jd", (intmax_t)val); - write (fd, intbuf, strlen (intbuf)); - - return 0; + return write (fd, intbuf, strlen (intbuf)); } static int @@ -327,9 +334,7 @@ ucl_fd_append_double (double val, void *ud) snprintf (nbuf, sizeof (nbuf), "%lf", val); } - write (fd, nbuf, strlen (nbuf)); - - return 0; + return write (fd, nbuf, strlen (nbuf)); } struct ucl_emitter_functions* @@ -464,3 +469,18 @@ ucl_object_emit_single_json (const ucl_object_t *obj) return res; } + +#define LONG_STRING_LIMIT 80 + +bool +ucl_maybe_long_string (const ucl_object_t *obj) +{ + if (obj->len > LONG_STRING_LIMIT || (obj->flags & UCL_OBJECT_MULTILINE)) { + /* String is long enough, so search for newline characters in it */ + if (memchr (obj->value.sv, '\n', obj->len) != NULL) { + return true; + } + } + + return false; +} diff --git a/src/ucl_hash.c b/src/ucl_hash.c index c2e80cb4b252..ea55491ed504 100644 --- a/src/ucl_hash.c +++ b/src/ucl_hash.c @@ -66,6 +66,20 @@ ucl_hash_insert (ucl_hash_t* hashlin, const ucl_object_t *obj, HASH_ADD_KEYPTR (hh, hashlin->buckets, key, keylen, node); } +void ucl_hash_replace (ucl_hash_t* hashlin, const ucl_object_t *old, + const ucl_object_t *new) +{ + ucl_hash_node_t *node; + + HASH_FIND (hh, hashlin->buckets, old->key, old->keylen, node); + if (node != NULL) { + /* Direct replacement */ + node->data = new; + node->hh.key = new->key; + node->hh.keylen = new->keylen; + } +} + const void* ucl_hash_iterate (ucl_hash_t *hashlin, ucl_hash_iter_t *iter) { @@ -122,5 +136,6 @@ ucl_hash_delete (ucl_hash_t* hashlin, const ucl_object_t *obj) if (found) { HASH_DELETE (hh, hashlin->buckets, found); + UCL_FREE (sizeof (ucl_hash_node_t), found); } } diff --git a/src/ucl_hash.h b/src/ucl_hash.h index cbbf005240bd..ddbfdba19ce8 100644 --- a/src/ucl_hash.h +++ b/src/ucl_hash.h @@ -65,6 +65,12 @@ void ucl_hash_destroy (ucl_hash_t* hashlin, ucl_hash_free_func *func); void ucl_hash_insert (ucl_hash_t* hashlin, const ucl_object_t *obj, const char *key, unsigned keylen); +/** + * Replace element in the hash + */ +void ucl_hash_replace (ucl_hash_t* hashlin, const ucl_object_t *old, + const ucl_object_t *new); + /** * Delete an element from the the hashtable. */ diff --git a/src/ucl_internal.h b/src/ucl_internal.h index 0ac8de84c2ed..2f75872b7bb8 100644 --- a/src/ucl_internal.h +++ b/src/ucl_internal.h @@ -163,6 +163,7 @@ struct ucl_chunk { size_t remain; unsigned int line; unsigned int column; + unsigned priority; struct ucl_chunk *next; }; @@ -182,7 +183,7 @@ struct ucl_variable { char *value; size_t var_len; size_t value_len; - struct ucl_variable *next; + struct ucl_variable *prev, *next; }; struct ucl_parser { @@ -192,6 +193,7 @@ struct ucl_parser { int flags; ucl_object_t *top_obj; ucl_object_t *cur_obj; + char *cur_file; struct ucl_macro *macroes; struct ucl_stack *stack; struct ucl_chunk *chunks; @@ -202,6 +204,12 @@ struct ucl_parser { UT_string *err; }; +struct ucl_object_userdata { + ucl_object_t obj; + ucl_userdata_dtor dtor; + ucl_userdata_emitter emitter; +}; + /** * Unescape json string inplace * @param str @@ -216,9 +224,11 @@ size_t ucl_unescape_json_string (char *str, size_t len); * @param err error ptr * @return */ -bool ucl_include_handler (const unsigned char *data, size_t len, void* ud); +bool ucl_include_handler (const unsigned char *data, size_t len, + const ucl_object_t *args, void* ud); -bool ucl_try_include_handler (const unsigned char *data, size_t len, void* ud); +bool ucl_try_include_handler (const unsigned char *data, size_t len, + const ucl_object_t *args, void* ud); /** * Handle includes macro @@ -228,7 +238,8 @@ bool ucl_try_include_handler (const unsigned char *data, size_t len, void* ud); * @param err error ptr * @return */ -bool ucl_includes_handler (const unsigned char *data, size_t len, void* ud); +bool ucl_includes_handler (const unsigned char *data, size_t len, + const ucl_object_t *args, void* ud); size_t ucl_strlcpy (char *dst, const char *src, size_t siz); size_t ucl_strlcpy_unsafe (char *dst, const char *src, size_t siz); @@ -264,7 +275,7 @@ ucl_create_err (UT_string **err, const char *fmt, ...) static inline bool ucl_maybe_parse_boolean (ucl_object_t *obj, const unsigned char *start, size_t len) { - const unsigned char *p = start; + const char *p = (const char *)start; bool ret = false, val = false; if (len == 5) { @@ -351,13 +362,22 @@ const struct ucl_emitter_context * ucl_emit_get_standard_context (enum ucl_emitter emit_type); /** - * Serialise string + * Serialize string as JSON string * @param str string to emit * @param buf target buffer */ void ucl_elt_string_write_json (const char *str, size_t size, struct ucl_emitter_context *ctx); +/** + * Write multiline string using `EOD` as string terminator + * @param str + * @param size + * @param ctx + */ +void ucl_elt_string_write_multiline (const char *str, size_t size, + struct ucl_emitter_context *ctx); + /** * Emit a single object to string * @param obj @@ -365,4 +385,12 @@ void ucl_elt_string_write_json (const char *str, size_t size, */ unsigned char * ucl_object_emit_single_json (const ucl_object_t *obj); +/** + * Check whether a specified string is long and should be likely printed in + * multiline mode + * @param obj + * @return + */ +bool ucl_maybe_long_string (const ucl_object_t *obj); + #endif /* UCL_INTERNAL_H_ */ diff --git a/src/ucl_parser.c b/src/ucl_parser.c index e51a54b77bc6..0d118d84b75a 100644 --- a/src/ucl_parser.c +++ b/src/ucl_parser.c @@ -26,8 +26,8 @@ #include "ucl_chartable.h" /** - * @file rcl_parser.c - * The implementation of rcl parser + * @file ucl_parser.c + * The implementation of ucl parser */ struct ucl_parser_saved_state { @@ -56,20 +56,33 @@ struct ucl_parser_saved_state { } while (0) static inline void -ucl_set_err (struct ucl_chunk *chunk, int code, const char *str, UT_string **err) +ucl_set_err (struct ucl_parser *parser, int code, const char *str, UT_string **err) { - if (chunk->pos < chunk->end) { - if (isgraph (*chunk->pos)) { - ucl_create_err (err, "error on line %d at column %d: '%s', character: '%c'", - chunk->line, chunk->column, str, *chunk->pos); - } - else { - ucl_create_err (err, "error on line %d at column %d: '%s', character: '0x%02x'", - chunk->line, chunk->column, str, (int)*chunk->pos); - } + const char *fmt_string, *filename; + struct ucl_chunk *chunk = parser->chunks; + + if (parser->cur_file) { + filename = parser->cur_file; } else { - ucl_create_err (err, "error at the end of chunk: %s", str); + filename = ""; + } + if (chunk->pos < chunk->end) { + if (isgraph (*chunk->pos)) { + fmt_string = "error while parsing %s: " + "line: %d, column: %d - '%s', character: '%c'"; + } + else { + fmt_string = "error while parsing %s: " + "line: %d, column: %d - '%s', character: '0x%02x'"; + } + ucl_create_err (err, fmt_string, + filename, chunk->line, chunk->column, + str, *chunk->pos); + } + else { + ucl_create_err (err, "error while parsing %s: at the end of chunk: %s", + filename, str); } } @@ -84,11 +97,12 @@ ucl_skip_comments (struct ucl_parser *parser) struct ucl_chunk *chunk = parser->chunks; const unsigned char *p; int comments_nested = 0; + bool quoted = false; p = chunk->pos; start: - if (*p == '#') { + if (chunk->remain > 0 && *p == '#') { if (parser->state != UCL_STATE_SCOMMENT && parser->state != UCL_STATE_MCOMMENT) { while (p < chunk->end) { @@ -100,34 +114,41 @@ start: } } } - else if (*p == '/' && chunk->remain >= 2) { + else if (chunk->remain >= 2 && *p == '/') { if (p[1] == '*') { ucl_chunk_skipc (chunk, p); comments_nested ++; ucl_chunk_skipc (chunk, p); while (p < chunk->end) { - if (*p == '*') { - ucl_chunk_skipc (chunk, p); - if (*p == '/') { - comments_nested --; - if (comments_nested == 0) { - ucl_chunk_skipc (chunk, p); - goto start; - } - } - ucl_chunk_skipc (chunk, p); + if (*p == '"' && *(p - 1) != '\\') { + quoted = !quoted; } - else if (p[0] == '/' && chunk->remain >= 2 && p[1] == '*') { - comments_nested ++; - ucl_chunk_skipc (chunk, p); - ucl_chunk_skipc (chunk, p); - continue; + + if (!quoted) { + if (*p == '*') { + ucl_chunk_skipc (chunk, p); + if (*p == '/') { + comments_nested --; + if (comments_nested == 0) { + ucl_chunk_skipc (chunk, p); + goto start; + } + } + ucl_chunk_skipc (chunk, p); + } + else if (p[0] == '/' && chunk->remain >= 2 && p[1] == '*') { + comments_nested ++; + ucl_chunk_skipc (chunk, p); + ucl_chunk_skipc (chunk, p); + continue; + } } ucl_chunk_skipc (chunk, p); } if (comments_nested != 0) { - ucl_set_err (chunk, UCL_ENESTED, "unfinished multiline comment", &parser->err); + ucl_set_err (parser, UCL_ENESTED, + "unfinished multiline comment", &parser->err); return false; } } @@ -492,7 +513,8 @@ ucl_copy_or_store_ptr (struct ucl_parser *parser, /* Copy string */ *dst = UCL_ALLOC (in_len + 1); if (*dst == NULL) { - ucl_set_err (parser->chunks, 0, "cannot allocate memory for a string", &parser->err); + ucl_set_err (parser, 0, "cannot allocate memory for a string", + &parser->err); return false; } if (need_lowercase) { @@ -514,6 +536,10 @@ ucl_copy_or_store_ptr (struct ucl_parser *parser, *dst = tmp; ret = tret; } + else { + /* Free unexpanded value */ + UCL_FREE (in_len + 1, tmp); + } } *dst_const = *dst; } @@ -539,7 +565,7 @@ ucl_add_parser_stack (ucl_object_t *obj, struct ucl_parser *parser, bool is_arra if (!is_array) { if (obj == NULL) { - obj = ucl_object_typed_new (UCL_OBJECT); + obj = ucl_object_new_full (UCL_OBJECT, parser->chunks->priority); } else { obj->type = UCL_OBJECT; @@ -549,7 +575,7 @@ ucl_add_parser_stack (ucl_object_t *obj, struct ucl_parser *parser, bool is_arra } else { if (obj == NULL) { - obj = ucl_object_typed_new (UCL_ARRAY); + obj = ucl_object_new_full (UCL_ARRAY, parser->chunks->priority); } else { obj->type = UCL_ARRAY; @@ -559,7 +585,9 @@ ucl_add_parser_stack (ucl_object_t *obj, struct ucl_parser *parser, bool is_arra st = UCL_ALLOC (sizeof (struct ucl_stack)); if (st == NULL) { - ucl_set_err (parser->chunks, 0, "cannot allocate memory for an object", &parser->err); + ucl_set_err (parser, 0, "cannot allocate memory for an object", + &parser->err); + ucl_object_unref (obj); return NULL; } st->obj = obj; @@ -676,8 +704,7 @@ ucl_maybe_parse_number (ucl_object_t *obj, } /* Now check endptr */ - if (endptr == NULL || ucl_lex_is_atom_end (*endptr) || *endptr == '\0' || - ucl_test_character (*endptr, UCL_CHARACTER_WHITESPACE_UNSAFE)) { + if (endptr == NULL || ucl_lex_is_atom_end (*endptr) || *endptr == '\0') { p = endptr; goto set_obj; } @@ -788,8 +815,21 @@ ucl_maybe_parse_number (ucl_object_t *obj, goto set_obj; } break; + case '\t': + case ' ': + while (p < end && ucl_test_character(*p, UCL_CHARACTER_WHITESPACE)) { + p++; + } + if (ucl_lex_is_atom_end(*p)) + goto set_obj; + break; } } + else if (endptr == end) { + /* Just a number at the end of chunk */ + p = endptr; + goto set_obj; + } *pos = c; return EINVAL; @@ -835,7 +875,7 @@ ucl_lex_number (struct ucl_parser *parser, return true; } else if (ret == ERANGE) { - ucl_set_err (chunk, ERANGE, "numeric value out of range", &parser->err); + ucl_set_err (parser, ERANGE, "numeric value out of range", &parser->err); } return false; @@ -860,10 +900,12 @@ ucl_lex_json_string (struct ucl_parser *parser, if (c < 0x1F) { /* Unmasked control character */ if (c == '\n') { - ucl_set_err (chunk, UCL_ESYNTAX, "unexpected newline", &parser->err); + ucl_set_err (parser, UCL_ESYNTAX, "unexpected newline", + &parser->err); } else { - ucl_set_err (chunk, UCL_ESYNTAX, "unexpected control character", &parser->err); + ucl_set_err (parser, UCL_ESYNTAX, "unexpected control character", + &parser->err); } return false; } @@ -871,7 +913,8 @@ ucl_lex_json_string (struct ucl_parser *parser, ucl_chunk_skipc (chunk, p); c = *p; if (p >= chunk->end) { - ucl_set_err (chunk, UCL_ESYNTAX, "unfinished escape character", &parser->err); + ucl_set_err (parser, UCL_ESYNTAX, "unfinished escape character", + &parser->err); return false; } else if (ucl_test_character (c, UCL_CHARACTER_ESCAPE)) { @@ -879,13 +922,15 @@ ucl_lex_json_string (struct ucl_parser *parser, ucl_chunk_skipc (chunk, p); for (i = 0; i < 4 && p < chunk->end; i ++) { if (!isxdigit (*p)) { - ucl_set_err (chunk, UCL_ESYNTAX, "invalid utf escape", &parser->err); + ucl_set_err (parser, UCL_ESYNTAX, "invalid utf escape", + &parser->err); return false; } ucl_chunk_skipc (chunk, p); } if (p >= chunk->end) { - ucl_set_err (chunk, UCL_ESYNTAX, "unfinished escape character", &parser->err); + ucl_set_err (parser, UCL_ESYNTAX, "unfinished escape character", + &parser->err); return false; } } @@ -910,10 +955,42 @@ ucl_lex_json_string (struct ucl_parser *parser, ucl_chunk_skipc (chunk, p); } - ucl_set_err (chunk, UCL_ESYNTAX, "no quote at the end of json string", &parser->err); + ucl_set_err (parser, UCL_ESYNTAX, "no quote at the end of json string", + &parser->err); return false; } +static void +ucl_parser_append_elt (struct ucl_parser *parser, ucl_hash_t *cont, + ucl_object_t *top, + ucl_object_t *elt) +{ + ucl_object_t *nobj; + + if ((parser->flags & UCL_PARSER_NO_IMPLICIT_ARRAYS) == 0) { + /* Implicit array */ + top->flags |= UCL_OBJECT_MULTIVALUE; + DL_APPEND (top, elt); + } + else { + if ((top->flags & UCL_OBJECT_MULTIVALUE) != 0) { + /* Just add to the explicit array */ + DL_APPEND (top->value.av, elt); + } + else { + /* Convert to an array */ + ucl_hash_delete (cont, top); + nobj = ucl_object_typed_new (UCL_ARRAY); + nobj->key = top->key; + nobj->keylen = top->keylen; + nobj->flags |= UCL_OBJECT_MULTIVALUE; + DL_APPEND (nobj->value.av, top); + DL_APPEND (nobj->value.av, elt); + ucl_hash_insert (cont, nobj, nobj->key, nobj->keylen); + } + } +} + /** * Parse a key in an object * @param parser @@ -981,7 +1058,8 @@ ucl_parse_key (struct ucl_parser *parser, struct ucl_chunk *chunk, bool *next_ke } else { /* Invalid identifier */ - ucl_set_err (chunk, UCL_ESYNTAX, "key must begin with a letter", &parser->err); + ucl_set_err (parser, UCL_ESYNTAX, "key must begin with a letter", + &parser->err); return false; } } @@ -997,7 +1075,8 @@ ucl_parse_key (struct ucl_parser *parser, struct ucl_chunk *chunk, bool *next_ke break; } else { - ucl_set_err (chunk, UCL_ESYNTAX, "invalid character in a key", &parser->err); + ucl_set_err (parser, UCL_ESYNTAX, "invalid character in a key", + &parser->err); return false; } } @@ -1015,7 +1094,7 @@ ucl_parse_key (struct ucl_parser *parser, struct ucl_chunk *chunk, bool *next_ke } if (p >= chunk->end && got_content) { - ucl_set_err (chunk, UCL_ESYNTAX, "unfinished key", &parser->err); + ucl_set_err (parser, UCL_ESYNTAX, "unfinished key", &parser->err); return false; } else if (!got_content) { @@ -1033,7 +1112,8 @@ ucl_parse_key (struct ucl_parser *parser, struct ucl_chunk *chunk, bool *next_ke got_eq = true; } else { - ucl_set_err (chunk, UCL_ESYNTAX, "unexpected '=' character", &parser->err); + ucl_set_err (parser, UCL_ESYNTAX, "unexpected '=' character", + &parser->err); return false; } } @@ -1043,7 +1123,8 @@ ucl_parse_key (struct ucl_parser *parser, struct ucl_chunk *chunk, bool *next_ke got_semicolon = true; } else { - ucl_set_err (chunk, UCL_ESYNTAX, "unexpected ':' character", &parser->err); + ucl_set_err (parser, UCL_ESYNTAX, "unexpected ':' character", + &parser->err); return false; } } @@ -1061,7 +1142,7 @@ ucl_parse_key (struct ucl_parser *parser, struct ucl_chunk *chunk, bool *next_ke } if (p >= chunk->end && got_content) { - ucl_set_err (chunk, UCL_ESYNTAX, "unfinished key", &parser->err); + ucl_set_err (parser, UCL_ESYNTAX, "unfinished key", &parser->err); return false; } @@ -1096,7 +1177,7 @@ ucl_parse_key (struct ucl_parser *parser, struct ucl_chunk *chunk, bool *next_ke } /* Create a new object */ - nobj = ucl_object_new (); + nobj = ucl_object_new_full (UCL_NULL, parser->chunks->priority); keylen = ucl_copy_or_store_ptr (parser, c, &nobj->trash_stack[UCL_TRASH_KEY], &key, end - c, need_unescape, parser->flags & UCL_PARSER_KEY_LOWERCASE, false); if (keylen == -1) { @@ -1104,7 +1185,7 @@ ucl_parse_key (struct ucl_parser *parser, struct ucl_chunk *chunk, bool *next_ke return false; } else if (keylen == 0) { - ucl_set_err (chunk, UCL_ESYNTAX, "empty keys are not allowed", &parser->err); + ucl_set_err (parser, UCL_ESYNTAX, "empty keys are not allowed", &parser->err); ucl_object_unref (nobj); return false; } @@ -1120,7 +1201,27 @@ ucl_parse_key (struct ucl_parser *parser, struct ucl_chunk *chunk, bool *next_ke parser->stack->obj->len ++; } else { - DL_APPEND (tobj, nobj); + /* + * The logic here is the following: + * + * - if we have two objects with the same priority, then we form an + * implicit or explicit array + * - if a new object has bigger priority, then we overwrite an old one + * - if a new object has lower priority, then we ignore it + */ + unsigned priold = ucl_object_get_priority (tobj), + prinew = ucl_object_get_priority (nobj); + if (priold == prinew) { + ucl_parser_append_elt (parser, container, tobj, nobj); + } + else if (priold > prinew) { + ucl_object_unref (nobj); + return true; + } + else { + ucl_hash_replace (container, tobj, nobj); + ucl_object_unref (tobj); + } } if (ucl_escape) { @@ -1197,11 +1298,6 @@ ucl_parse_string_value (struct ucl_parser *parser, ucl_chunk_skipc (chunk, p); } - if (p >= chunk->end) { - ucl_set_err (chunk, UCL_ESYNTAX, "unfinished value", &parser->err); - return false; - } - return true; } @@ -1219,7 +1315,7 @@ ucl_parse_multiline_string (struct ucl_parser *parser, int term_len, unsigned char const **beg, bool *var_expand) { - const unsigned char *p, *c; + const unsigned char *p, *c, *tend; bool newline = false; int len = 0; @@ -1232,7 +1328,13 @@ ucl_parse_multiline_string (struct ucl_parser *parser, if (chunk->end - p < term_len) { return 0; } - else if (memcmp (p, term, term_len) == 0 && (p[term_len] == '\n' || p[term_len] == '\r')) { + else if (memcmp (p, term, term_len) == 0) { + tend = p + term_len; + if (*tend != '\n' && *tend != ';' && *tend != ',') { + /* Incomplete terminator */ + ucl_chunk_skipc (chunk, p); + continue; + } len = p - c; chunk->remain -= term_len; chunk->pos = p + term_len; @@ -1263,7 +1365,7 @@ ucl_get_value_object (struct ucl_parser *parser) if (parser->stack->obj->type == UCL_ARRAY) { /* Object must be allocated */ - obj = ucl_object_new (); + obj = ucl_object_new_full (UCL_NULL, parser->chunks->priority); t = parser->stack->obj->value.av; DL_APPEND (t, obj); parser->cur_obj = obj; @@ -1378,7 +1480,8 @@ ucl_parse_value (struct ucl_parser *parser, struct ucl_chunk *chunk) chunk->line ++; if ((str_len = ucl_parse_multiline_string (parser, chunk, c, p - c, &c, &var_expand)) == 0) { - ucl_set_err (chunk, UCL_ESYNTAX, "unterminated multiline value", &parser->err); + ucl_set_err (parser, UCL_ESYNTAX, + "unterminated multiline value", &parser->err); return false; } obj->type = UCL_STRING; @@ -1423,7 +1526,8 @@ parse_string: } str_len = chunk->pos - c - stripped_spaces; if (str_len <= 0) { - ucl_set_err (chunk, 0, "string value must not be empty", &parser->err); + ucl_set_err (parser, 0, "string value must not be empty", + &parser->err); return false; } else if (str_len == 4 && memcmp (c, "null", 4) == 0) { @@ -1482,7 +1586,9 @@ ucl_parse_after_value (struct ucl_parser *parser, struct ucl_chunk *chunk) else if (ucl_test_character (*p, UCL_CHARACTER_VALUE_END)) { if (*p == '}' || *p == ']') { if (parser->stack == NULL) { - ucl_set_err (chunk, UCL_ESYNTAX, "end of array or object detected without corresponding start", &parser->err); + ucl_set_err (parser, UCL_ESYNTAX, + "end of array or object detected without corresponding start", + &parser->err); return false; } if ((*p == '}' && parser->stack->obj->type == UCL_OBJECT) || @@ -1503,7 +1609,9 @@ ucl_parse_after_value (struct ucl_parser *parser, struct ucl_chunk *chunk) } } else { - ucl_set_err (chunk, UCL_ESYNTAX, "unexpected terminating symbol detected", &parser->err); + ucl_set_err (parser, UCL_ESYNTAX, + "unexpected terminating symbol detected", + &parser->err); return false; } @@ -1525,7 +1633,8 @@ ucl_parse_after_value (struct ucl_parser *parser, struct ucl_chunk *chunk) else { /* Anything else */ if (!got_sep) { - ucl_set_err (chunk, UCL_ESYNTAX, "delimiter is missing", &parser->err); + ucl_set_err (parser, UCL_ESYNTAX, "delimiter is missing", + &parser->err); return false; } return true; @@ -1612,6 +1721,120 @@ ucl_parse_macro_value (struct ucl_parser *parser, return true; } +/** + * Parse macro arguments as UCL object + * @param parser parser structure + * @param chunk the current data chunk + * @return + */ +static ucl_object_t * +ucl_parse_macro_arguments (struct ucl_parser *parser, + struct ucl_chunk *chunk) +{ + ucl_object_t *res = NULL; + struct ucl_parser *params_parser; + int obraces = 1, ebraces = 0, state = 0; + const unsigned char *p, *c; + size_t args_len = 0; + struct ucl_parser_saved_state saved; + + saved.column = chunk->column; + saved.line = chunk->line; + saved.pos = chunk->pos; + saved.remain = chunk->remain; + p = chunk->pos; + + if (*p != '(' || chunk->remain < 2) { + return NULL; + } + + /* Set begin and start */ + ucl_chunk_skipc (chunk, p); + c = p; + + while ((p) < (chunk)->end) { + switch (state) { + case 0: + /* Parse symbols and check for '(', ')' and '"' */ + if (*p == '(') { + obraces ++; + } + else if (*p == ')') { + ebraces ++; + } + else if (*p == '"') { + state = 1; + } + /* Check pairing */ + if (obraces == ebraces) { + state = 99; + } + else { + args_len ++; + } + /* Check overflow */ + if (chunk->remain == 0) { + goto restore_chunk; + } + ucl_chunk_skipc (chunk, p); + break; + case 1: + /* We have quote character, so skip all but quotes */ + if (*p == '"' && *(p - 1) != '\\') { + state = 0; + } + if (chunk->remain == 0) { + goto restore_chunk; + } + ucl_chunk_skipc (chunk, p); + break; + case 99: + /* + * We have read the full body of arguments, so we need to parse and set + * object from that + */ + params_parser = ucl_parser_new (parser->flags); + if (!ucl_parser_add_chunk (params_parser, c, args_len)) { + ucl_set_err (parser, UCL_ESYNTAX, "macro arguments parsing error", + &parser->err); + } + else { + res = ucl_parser_get_object (params_parser); + } + ucl_parser_free (params_parser); + + return res; + + break; + } + } + + return res; + +restore_chunk: + chunk->column = saved.column; + chunk->line = saved.line; + chunk->pos = saved.pos; + chunk->remain = saved.remain; + + return NULL; +} + +#define SKIP_SPACES_COMMENTS(parser, chunk, p) do { \ + while ((p) < (chunk)->end) { \ + if (!ucl_test_character (*(p), UCL_CHARACTER_WHITESPACE_UNSAFE)) { \ + if ((chunk)->remain >= 2 && ucl_lex_is_comment ((p)[0], (p)[1])) { \ + if (!ucl_skip_comments (parser)) { \ + return false; \ + } \ + p = (chunk)->pos; \ + } \ + break; \ + } \ + ucl_chunk_skipc (chunk, p); \ + } \ +} while(0) + /** * Handle the main states of rcl parser * @param parser parser structure @@ -1622,13 +1845,13 @@ ucl_parse_macro_value (struct ucl_parser *parser, static bool ucl_state_machine (struct ucl_parser *parser) { - ucl_object_t *obj; + ucl_object_t *obj, *macro_args; struct ucl_chunk *chunk = parser->chunks; const unsigned char *p, *c = NULL, *macro_start = NULL; unsigned char *macro_escaped; size_t macro_len = 0; struct ucl_macro *macro = NULL; - bool next_key = false, end_of_object = false; + bool next_key = false, end_of_object = false, ret; if (parser->top_obj == NULL) { if (*chunk->pos == '[') { @@ -1654,7 +1877,6 @@ ucl_state_machine (struct ucl_parser *parser) * if we got [ or { correspondingly or can just treat new data as * a key of newly created object */ - obj = parser->cur_obj; if (!ucl_skip_comments (parser)) { parser->prev_state = parser->state; parser->state = UCL_STATE_ERROR; @@ -1691,7 +1913,7 @@ ucl_state_machine (struct ucl_parser *parser) } if (parser->stack == NULL) { /* No objects are on stack, but we want to parse a key */ - ucl_set_err (chunk, UCL_ESYNTAX, "top object is finished but the parser " + ucl_set_err (parser, UCL_ESYNTAX, "top object is finished but the parser " "expects a key", &parser->err); parser->prev_state = parser->state; parser->state = UCL_STATE_ERROR; @@ -1757,7 +1979,8 @@ ucl_state_machine (struct ucl_parser *parser) p = chunk->pos; break; case UCL_STATE_MACRO_NAME: - if (!ucl_test_character (*p, UCL_CHARACTER_WHITESPACE_UNSAFE)) { + if (!ucl_test_character (*p, UCL_CHARACTER_WHITESPACE_UNSAFE) && + *p != '(') { ucl_chunk_skipc (chunk, p); } else if (p - c > 0) { @@ -1772,48 +1995,51 @@ ucl_state_machine (struct ucl_parser *parser) return false; } /* Now we need to skip all spaces */ - while (p < chunk->end) { - if (!ucl_test_character (*p, UCL_CHARACTER_WHITESPACE_UNSAFE)) { - if (chunk->remain >= 2 && ucl_lex_is_comment (p[0], p[1])) { - /* Skip comment */ - if (!ucl_skip_comments (parser)) { - return false; - } - p = chunk->pos; - } - break; - } - ucl_chunk_skipc (chunk, p); - } + SKIP_SPACES_COMMENTS(parser, chunk, p); parser->state = UCL_STATE_MACRO; } break; case UCL_STATE_MACRO: + if (*chunk->pos == '(') { + macro_args = ucl_parse_macro_arguments (parser, chunk); + p = chunk->pos; + if (macro_args) { + SKIP_SPACES_COMMENTS(parser, chunk, p); + } + } + else { + macro_args = NULL; + } if (!ucl_parse_macro_value (parser, chunk, macro, ¯o_start, ¯o_len)) { parser->prev_state = parser->state; parser->state = UCL_STATE_ERROR; return false; } - macro_len = ucl_expand_variable (parser, ¯o_escaped, macro_start, macro_len); + macro_len = ucl_expand_variable (parser, ¯o_escaped, + macro_start, macro_len); parser->state = parser->prev_state; if (macro_escaped == NULL) { - if (!macro->handler (macro_start, macro_len, macro->ud)) { - return false; - } + ret = macro->handler (macro_start, macro_len, macro_args, + macro->ud); } else { - if (!macro->handler (macro_escaped, macro_len, macro->ud)) { - UCL_FREE (macro_len + 1, macro_escaped); - return false; - } + ret = macro->handler (macro_escaped, macro_len, macro_args, + macro->ud); UCL_FREE (macro_len + 1, macro_escaped); } p = chunk->pos; + if (macro_args) { + ucl_object_unref (macro_args); + } + if (!ret) { + return false; + } break; default: /* TODO: add all states */ - ucl_set_err (chunk, UCL_EINTERNAL, "internal error: parser is in an unknown state", &parser->err); + ucl_set_err (parser, UCL_EINTERNAL, + "internal error: parser is in an unknown state", &parser->err); parser->state = UCL_STATE_ERROR; return false; } @@ -1888,7 +2114,7 @@ ucl_parser_register_variable (struct ucl_parser *parser, const char *var, if (new != NULL) { /* Remove variable */ - LL_DELETE (parser->variables, new); + DL_DELETE (parser->variables, new); free (new->var); free (new->value); UCL_FREE (sizeof (struct ucl_variable), new); @@ -1910,7 +2136,7 @@ ucl_parser_register_variable (struct ucl_parser *parser, const char *var, new->value = strdup (value); new->value_len = strlen (value); - LL_PREPEND (parser->variables, new); + DL_APPEND (parser->variables, new); } else { free (new->value); @@ -1929,15 +2155,19 @@ ucl_parser_set_variables_handler (struct ucl_parser *parser, } bool -ucl_parser_add_chunk (struct ucl_parser *parser, const unsigned char *data, - size_t len) +ucl_parser_add_chunk_priority (struct ucl_parser *parser, const unsigned char *data, + size_t len, unsigned priority) { struct ucl_chunk *chunk; - if (data == NULL || len == 0) { + if (data == NULL) { ucl_create_err (&parser->err, "invalid chunk added"); return false; } + if (len == 0) { + parser->top_obj = ucl_object_new_full (UCL_OBJECT, priority); + return true; + } if (parser->state != UCL_STATE_ERROR) { chunk = UCL_ALLOC (sizeof (struct ucl_chunk)); if (chunk == NULL) { @@ -1950,6 +2180,7 @@ ucl_parser_add_chunk (struct ucl_parser *parser, const unsigned char *data, chunk->end = chunk->begin + len; chunk->line = 1; chunk->column = 0; + chunk->priority = priority; LL_PREPEND (parser->chunks, chunk); parser->recursion ++; if (parser->recursion > UCL_MAX_RECURSION) { @@ -1965,6 +2196,13 @@ ucl_parser_add_chunk (struct ucl_parser *parser, const unsigned char *data, return false; } +bool +ucl_parser_add_chunk (struct ucl_parser *parser, const unsigned char *data, + size_t len) +{ + return ucl_parser_add_chunk_priority (parser, data, len, 0); +} + bool ucl_parser_add_string (struct ucl_parser *parser, const char *data, size_t len) diff --git a/src/ucl_util.c b/src/ucl_util.c index 63f5e629826f..41702e941f5b 100644 --- a/src/ucl_util.c +++ b/src/ucl_util.c @@ -25,6 +25,8 @@ #include "ucl_internal.h" #include "ucl_chartable.h" +#include + #ifdef HAVE_LIBGEN_H #include /* For dirname */ #endif @@ -129,11 +131,6 @@ static char* ucl_realpath(const char *path, char *resolved_path) { #define ucl_realpath realpath #endif -/** - * @file rcl_util.c - * Utilities for rcl parsing - */ - typedef void (*ucl_object_dtor) (ucl_object_t *obj); static void ucl_object_free_internal (ucl_object_t *obj, bool allow_rec, ucl_object_dtor dtor); @@ -148,7 +145,19 @@ ucl_object_dtor_free (ucl_object_t *obj) if (obj->trash_stack[UCL_TRASH_VALUE] != NULL) { UCL_FREE (obj->len, obj->trash_stack[UCL_TRASH_VALUE]); } - UCL_FREE (sizeof (ucl_object_t), obj); + /* Do not free ephemeral objects */ + if ((obj->flags & UCL_OBJECT_EPHEMERAL) == 0) { + if (obj->type != UCL_USERDATA) { + UCL_FREE (sizeof (ucl_object_t), obj); + } + else { + struct ucl_object_userdata *ud = (struct ucl_object_userdata *)obj; + if (ud->dtor) { + ud->dtor (obj->value.ud); + } + UCL_FREE (sizeof (*ud), obj); + } + } } /* @@ -423,7 +432,11 @@ ucl_parser_free (struct ucl_parser *parser) } if (parser->err != NULL) { - utstring_free(parser->err); + utstring_free (parser->err); + } + + if (parser->cur_file) { + free (parser->cur_file); } UCL_FREE (sizeof (struct ucl_parser), parser); @@ -701,7 +714,8 @@ ucl_sig_check (const unsigned char *data, size_t datalen, */ static bool ucl_include_url (const unsigned char *data, size_t len, - struct ucl_parser *parser, bool check_signature, bool must_exist) + struct ucl_parser *parser, bool check_signature, bool must_exist, + unsigned priority) { bool res; @@ -744,7 +758,7 @@ ucl_include_url (const unsigned char *data, size_t len, prev_state = parser->state; parser->state = UCL_STATE_INIT; - res = ucl_parser_add_chunk (parser, buf, buflen); + res = ucl_parser_add_chunk_priority (parser, buf, buflen, priority); if (res == true) { /* Remove chunk from the stack */ chunk = parser->chunks; @@ -761,23 +775,30 @@ ucl_include_url (const unsigned char *data, size_t len, } /** - * Include a file to configuration + * Include a single file to the parser * @param data * @param len * @param parser - * @param err + * @param check_signature + * @param must_exist + * @param allow_glob + * @param priority * @return */ static bool -ucl_include_file (const unsigned char *data, size_t len, - struct ucl_parser *parser, bool check_signature, bool must_exist) +ucl_include_file_single (const unsigned char *data, size_t len, + struct ucl_parser *parser, bool check_signature, bool must_exist, + unsigned priority) { bool res; struct ucl_chunk *chunk; unsigned char *buf = NULL; + char *old_curfile; size_t buflen; char filebuf[PATH_MAX], realbuf[PATH_MAX]; int prev_state; + struct ucl_variable *cur_var, *tmp_var, *old_curdir = NULL, + *old_filename = NULL; snprintf (filebuf, sizeof (filebuf), "%.*s", (int)len, data); if (ucl_realpath (filebuf, realbuf) == NULL) { @@ -790,6 +811,13 @@ ucl_include_file (const unsigned char *data, size_t len, return false; } + if (parser->cur_file && strcmp (realbuf, parser->cur_file) == 0) { + /* We are likely including the file itself */ + ucl_create_err (&parser->err, "trying to include the file %s from itself", + realbuf); + return false; + } + if (!ucl_fetch_file (realbuf, &buf, &buflen, &parser->err, must_exist)) { return (!must_exist || false); } @@ -818,19 +846,66 @@ ucl_include_file (const unsigned char *data, size_t len, #endif } + old_curfile = parser->cur_file; + parser->cur_file = strdup (realbuf); + + /* Store old file vars */ + DL_FOREACH_SAFE (parser->variables, cur_var, tmp_var) { + if (strcmp (cur_var->var, "CURDIR") == 0) { + old_curdir = cur_var; + DL_DELETE (parser->variables, cur_var); + } + else if (strcmp (cur_var->var, "FILENAME") == 0) { + old_filename = cur_var; + DL_DELETE (parser->variables, cur_var); + } + } + ucl_parser_set_filevars (parser, realbuf, false); prev_state = parser->state; parser->state = UCL_STATE_INIT; - res = ucl_parser_add_chunk (parser, buf, buflen); - if (res == true) { - /* Remove chunk from the stack */ - chunk = parser->chunks; - if (chunk != NULL) { - parser->chunks = chunk->next; - UCL_FREE (sizeof (struct ucl_chunk), chunk); + res = ucl_parser_add_chunk_priority (parser, buf, buflen, priority); + if (!res && !must_exist) { + /* Free error */ + utstring_free (parser->err); + parser->err = NULL; + parser->state = UCL_STATE_AFTER_VALUE; + } + + /* Remove chunk from the stack */ + chunk = parser->chunks; + if (chunk != NULL) { + parser->chunks = chunk->next; + UCL_FREE (sizeof (struct ucl_chunk), chunk); + parser->recursion --; + } + + /* Restore old file vars */ + parser->cur_file = old_curfile; + DL_FOREACH_SAFE (parser->variables, cur_var, tmp_var) { + if (strcmp (cur_var->var, "CURDIR") == 0 && old_curdir) { + DL_DELETE (parser->variables, cur_var); + free (cur_var->var); + free (cur_var->value); + UCL_FREE (sizeof (struct ucl_variable), cur_var); } + else if (strcmp (cur_var->var, "FILENAME") == 0 && old_filename) { + DL_DELETE (parser->variables, cur_var); + free (cur_var->var); + free (cur_var->value); + UCL_FREE (sizeof (struct ucl_variable), cur_var); + } + } + if (old_filename) { + DL_APPEND (parser->variables, old_filename); + } + if (old_curdir) { + DL_APPEND (parser->variables, old_curdir); + } + if (old_curfile) { + free (old_curfile); } parser->state = prev_state; @@ -842,6 +917,138 @@ ucl_include_file (const unsigned char *data, size_t len, return res; } +/** + * Include a file to configuration + * @param data + * @param len + * @param parser + * @param err + * @return + */ +static bool +ucl_include_file (const unsigned char *data, size_t len, + struct ucl_parser *parser, bool check_signature, bool must_exist, + bool allow_glob, unsigned priority) +{ + const unsigned char *p = data, *end = data + len; + bool need_glob = false; + int cnt = 0; + glob_t globbuf; + char glob_pattern[PATH_MAX]; + size_t i; + + if (!allow_glob) { + return ucl_include_file_single (data, len, parser, check_signature, + must_exist, priority); + } + else { + /* Check for special symbols in a filename */ + while (p != end) { + if (*p == '*' || *p == '?') { + need_glob = true; + break; + } + p ++; + } + if (need_glob) { + memset (&globbuf, 0, sizeof (globbuf)); + ucl_strlcpy (glob_pattern, (const char *)data, sizeof (glob_pattern)); + if (glob (glob_pattern, 0, NULL, &globbuf) != 0) { + return (!must_exist || false); + } + for (i = 0; i < globbuf.gl_pathc; i ++) { + if (!ucl_include_file_single ((unsigned char *)globbuf.gl_pathv[i], + strlen (globbuf.gl_pathv[i]), parser, check_signature, + must_exist, priority)) { + globfree (&globbuf); + return false; + } + cnt ++; + } + globfree (&globbuf); + + if (cnt == 0 && must_exist) { + ucl_create_err (&parser->err, "cannot match any files for pattern %s", + glob_pattern); + return false; + } + } + else { + return ucl_include_file_single (data, len, parser, check_signature, + must_exist, priority); + } + } + + return true; +} + +/** + * Common function to handle .*include* macros + * @param data + * @param len + * @param args + * @param parser + * @param default_try + * @param default_sign + * @return + */ +static bool +ucl_include_common (const unsigned char *data, size_t len, + const ucl_object_t *args, struct ucl_parser *parser, + bool default_try, + bool default_sign) +{ + bool try_load, allow_glob, allow_url, need_sign; + unsigned priority; + const ucl_object_t *param; + ucl_object_iter_t it = NULL; + + /* Default values */ + try_load = default_try; + allow_glob = false; + allow_url = true; + need_sign = default_sign; + priority = 0; + + /* Process arguments */ + if (args != NULL && args->type == UCL_OBJECT) { + while ((param = ucl_iterate_object (args, &it, true)) != NULL) { + if (param->type == UCL_BOOLEAN) { + if (strcmp (param->key, "try") == 0) { + try_load = ucl_object_toboolean (param); + } + else if (strcmp (param->key, "sign") == 0) { + need_sign = ucl_object_toboolean (param); + } + else if (strcmp (param->key, "glob") == 0) { + allow_glob = ucl_object_toboolean (param); + } + else if (strcmp (param->key, "url") == 0) { + allow_url = ucl_object_toboolean (param); + } + } + else if (param->type == UCL_INT) { + if (strcmp (param->key, "priority") == 0) { + priority = ucl_object_toint (param); + } + } + } + } + + if (*data == '/' || *data == '.') { + /* Try to load a file */ + return ucl_include_file (data, len, parser, need_sign, !try_load, + allow_glob, priority); + } + else if (allow_url) { + /* Globbing is not used for URL's */ + return ucl_include_url (data, len, parser, need_sign, !try_load, + priority); + } + + return false; +} + /** * Handle include macro * @param data include data @@ -851,16 +1058,12 @@ ucl_include_file (const unsigned char *data, size_t len, * @return */ UCL_EXTERN bool -ucl_include_handler (const unsigned char *data, size_t len, void* ud) +ucl_include_handler (const unsigned char *data, size_t len, + const ucl_object_t *args, void* ud) { struct ucl_parser *parser = ud; - if (*data == '/' || *data == '.') { - /* Try to load a file */ - return ucl_include_file (data, len, parser, false, true); - } - - return ucl_include_url (data, len, parser, false, true); + return ucl_include_common (data, len, args, parser, false, false); } /** @@ -872,30 +1075,22 @@ ucl_include_handler (const unsigned char *data, size_t len, void* ud) * @return */ UCL_EXTERN bool -ucl_includes_handler (const unsigned char *data, size_t len, void* ud) +ucl_includes_handler (const unsigned char *data, size_t len, + const ucl_object_t *args, void* ud) { struct ucl_parser *parser = ud; - if (*data == '/' || *data == '.') { - /* Try to load a file */ - return ucl_include_file (data, len, parser, true, true); - } - - return ucl_include_url (data, len, parser, true, true); + return ucl_include_common (data, len, args, parser, false, true); } UCL_EXTERN bool -ucl_try_include_handler (const unsigned char *data, size_t len, void* ud) +ucl_try_include_handler (const unsigned char *data, size_t len, + const ucl_object_t *args, void* ud) { struct ucl_parser *parser = ud; - if (*data == '/' || *data == '.') { - /* Try to load a file */ - return ucl_include_file (data, len, parser, false, false); - } - - return ucl_include_url (data, len, parser, false, false); + return ucl_include_common (data, len, args, parser, true, false); } UCL_EXTERN bool @@ -947,6 +1142,10 @@ ucl_parser_add_file (struct ucl_parser *parser, const char *filename) return false; } + if (parser->cur_file) { + free (parser->cur_file); + } + parser->cur_file = strdup (realbuf); ucl_parser_set_filevars (parser, realbuf, false); ret = ucl_parser_add_chunk (parser, buf, len); @@ -957,6 +1156,39 @@ ucl_parser_add_file (struct ucl_parser *parser, const char *filename) return ret; } +UCL_EXTERN bool +ucl_parser_add_fd (struct ucl_parser *parser, int fd) +{ + unsigned char *buf; + size_t len; + bool ret; + struct stat st; + + if (fstat (fd, &st) == -1) { + ucl_create_err (&parser->err, "cannot stat fd %d: %s", + fd, strerror (errno)); + return false; + } + if ((buf = ucl_mmap (NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) { + ucl_create_err (&parser->err, "cannot mmap fd %d: %s", + fd, strerror (errno)); + return false; + } + + if (parser->cur_file) { + free (parser->cur_file); + } + parser->cur_file = NULL; + len = st.st_size; + ret = ucl_parser_add_chunk (parser, buf, len); + + if (len > 0) { + ucl_munmap (buf, len); + } + + return ret; +} + size_t ucl_strlcpy (char *dst, const char *src, size_t siz) { @@ -1176,6 +1408,15 @@ ucl_object_insert_key_common (ucl_object_t *top, ucl_object_t *elt, } } + /* workaround for some use cases */ + if (elt->trash_stack[UCL_TRASH_KEY] != NULL && + key != (const char *)elt->trash_stack[UCL_TRASH_KEY]) { + /* Remove copied key */ + free (elt->trash_stack[UCL_TRASH_KEY]); + elt->trash_stack[UCL_TRASH_KEY] = NULL; + elt->flags &= ~UCL_OBJECT_ALLOCATED_KEY; + } + elt->key = key; elt->keylen = keylen; @@ -1185,9 +1426,8 @@ ucl_object_insert_key_common (ucl_object_t *top, ucl_object_t *elt, found = __DECONST (ucl_object_t *, ucl_hash_search_obj (top->value.ov, elt)); - if (!found) { + if (found == NULL) { top->value.ov = ucl_hash_insert_object (top->value.ov, elt); - DL_APPEND (found, elt); top->len ++; if (replace) { ret = false; @@ -1195,11 +1435,8 @@ ucl_object_insert_key_common (ucl_object_t *top, ucl_object_t *elt, } else { if (replace) { - ucl_hash_delete (top->value.ov, found); + ucl_hash_replace (top->value.ov, found, elt); ucl_object_unref (found); - top->value.ov = ucl_hash_insert_object (top->value.ov, elt); - found = NULL; - DL_APPEND (found, elt); } else if (merge) { if (found->type != UCL_OBJECT && elt->type == UCL_OBJECT) { @@ -1310,6 +1547,40 @@ ucl_object_replace_key (ucl_object_t *top, ucl_object_t *elt, return ucl_object_insert_key_common (top, elt, key, keylen, copy_key, false, true); } +bool +ucl_object_merge (ucl_object_t *top, ucl_object_t *elt, bool copy) +{ + ucl_object_t *cur = NULL, *cp = NULL, *found = NULL; + ucl_object_iter_t iter = NULL; + + if (top == NULL || top->type != UCL_OBJECT || elt == NULL || elt->type != UCL_OBJECT) { + return false; + } + + /* Mix two hashes */ + while ((cur = (ucl_object_t*)ucl_hash_iterate (elt->value.ov, &iter))) { + if (copy) { + cp = ucl_object_copy (cur); + } + else { + cp = ucl_object_ref (cur); + } + found = __DECONST(ucl_object_t *, ucl_hash_search (top->value.ov, cp->key, cp->keylen)); + if (found == NULL) { + /* The key does not exist */ + top->value.ov = ucl_hash_insert_object (top->value.ov, cp); + top->len ++; + } + else { + /* The key already exists, replace it */ + ucl_hash_replace (top->value.ov, found, cp); + ucl_object_unref (found); + } + } + + return true; +} + const ucl_object_t * ucl_object_find_keyl (const ucl_object_t *obj, const char *key, size_t klen) { @@ -1372,9 +1643,6 @@ ucl_iterate_object (const ucl_object_t *obj, ucl_object_iter_t *iter, bool expan elt = *iter; if (elt == NULL) { elt = obj; - if (elt == NULL) { - return NULL; - } } else if (elt == obj) { return NULL; @@ -1442,29 +1710,59 @@ ucl_lookup_path (const ucl_object_t *top, const char *path_in) { ucl_object_t * ucl_object_new (void) { - ucl_object_t *new; - new = malloc (sizeof (ucl_object_t)); - if (new != NULL) { - memset (new, 0, sizeof (ucl_object_t)); - new->ref = 1; - new->type = UCL_NULL; - } - return new; + return ucl_object_typed_new (UCL_NULL); } ucl_object_t * ucl_object_typed_new (ucl_type_t type) +{ + return ucl_object_new_full (type, 0); +} + +ucl_object_t * +ucl_object_new_full (ucl_type_t type, unsigned priority) { ucl_object_t *new; - new = malloc (sizeof (ucl_object_t)); - if (new != NULL) { - memset (new, 0, sizeof (ucl_object_t)); - new->ref = 1; - new->type = (type <= UCL_NULL ? type : UCL_NULL); + + if (type != UCL_USERDATA) { + new = UCL_ALLOC (sizeof (ucl_object_t)); + if (new != NULL) { + memset (new, 0, sizeof (ucl_object_t)); + new->ref = 1; + new->type = (type <= UCL_NULL ? type : UCL_NULL); + new->next = NULL; + new->prev = new; + ucl_object_set_priority (new, priority); + } } + else { + new = ucl_object_new_userdata (NULL, NULL); + ucl_object_set_priority (new, priority); + } + return new; } +ucl_object_t* +ucl_object_new_userdata (ucl_userdata_dtor dtor, ucl_userdata_emitter emitter) +{ + struct ucl_object_userdata *new; + size_t nsize = sizeof (*new); + + new = UCL_ALLOC (nsize); + if (new != NULL) { + memset (new, 0, nsize); + new->obj.ref = 1; + new->obj.type = UCL_USERDATA; + new->obj.next = NULL; + new->obj.prev = (ucl_object_t *)new; + new->dtor = dtor; + new->emitter = emitter; + } + + return (ucl_object_t *)new; +} + ucl_type_t ucl_object_type (const ucl_object_t *obj) { @@ -1576,6 +1874,30 @@ ucl_array_prepend (ucl_object_t *top, ucl_object_t *elt) return true; } +bool +ucl_array_merge (ucl_object_t *top, ucl_object_t *elt, bool copy) +{ + ucl_object_t *cur, *tmp, *cp; + + if (elt == NULL || top == NULL || top->type != UCL_ARRAY || elt->type != UCL_ARRAY) { + return false; + } + + DL_FOREACH_SAFE (elt->value.av, cur, tmp) { + if (copy) { + cp = ucl_object_copy (cur); + } + else { + cp = ucl_object_ref (cur); + } + if (cp != NULL) { + ucl_array_append (top, cp); + } + } + + return true; +} + ucl_object_t * ucl_array_delete (ucl_object_t *top, ucl_object_t *elt) { @@ -1660,6 +1982,28 @@ ucl_array_find_index (const ucl_object_t *top, unsigned int index) return NULL; } +ucl_object_t * +ucl_array_replace_index (ucl_object_t *top, ucl_object_t *elt, + unsigned int index) +{ + ucl_object_t *cur, *tmp; + + if (top == NULL || top->type != UCL_ARRAY || elt == NULL || + top->len == 0 || (index + 1) > top->len) { + return NULL; + } + + DL_FOREACH_SAFE (top->value.av, cur, tmp) { + if (index == 0) { + DL_REPLACE_ELEM (top->value.av, cur, elt); + return cur; + } + --index; + } + + return NULL; +} + ucl_object_t * ucl_elt_append (ucl_object_t *head, ucl_object_t *elt) { @@ -1849,16 +2193,99 @@ ucl_object_ref (const ucl_object_t *obj) ucl_object_t *res = NULL; if (obj != NULL) { - res = __DECONST (ucl_object_t *, obj); + if (obj->flags & UCL_OBJECT_EPHEMERAL) { + /* + * Use deep copy for ephemeral objects, note that its refcount + * is NOT increased, since ephemeral objects does not need refcount + * at all + */ + res = ucl_object_copy (obj); + } + else { + res = __DECONST (ucl_object_t *, obj); #ifdef HAVE_ATOMIC_BUILTINS - (void)__sync_add_and_fetch (&res->ref, 1); + (void)__sync_add_and_fetch (&res->ref, 1); #else - res->ref ++; + res->ref ++; #endif + } } return res; } +static ucl_object_t * +ucl_object_copy_internal (const ucl_object_t *other, bool allow_array) +{ + + ucl_object_t *new; + ucl_object_iter_t it = NULL; + const ucl_object_t *cur; + + new = malloc (sizeof (*new)); + + if (new != NULL) { + memcpy (new, other, sizeof (*new)); + if (other->flags & UCL_OBJECT_EPHEMERAL) { + /* Copied object is always non ephemeral */ + new->flags &= ~UCL_OBJECT_EPHEMERAL; + } + new->ref = 1; + /* Unlink from others */ + new->next = NULL; + new->prev = new; + + /* deep copy of values stored */ + if (other->trash_stack[UCL_TRASH_KEY] != NULL) { + new->trash_stack[UCL_TRASH_KEY] = + strdup (other->trash_stack[UCL_TRASH_KEY]); + if (other->key == (const char *)other->trash_stack[UCL_TRASH_KEY]) { + new->key = new->trash_stack[UCL_TRASH_KEY]; + } + } + if (other->trash_stack[UCL_TRASH_VALUE] != NULL) { + new->trash_stack[UCL_TRASH_VALUE] = + strdup (other->trash_stack[UCL_TRASH_VALUE]); + if (new->type == UCL_STRING) { + new->value.sv = new->trash_stack[UCL_TRASH_VALUE]; + } + } + + if (other->type == UCL_ARRAY || other->type == UCL_OBJECT) { + /* reset old value */ + memset (&new->value, 0, sizeof (new->value)); + + while ((cur = ucl_iterate_object (other, &it, true)) != NULL) { + if (other->type == UCL_ARRAY) { + ucl_array_append (new, ucl_object_copy_internal (cur, false)); + } + else { + ucl_object_t *cp = ucl_object_copy_internal (cur, true); + if (cp != NULL) { + ucl_object_insert_key (new, cp, cp->key, cp->keylen, + false); + } + } + } + } + else if (allow_array && other->next != NULL) { + LL_FOREACH (other->next, cur) { + ucl_object_t *cp = ucl_object_copy_internal (cur, false); + if (cp != NULL) { + DL_APPEND (new, cp); + } + } + } + } + + return new; +} + +ucl_object_t * +ucl_object_copy (const ucl_object_t *other) +{ + return ucl_object_copy_internal (other, true); +} + void ucl_object_unref (ucl_object_t *obj) { @@ -1956,3 +2383,25 @@ ucl_object_array_sort (ucl_object_t *ar, DL_SORT (ar->value.av, cmp); } + +#define PRIOBITS 4 + +unsigned int +ucl_object_get_priority (const ucl_object_t *obj) +{ + if (obj == NULL) { + return 0; + } + + return (obj->flags >> ((sizeof (obj->flags) * NBBY) - PRIOBITS)); +} + +void +ucl_object_set_priority (ucl_object_t *obj, + unsigned int priority) +{ + if (obj != NULL) { + priority &= (0x1 << PRIOBITS) - 1; + obj->flags |= priority << ((sizeof (obj->flags) * NBBY) - PRIOBITS); + } +} diff --git a/tests/Makefile.am b/tests/Makefile.am index a21a65c16534..5b17e1fb252e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -EXTRA_DIST = $(TESTS) basic schema generate.res rcl_test.json.xz +EXTRA_DIST = $(TESTS) basic schema generate.res streamline.res rcl_test.json.xz TESTS = basic.test \ generate.test \ diff --git a/tests/basic/12.in b/tests/basic/12.in new file mode 100644 index 000000000000..b63a32fbf92d --- /dev/null +++ b/tests/basic/12.in @@ -0,0 +1,2 @@ +key1: 12 , +key2: 12 value diff --git a/tests/basic/12.res b/tests/basic/12.res new file mode 100644 index 000000000000..163af46c7f17 --- /dev/null +++ b/tests/basic/12.res @@ -0,0 +1,3 @@ +key1 = 12; +key2 = "12 value"; + diff --git a/tests/basic/13.in b/tests/basic/13.in new file mode 100644 index 000000000000..81f03a61d286 --- /dev/null +++ b/tests/basic/13.in @@ -0,0 +1,9 @@ +key = value_orig; + +# test glob +.include(glob=true) "${CURDIR}/include_dir/test*.conf" + +.include(priority=1) "${CURDIR}/include_dir/pri1.conf" +.include(priority=2) "${CURDIR}/include_dir/pri2.conf" + +.include(try=true) "${CURDIR}/include_dir/invalid.conf" diff --git a/tests/basic/13.res b/tests/basic/13.res new file mode 100644 index 000000000000..aa13a5471f2e --- /dev/null +++ b/tests/basic/13.res @@ -0,0 +1,8 @@ +key = "value_orig"; +key = "value1"; +key = "value2"; +key = "value3"; +key_pri = "priority2"; +key_trace1 = "pri1"; +key_trace2 = "pri2"; + diff --git a/tests/basic/4.res b/tests/basic/4.res index 58c3599432b8..2b862fc1410a 100644 --- a/tests/basic/4.res +++ b/tests/basic/4.res @@ -10,7 +10,14 @@ licenses [ "BSD", ] flatsize = 60523; -desc = "pkgconf is a program which helps to configure compiler and linker flags for\ndevelopment frameworks. It is similar to pkg-config, but was written from\nscratch in Summer of 2011 to replace pkg-config, which now needs itself to build\nitself.\n\nWWW: https://github.com/pkgconf/pkgconf"; +desc = <type == UCL_OBJECT) { printf ("%stype: UCL_OBJECT\n", pre); printf ("%svalue: %p\n", pre, obj->value.ov); + it_obj = NULL; while ((cur = ucl_iterate_object (obj, &it_obj, true))) { ucl_obj_dump (cur, shift + 2); } From 0fa5393fa8146125584e6d1cf54e64a0a3bc84c7 Mon Sep 17 00:00:00 2001 From: Roman Divacky Date: Sat, 29 Nov 2014 08:59:26 +0000 Subject: [PATCH 57/64] Shrink boot2 a bit more by factoring out common pattern of printf();return(-1); This shrinks it by 8bytes using clang35 and by 12bytes using clang34. --- sys/boot/i386/boot2/boot2.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sys/boot/i386/boot2/boot2.c b/sys/boot/i386/boot2/boot2.c index 4e1a83522f14..001126fb83f8 100644 --- a/sys/boot/i386/boot2/boot2.c +++ b/sys/boot/i386/boot2/boot2.c @@ -501,6 +501,7 @@ dskread(void *buf, unsigned lba, unsigned nblk) char *sec; unsigned i; uint8_t sl; + const char *reason; if (!dsk_meta) { sec = dmadat->secbuf; @@ -525,8 +526,8 @@ dskread(void *buf, unsigned lba, unsigned nblk) if (sl != COMPATIBILITY_SLICE) dp += sl - BASE_SLICE; if (dp->dp_typ != DOSPTYP_386BSD) { - printf("Invalid %s\n", "slice"); - return -1; + reason = "slice"; + goto error; } dsk.start = dp->dp_start; } @@ -535,8 +536,8 @@ dskread(void *buf, unsigned lba, unsigned nblk) d = (void *)(sec + LABELOFFSET); if (d->d_magic != DISKMAGIC || d->d_magic2 != DISKMAGIC) { if (dsk.part != RAW_PART) { - printf("Invalid %s\n", "label"); - return -1; + reason = "label"; + goto error; } } else { if (!dsk.init) { @@ -546,14 +547,17 @@ dskread(void *buf, unsigned lba, unsigned nblk) } if (dsk.part >= d->d_npartitions || !d->d_partitions[dsk.part].p_size) { - printf("Invalid %s\n", "partition"); - return -1; + reason = "partition"; + goto error; } dsk.start += d->d_partitions[dsk.part].p_offset; dsk.start -= d->d_partitions[RAW_PART].p_offset; } } return drvread(buf, dsk.start + lba, nblk); +error: + printf("Invalid %s\n", reason); + return -1; } static void From 6d6911c44b6787e461e36a585df5158813657be1 Mon Sep 17 00:00:00 2001 From: Yoshihiro Takahashi Date: Sat, 29 Nov 2014 09:27:18 +0000 Subject: [PATCH 58/64] MFi386: r275237 (by rdivacky) Shrink boot2 a bit more by factoring out common pattern of printf();return(-1); --- sys/boot/pc98/boot2/boot2.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sys/boot/pc98/boot2/boot2.c b/sys/boot/pc98/boot2/boot2.c index 69a422e5cb44..010fd5093bcc 100644 --- a/sys/boot/pc98/boot2/boot2.c +++ b/sys/boot/pc98/boot2/boot2.c @@ -639,6 +639,7 @@ dskread(void *buf, unsigned lba, unsigned nblk) unsigned i; uint8_t sl; u_char *p; + const char *reason; if (!dsk_meta) { sec = dmadat->secbuf; @@ -660,8 +661,8 @@ dskread(void *buf, unsigned lba, unsigned nblk) if (sl != WHOLE_DISK_SLICE) { dp += sl - BASE_SLICE; if (dp->dp_mid != DOSMID_386BSD) { - printf("Invalid %s\n", "slice"); - return -1; + reason = "slice"; + goto error; } dsk.start = dp->dp_scyl * dsk.head * dsk.sec + dp->dp_shd * dsk.sec + dp->dp_ssect; @@ -671,14 +672,14 @@ dskread(void *buf, unsigned lba, unsigned nblk) d = (void *)(sec + LABELOFFSET); if (d->d_magic != DISKMAGIC || d->d_magic2 != DISKMAGIC) { if (dsk.part != RAW_PART) { - printf("Invalid %s\n", "label"); - return -1; + reason = "label"; + goto error; } } else { if (dsk.part >= d->d_npartitions || !d->d_partitions[dsk.part].p_size) { - printf("Invalid %s\n", "partition"); - return -1; + reason = "partition"; + goto error; } dsk.start += d->d_partitions[dsk.part].p_offset; dsk.start -= d->d_partitions[RAW_PART].p_offset; @@ -690,6 +691,9 @@ dskread(void *buf, unsigned lba, unsigned nblk) return i; } return 0; +error: + printf("Invalid %s\n", reason); + return -1; } static void From c04c7681075f087566c63e3935a0d3cff4782247 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sat, 29 Nov 2014 11:50:19 +0000 Subject: [PATCH 59/64] Implement --no-fatal-warning for compatibility with newer ld what ever order the options are passed to ld(1) the --no-fatal-warning always disable --fatal-warning --- contrib/binutils/ld/lexsup.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/contrib/binutils/ld/lexsup.c b/contrib/binutils/ld/lexsup.c index 6ef5053dedcb..2dfab983481d 100644 --- a/contrib/binutils/ld/lexsup.c +++ b/contrib/binutils/ld/lexsup.c @@ -84,6 +84,7 @@ enum option_values OPTION_NO_KEEP_MEMORY, OPTION_NO_WARN_MISMATCH, OPTION_NO_WARN_SEARCH_MISMATCH, + OPTION_NO_WARN_FATAL, OPTION_NOINHIBIT_EXEC, OPTION_NON_SHARED, OPTION_NO_WHOLE_ARCHIVE, @@ -375,6 +376,9 @@ static const struct ld_option ld_options[] = { {"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL}, '\0', NULL, N_("Treat warnings as errors"), TWO_DASHES }, + { {"no-fatal-warnings", no_argument, NULL, OPTION_NO_WARN_FATAL}, + '\0', NULL, N_("Don't treat warnings as errors"), + TWO_DASHES }, { {"fini", required_argument, NULL, OPTION_FINI}, '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH }, { {"force-exe-suffix", no_argument, NULL, OPTION_FORCE_EXE_SUFFIX}, @@ -568,6 +572,7 @@ parse_args (unsigned argc, char **argv) struct option *really_longopts; int last_optind; enum report_method how_to_report_unresolved_symbols = RM_GENERATE_ERROR; + int no_fatal_warnings = FALSE; shortopts = xmalloc (OPTION_COUNT * 3 + 2); longopts = xmalloc (sizeof (*longopts) * (OPTION_COUNT + 1)); @@ -1317,6 +1322,9 @@ parse_args (unsigned argc, char **argv) case OPTION_WARN_FATAL: config.fatal_warnings = TRUE; break; + case OPTION_NO_WARN_FATAL: + no_fatal_warnings = TRUE; + break; case OPTION_WARN_MULTIPLE_GP: config.warn_multiple_gp = TRUE; break; @@ -1438,6 +1446,8 @@ parse_args (unsigned argc, char **argv) break; } } + if (no_fatal_warnings) + config.fatal_warnings = FALSE; if (ingroup) lang_leave_group (); From ed7959517bbc2327046d6d47938b9703bb04bb10 Mon Sep 17 00:00:00 2001 From: Yoshihiro Takahashi Date: Sat, 29 Nov 2014 12:22:31 +0000 Subject: [PATCH 60/64] MFi386: r275059, r275061, r275062 and r275191 (by rdivacky) Shrink boot2 by a couple more bytes. --- sys/boot/pc98/boot2/boot2.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sys/boot/pc98/boot2/boot2.c b/sys/boot/pc98/boot2/boot2.c index 010fd5093bcc..936760e62fd3 100644 --- a/sys/boot/pc98/boot2/boot2.c +++ b/sys/boot/pc98/boot2/boot2.c @@ -462,7 +462,8 @@ load(void) caddr_t p; ufs_ino_t ino; uint32_t addr; - int i, j; + int k; + uint8_t i, j; if (!(ino = lookup(kname))) { if (!ls) @@ -483,7 +484,7 @@ load(void) return; } else if (IS_ELF(hdr.eh)) { fs_off = hdr.eh.e_phoff; - for (j = i = 0; i < hdr.eh.e_phnum && j < 2; i++) { + for (j = k = 0; k < hdr.eh.e_phnum && j < 2; k++) { if (xfsread(ino, ep + j, sizeof(ep[0]))) return; if (ep[j].p_type == PT_LOAD) @@ -533,6 +534,7 @@ parse() const char *cp; unsigned int drv; int c, i, j; + size_t k; while ((c = *arg++)) { if (c == ' ' || c == '\t' || c == '\n') @@ -555,7 +557,7 @@ parse() #if SERIAL } else if (c == 'S') { j = 0; - while ((unsigned int)(i = *arg++ - '0') <= 9) + while ((i = *arg++ - '0') <= 9) j = j * 10 + i; if (j > 0 && i == -'0') { comspeed = j; @@ -618,10 +620,10 @@ parse() dsk.daua = dsk.disk | dsk.unit; dsk_meta = 0; } - if ((i = ep - arg)) { - if ((size_t)i >= sizeof(knamebuf)) + if (k = ep - arg) { + if (k >= sizeof(knamebuf)) return -1; - memcpy(knamebuf, arg, i + 1); + memcpy(knamebuf, arg, k + 1); kname = knamebuf; } } @@ -754,8 +756,10 @@ drvread(void *buf, unsigned lba) head = x / dsk.sec; sec = x % dsk.sec; - if (!OPT_CHECK(RBX_QUIET)) - printf("%c\b", c = c << 8 | c >> 24); + if (!OPT_CHECK(RBX_QUIET)) { + xputc(c = c << 8 | c >> 24); + xputc('\b'); + } v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS; v86.addr = READORG; /* call to read in boot1 */ v86.ecx = cyl; From 575bd6d8aa8532ab1f2c49662c8dbc3559f36f1c Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sat, 29 Nov 2014 14:30:39 +0000 Subject: [PATCH 61/64] Ignore more warnings with external gcc --- sys/conf/kern.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk index ac94936166c9..6d59f61aa64d 100644 --- a/sys/conf/kern.mk +++ b/sys/conf/kern.mk @@ -39,7 +39,8 @@ CWARNEXTRA?= -Wno-error-tautological-compare -Wno-error-empty-body \ CWARNEXTRA?= -Wno-error=inline -Wno-error=enum-compare -Wno-error=unused-but-set-variable \ -Wno-error=aggressive-loop-optimizations -Wno-error=maybe-uninitialized \ -Wno-error=array-bounds -Wno-error=address \ - -Wno-error=cast-qual -Wno-error=sequence-point -Wno-error=attributes + -Wno-error=cast-qual -Wno-error=sequence-point -Wno-error=attributes \ + -Wno-error=strict-overflow -Wno-error=overflow .endif # External compilers may not support our format extensions. Allow them From a215cdfdb0656f80bfc9a43ff914107596fd560a Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Sat, 29 Nov 2014 15:56:52 +0000 Subject: [PATCH 62/64] Switch to the ARM unified assembly language as the clang integrated as only supports it. Binutils supports it when the ".syntax unified" directive is set. Sponsored by: ABT Systems Ltd --- lib/libc/arm/string/ffs.S | 4 +- lib/libc/arm/string/memcmp.S | 4 +- lib/libc/arm/string/memcpy_arm.S | 37 +++++----- lib/libc/arm/string/memcpy_xscale.S | 38 ++++++----- lib/libc/arm/string/memmove.S | 62 +++++++++-------- lib/libc/arm/string/memset.S | 102 ++++++++++++++-------------- lib/libc/arm/string/strlen.S | 14 ++-- 7 files changed, 138 insertions(+), 123 deletions(-) diff --git a/lib/libc/arm/string/ffs.S b/lib/libc/arm/string/ffs.S index d3684ed417bc..4567f6c9ca3d 100644 --- a/lib/libc/arm/string/ffs.S +++ b/lib/libc/arm/string/ffs.S @@ -32,6 +32,8 @@ __FBSDID("$FreeBSD$"); +.syntax unified + /* * ffs - find first set bit, this algorithm isolates the first set * bit, then multiplies the number by 0x0450fbaf which leaves the top @@ -60,7 +62,7 @@ ENTRY(ffs) rsbne r0, r0, r0, lsl #16 /* r0 = X * 0x0450fbaf */ /* now lookup in table indexed on top 6 bits of r0 */ - ldrneb r0, [ r2, r0, lsr #26 ] + ldrbne r0, [ r2, r0, lsr #26 ] RET .text; diff --git a/lib/libc/arm/string/memcmp.S b/lib/libc/arm/string/memcmp.S index 63a00ef1bfc4..6fd8130f79b0 100644 --- a/lib/libc/arm/string/memcmp.S +++ b/lib/libc/arm/string/memcmp.S @@ -66,6 +66,8 @@ __FBSDID("$FreeBSD$"); +.syntax unified + ENTRY(memcmp) mov ip, r0 #if defined(_KERNEL) && !defined(_STANDALONE) @@ -76,7 +78,7 @@ ENTRY(memcmp) /* Are both addresses aligned the same way? */ cmp r2, #0x00 - eornes r3, ip, r1 + eorsne r3, ip, r1 RETeq /* len == 0, or same addresses! */ tst r3, #0x03 subne r2, r2, #0x01 diff --git a/lib/libc/arm/string/memcpy_arm.S b/lib/libc/arm/string/memcpy_arm.S index eff1eb076549..56fb70314d11 100644 --- a/lib/libc/arm/string/memcpy_arm.S +++ b/lib/libc/arm/string/memcpy_arm.S @@ -31,6 +31,9 @@ #include __FBSDID("$FreeBSD$"); + +.syntax unified + /* * This is one fun bit of code ... * Some easy listening music is suggested while trying to understand this @@ -91,8 +94,8 @@ ENTRY(memcpy) bge .Lmemcpy_loop32 cmn r2, #0x10 - ldmgeia r1!, {r3, r4, r12, lr} /* blat a remaining 16 bytes */ - stmgeia r0!, {r3, r4, r12, lr} + ldmiage r1!, {r3, r4, r12, lr} /* blat a remaining 16 bytes */ + stmiage r0!, {r3, r4, r12, lr} subge r2, r2, #0x10 ldmia sp!, {r4} /* return r4 */ @@ -101,9 +104,9 @@ ENTRY(memcpy) /* blat 12 bytes at a time */ .Lmemcpy_loop12: - ldmgeia r1!, {r3, r12, lr} - stmgeia r0!, {r3, r12, lr} - subges r2, r2, #0x0c + ldmiage r1!, {r3, r12, lr} + stmiage r0!, {r3, r12, lr} + subsge r2, r2, #0x0c bge .Lmemcpy_loop12 .Lmemcpy_l12: @@ -113,26 +116,26 @@ ENTRY(memcpy) subs r2, r2, #4 ldrlt r3, [r1], #4 strlt r3, [r0], #4 - ldmgeia r1!, {r3, r12} - stmgeia r0!, {r3, r12} + ldmiage r1!, {r3, r12} + stmiage r0!, {r3, r12} subge r2, r2, #4 .Lmemcpy_l4: /* less than 4 bytes to go */ adds r2, r2, #4 #ifdef __APCS_26_ - ldmeqia sp!, {r0, pc}^ /* done */ + ldmiaeq sp!, {r0, pc}^ /* done */ #else - ldmeqia sp!, {r0, pc} /* done */ + ldmiaeq sp!, {r0, pc} /* done */ #endif /* copy the crud byte at a time */ cmp r2, #2 ldrb r3, [r1], #1 strb r3, [r0], #1 - ldrgeb r3, [r1], #1 - strgeb r3, [r0], #1 - ldrgtb r3, [r1], #1 - strgtb r3, [r0], #1 + ldrbge r3, [r1], #1 + strbge r3, [r0], #1 + ldrbgt r3, [r1], #1 + strbgt r3, [r0], #1 ldmia sp!, {r0, pc} /* erg - unaligned destination */ @@ -143,10 +146,10 @@ ENTRY(memcpy) /* align destination with byte copies */ ldrb r3, [r1], #1 strb r3, [r0], #1 - ldrgeb r3, [r1], #1 - strgeb r3, [r0], #1 - ldrgtb r3, [r1], #1 - strgtb r3, [r0], #1 + ldrbge r3, [r1], #1 + strbge r3, [r0], #1 + ldrbgt r3, [r1], #1 + strbgt r3, [r0], #1 subs r2, r2, r12 blt .Lmemcpy_l4 /* less the 4 bytes */ diff --git a/lib/libc/arm/string/memcpy_xscale.S b/lib/libc/arm/string/memcpy_xscale.S index 1f48cd962d69..a451de46bc44 100644 --- a/lib/libc/arm/string/memcpy_xscale.S +++ b/lib/libc/arm/string/memcpy_xscale.S @@ -38,6 +38,8 @@ #include __FBSDID("$FreeBSD$"); +.syntax unified + /* LINTSTUB: Func: void *memcpy(void *dst, const void *src, size_t len) */ ENTRY(memcpy) pld [r1] @@ -52,12 +54,12 @@ ENTRY(memcpy) ldrb ip, [r1], #0x01 sub r2, r2, #0x01 strb ip, [r3], #0x01 - ldrleb ip, [r1], #0x01 + ldrble ip, [r1], #0x01 suble r2, r2, #0x01 - strleb ip, [r3], #0x01 - ldrltb ip, [r1], #0x01 + strble ip, [r3], #0x01 + ldrblt ip, [r1], #0x01 sublt r2, r2, #0x01 - strltb ip, [r3], #0x01 + strblt ip, [r3], #0x01 /* Destination buffer is now word aligned */ .Lmemcpy_wordaligned: @@ -134,7 +136,7 @@ ENTRY(memcpy) .Lmemcpy_w_lessthan128: adds r2, r2, #0x80 /* Adjust for extra sub */ - ldmeqfd sp!, {r4-r9} + ldmfdeq sp!, {r4-r9} bxeq lr /* Return now if done */ subs r2, r2, #0x20 blt .Lmemcpy_w_lessthan32 @@ -159,7 +161,7 @@ ENTRY(memcpy) .Lmemcpy_w_lessthan32: adds r2, r2, #0x20 /* Adjust for extra sub */ - ldmeqfd sp!, {r4-r9} + ldmfdeq sp!, {r4-r9} bxeq lr /* Return now if done */ and r4, r2, #0x18 @@ -195,11 +197,11 @@ ENTRY(memcpy) addlt r2, r2, #0x04 ldrb ip, [r1], #0x01 cmp r2, #0x02 - ldrgeb r2, [r1], #0x01 + ldrbge r2, [r1], #0x01 strb ip, [r3], #0x01 - ldrgtb ip, [r1] - strgeb r2, [r3], #0x01 - strgtb ip, [r3] + ldrbgt ip, [r1] + strbge r2, [r3], #0x01 + strbgt ip, [r3] bx lr @@ -253,7 +255,7 @@ ENTRY(memcpy) bge .Lmemcpy_bad1_loop16 adds r2, r2, #0x10 - ldmeqfd sp!, {r4-r7} + ldmfdeq sp!, {r4-r7} bxeq lr /* Return now if done */ subs r2, r2, #0x04 sublt r1, r1, #0x03 @@ -314,7 +316,7 @@ ENTRY(memcpy) bge .Lmemcpy_bad2_loop16 adds r2, r2, #0x10 - ldmeqfd sp!, {r4-r7} + ldmfdeq sp!, {r4-r7} bxeq lr /* Return now if done */ subs r2, r2, #0x04 sublt r1, r1, #0x02 @@ -375,7 +377,7 @@ ENTRY(memcpy) bge .Lmemcpy_bad3_loop16 adds r2, r2, #0x10 - ldmeqfd sp!, {r4-r7} + ldmfdeq sp!, {r4-r7} bxeq lr /* Return now if done */ subs r2, r2, #0x04 sublt r1, r1, #0x01 @@ -404,11 +406,11 @@ ENTRY(memcpy) bxeq lr ldrb ip, [r1], #0x01 cmp r2, #0x02 - ldrgeb r2, [r1], #0x01 + ldrbge r2, [r1], #0x01 strb ip, [r3], #0x01 - ldrgtb ip, [r1] - strgeb r2, [r3], #0x01 - strgtb ip, [r3] + ldrbgt ip, [r1] + strbge r2, [r3], #0x01 + strbgt ip, [r3] bx lr @@ -440,7 +442,7 @@ ENTRY(memcpy) ldrb ip, [r1], #0x01 1: subs r2, r2, #0x01 strb ip, [r3], #0x01 - ldrneb ip, [r1], #0x01 + ldrbne ip, [r1], #0x01 bne 1b bx lr diff --git a/lib/libc/arm/string/memmove.S b/lib/libc/arm/string/memmove.S index 75a274492437..94e5474000b0 100644 --- a/lib/libc/arm/string/memmove.S +++ b/lib/libc/arm/string/memmove.S @@ -32,6 +32,8 @@ #include __FBSDID("$FreeBSD$"); +.syntax unified + #ifndef _BCOPY /* LINTSTUB: Func: void *memmove(void *, const void *, size_t) */ ENTRY(memmove) @@ -86,8 +88,8 @@ ENTRY(bcopy) bge .Lmemmove_floop32 cmn r2, #0x10 - ldmgeia r1!, {r3, r4, r12, lr} /* blat a remaining 16 bytes */ - stmgeia r0!, {r3, r4, r12, lr} + ldmiage r1!, {r3, r4, r12, lr} /* blat a remaining 16 bytes */ + stmiage r0!, {r3, r4, r12, lr} subge r2, r2, #0x10 ldmia sp!, {r4} /* return r4 */ @@ -96,9 +98,9 @@ ENTRY(bcopy) /* blat 12 bytes at a time */ .Lmemmove_floop12: - ldmgeia r1!, {r3, r12, lr} - stmgeia r0!, {r3, r12, lr} - subges r2, r2, #0x0c + ldmiage r1!, {r3, r12, lr} + stmiage r0!, {r3, r12, lr} + subsge r2, r2, #0x0c bge .Lmemmove_floop12 .Lmemmove_fl12: @@ -108,23 +110,23 @@ ENTRY(bcopy) subs r2, r2, #4 ldrlt r3, [r1], #4 strlt r3, [r0], #4 - ldmgeia r1!, {r3, r12} - stmgeia r0!, {r3, r12} + ldmiage r1!, {r3, r12} + stmiage r0!, {r3, r12} subge r2, r2, #4 .Lmemmove_fl4: /* less than 4 bytes to go */ adds r2, r2, #4 - ldmeqia sp!, {r0, pc} /* done */ + ldmiaeq sp!, {r0, pc} /* done */ /* copy the crud byte at a time */ cmp r2, #2 ldrb r3, [r1], #1 strb r3, [r0], #1 - ldrgeb r3, [r1], #1 - strgeb r3, [r0], #1 - ldrgtb r3, [r1], #1 - strgtb r3, [r0], #1 + ldrbge r3, [r1], #1 + strbge r3, [r0], #1 + ldrbgt r3, [r1], #1 + strbgt r3, [r0], #1 ldmia sp!, {r0, pc} /* erg - unaligned destination */ @@ -135,10 +137,10 @@ ENTRY(bcopy) /* align destination with byte copies */ ldrb r3, [r1], #1 strb r3, [r0], #1 - ldrgeb r3, [r1], #1 - strgeb r3, [r0], #1 - ldrgtb r3, [r1], #1 - strgtb r3, [r0], #1 + ldrbge r3, [r1], #1 + strbge r3, [r0], #1 + ldrbgt r3, [r1], #1 + strbgt r3, [r0], #1 subs r2, r2, r12 blt .Lmemmove_fl4 /* less the 4 bytes */ @@ -353,12 +355,12 @@ ENTRY(bcopy) .Lmemmove_bl32: cmn r2, #0x10 - ldmgedb r1!, {r3, r4, r12, lr} /* blat a remaining 16 bytes */ - stmgedb r0!, {r3, r4, r12, lr} + ldmdbge r1!, {r3, r4, r12, lr} /* blat a remaining 16 bytes */ + stmdbge r0!, {r3, r4, r12, lr} subge r2, r2, #0x10 adds r2, r2, #0x14 - ldmgedb r1!, {r3, r12, lr} /* blat a remaining 12 bytes */ - stmgedb r0!, {r3, r12, lr} + ldmdbge r1!, {r3, r12, lr} /* blat a remaining 12 bytes */ + stmdbge r0!, {r3, r12, lr} subge r2, r2, #0x0c ldmia sp!, {r4, lr} @@ -368,8 +370,8 @@ ENTRY(bcopy) subs r2, r2, #4 ldrlt r3, [r1, #-4]! strlt r3, [r0, #-4]! - ldmgedb r1!, {r3, r12} - stmgedb r0!, {r3, r12} + ldmdbge r1!, {r3, r12} + stmdbge r0!, {r3, r12} subge r2, r2, #4 .Lmemmove_bl4: @@ -381,10 +383,10 @@ ENTRY(bcopy) cmp r2, #2 ldrb r3, [r1, #-1]! strb r3, [r0, #-1]! - ldrgeb r3, [r1, #-1]! - strgeb r3, [r0, #-1]! - ldrgtb r3, [r1, #-1]! - strgtb r3, [r0, #-1]! + ldrbge r3, [r1, #-1]! + strbge r3, [r0, #-1]! + ldrbgt r3, [r1, #-1]! + strbgt r3, [r0, #-1]! RET /* erg - unaligned destination */ @@ -394,10 +396,10 @@ ENTRY(bcopy) /* align destination with byte copies */ ldrb r3, [r1, #-1]! strb r3, [r0, #-1]! - ldrgeb r3, [r1, #-1]! - strgeb r3, [r0, #-1]! - ldrgtb r3, [r1, #-1]! - strgtb r3, [r0, #-1]! + ldrbge r3, [r1, #-1]! + strbge r3, [r0, #-1]! + ldrbgt r3, [r1, #-1]! + strbgt r3, [r0, #-1]! subs r2, r2, r12 blt .Lmemmove_bl4 /* less than 4 bytes to go */ ands r12, r1, #3 diff --git a/lib/libc/arm/string/memset.S b/lib/libc/arm/string/memset.S index 458f8f7d73ff..66af33ec07dd 100644 --- a/lib/libc/arm/string/memset.S +++ b/lib/libc/arm/string/memset.S @@ -69,6 +69,8 @@ #include __FBSDID("$FreeBSD$"); +.syntax unified + /* * memset: Sets a block of memory to the specified value * @@ -125,39 +127,39 @@ ENTRY(memset) .Lmemset_loop128: subs r1, r1, #0x80 #ifdef _ARM_ARCH_5E - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 #else - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} #endif bgt .Lmemset_loop128 RETeq /* Zero length so just exit */ @@ -168,15 +170,15 @@ ENTRY(memset) .Lmemset_loop32: subs r1, r1, #0x20 #ifdef _ARM_ARCH_5E - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 #else - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} #endif bgt .Lmemset_loop32 RETeq /* Zero length so just exit */ @@ -185,11 +187,11 @@ ENTRY(memset) /* Deal with 16 bytes or more */ #ifdef _ARM_ARCH_5E - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 #else - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} #endif RETeq /* Zero length so just exit */ @@ -212,17 +214,17 @@ ENTRY(memset) #endif strb r3, [ip], #0x01 /* Set 1 byte */ - strgeb r3, [ip], #0x01 /* Set another byte */ - strgtb r3, [ip] /* and a third */ + strbge r3, [ip], #0x01 /* Set another byte */ + strbgt r3, [ip] /* and a third */ RET /* Exit */ .Lmemset_wordunaligned: rsb r2, r2, #0x004 strb r3, [ip], #0x01 /* Set 1 byte */ cmp r2, #0x02 - strgeb r3, [ip], #0x01 /* Set another byte */ + strbge r3, [ip], #0x01 /* Set another byte */ sub r1, r1, r2 - strgtb r3, [ip], #0x01 /* and a third */ + strbgt r3, [ip], #0x01 /* and a third */ cmp r1, #0x04 /* More than 4 bytes left? */ bge .Lmemset_wordaligned /* Yup */ @@ -231,8 +233,8 @@ ENTRY(memset) RETeq /* Zero length so exit */ strb r3, [ip], #0x01 /* Set 1 byte */ cmp r1, #0x02 - strgeb r3, [ip], #0x01 /* Set another byte */ - strgtb r3, [ip] /* and a third */ + strbge r3, [ip], #0x01 /* Set another byte */ + strbgt r3, [ip] /* and a third */ RET /* Exit */ #ifdef _BZERO END(bzero) diff --git a/lib/libc/arm/string/strlen.S b/lib/libc/arm/string/strlen.S index 3d7726fb52ef..7447710d16b1 100644 --- a/lib/libc/arm/string/strlen.S +++ b/lib/libc/arm/string/strlen.S @@ -27,6 +27,8 @@ #include __FBSDID("$FreeBSD$"); +.syntax unified + ENTRY(strlen) mov r1, #0 /* Check that the pointer is aligned on 32 bits. */ @@ -53,23 +55,23 @@ ENTRY(strlen) addne r1, r1, #1 .Ldo_3: #ifndef __ARMEB__ - andnes r3, r2, #0x0000ff00 + andsne r3, r2, #0x0000ff00 #else - andnes r3, r2, #0x00ff0000 + andsne r3, r2, #0x00ff0000 #endif addne r1, r1, #1 .Ldo_2: #ifndef __ARMEB__ - andnes r3, r2, #0x00ff0000 + andsne r3, r2, #0x00ff0000 #else - andnes r3, r2, #0x0000ff00 + andsne r3, r2, #0x0000ff00 #endif addne r1, r1, #1 .Ldo_1: #ifndef __ARMEB__ - andnes r3, r2, #0xff000000 + andsne r3, r2, #0xff000000 #else - andnes r3, r2, #0x000000ff + andsne r3, r2, #0x000000ff #endif addne r1, r1, #1 bne .Loop From 6762091ea486129f08affb92381db0bbf7d143fd Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sat, 29 Nov 2014 17:18:20 +0000 Subject: [PATCH 63/64] Remove lock recursion for the pipe pair mutex, and disable the recursion on mutex initialization. The only places where the recursive acquire is performed are read and write filters, since knlist, which uses the pipe pair mutex as lock, is locked when filter is called. The recursion was added in r93296, and consistent locking for kn_fop->f_event() introduced in r133741. Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 month --- sys/kern/sys_pipe.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index 22386e832793..f21b19c886cc 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -318,7 +318,7 @@ pipe_zone_init(void *mem, int size, int flags) pp = (struct pipepair *)mem; - mtx_init(&pp->pp_mtx, "pipe mutex", NULL, MTX_DEF | MTX_RECURSE); + mtx_init(&pp->pp_mtx, "pipe mutex", NULL, MTX_DEF); return (0); } @@ -1792,7 +1792,7 @@ filt_piperead(struct knote *kn, long hint) struct pipe *wpipe = rpipe->pipe_peer; int ret; - PIPE_LOCK(rpipe); + PIPE_LOCK_ASSERT(rpipe, MA_OWNED); kn->kn_data = rpipe->pipe_buffer.cnt; if ((kn->kn_data == 0) && (rpipe->pipe_state & PIPE_DIRECTW)) kn->kn_data = rpipe->pipe_map.cnt; @@ -1801,11 +1801,9 @@ filt_piperead(struct knote *kn, long hint) wpipe->pipe_present != PIPE_ACTIVE || (wpipe->pipe_state & PIPE_EOF)) { kn->kn_flags |= EV_EOF; - PIPE_UNLOCK(rpipe); return (1); } ret = kn->kn_data > 0; - PIPE_UNLOCK(rpipe); return ret; } @@ -1816,12 +1814,11 @@ filt_pipewrite(struct knote *kn, long hint) struct pipe *wpipe; wpipe = kn->kn_hook; - PIPE_LOCK(wpipe); + PIPE_LOCK_ASSERT(wpipe, MA_OWNED); if (wpipe->pipe_present != PIPE_ACTIVE || (wpipe->pipe_state & PIPE_EOF)) { kn->kn_data = 0; kn->kn_flags |= EV_EOF; - PIPE_UNLOCK(wpipe); return (1); } kn->kn_data = (wpipe->pipe_buffer.size > 0) ? @@ -1829,7 +1826,6 @@ filt_pipewrite(struct knote *kn, long hint) if (wpipe->pipe_state & PIPE_DIRECTW) kn->kn_data = 0; - PIPE_UNLOCK(wpipe); return (kn->kn_data >= PIPE_BUF); } From fac92ae126c1b5f8e0290b567ae4e4017ef7e576 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Sat, 29 Nov 2014 17:29:30 +0000 Subject: [PATCH 64/64] The current limit of 100k for the linker hints file is getting a bit crowded as we now are at about 70k. Bump the limit to 1MB instead which is still quite a reasonable limit and allows for future growth of this file and possible future expansion to additional data. MFC After: 2 weeks --- sys/boot/common/module.c | 2 +- sys/kern/kern_linker.c | 2 +- sys/sys/linker.h | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/boot/common/module.c b/sys/boot/common/module.c index a4bb2158e21d..6339f8562665 100644 --- a/sys/boot/common/module.c +++ b/sys/boot/common/module.c @@ -938,7 +938,7 @@ moduledir_readhints(struct moduledir *mdp) path = moduledir_fullpath(mdp, "linker.hints"); if (stat(path, &st) != 0 || st.st_size < (ssize_t)(sizeof(version) + sizeof(int)) || - st.st_size > 100 * 1024 || (fd = open(path, O_RDONLY)) < 0) { + st.st_size > LINKER_HINTS_MAX || (fd = open(path, O_RDONLY)) < 0) { free(path); mdp->d_flags |= MDIR_NOHINTS; return; diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index ccfa8f3501be..73c8c0fbaca0 100644 --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -1752,7 +1752,7 @@ linker_hints_lookup(const char *path, int pathlen, const char *modname, /* * XXX: we need to limit this number to some reasonable value */ - if (vattr.va_size > 100 * 1024) { + if (vattr.va_size > LINKER_HINTS_MAX) { printf("hints file too large %ld\n", (long)vattr.va_size); goto bad; } diff --git a/sys/sys/linker.h b/sys/sys/linker.h index e09ff59cfea1..5d24f003944d 100644 --- a/sys/sys/linker.h +++ b/sys/sys/linker.h @@ -228,6 +228,7 @@ void *linker_hwpmc_list_objects(void); #endif #define LINKER_HINTS_VERSION 1 /* linker.hints file version */ +#define LINKER_HINTS_MAX (1 << 20) /* Allow at most 1MB for linker.hints */ #ifdef _KERNEL