#
-# Copyright (c) 2011 Todd C. Miller <Todd.Miller@courtesan.com>
+# Copyright (c) 2012 Todd C. Miller <Todd.Miller@courtesan.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
cross_compiling = @CROSS_COMPILING@
# Tools to use
+SED = @SED@
NROFF = @NROFFPROG@
MANDOC = mandoc
MANCOMPRESS = @MANCOMPRESS@
varsub: $(top_srcdir)/configure.in
@if [ -n "$(DEVEL)" ]; then \
printf 's#@%s@#1#\ns#@%s@#1#\ns#@%s@#1#\ns#@%s@#1#\ns#@%s@#/etc#g\ns#@%s@#/usr/local#g\ns#@%s@#5#g\ns#@%s@#8#g\ns#@%s@#%s#\n' SEMAN BAMAN LCMAN PSMAN sysconfdir prefix mansectform mansectsu PACKAGE_VERSION $(VERSION) > $@; \
- sed -n '/Begin initial values for man page substitution/,/End initial values for man page substitution/{;p;}' $(top_srcdir)/configure.in | sed -e '/^#/d' -e 's/^/s#@/' -e 's/=[\\"]*/@#/' -e 's/[\\"]*$$/#g/' >> $@; \
+ $(SED) -n '/Begin initial values for man page substitution/,/End initial values for man page substitution/{;p;}' $(top_srcdir)/configure.in | $(SED) -e '/^#/d' -e 's/^/s#@/' -e 's/=[\\"]*/@#/' -e 's/[\\"]*$$/#g/' >> $@; \
fi
$(srcdir)/sudo.man.in: $(srcdir)/sudo.mdoc.in
mansectform=`echo @MANSECTFORM@|tr A-Z a-z`; \
printf '.\\" DO NOT EDIT THIS FILE, IT IS NOT THE MASTER!\n' > $@; \
printf '.\\" IT IS GENERATED AUTOMATICALLY FROM sudo.mdoc.in\n' >> $@; \
- sed -n -e '/^.Dd/q' -e '/^\.\\/p' $(srcdir)/sudo.mdoc.in >> $@; \
- sed -e 's/^\.Os.*/.Os @PACKAGE_VERSION@/' -e "s/$$mansectsu/8/g" -e "s/$$mansectform/5/g" $(srcdir)/sudo.mdoc.in | $(MANDOC) -Tman | sed -e 's/^\(\.TH "SUDO" \)"8"\(.*"\)OpenBSD \(.*\)/\1"'$$mansectsu'"\2\3/' -e "s/(5)/($$mansectform)/g" -e "s/(8)/($$mansectsu)/g" >> $@; \
+ $(SED) -n -e '/^.Dd/q' -e '/^\.\\/p' $(srcdir)/sudo.mdoc.in >> $@; \
+ $(SED) -e 's/^\.Os.*/.Os @PACKAGE_VERSION@/' -e "s/$$mansectsu/8/g" -e "s/$$mansectform/5/g" $(srcdir)/sudo.mdoc.in | $(MANDOC) -Tman | $(SED) -e 's/^\(\.TH "SUDO" \)"8"\(.*"\)OpenBSD \(.*\)/\1"'$$mansectsu'"\2\3/' -e "s/(5)/($$mansectform)/g" -e "s/(8)/($$mansectsu)/g" >> $@; \
fi
-sudo.man: $(srcdir)/sudo.man.in
- (cd $(top_builddir) && $(SHELL) config.status --file=doc/$@)
+sudo.man: $(srcdir)/sudo.man.in $(srcdir)/sudo.man.sh
+ $(SHELL) $(top_builddir)/config.status --file=- < $@.in | SED=$(SED) BAMAN=@BAMAN@ LCMAN=@LCMAN@ SEMAN=@SEMAN@ $(SHELL) $(srcdir)/$@.sh > $@
-sudo.mdoc: $(srcdir)/sudo.mdoc.in
- (cd $(top_builddir) && $(SHELL) config.status --file=doc/$@)
+sudo.mdoc: $(srcdir)/sudo.mdoc.in $(srcdir)/sudo.mdoc.sh
+ $(SHELL) $(top_builddir)/config.status --file=- < $@.in | SED=$(SED) BAMAN=@BAMAN@ LCMAN=@LCMAN@ SEMAN=@SEMAN@ $(SHELL) $(srcdir)/$@.sh > $@
$(srcdir)/sudo.cat: varsub $(srcdir)/sudo.mdoc.in
@if [ -n "$(DEVEL)" ]; then \
echo "Generating $@"; \
- sed -f varsub $(srcdir)/sudo.mdoc.in | $(NROFF) -mdoc | sed -e 's/ OpenBSD \([^ ].* \)/ \1 /' -e 's/(5)/(4)/g' -e 's/(8)/(1m)/g' > $@; \
+ $(SED) -f varsub $(srcdir)/sudo.mdoc.in | $(NROFF) -mdoc | $(SED) -e 's/ OpenBSD \([^ ].* \)/ \1 /' -e 's/(5)/(4)/g' -e 's/(8)/(1m)/g' > $@; \
fi
$(srcdir)/visudo.man.in: $(srcdir)/visudo.mdoc.in
mansectform=`echo @MANSECTFORM@|tr A-Z a-z`; \
printf '.\\" DO NOT EDIT THIS FILE, IT IS NOT THE MASTER!\n' > $@; \
printf '.\\" IT IS GENERATED AUTOMATICALLY FROM visudo.mdoc.in\n' >> $@; \
- sed -n -e '/^.Dd/q' -e '/^\.\\/p' $(srcdir)/visudo.mdoc.in >> $@; \
- sed -e 's/^\.Os.*/.Os @PACKAGE_VERSION@/' -e "s/$$mansectsu/8/g" -e "s/$$mansectform/5/g" $(srcdir)/visudo.mdoc.in | $(MANDOC) -Tman | sed -e 's/^\(\.TH "VISUDO" \)"8"\(.*"\)OpenBSD \(.*\)/\1"'$$mansectsu'"\2\3/' -e "s/(5)/($$mansectform)/g" -e "s/(8)/($$mansectsu)/g" >> $@; \
+ $(SED) -n -e '/^.Dd/q' -e '/^\.\\/p' $(srcdir)/visudo.mdoc.in >> $@; \
+ $(SED) -e 's/^\.Os.*/.Os @PACKAGE_VERSION@/' -e "s/$$mansectsu/8/g" -e "s/$$mansectform/5/g" $(srcdir)/visudo.mdoc.in | $(MANDOC) -Tman | $(SED) -e 's/^\(\.TH "VISUDO" \)"8"\(.*"\)OpenBSD \(.*\)/\1"'$$mansectsu'"\2\3/' -e "s/(5)/($$mansectform)/g" -e "s/(8)/($$mansectsu)/g" >> $@; \
fi
visudo.man: $(srcdir)/visudo.man.in
$(srcdir)/visudo.cat: varsub $(srcdir)/visudo.mdoc.in
@if [ -n "$(DEVEL)" ]; then \
echo "Generating $@"; \
- sed -f varsub $(srcdir)/visudo.mdoc.in | $(NROFF) -mdoc | sed -e 's/ OpenBSD \([^ ].* \)/ \1 /' -e 's/(5)/(4)/g' -e 's/(8)/(1m)/g' > $@; \
+ $(SED) -f varsub $(srcdir)/visudo.mdoc.in | $(NROFF) -mdoc | $(SED) -e 's/ OpenBSD \([^ ].* \)/ \1 /' -e 's/(5)/(4)/g' -e 's/(8)/(1m)/g' > $@; \
fi
$(srcdir)/sudoers.man.in: $(srcdir)/sudoers.mdoc.in
mansectform=`echo @MANSECTFORM@|tr A-Z a-z`; \
printf '.\\" DO NOT EDIT THIS FILE, IT IS NOT THE MASTER!\n' > $@; \
printf '.\\" IT IS GENERATED AUTOMATICALLY FROM sudoers.mdoc.in\n' >> $@; \
- sed -n -e '/^.Dd/q' -e '/^\.\\/p' $(srcdir)/sudoers.mdoc.in >> $@; \
- sed -e 's/^\.Os.*/.Os @PACKAGE_VERSION@/' -e "s/$$mansectsu/8/g" -e "s/$$mansectform/5/g" $(srcdir)/sudoers.mdoc.in | $(MANDOC) -Tman | sed -e 's/^\(\.TH "SUDOERS" \)"5"\(.*"\)OpenBSD \(.*\)/\1"'$$mansectsu'"\2\3/' -e "s/(5)/($$mansectform)/g" -e "s/(8)/($$mansectsu)/g" >> $@; \
+ $(SED) -n -e '/^.Dd/q' -e '/^\.\\/p' $(srcdir)/sudoers.mdoc.in >> $@; \
+ $(SED) -e 's/^\.Os.*/.Os @PACKAGE_VERSION@/' -e "s/$$mansectsu/8/g" -e "s/$$mansectform/5/g" $(srcdir)/sudoers.mdoc.in | $(MANDOC) -Tman | $(SED) -e 's/^\(\.TH "SUDOERS" \)"5"\(.*"\)OpenBSD \(.*\)/\1"'$$mansectsu'"\2\3/' -e "s/(5)/($$mansectform)/g" -e "s/(8)/($$mansectsu)/g" >> $@; \
fi
-sudoers.man: $(srcdir)/sudoers.man.in
- (cd $(top_builddir) && $(SHELL) config.status --file=doc/$@)
+sudoers.man: $(srcdir)/sudoers.man.in $(srcdir)/sudoers.man.sh
+ $(SHELL) $(top_builddir)/config.status --file=- < $@.in | SED=$(SED) LCMAN=@LCMAN@ SEMAN=@SEMAN@ PSMAN=@PSMAN@ $(SHELL) $(srcdir)/$@.sh > $@
-sudoers.mdoc: $(srcdir)/sudoers.mdoc.in
- (cd $(top_builddir) && $(SHELL) config.status --file=doc/$@)
+sudoers.mdoc: $(srcdir)/sudoers.mdoc.in $(srcdir)/sudoers.mdoc.sh
+ $(SHELL) $(top_builddir)/config.status --file=- < $@.in | SED=$(SED) LCMAN=@LCMAN@ SEMAN=@SEMAN@ PSMAN=@PSMAN@ $(SHELL) $(srcdir)/$@.sh > $@
$(srcdir)/sudoers.cat: varsub $(srcdir)/sudoers.mdoc.in
@if [ -n "$(DEVEL)" ]; then \
echo "Generating $@"; \
- sed -f varsub $(srcdir)/sudoers.mdoc.in | $(NROFF) -mdoc | sed -e 's/ OpenBSD \([^ ].* \)/ \1 /' -e 's/(5)/(4)/g' -e 's/(8)/(1m)/g' > $@; \
+ $(SED) -f varsub $(srcdir)/sudoers.mdoc.in | $(NROFF) -mdoc | $(SED) -e 's/ OpenBSD \([^ ].* \)/ \1 /' -e 's/(5)/(4)/g' -e 's/(8)/(1m)/g' > $@; \
fi
$(srcdir)/sudoers.ldap.man.in: $(srcdir)/sudoers.ldap.mdoc.in
mansectform=`echo @MANSECTFORM@|tr A-Z a-z`; \
printf '.\\" DO NOT EDIT THIS FILE, IT IS NOT THE MASTER!\n' > $@; \
printf '.\\" IT IS GENERATED AUTOMATICALLY FROM sudoers.ldap.mdoc.in\n' >> $@; \
- sed -n -e '/^.Dd/q' -e '/^\.\\/p' $(srcdir)/sudoers.ldap.mdoc.in >> $@; \
- sed -e 's/^\.Os.*/.Os @PACKAGE_VERSION@/' -e "s/$$mansectsu/8/g" -e "s/$$mansectform/5/g" $(srcdir)/sudoers.ldap.mdoc.in | $(MANDOC) -Tman | sed -e 's/^\(\.TH "SUDOERS.LDAP" \)"5"\(.*"\)OpenBSD \(.*\)/\1"'$$mansectsu'"\2\3/' -e "s/(5)/($$mansectform)/g" -e "s/(8)/($$mansectsu)/g" >> $@; \
+ $(SED) -n -e '/^.Dd/q' -e '/^\.\\/p' $(srcdir)/sudoers.ldap.mdoc.in >> $@; \
+ $(SED) -e 's/^\.Os.*/.Os @PACKAGE_VERSION@/' -e "s/$$mansectsu/8/g" -e "s/$$mansectform/5/g" $(srcdir)/sudoers.ldap.mdoc.in | $(MANDOC) -Tman | $(SED) -e 's/^\(\.TH "SUDOERS.LDAP" \)"5"\(.*"\)OpenBSD \(.*\)/\1"'$$mansectsu'"\2\3/' -e "s/(5)/($$mansectform)/g" -e "s/(8)/($$mansectsu)/g" >> $@; \
fi
sudoers.ldap.man: $(srcdir)/sudoers.ldap.man.in
$(srcdir)/sudoers.ldap.cat: varsub $(srcdir)/sudoers.ldap.mdoc.in
@if [ -n "$(DEVEL)" ]; then \
echo "Generating $@"; \
- sed -f varsub $(srcdir)/sudoers.ldap.mdoc.in | $(NROFF) -mdoc | sed -e 's/ OpenBSD \([^ ].* \)/ \1 /' -e 's/(5)/(4)/g' -e 's/(8)/(1m)/g' > $@; \
+ $(SED) -f varsub $(srcdir)/sudoers.ldap.mdoc.in | $(NROFF) -mdoc | $(SED) -e 's/ OpenBSD \([^ ].* \)/ \1 /' -e 's/(5)/(4)/g' -e 's/(8)/(1m)/g' > $@; \
fi
$(srcdir)/sudoreplay.man.in: $(srcdir)/sudoreplay.mdoc.in
mansectform=`echo @MANSECTFORM@|tr A-Z a-z`; \
printf '.\\" DO NOT EDIT THIS FILE, IT IS NOT THE MASTER!\n' > $@; \
printf '.\\" IT IS GENERATED AUTOMATICALLY FROM sudoreplay.mdoc.in\n' >> $@; \
- sed -n -e '/^.Dd/q' -e '/^\.\\/p' $(srcdir)/sudoreplay.mdoc.in >> $@; \
- sed -e 's/^\.Os.*/.Os @PACKAGE_VERSION@/' -e "s/$$mansectsu/8/g" -e "s/$$mansectform/5/g" $(srcdir)/sudoreplay.mdoc.in | $(MANDOC) -Tman | sed -e 's/^\(\.TH "SUDOREPLAY" \)"8"\(.*"\)OpenBSD \(.*\)/\1"'$$mansectsu'"\2\3/' -e "s/(5)/($$mansectform)/g" -e "s/(8)/($$mansectsu)/g" >> $@; \
+ $(SED) -n -e '/^.Dd/q' -e '/^\.\\/p' $(srcdir)/sudoreplay.mdoc.in >> $@; \
+ $(SED) -e 's/^\.Os.*/.Os @PACKAGE_VERSION@/' -e "s/$$mansectsu/8/g" -e "s/$$mansectform/5/g" $(srcdir)/sudoreplay.mdoc.in | $(MANDOC) -Tman | $(SED) -e 's/^\(\.TH "SUDOREPLAY" \)"8"\(.*"\)OpenBSD \(.*\)/\1"'$$mansectsu'"\2\3/' -e "s/(5)/($$mansectform)/g" -e "s/(8)/($$mansectsu)/g" >> $@; \
fi
sudoreplay.man: $(srcdir)/sudoreplay.man.in
$(srcdir)/sudoreplay.cat: varsub $(srcdir)/sudoreplay.mdoc.in
@if [ -n "$(DEVEL)" ]; then \
echo "Generating $@"; \
- sed -f varsub $(srcdir)/sudoreplay.mdoc.in | $(NROFF) -mdoc | sed -e 's/ OpenBSD \([^ ].* \)/ \1 /' -e 's/(5)/(4)/g' -e 's/(8)/(1m)/g' > $@; \
+ $(SED) -f varsub $(srcdir)/sudoreplay.mdoc.in | $(NROFF) -mdoc | $(SED) -e 's/ OpenBSD \([^ ].* \)/ \1 /' -e 's/(5)/(4)/g' -e 's/(8)/(1m)/g' > $@; \
fi
$(srcdir)/sudo_plugin.man.in: $(srcdir)/sudo_plugin.mdoc.in
mansectform=`echo @MANSECTFORM@|tr A-Z a-z`; \
printf '.\\" DO NOT EDIT THIS FILE, IT IS NOT THE MASTER!\n' > $@; \
printf '.\\" IT IS GENERATED AUTOMATICALLY FROM sudo_plugin.mdoc.in\n' >> $@; \
- sed -n -e '/^.Dd/q' -e '/^\.\\/p' $(srcdir)/sudo_plugin.mdoc.in >> $@; \
- sed -e 's/^\.Os.*/.Os @PACKAGE_VERSION@/' -e "s/$$mansectsu/8/g" -e "s/$$mansectform/5/g" $(srcdir)/sudo_plugin.mdoc.in | $(MANDOC) -Tman | sed -e 's/^\(\.TH "SUDO_PLUGIN" \)"8"\(.*"\)OpenBSD \(.*\)/\1"'$$mansectsu'"\2\3/' -e "s/(5)/($$mansectform)/g" -e "s/(8)/($$mansectsu)/g" >> $@; \
+ $(SED) -n -e '/^.Dd/q' -e '/^\.\\/p' $(srcdir)/sudo_plugin.mdoc.in >> $@; \
+ $(SED) -e 's/^\.Os.*/.Os @PACKAGE_VERSION@/' -e "s/$$mansectsu/8/g" -e "s/$$mansectform/5/g" $(srcdir)/sudo_plugin.mdoc.in | $(MANDOC) -Tman | $(SED) -e 's/^\(\.TH "SUDO_PLUGIN" \)"8"\(.*"\)OpenBSD \(.*\)/\1"'$$mansectsu'"\2\3/' -e "s/(5)/($$mansectform)/g" -e "s/(8)/($$mansectsu)/g" >> $@; \
fi
sudo_plugin.man: $(srcdir)/sudo_plugin.man.in
$(srcdir)/sudo_plugin.cat: varsub $(srcdir)/sudo_plugin.mdoc.in
@if [ -n "$(DEVEL)" ]; then \
echo "Generating $@"; \
- sed -f varsub $(srcdir)/sudo_plugin.mdoc.in | $(NROFF) -mdoc | sed -e 's/ OpenBSD \([^ ].* \)/ \1 /' -e 's/(5)/(4)/g' -e 's/(8)/(1m)/g' > $@; \
+ $(SED) -f varsub $(srcdir)/sudo_plugin.mdoc.in | $(NROFF) -mdoc | $(SED) -e 's/ OpenBSD \([^ ].* \)/ \1 /' -e 's/(5)/(4)/g' -e 's/(8)/(1m)/g' > $@; \
fi
CONTRIBUTORS: $(srcdir)/contributors.pod
@if [ -n "$(DEVEL)" ]; then \
echo "Generating $@"; \
- pod2text -l -i0 $(srcdir)/contributors.pod | sed '1,3d' > $@; \
+ pod2text -l -i0 $(srcdir)/contributors.pod | $(SED) '1,3d' > $@; \
fi
HISTORY: $(srcdir)/history.pod
LICENSE: $(srcdir)/license.pod
@if [ -n "$(DEVEL)" ]; then \
echo "Generating $@"; \
- pod2text -l -i0 $(srcdir)/license.pod | sed '1,3d' > $@; \
+ pod2text -l -i0 $(srcdir)/license.pod | $(SED) '1,3d' > $@; \
fi
pre-install:
--- /dev/null
+#!/bin/sh
+
+: ${SED='sed'}
+
+# BSD auth
+BA_FLAG=""
+BA_ITEM=""
+if [ X"$BAMAN" != X"1" ]; then
+ BA_FLAG='/^.*\n\.Op Fl a Ar auth_type/{;N;/^.*\n\.Ek$/d;};'
+ BA_ITEM=';/^\.It Fl a Ar type/,/BSD authentication\.$/{;d;}'
+fi
+
+# BSD login class
+LC_FLAG=""
+LC_ITEM=""
+if [ X"$LCMAN" != X"1" ]; then
+ LC_FLAG='/^.*\n\.Op Fl c Ar class/{;N;/^.*\n\.Ek$/d;};'
+ LC_ITEM=';/^\.It Fl c Ar class/,/BSD login classes\.$/{;d;};/^\.Xr login_cap 3 ,$/d'
+fi
+
+# SELinux
+SE_FLAG=""
+SE_ITEM=""
+if [ X"$SEMAN" != X"1" ]; then
+ SE_FLAG='/^.*\n\.Op Fl r Ar role/{;N;/^.*\n\.Ek$/d;};/^.*\n\.Op Fl t Ar type/{;N;/^.*\n\.Ek$/d;};'
+ SE_ITEM=';/^\.It Fl r Ar role/,/newline character\.$/{;d;};/^\.It Fl t Ar type/,/specified role\.$/{;d;}'
+fi
+
+# Unsupported flags must be removed together
+RM_FLAGS=""
+if [ -n "$BA_FLAG$LC_FLAG$SE_FLAG" ]; then
+ RM_FLAGS=";/^\.Bk -words\$/{;N;$BA_FLAG$LC_FLAG$SE_FLAG}"
+fi
+
+# Now put it all together and replace "0 minutes" with "unlimited"
+$SED -e '/^\.Li 0$/{;N;s/^\.Li 0\nminutes\.$/unlimited./;}'"$RM_FLAGS$BA_ITEM$LC_ITEM$SE_ITEM"
+#!/bin/sh
+
+: ${SED='sed'}
+
+# BSD auth
+BA_FLAG=""
+BA_ITEM=""
+if [ X"$BAMAN" != X"1" ]; then
+ BA_FLAG='/^.*\n\.Op Fl a Ar auth_type/{;N;/^.*\n\.Ek$/d;};'
+ BA_ITEM=';/^\.It Fl a Ar type/,/BSD authentication\.$/{;d;}'
+fi
+
+# BSD login class
+LC_FLAG=""
+LC_ITEM=""
+if [ X"$LCMAN" != X"1" ]; then
+ LC_FLAG='/^.*\n\.Op Fl c Ar class/{;N;/^.*\n\.Ek$/d;};'
+ LC_ITEM=';/^\.It Fl c Ar class/,/BSD login classes\.$/{;d;};/^\.Xr login_cap 3 ,$/d'
+fi
+
+# SELinux
+SE_FLAG=""
+SE_ITEM=""
+if [ X"$SEMAN" != X"1" ]; then
+ SE_FLAG='/^.*\n\.Op Fl r Ar role/{;N;/^.*\n\.Ek$/d;};/^.*\n\.Op Fl t Ar type/{;N;/^.*\n\.Ek$/d;};'
+ SE_ITEM=';/^\.It Fl r Ar role/,/newline character\.$/{;d;};/^\.It Fl t Ar type/,/specified role\.$/{;d;}'
+fi
+
+# Unsupported flags must be removed together
+RM_FLAGS=""
+if [ -n "$BA_FLAG$LC_FLAG$SE_FLAG" ]; then
+ RM_FLAGS=";/^\.Bk -words\$/{;N;$BA_FLAG$LC_FLAG$SE_FLAG}"
+fi
+
+# Now put it all together and replace "0 minutes" with "unlimited"
+$SED -e '/^\.Li 0$/{;N;s/^\.Li 0\nminutes\.$/unlimited./;}'"$RM_FLAGS$BA_ITEM$LC_ITEM$SE_ITEM"