Subject: Re: pkg/30019 ([PATCH] textproc/openjade fails to build on OS X)
To: None <minskim@NetBSD.org, gnats-admin@netbsd.org,>
From: Idar Tollefsen <idart@performancedesign.no>
List: pkgsrc-bugs
Date: 06/26/2007 23:30:03
The following reply was made to PR pkg/30019; it has been noted by GNATS.

From: Idar Tollefsen <idart@performancedesign.no>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/30019 ([PATCH] textproc/openjade fails to build on OS X)
Date: Tue, 26 Jun 2007 23:30:17 +0200

 This is a multi-part message in MIME format.
 --------------040804000902060107000607
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 > This should be fixed now.  Do you still have this problem?
 
 
 Yes, all except the undefined symbols problems which has disappeared.
 Here's the output of the warnings and errors:
 
 -----
 
 rm -f MifFOTBuilder_inst.cxx
 /usr/pkg/bin/perl ./../instmac.pl MifFOTBuilder_inst.m4 
  >MifFOTBuilder_inst.cxx
 chmod -w MifFOTBuilder_inst.cxx
 /usr/pkg/bin/perl -w ./../msggen.pl -l jstyleModule MifMessages.msg
 g++ -DNDEBUG -O2 -mtune=G4 -mcpu=7450 -I/usr/pkg/include -I/usr/include 
 -I. -I./../include -I/usr/pkg/include/OpenSP 
 -I/usr/pkg/include/OpenSP/.. -I./../grove -I./../spgrove -I./../style 
 -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" 
 -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"openjade\" 
 -DVERSION=\"1.3.2\" -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 
 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 
 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 
 -DHAVE_STRUCT_STAT_ST_BLKSIZE=1 -DHAVE_ST_BLKSIZE=1 -DSIZEOF_SIZE_T=4 
 -DSIZEOF_UNSIGNED_INT=4 -DSP_HAVE_LOCALE=1 -DSP_HAVE_WCHAR=1 
 -DSP_HAVE_GETTEXT=1 -DSP_HAVE_BOOL=1 -DSP_ANSI_CLASS_INST=1 -DJADE_MIF=1 
 -DJADE_HTML=1 -DSP_MULTI_BYTE=1 
 -DSGML_CATALOG_FILES_DEFAULT=\"/usr/pkg/share/sgml/openjade/catalog\" 
 -DHAVE_DLFCN_H=1 
 -DDEFAULT_SCHEME_BUILTINS=\"/usr/pkg/share/sgml/openjade/builtins.dsl\" 
 -c MifFOTBuilder.cxx
 In file included from ./../include/config.h:10,
                   from MifFOTBuilder.cxx:29:
 /usr/pkg/include/OpenSP/config.h:329:1: warning: 
 "SGML_CATALOG_FILES_DEFAULT" redefined
 <command line>:1:1: warning: this is the location of the previous definition
 In file included from MifFOTBuilder.cxx:29:
 ./../include/config.h:39:1: warning: "SP_DEFINE_TEMPLATES" redefined
 In file included from ./../include/config.h:10,
                   from MifFOTBuilder.cxx:29:
 /usr/pkg/include/OpenSP/config.h:357:1: warning: this is the location of 
 the previous definition
 gnumake[2]: *** No rule to make target `-lintl', needed by `openjade'. 
 Stop.
 gnumake[1]: *** [jade] Error 2
 gnumake: *** [all] Error 2
 *** Error code 2
 
 Stop.
 bmake: stopped in /usr/pkg/pkgsrc/textproc/openjade
 *** Error code 1
 
 Stop.
 bmake: stopped in /usr/pkg/pkgsrc/textproc/openjade
 
 -----
 
 The warnings refer to the following;
 
 SGML catalog defined on the command line:
 -DSGML_CATALOG_FILES_DEFAULT=\"/usr/pkg/share/sgml/openjade/catalog\"
 SGML catalog defined bu OpenSP config.h:
 #define SGML_CATALOG_FILES_DEFAULT "/usr/pkg/share/sgml/catalog"
 
 SP_DEFINE_TEMPLATES from ${WRKSRC}/include/config.h:
      #ifdef __APPLE__
      #define SP_DEFINE_TEMPLATES
      #undef SP_MANUAL_INST
      #endif
 SP_DEFINE_TEMPLATES from OpenSP config.h:
      #define SP_DEFINE_TEMPLATES 1
 
 The error speaks for itself.
 
 I've attached a patch for openjade-1.3.2nb5 that's a variation and 
 improvement of the previously suggested incarnations. I'll try to explain;
 
 1. Change OpenJade's SGML catalog definition to match that of OpenSP.
 2. Don't set CXXFLAGS to CFLAGS unless CXXFLAGS is empty.
 3. Add LDFLAGS to LINKFLAGS variables in various makefiles to make sure 
 it uses them.
 4. Pull in gettext-lib to get the libintl dependency straight.
 5. Modify existing patch-ae (against ${WRKSRC}/Makefile.prog.in) to 
 remove -lintl as a target.
 6. Introduce patch-ag (against ${WRKSRC}/include/config.h.in) to avoid 
 redefinition of SP_DEFINE_TEMPLATES.
 7. Update distinfo to reflect changes in patch-ae and the addition of 
 patch-ag.
 
 A little more in depth;
 
 1. I'm not sure why OpenJade wants to fight OpenSP on the definition of 
 the SGML catalog directory. If it's actually a reason why they shouldn't 
 be equal, then this part of the patch can be ignored and disregarded. 
 Otherwise, it would be nice to get rid of the warning.
 
 2. Some users (myself included) take great care and interested in the 
 flags passed to pkgsrc. For this reason, overwriting CXXFLAGS with 
 CFLAGS seems unwarranted. If there are specific flags you're looking for 
 that are normally defined in CFLAGS, add them instead of replacing the 
 entire thing. The only exception would be if CXXFLAGS is empty, in which 
 case setting it to CFLAGS will probably yield better results.
 
 3. Same reason as for 3. I'm picky about my flags, use them ;)
 
 4. Since OpenJade links against libintl, shouldn't it be listed as a 
 dependency?
 
 5. In ${WRKSRC}/Makefile.prog.in, the variable ALL_LIBS in set to 
 ${XLIBS} ${LIBS}. LIBS is set in ${WRKSRC}/Makefile.comm after 
 configuration to -lintl. ALL_LIBS in Makefile.prog.in is used to 
 generated dependency targets in sub-directories when building. For 
 ${WRKSRC}/jade, this means -lintl ends up as a target in 
 ${WRKSRC}/jade/Makefile.lt. That's what the error is about. By removing 
 ALL_LIBS and simply using ${XLIBS} (excluding ${LIBS}) to generate 
 dependency targets, -lintl is also removed as a target. I haven't tried 
 this on any other platforms, and can't figure out why nobody else has 
 this problem. Is the LIBS variable in ${WRKSRC}/Makefile.comm empty for 
 everyone else? To me, it looks like it would fail no matter what LIBS 
 contained, unless it was actual dependency targets.
 
 6. The new patch against ${WRKSRC}/include/config.h.in simply wraps 
 #define SP_DEFINE_TEMPLATES in #ifndef..#endif to avoid the redefinition 
 warning.
 
 7. As it says; updated patch-ae and new patch-ag requires a updated 
 distinfo file.
 
 --------------040804000902060107000607
 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
  name="openjade.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="openjade.diff"
 
 diff -ruN openjade.orig/Makefile openjade/Makefile
 --- openjade.orig/Makefile	2006-03-21 07:00:50.000000000 +0100
 +++ openjade/Makefile	2007-06-26 12:10:59.000000000 +0200
 @@ -15,20 +15,31 @@
  USE_LIBTOOL=	YES
  GNU_CONFIGURE=	YES
  
 -CONFIGURE_ENV+=	CXXFLAGS=${CFLAGS:M*:Q}
 -CONFIGURE_ARGS+=	--enable-default-catalog=${OPENJADE_DATA_DIR}/catalog \
 -		--datadir=${OPENJADE_DATA_DIR:Q}
 -
 -SGML_CATALOGS=		${PREFIX}/share/sgml/openjade/catalog
 +.include "../../mk/bsd.prefs.mk"
  
 +SGML_CATALOGS=		${PREFIX}/share/sgml/catalog
  OPENJADE_DATA_DIR=	${PREFIX}/share/sgml/openjade
  OPENJADE_DOC_DIR=	${PREFIX}/share/doc/openjade
  
 +.if !defined(CXXFLAGS) || empty(CXXFLAGS)
 +CONFIGURE_ENV+=	CXXFLAGS=${CFLAGS:M*:Q}
 +.endif
 +
 +CONFIGURE_ARGS+=	--enable-default-catalog=${SGML_CATALOGS} \
 +		--datadir=${OPENJADE_DATA_DIR:Q}
 +
 +post-configure:
 +	@${CP} ${WRKSRC}/Makefile.lib ${WRKSRC}/Makefile.lib.orig
 +	@${SED} "s|LINKFLAGS = \(.*\)|LINKFLAGS = \1 ${LDFLAGS}|g" \
 +		< ${WRKSRC}/Makefile.lib.orig > ${WRKSRC}/Makefile.lib
 +	@${CP} ${WRKSRC}/Makefile.prog ${WRKSRC}/Makefile.prog.orig
 +	@${SED} "s|LINKFLAGS = \(.*\)|LINKFLAGS = \1 ${LDFLAGS}|g" \
 +		< ${WRKSRC}/Makefile.prog.orig > ${WRKSRC}/Makefile.prog
 +
  post-install:
  	${INSTALL_DATA_DIR} ${OPENJADE_DATA_DIR}/pubtext
  	${INSTALL_DATA} ${WRKSRC}/dsssl/* ${OPENJADE_DATA_DIR}
  	${INSTALL_DATA} ${WRKSRC}/pubtext/* ${OPENJADE_DATA_DIR}/pubtext
 -
  	${INSTALL_DATA_DIR} ${OPENJADE_DOC_DIR}/doc
  	${INSTALL_DATA_DIR} ${OPENJADE_DOC_DIR}/jadedoc/images
  	${INSTALL_DATA} ${WRKSRC}/doc/*.htm ${OPENJADE_DOC_DIR}/doc
 @@ -36,6 +47,7 @@
  	${INSTALL_DATA} ${WRKSRC}/jadedoc/*.htm ${OPENJADE_DOC_DIR}/jadedoc
  	${INSTALL_DATA} ${WRKSRC}/jadedoc/images/* ${OPENJADE_DOC_DIR}/jadedoc/images
  
 +.include "../../devel/gettext-lib/buildlink3.mk"
  .include "../../textproc/opensp/buildlink3.mk"
  .include "../../textproc/xmlcatmgr/catalogs.mk"
  .include "../../mk/bsd.pkg.mk"
 diff -ruN openjade.orig/distinfo openjade/distinfo
 --- openjade.orig/distinfo	2007-02-17 00:49:43.000000000 +0100
 +++ openjade/distinfo	2007-06-26 11:27:40.000000000 +0200
 @@ -7,5 +7,6 @@
  SHA1 (patch-ab) = cc5be75d416be38ada244301ba7171dc30751e75
  SHA1 (patch-ac) = 535d81d8c04e5133878e329b274a00b910c61c96
  SHA1 (patch-ad) = f8c950cc4a0ffb5bdba315a298c14a3e7ebcd637
 -SHA1 (patch-ae) = 0dad9fc8b5c2efd5a7b816539ea69d1e51663bd5
 +SHA1 (patch-ae) = eaee7864d6304cd03718a6f3cba37f4d1a92cfe1
  SHA1 (patch-af) = 1e0db04b5b85ad3b71066e55f94bf3144d69efe5
 +SHA1 (patch-ag) = 33aac18e238e64e08b4a292c013984c2ea2190ee
 diff -ruN openjade.orig/patches/patch-ae openjade/patches/patch-ae
 --- openjade.orig/patches/patch-ae	2007-02-17 00:49:43.000000000 +0100
 +++ openjade/patches/patch-ae	2007-06-26 11:27:30.000000000 +0200
 @@ -1,13 +1,13 @@
 -$NetBSD: patch-ae,v 1.2 2007/02/16 23:49:43 dmcmahill Exp $
 -
 ---- Makefile.prog.in.orig	2002-01-22 03:57:53.000000000 -0800
 -+++ Makefile.prog.in
 -@@ -12,14 +12,14 @@ LINKFLAGS = @LINKFLAGS@
 +--- Makefile.prog.in.orig	2002-01-22 12:57:53.000000000 +0100
 ++++ Makefile.prog.in	2007-06-26 11:26:25.000000000 +0200
 +@@ -10,16 +10,15 @@
 + top_builddir=@TOP@
 + LINKFLAGS = @LINKFLAGS@
   
 - ALL_LIBS = $(XLIBS) $(LIBS)
 +-ALL_LIBS = $(XLIBS) $(LIBS)
   Makefile.lt:
  -	echo 'LT_LIBS='`echo $(ALL_LIBS)|sed 's/\.a/.la/g'` >Makefile.lt
 -+	echo 'LT_LIBS='`echo $(ALL_LIBS)|sed -e 's/\.a/.la/g' -e 's/(^| )-l[0-9a-z]*//g'` >Makefile.lt
 ++	echo 'LT_LIBS='`echo $(XLIBS)|sed -e 's/\.a/.la/g' -e 's/(^| )-l[0-9a-z]*//g'` >Makefile.lt
   
   PROG:=$(shell echo "$(PROG)" | sed '@program_transform_name@')
   
 diff -ruN openjade.orig/patches/patch-ag openjade/patches/patch-ag
 --- openjade.orig/patches/patch-ag	1970-01-01 01:00:00.000000000 +0100
 +++ openjade/patches/patch-ag	2007-06-26 09:42:04.000000000 +0200
 @@ -0,0 +1,44 @@
 +--- include/config.h.in.orig	2007-06-26 09:39:11.000000000 +0200
 ++++ include/config.h.in	2007-06-26 09:41:11.000000000 +0200
 +@@ -36,7 +36,9 @@
 + // set_new_handler() has to be declared extern "C"
 + #define SP_SET_NEW_HANDLER_EXTERN_C
 + #ifdef __APPLE__
 ++#ifndef SP_DEFINE_TEMPLATES
 + #define SP_DEFINE_TEMPLATES
 ++#endif
 + #undef SP_MANUAL_INST
 + #endif
 + #ifndef SP_ANSI_CLASS_INST
 +@@ -133,8 +135,10 @@
 + // so instead we include the template definitions in the headers,
 + // which allows Visual C++ to instantiate any needed templates
 + // in the client.
 ++#ifndef SP_DEFINE_TEMPLATES
 + #define SP_DEFINE_TEMPLATES
 + #endif
 ++#endif
 + #endif /* SP_USE_DLL */
 + 
 + #ifndef SP_MANUAL_INST
 +@@ -211,8 +215,10 @@
 + #define SP_DLLIMPORT __declspec(dllimport)
 + #ifdef SP_USE_DLL
 + #ifndef BUILD_LIBSP
 ++#ifndef SP_DEFINE_TEMPLATES
 + #define SP_DEFINE_TEMPLATES
 + #endif
 ++#endif
 + #endif /* SP_USE_DLL */
 + #define SP_WCHAR_T_USHORT
 + #endif /* __BORLANDC__ */
 +@@ -251,7 +257,9 @@
 + // Metrowerks for some platform (MacOS in this case)
 + 
 + #pragma mpwc_newline off
 ++#ifndef SP_DEFINE_TEMPLATES
 + #define SP_DEFINE_TEMPLATES
 ++#endif
 + // #define SP_USE_DLL -- __declspec doesn't work with classes (yet)
 + #ifdef SP_USE_DLL
 + #define SP_DLLEXPORT __declspec(export)
 
 --------------040804000902060107000607--