From e53df4eee57764207f5e7bab4635abcd6de40eea Mon Sep 17 00:00:00 2001
From: Endi Sukma Dewata <edewata@redhat.com>
Date: Fri, 23 Mar 2012 10:44:33 -0500
Subject: [PATCH] Added option to build without Javadoc.

The build scripts have been modified to provide an option to build
without Javadoc to speed up development builds. The option can be
used as follows:

  compose_pki_core_packages --without-javadoc hybrid_rpms

Ticket #111
---
 CMakeLists.txt                     |    2 +
 base/common/src/CMakeLists.txt     |   22 ++++++++++--------
 base/java-tools/src/CMakeLists.txt |   22 ++++++++++--------
 base/util/src/CMakeLists.txt       |   43 ++++++++++++++++++-----------------
 scripts/compose_functions          |   35 +++++++++++++++++++++-------
 specs/pki-core.spec                |   20 +++++++++++++---
 6 files changed, 90 insertions(+), 54 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 95325025946b0f424a6ca0f22de0160369e0b1a4..d6c5d823eb7c153f59d1de1157cce272e9a99c8c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,6 +10,8 @@ set(APPLICATION_VERSION_MAJOR "10")
 set(APPLICATION_VERSION_MINOR "0")
 set(APPLICATION_VERSION_PATCH "0")
 
+option(WITH_JAVADOC "Build with Javadoc" ON)
+
 if (BUILD_IPA_PKI_THEME)
     set(APPLICATION_FLAVOR_IPA_PKI_THEME TRUE)
     # override APPLICATION VERSION
diff --git a/base/common/src/CMakeLists.txt b/base/common/src/CMakeLists.txt
index a9d4a765c95d1c47759afac25cb1c084e4920653..7a7c38a44c95e97c3aeadeb198d3041dd8756dce 100644
--- a/base/common/src/CMakeLists.txt
+++ b/base/common/src/CMakeLists.txt
@@ -1063,16 +1063,18 @@ add_dependencies(pki-cms pki-nsutil pki-cmsutil pki-certsrv)
 install_jar(pki-cms ${JAVA_JAR_INSTALL_DIR}/pki)
 set(PKI_CMS_JAR ${pki-cms_JAR_FILE} CACHE INTERNAL "pki-cms jar file")
 
-create_javadoc(pki-common-${APPLICATION_VERSION}
-    FILES ${pki-cms_java_SRCS} ${pki-certsrv_java_SRCS}
-    CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH} ${pki-certsrv_JAR_FILE}
-    WINDOWTITLE "pki-common"
-    DOCTITLE "<h1>pki-common</h1>"
-    AUTHOR TRUE
-    USE TRUE
-    VERSION TRUE
-)
-add_dependencies(pki-common-${APPLICATION_VERSION}_javadoc pki-cms pki-certsrv)
+if(WITH_JAVADOC)
+    create_javadoc(pki-common-${APPLICATION_VERSION}
+        FILES ${pki-cms_java_SRCS} ${pki-certsrv_java_SRCS}
+        CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH} ${pki-certsrv_JAR_FILE}
+        WINDOWTITLE "pki-common"
+        DOCTITLE "<h1>pki-common</h1>"
+        AUTHOR TRUE
+        USE TRUE
+        VERSION TRUE
+    )
+    add_dependencies(pki-common-${APPLICATION_VERSION}_javadoc pki-cms pki-certsrv)
+endif(WITH_JAVADOC)
 
 # build pki-cmscore
 set(CMAKE_JAR_CLASSES_PREFIX com/netscape/cmscore)
