Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 Aug 1998 00:28:49 -0400
From:      Tim Vanderhoek <ac199@hwcn.org>
To:        Satoshi Asami <asami@FreeBSD.ORG>
Cc:        ports@FreeBSD.ORG, "David O'Brien" <obrien@NUXI.com>
Subject:   Re: cvs commit: ports/x11-wm/afterstep/pkg PLIST (more bsd.port.mk mods)
Message-ID:  <19980831002849.A5522@zappo>
In-Reply-To: <199808250639.XAA00876@silvia.hip.berkeley.edu>; from Satoshi Asami on Mon, Aug 24, 1998 at 11:39:55PM -0700
References:  <Pine.BSF.3.96.980824214720.7081A-100000@localhost> <199808250639.XAA00876@silvia.hip.berkeley.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Aug 24, 1998 at 11:39:55PM -0700, Satoshi Asami wrote:
> 
> Really.  This isn't the stuff for makefiles.
> 
> Looking at bsd.man.mk, they seem to have a much easier time dealing
> with it.  Do you know why it is?

The bsd.man.mk doesn't need to handle MANLANG, MANxPREFIX, strange
manpages such as zzz.3qt, and it doesn't have to repeat the whole
mess for generate-plist.  It doesn't allow absolute manpage paths,
and it doesn't have a '-' option.  It doesn't do syntax checking
nearly as well.

[Okay, so it does have to repeat the whole mess for the catpages, but
if you count those lines, and discount my syntax-checking lines
(leaving a few little ones for equivalent functionality), it's about
even.]


>  * generate-plist:
>  * [...]
>  * 	${SED} ${_sedsubplist} ${PLIST} >> ${TMPPLIST}
>  * 	@${ECHO} @cwd / >> ${TMPPLIST}
>  * 	@for link in ${_HMLINKS}; do \
> 
> Ok, fixed.  This is kinda yucky though.  What's going to happen if the
> user uses "pkg_add -p"?

Well, I have very little sympathy for a user who is trying to do this.
It's simply not supported for binary packages...

However, this new patch tries to avoid it where possible.


[Re: Flagging an error for inter-section manpage linking]
> Or are there some packages out there that require linking different
> section man pages?  (Eek....)

I don't know.  Since bsd.man.mk seems to go out of its way to allow
inter-section linking, I figured there must be some.  <shrug>


> Another is that the direction of the link is backwards.  Ok, it's the
> same is bsd.man.mk's MLINKS, but then we shouldn't have to write
> "to.1 -> from.1".  I changed the sed lines to

Well, I was outvoted by a ratio of 2:1 on this (actually, it was also
a count of 2:1, but anyways...  :).  The arrows have been toasted
altogether.

Just for the record, ls(1) prints arrows from target -> source.
Doesn't that strike anyone else as being totally backwards?  <sigh>


Here are the changes I've made...

- add syntax check on MLINKS.
- change "->" to "".
- integrate more nicely with pkg_*(1).
- all (_all_) links are now relative symlinks.  This means it is possible
  to get something like "check.1 -> ../../../../../../ten/two/zed.1"
- if we have "MLINKS=a.1 b.1", then we will "rm -f b.1 b.1.gz" first.
- a repeated target file may be specified by just a "-".  Eg.
  "MLINKS=sanity.1 insane.3	- moon.4	- wolf.5".  This is
  useful for ports like devel/ORBacus and print/mp.  It looks nicer
  in practice than in example.

Speed was a consideration, and to further increase the speed, it seems
necessary to begin optimizing make(1)...

Breakdown of functionality by hunk:

hunk #1: syntax check and '-' substitution (the Awk script).
         encode section name and page name together (the Sed expression)
hunk #2: substitute MANxPREFIX for the encoded section name, and add
         MANEXT (whatever that may be).  _TMLINKS lists only the
         target half of MLINKS.  _MLINKS lists both halves.
hunk #3: list in ${TMPPLIST}, cutting-off ^${PREFIX} if possible.
hunk #4: link---essentially copied from bsd.man.mk, but with an Awk
         script to force relative symlinks, etc.

If you want patches to test against current ports, I have them for ten
ports.  I can't get them right now since they're on bento which isn't
allowing my ssh login at the moment.  The ports are listed in
/a/tmp/hoek/plist/ports/mlink.ports (or was that "mlinks.ports"?),
though.  I can extract patches once bento starts behaving again...

[FWIW, not all ten of those have been tested against the latest rev.
of these patches...]

As usual, beware of embedded ^H's, tabs, etc.  :)

Comments solicited, of course.

--- /usr/share/mk/bsd.port.mk.orig	Fri Aug 28 00:09:23 1998
+++ /usr/share/mk/bsd.port.mk	Sun Aug 30 16:38:29 1998
@@ -871,6 +871,29 @@
 
 MANLANG?=	""	# english only by default
 
