Subject: pkg/35291: graphics/netpbm fails to build on Irix with MIPSPro
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <fanch@kekpar.net>
List: pkgsrc-bugs
Date: 12/20/2006 09:45:00
>Number:         35291
>Category:       pkg
>Synopsis:       graphics/netpbm fails to build on Irix with MIPSPro
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 20 09:45:00 +0000 2006
>Originator:     Francois Brunel
>Release:        pkgsrc-2006Q3
>Organization:
>Environment:
IP30
Irix 6.5.30
MIPSPro 7.4.1m
ABI=32
>Description:
Some errors when building graphics/netpbm:

 - __inline__ not defined (patch-ag)
 - symbols not found due to libraries in wrong order in ld args (patch-ab)
 - define unknown with parameters (patch-ac)
 - JASPERLIB unset, must be set to NONE (patch-aa)
 - strdup not found (patch-ai)

>How-To-Repeat:

>Fix:
-----------------
patches/patch-ag
-----------------

--- converter/ppm/ppmtompeg/headers/frames.h.orig	2006-01-24 05:23:34.000000000 +0100
+++ converter/ppm/ppmtompeg/headers/frames.h
@@ -162,7 +162,7 @@ EncodeCDC(int32       const dc_term,
     x2 = (bx2)*DCTSIZE;             \
     }
 
