Skip site navigation (1)Skip section navigation (2)
Date:      12 Mar 2003 13:07:21 -0000
From:      Sergei Kolobov <sergei@kolobov.com>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/49955: [PATCH] bsd.port.mk: add target to automatically install port documentation
Message-ID:  <20030312130721.54119.qmail@outpost.globcon.net>

next in thread | raw e-mail | index | archive | help

>Number:         49955
>Category:       ports
>Synopsis:       [PATCH] bsd.port.mk: add target to automatically install port documentation
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 12 05:10:05 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Sergei Kolobov
>Release:        FreeBSD 4.7-STABLE i386
>Organization:
>Environment:
System: FreeBSD outpost.globcon.net 4.7-STABLE FreeBSD 4.7-STABLE #0: Mon Oct 14 02:23:23 MSD 2002     sgk@outpost.globcon.net:/data/FreeBSD/obj/data/FreeBSD/src/sys/OUTPOST  i386
>Description:
Many of the ports, including most of the port I maintain, have 
documentation files that are being installed into DOCSDIR 
by the post-install target.

To simplify the task for such port, the following trivial patch was created.
It achieves several goals:

1. It adds INSTALL_DOCS variable, which, when defined, contains a list
of files to be automatically installed into DOCSDIR.

So, instead of the following construct in port's Makefile:

	DOCS=	INSTALL NEWS README THANKS TODO doc/README.2nd

	post-install:
	.if !defined(NOPORTDOCS)
		@${MKDIR} ${DOCSDIR}
	.for file in ${DOCS}
		${INSTALL_DATA} ${WRKSRC}/${file} ${DOCSDIR}
	.endfor
	.endif

it will be just this:

	INSTALL_DOCS=	INSTALL NEWS README THANKS TODO doc/README.2nd

The actual installation is handled a newly-added install-docs phase 
of the post-install target.

2. DOCSDIR/NOPORTDOCS handling in pkg-plist
DOCSDIR variable has been added to PLIST_SUB some time ago.
Unfortunately, using it in pkg-plist leads to ugly constructs as this:

	%%PORTDOCS%%%%DOCSDIR%%/INSTALL

The attached patch sets DOCSDIR PLIST_SUB to "@comment " in the NOPORTSDOCS 
case (essentially the same as PORTDOCS PLIST_SUB). Still, PORTDOCS has
some other uses (e.g. in %%PORTDOCS%%@dirrm %%DOCSDIR%%) so it will NOT
be obsoleted by DOCSDIR.

>How-To-Repeat:
>Fix:

--- bsd.port.mk-docs.patch begins here ---
Index: bsd.port.mk
===================================================================
RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.442
diff -u -r1.442 bsd.port.mk
--- bsd.port.mk	12 Mar 2003 00:28:17 -0000	1.442
+++ bsd.port.mk	12 Mar 2003 12:51:26 -0000
@@ -648,12 +648,19 @@
 #				  apply here.  It is recommended that you use
 #				  %%PREFIX%% for ${PREFIX}, %%LOCALBASE%% for
 #				  ${LOCALBASE} and %%X11BASE%% for ${X11BASE}.
+# INSTALL_DOCS  - If set, bsd.port.mk will automatically create ${DOCSDIR}
+#				  and install files listed into it. 
+#				  Does nothing if NOPORTDOCS is defined.
+#				  Run from install-docs target. 
 # DOCSDIR		- Name of the directory to install the packages docs in
 #				  (default: ${PREFIX}/share/doc/${PORTNAME}).
+#				  This value is added to PLIST_SUB.
 # EXAMPLESDIR		- Name of the directory to install the packages examples in
 #				  (default: ${PREFIX}/share/examples/${PORTNAME}).
+#				  This value is added to PLIST_SUB.
 # DATADIR		- Name of the directory to install the packages shared data
 #				  in (default: ${PREFIX}/share/${PORTNAME}).
+#				  This value is added to PLIST_SUB.
 # 
 # Note that the install target will automatically add manpages (see
 # above) and also substitute special sequences of characters (delimited
@@ -1026,12 +1033,6 @@
 
 PLIST_SUB+=	OSREL=${OSREL} PREFIX=%D LOCALBASE=${LOCALBASE} X11BASE=${X11BASE}
 
-.if defined(NOPORTDOCS)
-PLIST_SUB+=	        PORTDOCS="@comment "
-.else
-PLIST_SUB+=	        PORTDOCS=""
-.endif
-
 CONFIGURE_SHELL?=	${SH}
 MAKE_SHELL?=	${SH}
 
@@ -2214,8 +2215,12 @@
 EXAMPLESDIR?=	${PREFIX}/share/examples/${PORTNAME}
 DATADIR?=	${PREFIX}/share/${PORTNAME}
 
-PLIST_SUB+=	DOCSDIR="${DOCSDIR:S,^${PREFIX}/,,}" \
-		EXAMPLESDIR="${EXAMPLESDIR:S,^${PREFIX}/,,}" \
+.if defined(NOPORTDOCS)
+PLIST_SUB+=	PORTDOCS="@comment" DOCSDIR="@comment "
+.else
+PLIST_SUB+=	PORTDOCS="" DOCSDIR="${DOCSDIR:S,^${PREFIX}/,,}" 
+.endif
+PLIST_SUB+=	EXAMPLESDIR="${EXAMPLESDIR:S,^${PREFIX}/,,}" \
 		DATADIR="${DATADIR:S,^${PREFIX}/,,}"
 
 # Put this as far down as possible so it will catch all PLIST_SUB definitions.
@@ -2893,6 +2898,17 @@
 .endif
 .endif
 
+.if !target(install-docs)
+install-docs:
+.if defined(INSTALL_DOCS) && !defined(NOPORTDOCS)
+	@${ECHO_MSG} "===>   Installing documentation"
+	@${MKDIR} ${DOCSDIR}
+	cd ${WRKSRC} && ${INSTALL_DATA} ${INSTALL_DOCS} ${DOCSDIR}
+.else
+	@${DO_NADA}
+.endif
+.endif
+
 .if !target(run-ldconfig)
 run-ldconfig:
 .if defined(INSTALLS_SHLIB)
@@ -3018,9 +3034,9 @@
 _INSTALL_DEP=	build
 _INSTALL_SEQ=	install-message check-categories check-already-installed \
 				check-umask run-depends lib-depends install-mtree pre-install \
-				pre-install-script do-install generate-plist post-install \
-				post-install-script compress-man run-ldconfig fake-pkg \
-				security-check
+				pre-install-script do-install install-docs generate-plist \
+				post-install post-install-script compress-man run-ldconfig \
+				fake-pkg security-check
 _PACKAGE_DEP=	install
 _PACKAGE_SEQ=	package-message pre-package pre-package-script \
 				do-package post-package-script
--- bsd.port.mk-docs.patch ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:

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




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