+.if !defined(NOMANCOMPRESS)
+MANEXT=	.gz
+.endif
+
+.if defined(MLINKS)
+__pmlinks!=	${ECHO} '${MLINKS:S/	/ /}' | ${AWK} \
+ '{ if (NF % 2 != 0) { print "broken"; exit; } \
+	for (i=1; i<=NF; i++) { \
+		if ($$i ~ /^-$$/ && i != 1 && i % 2 != 0) \
+			{ $$i = $$(i-2); printf " " $$i " "; } \
+		else if ($$i ~ /^[^ ]+\.[1-9ln][^. ]*$$/ || $$i ~ /^\//) \
+			printf " " $$i " "; \
+		else \
+			{ print "broken"; exit; } \
+	} \
+  }' | ${SED} -e 's/ \/[^ ]*/ &x/g' -e 's/ [^/ ][^ ]*\.\(.\)[^. ]*/ &\1/g'
+.if ${__pmlinks:Mbroken} == "broken"
+.BEGIN:
+	@${ECHO_MSG} "Error: Unable to parse MLINKS."
+	@${FALSE}
+.endif
+.endif
+
 .for lang in ${MANLANG}
 
 .for sect in 1 2 3 4 5 6 7 8 9
@@ -887,7 +910,22 @@
 _MANPAGES+=	${MANN:S%^%${MANNPREFIX}/man/${lang}/mann/%}
 .endif
 
+.if defined(MLINKS)
+.for __page in ${__pmlinks}
+__name=	${__page:S// /:N[1-9lnx]}
+__sect=	${__page:S// /:M[1-9lnx]}
+.if ${__name:M/*}x == x
+_MLINKS+=	${MAN${__sect:S/l/L/:S/n/N/}PREFIX}/man/${lang}/man${__sect}/${__name}${MANEXT}
+.else
+_MLINKS+=	${__name}${MANEXT}
+.endif
+_MLINKS:=	${_MLINKS}
 .endfor
+.endif
+
+.endfor lang in ${MANLANG}
+
+_TMLINKS!=	${ECHO} ${_MLINKS} | ${AWK} '{for (i=2; i<=NF; i+=2) print $$i}'
 
 .if defined(_MANPAGES) && defined(NOMANCOMPRESS)
 __MANPAGES:=	${_MANPAGES:S^${PREFIX}/^^:S/""//:S^//^/^g}
@@ -1929,13 +1967,27 @@
 .for man in ${__MANPAGES}
 	@${ECHO} ${man} >> ${TMPPLIST}
 .endfor
+.for _PREFIX in ${PREFIX}
+.if ${_TMLINKS:M${_PREFIX}*}x != x
+	@for i in ${_TMLINKS:M${_PREFIX}*:S,^${_PREFIX}/,,}; do \
+		${ECHO} "$$i" >> ${TMPPLIST}; \
+	done
+.endif
+.if ${_TMLINKS:N${_PREFIX}*}x != x
+	@${ECHO} @cwd / >> ${TMPPLIST}
+	@for i in ${_TMLINKS:N${_PREFIX}*:S,^/,,}; do \
+		${ECHO} "$$i" >> ${TMPPLIST}; \
+	done
+	@${ECHO} '@cwd ${PREFIX}' >> ${TMPPLIST}
+.endif
+.endfor
 	@${SED} ${_sedsubplist} ${PLIST} >> ${TMPPLIST}
 .endif
 
 ${TMPPLIST}:
 	@cd ${.CURDIR} && ${MAKE} generate-plist
 
-# Compress (or uncompress) manpages.
+# Compress (or uncompress) and symlink manpages.
 .if !target(compress-man)
 compress-man:
 .if ${MANCOMPRESSED} == yes && defined(NOMANCOMPRESS)
@@ -1948,6 +2000,19 @@
 .for manpage in ${_MANPAGES}
 	@${GZIP_CMD} ${manpage}
 .endfor
+.endif
+.if defined(_MLINKS)
+	@set ${_MLINKS:S,"",,g:S,//,/,g}; \
+	while :; do \
+		[ $$# -eq 0 ] && break || ${TRUE}; \
+		${RM} -f $${2%.gz}; ${RM} -f $$2.gz; \
+		${LN} -fs `${ECHO} $$1 $$2 | ${AWK} '{ \
+					z=split($$1, a, /\//); x=split($$2, b, /\//); \
+					while (a[i] == b[i]) i++; \
+					for (q=i; q<x; q++) printf "../"; \
+					for (; i<z; i++) printf a[i] "/"; printf a[z]; }'` $$2; \
+		shift; shift; \
+	done
 .endif
 .endif
 


-- 
This .sig is not innovative, witty, or profund.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980831002849.A5522>