-static __inline__ void
+static __inline void
 MotionToFrameCoord(int   const by,
                    int   const bx,
                    int   const my,
@@ -185,7 +185,7 @@ MotionToFrameCoord(int   const by,
      ((fy >= 0) && (fx >= 0) && (fy < (Fsize_y>>1)) && (fx < (Fsize_x>>1))))
 
 
-static __inline__ void
+static __inline void
 encodeMotionVector(int      const x,
                    int      const y,
                    vector * const qP,


-----------------
patches/patch-ab
-----------------

--- converter/other/Makefile.orig	2006-05-28 01:16:09.000000000 +0200
+++ converter/other/Makefile
@@ -126,6 +126,13 @@ all:	$(BINARIES) $(SUBDIRS:%=%/all)
 
 include $(SRCDIR)/Makefile.common
 
+# XXX sparc64 gcc 3.3.x toolchain bug; compile exif.o without optimisation
+ifeq ($(MACHINE),sparc64)
+exif.o: exif.c
+	$(CC) -c $(INCLUDES2) -DNDEBUG \
+	    $(CPPFLAGS) $(CFLAGS:-O2=) $(CFLAGS_PERSONAL) $(CADD) -o $@ $<
+endif
+
 ifeq ($(NEED_RUNTIME_PATH),Y)
   LIBOPTR = -runtime
 else
@@ -175,7 +182,7 @@ endif
 
 rletopnm pnmtorle: %: %.o $(NETPBMLIB) $(URTLIBDEP) $(LIBOPT)
 	$(LD) $(LDFLAGS) -o $@ $@.o \
-	  `$(LIBOPT) $(NETPBMLIB) $(URTLIB)` $(MATHLIB) $(LDLIBS) \
+	  `$(LIBOPT) $(URTLIB) $(NETPBMLIB)` $(MATHLIB) $(LDLIBS) \
 	   $(RPATH) $(LADD)
 
 pnmtops: %: %.o bmepsoe.o $(NETPBMLIB) $(LIBOPT)


-----------------
patches/patch-ac
-----------------

--- lib/pm.h.orig	2006-05-19 22:39:07.000000000 +0200
+++ lib/pm.h
@@ -65,7 +65,7 @@ extern "C" {
 #ifdef __GNUC__
 #define PM_GNU_PRINTF_ATTR(a,b) __attribute__ ((format (printf, a, b)))
 #else
-#define PM_GNU_PRINTF_ATTR
+#define PM_GNU_PRINTF_ATTR(a,b)
 #endif
 
 
-----------------
patches/patch-aa
-----------------

--- Makefile.config.in.orig	2006-06-18 21:23:40.000000000 +0200
+++ Makefile.config.in
@@ -24,7 +24,7 @@ DEFAULT_TARGET = nonmerge
 # and skip it on those systems unless you want to debug it and fix it.
 # OpenBSD:
 #BUILD_FIASCO = N
-BUILD_FIASCO = Y
+BUILD_FIASCO?= Y
 
 # The following are commands for the build process to use.  These values
 # do not get built into anything.
@@ -33,7 +33,7 @@ BUILD_FIASCO = Y
 #CC = gcc
 # Note that 'cc' is usually an alias for whatever is the main compiler
 # on a system, e.g. the GNU Compiler on Linux.
-CC = cc
+#CC = cc
 
 # The linker.
 LD = $(CC)
@@ -99,7 +99,7 @@ CFLAGS_FOR_BUILD = $(CFLAGS)
 
 # MAKE is set automatically by Make to what was used to invoke Make.
 
-INSTALL = $(SRCDIR)/buildtools/install.sh
+#INSTALL = $(SRCDIR)/buildtools/install.sh
 #Solaris:
 #INSTALL = /usr/ucb/install
 #Tru64:
@@ -111,7 +111,7 @@ INSTALL = $(SRCDIR)/buildtools/install.s
 
 # STRIPFLAG is the option you pass to the above install program to make it
 # strip unnecessary information out of binaries.
-STRIPFLAG = -s
+#STRIPFLAG = -s
 # If you don't want to strip the binaries, just leave it null:
 #STRIPFLAG = 
 
@@ -130,8 +130,10 @@ MANPAGE_FORMAT = nroff
 AR = ar
 RANLIB = ranlib
 # IRIX, SCO don't have Ranlib:
-#RANLIB = true
-LEX = flex
+ifeq ($(OPSYS),IRIX)
+RANLIB = ar rs
+endif
+#LEX = flex
 # Solaris:
 # LEX = flex -e
 # Or just skip parts that need Lex:
@@ -220,7 +222,7 @@ EXE =
 
 # Here, $(SONAME) resolves to the soname for the shared library being created.
 # The following are gcc options.  This works on GNU libc systems.
-LDSHLIB = -shared -Wl,-soname,$(SONAME)
+LDSHLIB = -shared -Wl,-h,$(SONAME)
 # You need -nostart instead of -shared on BeOS.  Though the BeOS compiler is
 # ostensibly gcc, it has the -nostart option, which is not mentioned in gcc
 # documentation and doesn't exist in at least one non-BeOS installation.
@@ -253,6 +255,19 @@ LDRELOC = NONE
 #LDRELOC = ld --reloc
 #LDRELOC = ld -r
 
+ifeq ($(OPSYS),SunOS)
+LDSHLIB = -Wl,-B,dynamic,-G,-h,$(SONAME) 
+endif
+
+ifeq ($(OPSYS),Darwin)
+LDSHLIB = -dynamiclib -install_name $(PREFIX)/lib/libnetpbm.$(MAJ).dylib \
+	-compatibility_version $(MAJ) -current_version $(MAJ).$(MIN)
+endif
+
+ifeq ($(OPSYS),Interix)
+# random base address between 0x6B000000 and 0x6D000000
+LDSHLIB+= -Wl,--image-base,$$(($$RANDOM %64/2*1048576+1795162112))
+endif
 
 # On older systems, you have to make shared libraries out of position
 # independent code, so you need -fpic or fPIC here.  (The rule is: if
@@ -275,11 +290,23 @@ LDRELOC = NONE
 CFLAGS_SHLIB = 
 # Solaris or SunOS with gcc, and NetBSD:
 #CFLAGS_SHLIB = -fpic
-#CFLAGS_SHLIB = -fPIC
+CFLAGS_SHLIB = -fPIC
 # Sun compiler:
 #CFLAGS_SHLIB = -Kpic
 #CFLAGS_SHLIB = -KPIC
 
+ifeq ($(OPSYS),Darwin)
+CFLAGS_SHLIB = -fno-common
+endif
+
+ifeq ($(OPSYS),IRIX)
+CFLAGS_SHLIB = -KPIC
+endif
+
+ifeq ($(OPSYS),Interix)
+CFLAGS_SHLIB = # none!
+endif
+
 # SHLIB_CLIB is the link option to include the C library in a shared library,
 # normally "-lc".  On typical systems, this serves no purpose.  On some,
 # though, it causes information about which C library to use to be recorded
@@ -348,8 +375,8 @@ TIFFHDR_DIR =
 #TIFFLIB = libtiff.so
 #TIFFHDR_DIR = /usr/include/libtiff
 #NetBSD:
-#TIFFLIB = $(LOCALBASE)/lib/libtiff.so
-#TIFFHDR_DIR = $(LOCALBASE)/include
+TIFFLIB = $(BUILDLINK_DIR)/lib/libtiff.so
+TIFFHDR_DIR = $(BUILDLINK_DIR)/include
 # OSF, Tru64:
 #TIFFLIB = /usr/local1/DEC/lib/libtiff.so
 #TIFFHDR_DIR = /usr/local1/DEC/include
@@ -379,8 +406,8 @@ JPEGHDR_DIR =
 #JPEGLIB = libjpeg.so
 #JPEGHDR_DIR = /usr/include/jpeg
 # Netbsd:
-#JPEGLIB = ${LOCALBASE}/lib/libjpeg.so
-#JPEGHDR_DIR = ${LOCALBASE}/include
+JPEGLIB = ${BUILDLINK_DIR}/lib/libjpeg.so
+JPEGHDR_DIR = ${BUILDLINK_DIR}/include
 # OSF, Tru64:
 #JPEGLIB = /usr/local1/DEC/libjpeg.so
 #JPEGHDR_DIR = /usr/local1/DEC/include
@@ -400,12 +427,12 @@ JPEGHDR_DIR =
 # option.
 PNGLIB = NONE
 PNGHDR_DIR =
-PNGVER = 
+PNGVER = 12
 #PNGLIB = libpng$(PNGVER).so
 #PNGHDR_DIR = /usr/include/libpng$(PNGVER)
 # NetBSD:
-#PNGLIB = $(LOCALBASE)/lib/libpng$(PNGVER).so
-#PNGHDR_DIR = $(LOCALBASE)/include
+PNGLIB = $(BUILDLINK_DIR)/lib/libpng$(PNGVER).so
+PNGHDR_DIR = $(BUILDLINK_DIR)/include
 # OSF/Tru64:
 #PNGLIB = /usr/local1/DEC/lib/libpng$(PNGVER).so
 #PNGHDR_DIR = /usr/local1/DEC/include
@@ -415,8 +442,8 @@ PNGVER = 
 # NONE for the PNG library, it doesn't matter what you specify here --
 # it won't get used.
 
-ZLIB = NONE
-ZHDR_DIR = 
+ZLIB = $(BUILDLINK_DIR)/lib/libz.so
+ZHDR_DIR = $(BUILDLINK_DIR)/include
 #ZLIB = libz.so
 
 # The JBIG lossless image compression library (aka JBIG-KIT):
@@ -425,8 +452,8 @@ JBIGLIB = $(BUILDDIR)/converter/other/jb
 JBIGHDR_DIR = $(SRCDIR)/converter/other/jbig
 
 # The Jasper JPEG-2000 image compression library (aka JasPer):
-JASPERLIB = $(INTERNAL_JASPERLIB)
-JASPERHDR_DIR = $(INTERNAL_JASPERHDR_DIR)
+JASPERLIB = NONE
+JASPERHDR_DIR = NONE
 # JASPERDEPLIBS is the libraries (-l options or file names) on which
 # The Jasper library depends -- i.e. what you have to link into any
 # executable that links in the Jasper library.
@@ -471,7 +498,7 @@ OMIT_NETWORK =
 # built into the standard C library, so this can be null.  This is irrelevant
 # if OMIT_NETWORK is "y".
 
-NETWORKLD = 
+#NETWORKLD = 
 # Solaris, SunOS:
 #NETWORKLD = -lsocket -lnsl
 # SCO:
@@ -525,7 +552,7 @@ SUFFIXMANUALS5 = 5
 #Netpbm library functions.  The value is used only in make file tests.
 # "unixshared" means a unix-style shared library, typically named like 
 # libxyz.so.2.3
-NETPBMLIBTYPE = unixshared
+NETPBMLIBTYPE? = unixshared
 # "unixstatic" means a unix-style static library, (like libxyz.a)
 #NETPBMLIBTYPE = unixstatic
 # "dll" means a Windows DLL shared library
@@ -536,7 +563,7 @@ NETPBMLIBTYPE = unixshared
 #NETPBMLIBSUFFIX is the suffix used on whatever kind of library is 
 #selected above.  All this is used for is to construct library names.
 #The make files never examine the actual value.
-NETPBMLIBSUFFIX = so
+NETPBMLIBSUFFIX?= so
 
 # "a" is the suffix for unix-style static libraries.  It is also
 # traditionally used for shared libraries on AIX.  The Visual Age C


-----------------
patches/patch-ai
-----------------

--- editor/ppmdraw.c.orig	2006-04-24 03:01:54.000000000 +0200
+++ editor/ppmdraw.c
@@ -1,5 +1,6 @@
 #define _XOPEN_SOURCE    /* Make sure M_PI is in math.h */
 #define _BSD_SOURCE      /* Make sure strdup is in string.h */
+#define _XOPEN_SOURCE_EXTENDED 1 /* Same thing */
 
 #include <string.h>
 #include <ctype.h>