Wow you have it so backwards. So we will have embedded manuals for the case we don't need need the embedded manual because you have manuals installed (type ^Z and run man) but in the systems where you don't have manual pages, you won't have the embedded manuals.
Very logical to forget why this was added... Klemens Nanni <k...@openbsd.org> wrote: > On Thu, Aug 25, 2022 at 06:36:55PM +0000, Klemens Nanni wrote: > > Turns out all install media ship full copies of those two manuals due to > > what can be described like a makefile TOCTOU. > > > > In /usr/src/distrib/special, Makefile.inc sets NOMAN=1 but */Makefile > > only includes it in the very end through <bsd.prog.mk>. > > > > fdisk and disklabel have NOMAN logic before that include, so they don't > > see it set yet and include the whole thing: > > > > $ make -C fdisk manual.o > > mk -C fdisk manual.o > > mandoc -Tascii > > /usr/src/distrib/special/fdisk/../../../sbin/fdisk/fdisk.8 > fdisk.cat8 > > (echo 'const unsigned char manpage[] = {'; cat fdisk.cat8 | gzip -9c | > > hexdump -ve '"0x" 1/1 "%02x,"'; echo '};'; echo 'const int manpage_sz = > > sizeof(manpage);') > manual.c > > cc -O2 -pipe -DHAS_MBR -fno-pie -Oz -fno-stack-protector > > -fno-unwind-tables -fno-asynchronous-unwind-tables -MD -MP -c manual.c > > $ size fdisk/obj/manual.o > > text data bss dec hex > > 3552 0 0 3552 de0 > > > > Forcing it on the command line yields the desired behaviour: > > $ make -C fdisk NOMAN=1 manual.o > > (echo 'const unsigned char manpage[] = {'; echo 'no manual' | gzip -9c > > | hexdump -ve '"0x" 1/1 "%02x,"'; echo '};'; echo 'const int manpage_sz = > > sizeof(manpage);') > manual.c > > cc -O2 -pipe -DHAS_MBR -fno-pie -Oz -fno-stack-protector > > -fno-unwind-tables -fno-asynchronous-unwind-tables -MD -MP -c manual.c > > $ size fdisk/obj/manual.o > > text data bss dec hex > > 36 0 0 36 24 > > > > Same for disklabel, size before/after: > > text data bss dec hex > > 6160 0 0 6160 1810 > > 36 0 0 36 24 > > > > I've confirmed this through an amd64 snapshots bsd.rd where I paged > > through disklabel(8) via the 'M' command... > > > > Here's a minimal diff to highlight this non-obvious issue and avoid > > reshuffling, i.e. cut down on differences with /usr/src/sbin/*/Makefile. > > Alternatively, here's a more invasive diff that rips out the compile > logic around what I understand as purely man-install related NOMAN. > > Regular fdisk and disklabel always inlcude the manual and special ones > just print "no manual." rather than gzipping the string, decompressing > it at runtime and running a pager through it. > > I do like this a bit more as it makes the code simpler and just uses > SMALL for this, as I'd expect; This saves even more bits. > > > > > Haven't built ramdisks yet to see the final size decrease, but everyone > > should be happy with this. > > > > OK? > > > Index: sbin/fdisk/Makefile > =================================================================== > RCS file: /cvs/src/sbin/fdisk/Makefile,v > retrieving revision 1.46 > diff -u -p -r1.46 Makefile > --- sbin/fdisk/Makefile 23 May 2022 16:58:11 -0000 1.46 > +++ sbin/fdisk/Makefile 25 Aug 2022 18:47:14 -0000 > @@ -23,12 +23,6 @@ CLEANFILES += fdisk.cat8 manual.c > > .include <bsd.own.mk> > > -.ifdef NOMAN > -manual.c: > - (echo 'const unsigned char manpage[] = {'; \ > - echo 'no manual' | gzip -9c | hexdump -ve '"0x" 1/1 "%02x,"'; \ > - echo '};'; echo 'const int manpage_sz = sizeof(manpage);') > manual.c > -.else > fdisk.cat8: fdisk.8 > mandoc -Tascii ${.ALLSRC} > ${.TARGET} > > @@ -36,7 +30,6 @@ manual.c: fdisk.cat8 > (echo 'const unsigned char manpage[] = {'; \ > cat fdisk.cat8 | gzip -9c | hexdump -ve '"0x" 1/1 "%02x,"'; \ > echo '};'; echo 'const int manpage_sz = sizeof(manpage);') > manual.c > -.endif > > MAN= fdisk.8 > > Index: sbin/fdisk/cmd.c > =================================================================== > RCS file: /cvs/src/sbin/fdisk/cmd.c,v > retrieving revision 1.164 > diff -u -p -r1.164 cmd.c > --- sbin/fdisk/cmd.c 25 Jul 2022 17:45:16 -0000 1.164 > +++ sbin/fdisk/cmd.c 25 Aug 2022 18:51:02 -0000 > @@ -509,6 +509,9 @@ Xflag(const char *args, struct mbr *mbr) > int > Xmanual(const char *args, struct mbr *mbr) > { > +#ifdef SMALL > + printf("no manual.\n"); > +#else > char *pager = "/usr/bin/less"; > char *p; > FILE *f; > @@ -527,6 +530,7 @@ Xmanual(const char *args, struct mbr *mb > } > > signal(SIGPIPE, opipe); > +#endif /* !SMALL */ > > return CMD_CONT; > } > Index: sbin/disklabel/Makefile > =================================================================== > RCS file: /cvs/src/sbin/disklabel/Makefile,v > retrieving revision 1.70 > diff -u -p -r1.70 Makefile > --- sbin/disklabel/Makefile 20 Sep 2021 20:23:44 -0000 1.70 > +++ sbin/disklabel/Makefile 25 Aug 2022 18:46:48 -0000 > @@ -10,12 +10,6 @@ CLEANFILES += disklabel.cat8 manual.c > > .include <bsd.own.mk> > > -.ifdef NOMAN > -manual.c: > - (echo 'const unsigned char manpage[] = {'; \ > - echo 'no manual' | gzip -9c | hexdump -ve '"0x" 1/1 "%02x,"'; \ > - echo '};'; echo 'const int manpage_sz = sizeof(manpage);') > manual.c > -.else > disklabel.cat8: disklabel.8 > mandoc -Tascii ${.ALLSRC} > ${.TARGET} > > @@ -23,7 +17,6 @@ manual.c: disklabel.cat8 > (echo 'const unsigned char manpage[] = {'; \ > cat disklabel.cat8 | gzip -9c | hexdump -ve '"0x" 1/1 "%02x,"'; \ > echo '};'; echo 'const int manpage_sz = sizeof(manpage);') > manual.c > -.endif > > .if ${MACHINE} == "sparc64" > CFLAGS+= -DSUN_CYLCHECK -DSUN_AAT0 > Index: sbin/disklabel/editor.c > =================================================================== > RCS file: /cvs/src/sbin/disklabel/editor.c,v > retrieving revision 1.373 > diff -u -p -r1.373 editor.c > --- sbin/disklabel/editor.c 31 Jul 2022 14:29:19 -0000 1.373 > +++ sbin/disklabel/editor.c 25 Aug 2022 18:51:06 -0000 > @@ -346,6 +346,9 @@ editor(int f) > break; > > case 'M': { > +#ifdef SMALL > + puts("no manual."); > +#else > sig_t opipe = signal(SIGPIPE, SIG_IGN); > char *pager, *comm = NULL; > extern const u_char manpage[]; > @@ -363,6 +366,7 @@ editor(int f) > > free(comm); > (void)signal(SIGPIPE, opipe); > +#endif /* !SMALL */ > break; > } > > Index: distrib/special/fdisk/Makefile > =================================================================== > RCS file: /cvs/src/distrib/special/fdisk/Makefile,v > retrieving revision 1.6 > diff -u -p -r1.6 Makefile > --- distrib/special/fdisk/Makefile 23 May 2022 16:58:11 -0000 1.6 > +++ distrib/special/fdisk/Makefile 25 Aug 2022 18:46:12 -0000 > @@ -16,29 +16,12 @@ > # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. > > PROG= fdisk > -SRCS= fdisk.c user.c misc.c disk.c mbr.c part.c cmd.c manual.c gpt.c > +SRCS= fdisk.c user.c misc.c disk.c mbr.c part.c cmd.c gpt.c > +CFLAGS+= -DSMALL > DPADD= ${LIBUTIL} > LDADD= -lutil > -CLEANFILES += fdisk.cat8 manual.c > > .include <bsd.own.mk> > - > -.ifdef NOMAN > -manual.c: > - (echo 'const unsigned char manpage[] = {'; \ > - echo 'no manual' | gzip -9c | hexdump -ve '"0x" 1/1 "%02x,"'; \ > - echo '};'; echo 'const int manpage_sz = sizeof(manpage);') > manual.c > -.else > -fdisk.cat8: fdisk.8 > - mandoc -Tascii ${.ALLSRC} > ${.TARGET} > - > -manual.c: fdisk.cat8 > - (echo 'const unsigned char manpage[] = {'; \ > - cat fdisk.cat8 | gzip -9c | hexdump -ve '"0x" 1/1 "%02x,"'; \ > - echo '};'; echo 'const int manpage_sz = sizeof(manpage);') > manual.c > -.endif > - > -MAN= fdisk.8 > > .if ${MACHINE} == "amd64" || ${MACHINE} == "i386" || ${MACHINE} == "landisk" > CFLAGS += -DHAS_MBR > Index: distrib/special/disklabel/Makefile > =================================================================== > RCS file: /cvs/src/distrib/special/disklabel/Makefile,v > retrieving revision 1.13 > diff -u -p -r1.13 Makefile > --- distrib/special/disklabel/Makefile 21 Sep 2021 18:36:09 -0000 > 1.13 > +++ distrib/special/disklabel/Makefile 25 Aug 2022 18:45:42 -0000 > @@ -1,29 +1,12 @@ > # $OpenBSD: Makefile,v 1.13 2021/09/21 18:36:09 bluhm Exp $ > > PROG= disklabel > -SRCS= disklabel.c dkcksum.c editor.c manual.c > +SRCS= disklabel.c dkcksum.c editor.c > +CFLAGS+= -DSMALL > DPADD= ${LIBUTIL} > LDADD= -lutil > -MAN= disklabel.8 disklabel.5 > - > -CLEANFILES += disklabel.cat8 manual.c > > .include <bsd.own.mk> > - > -.ifdef NOMAN > -manual.c: > - (echo 'const unsigned char manpage[] = {'; \ > - echo 'no manual' | gzip -9c | hexdump -ve '"0x" 1/1 "%02x,"'; \ > - echo '};'; echo 'const int manpage_sz = sizeof(manpage);') > manual.c > -.else > -disklabel.cat8: disklabel.8 > - mandoc -Tascii ${.ALLSRC} > ${.TARGET} > - > -manual.c: disklabel.cat8 > - (echo 'const unsigned char manpage[] = {'; \ > - cat disklabel.cat8 | gzip -9c | hexdump -ve '"0x" 1/1 "%02x,"'; \ > - echo '};'; echo 'const int manpage_sz = sizeof(manpage);') > manual.c > -.endif > > .if ${MACHINE} == "sparc64" > CFLAGS+= -DSUN_CYLCHECK -DSUN_AAT0 >