diff --git a/base/java-tools/src/CMakeLists.txt b/base/java-tools/src/CMakeLists.txt
index 0411a54c75ea0bd1a84aa571aa20a164ba9f43db..e6152dcf997e05736f11c85d27e71feb7169f303 100644
--- a/base/java-tools/src/CMakeLists.txt
+++ b/base/java-tools/src/CMakeLists.txt
@@ -75,13 +75,15 @@ install(
 install_jar(pki-tools ${JAVA_JAR_INSTALL_DIR}/pki)
 set(PKI_TOOLS_JAR ${pki-tools_JAR_FILE} CACHE INTERNAL "pki-tools jar file")
 
-create_javadoc(pki-java-tools-${APPLICATION_VERSION}
-    FILES ${pki-tools_java_SRCS}
-    CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH}
-    WINDOWTITLE "pki-java-tools"
-    DOCTITLE "<h1>pki-java-tools</h1>"
-    AUTHOR TRUE
-    USE TRUE
-    VERSION TRUE
-)
-add_dependencies(pki-java-tools-${APPLICATION_VERSION}_javadoc pki-tools)
+if(WITH_JAVADOC)
+    create_javadoc(pki-java-tools-${APPLICATION_VERSION}
+        FILES ${pki-tools_java_SRCS}
+        CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH}
+        WINDOWTITLE "pki-java-tools"
+        DOCTITLE "<h1>pki-java-tools</h1>"
+        AUTHOR TRUE
+        USE TRUE
+        VERSION TRUE
+    )
+    add_dependencies(pki-java-tools-${APPLICATION_VERSION}_javadoc pki-tools)
+endif(WITH_JAVADOC)
diff --git a/base/util/src/CMakeLists.txt b/base/util/src/CMakeLists.txt
index 592e3b59bcaab79c5c625df8956c0d050241c3ba..f0c586ad6f82f1bf0214a766b2af74bf7b5d79be 100644
--- a/base/util/src/CMakeLists.txt
+++ b/base/util/src/CMakeLists.txt
@@ -346,24 +346,25 @@ add_dependencies(pki-cmsutil pki-nsutil)
 install_jar(pki-cmsutil ${JAVA_JAR_INSTALL_DIR}/pki)
 set(PKI_CMSUTIL_JAR ${pki-cmsutil_JAR_FILE} CACHE INTERNAL "pki-cmsutil jar file")
 
-create_javadoc(pki-util-${APPLICATION_VERSION}
-    PACKAGES com.netscape.cmsutil.crypto
-             com.netscape.cmsutil.http
-             com.netscape.cmsutil.ldap
-             com.netscape.cmsutil.net
-             com.netscape.cmsutil.ocsp
-             com.netscape.cmsutil.password
-             com.netscape.cmsutil.radius
-             com.netscape.cmsutil.scep
-             com.netscape.cmsutil.util
-             com.netscape.cmsutil.xml
-    SOURCEPATH ${CMAKE_CURRENT_SOURCE_DIR}
-    CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH}
-    WINDOWTITLE "pki-util"
-    WINDOWTITLE "pki-util"
-    DOCTITLE "<h1>dogtag</h1>"
-    AUTHOR TRUE
-    USE TRUE
-    VERSION TRUE
-)
-add_dependencies(pki-util-${APPLICATION_VERSION}_javadoc pki-cmsutil)
+if(WITH_JAVADOC)
+    create_javadoc(pki-util-${APPLICATION_VERSION}
+        PACKAGES com.netscape.cmsutil.crypto
+                 com.netscape.cmsutil.http
+                 com.netscape.cmsutil.ldap
+                 com.netscape.cmsutil.net
+                 com.netscape.cmsutil.ocsp
+                 com.netscape.cmsutil.password
+                 com.netscape.cmsutil.radius
+                 com.netscape.cmsutil.scep
+                 com.netscape.cmsutil.util
+                 com.netscape.cmsutil.xml
+        SOURCEPATH ${CMAKE_CURRENT_SOURCE_DIR}
+        CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH}
+        WINDOWTITLE "pki-util"
+        DOCTITLE "<h1>dogtag</h1>"
+        AUTHOR TRUE
+        USE TRUE
+        VERSION TRUE
+    )
+    add_dependencies(pki-util-${APPLICATION_VERSION}_javadoc pki-cmsutil)
+endif(WITH_JAVADOC)
diff --git a/scripts/compose_functions b/scripts/compose_functions
index 22c128df14a87baab9e02481920ae22694514a1a..913b13298d73a6f0deb92bcf5a1f41fd203e7df6 100644
--- a/scripts/compose_functions
+++ b/scripts/compose_functions
@@ -69,7 +69,7 @@ export PKI_DOGTAG_MANIFEST
 Usage()
 {
 	printf "\n"
-	printf "Usage:  $0 <target>\n\n"
+	printf "Usage:  $0 [options] <target>\n\n"
 	printf "        where <target> is one of the following:\n\n"
 	printf "            srpm         - copies a spec file from local source,\n"
 	printf "                           generates a tarball from local source, "
@@ -105,6 +105,8 @@ Usage()
 	printf " and\n"
 	printf "                           produces an SRPM and one or more RPMS\n"
 	printf "                           ${MESSAGE}\n\n"
+	printf "Options:\n"
+	printf "  --without-javadoc        do not build Javadoc RPMS\n\n"
 }
 
 
@@ -237,33 +239,50 @@ Fetch_Source_Tarball()
 ## Check for command line argument validity
 ##
 
+GETOPT=`getopt -o '' --long without-javadoc -n "$0" -- "$@"`
+
+if [ $? != 0 ] ; then
+    Usage
+    exit 255
+fi
+
+eval set -- "$GETOPT"
+
+while true ; do
+    case "$1" in
+        --without-javadoc) JAVADOC="--without javadoc" ; shift ;;
+        --) shift ; break ;;
+        *) echo "$0: unrecognized option '$1'" 1>&2 ; exit 255 ;;
+    esac
+done
+
 if [ $# -ne 1 ] ; then
 	Usage
 	exit 255
 fi
 
 if	[ $1 = "srpm" ] ; then
-	RPMBUILD_CMD="rpmbuild --define \"_topdir \`pwd\`\" -bs"
+	RPMBUILD_CMD="rpmbuild --define \"_topdir \`pwd\`\" $JAVADOC -bs"
 	FETCH_SOURCE_TARBALL=0
 	FETCH_PATCH_FILES=0
 elif [ $1 = "hybrid_srpm" ] ; then
-	RPMBUILD_CMD="rpmbuild --define \"_topdir \`pwd\`\" -bs"
+	RPMBUILD_CMD="rpmbuild --define \"_topdir \`pwd\`\" $JAVADOC -bs"
 	FETCH_SOURCE_TARBALL=0
 	FETCH_PATCH_FILES=1
 elif [ $1 = "patched_srpm" ] ; then
-	RPMBUILD_CMD="rpmbuild --define \"_topdir \`pwd\`\" -bs"
+	RPMBUILD_CMD="rpmbuild --define \"_topdir \`pwd\`\" $JAVADOC -bs"
 	FETCH_SOURCE_TARBALL=1
 	FETCH_PATCH_FILES=1
 elif [ $1 = "rpms" ] ; then
-	RPMBUILD_CMD="rpmbuild --define \"_topdir \`pwd\`\" -ba"
+	RPMBUILD_CMD="rpmbuild --define \"_topdir \`pwd\`\" $JAVADOC -ba"
 	FETCH_SOURCE_TARBALL=0
 	FETCH_PATCH_FILES=0
 elif [ $1 = "hybrid_rpms" ] ; then
-	RPMBUILD_CMD="rpmbuild --define \"_topdir \`pwd\`\" -ba"
+	RPMBUILD_CMD="rpmbuild --define \"_topdir \`pwd\`\" $JAVADOC -ba"
 	FETCH_SOURCE_TARBALL=0
 	FETCH_PATCH_FILES=1
 elif [ $1 = "patched_rpms" ] ; then
-	RPMBUILD_CMD="rpmbuild --define \"_topdir \`pwd\`\" -ba"
+	RPMBUILD_CMD="rpmbuild --define \"_topdir \`pwd\`\" $JAVADOC -ba"
 	FETCH_SOURCE_TARBALL=1
 	FETCH_PATCH_FILES=1
 else
@@ -271,5 +290,3 @@ else
 	exit 255
 fi
 export RPMBUILD_CMD
-
-
diff --git a/specs/pki-core.spec b/specs/pki-core.spec
index 2c1906fc503ec6c56ae0ce3ccceaa2509f08c039..329b84c4ad98a338c323944f02741778536beff4 100644
--- a/specs/pki-core.spec
+++ b/specs/pki-core.spec
@@ -14,7 +14,7 @@ distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
 
 Name:             pki-core
 Version:          10.0.0
-Release:          %{?relprefix}11%{?prerel}%{?dist}
+Release:          %{?relprefix}12%{?prerel}%{?dist}
 Summary:          Certificate System - PKI Core Components
 URL:              http://pki.fedoraproject.org/
 License:          GPLv2
@@ -694,7 +694,12 @@ This package is a part of the PKI Core used by the Certificate System.
 %build
 %{__mkdir_p} build
 cd build
-%cmake -DVAR_INSTALL_DIR:PATH=/var -DBUILD_PKI_CORE:BOOL=ON -DJAVA_LIB_INSTALL_DIR=%{_jnidir} -DSYSTEMD_LIB_INSTALL_DIR=%{_unitdir} ..
+%cmake -DVAR_INSTALL_DIR:PATH=/var \
+	-DBUILD_PKI_CORE:BOOL=ON \
+	-DJAVA_LIB_INSTALL_DIR=%{_jnidir} \
+	-DSYSTEMD_LIB_INSTALL_DIR=%{_unitdir} \
+	%{?_without_javadoc:-DWITH_JAVADOC:BOOL=OFF} \
+	..
 %{__make} VERBOSE=1 %{?_smp_mflags} all
 %{__make} VERBOSE=1 %{?_smp_mflags} test
 
@@ -1120,9 +1125,11 @@ fi
 %{_javadir}/pki/pki-nsutil-%{version}.jar
 %{_javadir}/pki/pki-nsutil.jar
 
+%if %{?_without_javadoc:0}%{!?_without_javadoc:1}
 %files -n pki-util-javadoc
 %defattr(-,root,root,-)
 %{_javadocdir}/pki-util-%{version}/
+%endif
 
 
 %files -n pki-java-tools
@@ -1152,10 +1159,11 @@ fi
 %{_javadir}/pki/pki-tools.jar
 %{_datadir}/pki/java-tools/
 
+%if %{?_without_javadoc:0}%{!?_without_javadoc:1}
 %files -n pki-java-tools-javadoc
 %defattr(-,root,root,-)
 %{_javadocdir}/pki-java-tools-%{version}/
-
+%endif
 
 %files -n pki-common
 %defattr(-,root,root,-)
@@ -1179,10 +1187,11 @@ fi
 
 %{_datadir}/pki/setup/
 
+%if %{?_without_javadoc:0}%{!?_without_javadoc:1}
 %files -n pki-common-javadoc
 %defattr(-,root,root,-)
 %{_javadocdir}/pki-common-%{version}/
-
+%endif
 
 %files -n pki-selinux
 %defattr(-,root,root,-)
@@ -1315,6 +1324,9 @@ fi
 
 
 %changelog
+* Fri Mar 23 2012 Endi S. Dewata <edewata@redhat.com> 10.0.0-0.12.a1
+- Added option to build without Javadoc
+
 * Fri Mar 16 2012 Ade Lee <alee@redhat.com> 10.0.0-0.11.a1
 - BZ 802396 - Change location of TOMCAT_LOG to match tomcat6 changes
 - Corrected patch selected for selinux f17 rules
-- 
1.7.7.4

