rpms/cernlib-g77/devel 002-fix-missing-mclibs.dpatch, NONE, 1.1 114-install-scripts-properly.dpatch, NONE, 1.1 210-improve-cfortran-header-files.dpatch, NONE, 1.1 306-patch-assert.h-for-makedepend.dpatch, NONE, 1.1 307-use-canonical-cfortran.dpatch, NONE, 1.1 315-fixes-for-MacOSX.dpatch, NONE, 1.1 700-remove-kernlib-from-packlib-Imakefile.dpatch, NONE, 1.1 702-patch-Imakefiles-for-packlib-mathlib.dpatch, NONE, 1.1 703-patch-code_motif-packlib-Imakefiles.dpatch, NONE, 1.1 705-patch-paw_motif-paw-Imakefiles.dpatch, NONE, 1.1 802-create-shared-libraries.dpatch, NONE, 1.1 cernlib-102-dont-optimize-some-code.dpatch, NONE, 1.1 cernlib-103-ignore-overly-long-macro-in-gen.h.dpatch, NONE, 1.1 cernlib-104-fix-undefined-insertchar-warning.dpatch, NONE, 1.1 cernlib-105-fix-obsolete-xmfontlistcreate-warning.dpatch, NONE, 1.1 cernlib-106-fix-paw++-menus-in-lesstif.dpatch, NONE, 1.1 cernlib-107-define-strdup-macro-safely.dpatch, NONE, 1.1 cernlib-110-ignore-included-lapack-rule.dpatch, NONE, 1.1 cernlib-111-fix-kuesvr-install-location.dpatch, NONE, 1.1 cernlib-112-remove-nonexistent-prototypes-from-gen.h.dpatch, NONE, 1.1 cernlib-115-rsrtnt64-goto-outer-block.dpatch, NONE, 1.1 cernlib-116-fix-fconc64-spaghetti-code.dpatch, NONE, 1.1 cernlib-118-rename-mathlib-common-blocks.dpatch, NONE, 1.1 cernlib-119-fix-compiler-warnings.dpatch, NONE, 1.1 cernlib-120-fix-gets-usage-in-kuipc.dpatch, NONE, 1.1 cernlib-121-fix-mathlib-test-case-c209m.dpatch, NONE, 1.1 cernlib-122-fix-cdf-file-syntax-errors.dpatch, NONE, 1.1 cernlib-123-extern-memmove-only-if-not-macro.dpatch, NONE, 1.1 cernlib-201-update-kuip-helper-apps.dpatch, NONE, 1.1 cernlib-202-fix-includes-in-minuit-example.dpatch, NONE, 1.1 cernlib-205-max-path-length-to-256.dpatch, NONE, 1.1 cernlib-208-fix-redundant-packlib-dependencies.dpatch, NONE, 1.1 cernlib-209-ignore-unneeded-headers-in-kmutil.c.dpatch, NONE, 1.1 cernlib-211-support-amd64-and-itanium.dpatch, NONE, 1.1 cernlib-211-support-digital-alpha.dpatch, NONE, 1.1 cernlib-300-skip-duplicate-lenocc.dpatch, NONE, 1.1 cernlib-303-shadow-passwords-supported.dpatch, NONE, 1.1 cernlib-304-update-Imake-config-files.dpatch, NONE, 1.1 cernlib-308-use-canonical-cfortran-location.dpatch, NONE, 1.1 cernlib-311-skip-duplicate-qnext.dpatch, NONE, 1.1 cernlib-313-comis-preserves-filename-case.dpatch, NONE, 1.1 cernlib-318-additional-gcc-3.4-fixes.dpatch, NONE, 1.1 cernlib-319-work-around-imake-segfaults.dpatch, NONE, 1.1 cernlib-320-support-ifort.dpatch, NONE, 1.1 cernlib-321-support-gfortran.dpatch, NONE, 1.1 cernlib-600-use-host.def-config-file.dpatch, NONE, 1.1 cernlib-64test.patch, NONE, 1.1 cernlib-701-patch-hbook-comis-Imakefiles.dpatch, NONE, 1.1 cernlib-704-patch-code_kuip-higzcc-Imakefiles.dpatch, NONE, 1.1 cernlib-800-implement-shared-library-rules-in-Imake.dpatch, NONE, 1.1 cernlib-801-non-optimized-rule-uses-fPIC-g.dpatch, NONE, 1.1 cernlib-803-link-binaries-dynamically.dpatch, NONE, 1.1 cernlib-805-expunge-missing-mathlib-kernlib-symbols.dpatch, NONE, 1.1 cernlib-806-bump-mathlib-and-dependents-sonames.dpatch, NONE, 1.1 cernlib-deadpool.txt, NONE, 1.1 cernlib-debian-copyright.in, NONE, 1.1 cernlib-enforce-FHS.diff, NONE, 1.1 cernlib-fedora_desktop.patch, NONE, 1.1 cernlib-g77.spec, NONE, 1.1 cernlib-gxint-script.diff, NONE, 1.1 cernlib-man_static.patch, NONE, 1.1 cernlib-ppc64test.patch, NONE, 1.1 cernlib-remove-deadpool, NONE, 1.1 cernlib-script.patch, NONE, 1.1 cernlib-segf_eudtest.patch, NONE, 1.1 cernlib-test.patch, NONE, 1.1 cernlib.README, NONE, 1.1 cernlib.csh.in, NONE, 1.1 cernlib.m4, NONE, 1.1 cernlib.sh.in, NONE, 1.1 geant321-001-fix-missing-fluka.dpatch, NONE, 1.1 geant321-003-geant-dummy-functions.dpatch, NONE, 1.1 geant321-109-fix-broken-xsneut95.dat-link.dpatch, NONE, 1.1 geant321-117-fix-optimizer-bug-in-gphot.dpatch, NONE, 1.1 geant321-203-compile-geant-with-ertrak.dpatch, NONE, 1.1 geant321-806-bump-mathlib-and-dependents-sonames.dpatch, NONE, 1.1 mclibs-100-fix-isajet-manual-corruption.dpatch, NONE, 1.1 mclibs-101-undefine-PPC.dpatch, NONE, 1.1 mclibs-102-dont-optimize-some-code.dpatch, NONE, 1.1 mclibs-204-compile-isajet-with-isasrt.dpatch, NONE, 1.1 mclibs-206-herwig-uses-DBLE-not-REAL.dpatch, NONE, 1.1 mclibs-305-use-POWERPC-not-PPC-as-test.dpatch, NONE, 1.1 mclibs-309-define-dummy-herwig-routines.dpatch, NONE, 1.1 mclibs-310-define-dummy-fowl-routines.dpatch, NONE, 1.1 mclibs-312-skip-duplicate-gamma.dpatch, NONE, 1.1 mclibs-321-support-gfortran.dpatch, NONE, 1.1 mclibs-806-bump-mathlib-and-dependents-sonames.dpatch, NONE, 1.1 mkdirhier, NONE, 1.1 npatchy-curdir.patch, NONE, 1.1 npatchy-np_flags.patch, NONE, 1.1 patchy-insecure_tmp_use.diff, NONE, 1.1 patchy-p4comp.patch, NONE, 1.1 patchy-perror.patch, NONE, 1.1 patchy-rceta.patch, NONE, 1.1 patchy-unpack-rceta, NONE, 1.1 patchy-use_OPT.patch, NONE, 1.1 paw-102-dont-optimize-some-code.dpatch, NONE, 1.1 paw-105-fix-obsolete-xmfontlistcreate-warning.dpatch, NONE, 1.1 paw-108-quote-protect-comis-script.dpatch, NONE, 1.1 paw-119-fix-compiler-warnings.dpatch, NONE, 1.1 paw-120-fix-mlp-cdf-file.dpatch, NONE, 1.1 paw-121-call-gfortran-in-cscrexec.dpatch, NONE, 1.1 paw-200-comis-allow-special-chars-in-path.dpatch, NONE, 1.1 paw-207-compile-temp-libs-with-fPIC.dpatch, NONE, 1.1 paw-211-support-amd64-and-itanium.dpatch, NONE, 1.1 paw-305-use-POWERPC-not-PPC-as-test.dpatch, NONE, 1.1 paw-308-use-canonical-cfortran-location.dpatch, NONE, 1.1 paw-313-comis-preserves-filename-case.dpatch, NONE, 1.1 paw-320-support-ifort-and-gfortran.dpatch, NONE, 1.1 paw-701-patch-hbook-comis-Imakefiles.dpatch, NONE, 1.1 paw-706-use-external-xbae-and-xaw.dpatch, NONE, 1.1 paw-801-non-optimized-rule-uses-fPIC-g.dpatch, NONE, 1.1 paw-803-link-binaries-dynamically.dpatch, NONE, 1.1 paw-804-workaround-for-comis-mdpool-struct-location.dpatch, NONE, 1.1 paw-806-bump-mathlib-and-dependents-sonames.dpatch, NONE, 1.1 paw.README, NONE, 1.1 .cvsignore, 1.1, 1.2 sources, 1.1, 1.2

Patrice Dumas (pertusus) fedora-extras-commits at redhat.com
Sun Aug 5 09:42:22 UTC 2007


Author: pertusus

Update of /cvs/extras/rpms/cernlib-g77/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv21223

Modified Files:
	.cvsignore sources 
Added Files:
	002-fix-missing-mclibs.dpatch 
	114-install-scripts-properly.dpatch 
	210-improve-cfortran-header-files.dpatch 
	306-patch-assert.h-for-makedepend.dpatch 
	307-use-canonical-cfortran.dpatch 315-fixes-for-MacOSX.dpatch 
	700-remove-kernlib-from-packlib-Imakefile.dpatch 
	702-patch-Imakefiles-for-packlib-mathlib.dpatch 
	703-patch-code_motif-packlib-Imakefiles.dpatch 
	705-patch-paw_motif-paw-Imakefiles.dpatch 
	802-create-shared-libraries.dpatch 
	cernlib-102-dont-optimize-some-code.dpatch 
	cernlib-103-ignore-overly-long-macro-in-gen.h.dpatch 
	cernlib-104-fix-undefined-insertchar-warning.dpatch 
	cernlib-105-fix-obsolete-xmfontlistcreate-warning.dpatch 
	cernlib-106-fix-paw++-menus-in-lesstif.dpatch 
	cernlib-107-define-strdup-macro-safely.dpatch 
	cernlib-110-ignore-included-lapack-rule.dpatch 
	cernlib-111-fix-kuesvr-install-location.dpatch 
	cernlib-112-remove-nonexistent-prototypes-from-gen.h.dpatch 
	cernlib-115-rsrtnt64-goto-outer-block.dpatch 
	cernlib-116-fix-fconc64-spaghetti-code.dpatch 
	cernlib-118-rename-mathlib-common-blocks.dpatch 
	cernlib-119-fix-compiler-warnings.dpatch 
	cernlib-120-fix-gets-usage-in-kuipc.dpatch 
	cernlib-121-fix-mathlib-test-case-c209m.dpatch 
	cernlib-122-fix-cdf-file-syntax-errors.dpatch 
	cernlib-123-extern-memmove-only-if-not-macro.dpatch 
	cernlib-201-update-kuip-helper-apps.dpatch 
	cernlib-202-fix-includes-in-minuit-example.dpatch 
	cernlib-205-max-path-length-to-256.dpatch 
	cernlib-208-fix-redundant-packlib-dependencies.dpatch 
	cernlib-209-ignore-unneeded-headers-in-kmutil.c.dpatch 
	cernlib-211-support-amd64-and-itanium.dpatch 
	cernlib-211-support-digital-alpha.dpatch 
	cernlib-300-skip-duplicate-lenocc.dpatch 
	cernlib-303-shadow-passwords-supported.dpatch 
	cernlib-304-update-Imake-config-files.dpatch 
	cernlib-308-use-canonical-cfortran-location.dpatch 
	cernlib-311-skip-duplicate-qnext.dpatch 
	cernlib-313-comis-preserves-filename-case.dpatch 
	cernlib-318-additional-gcc-3.4-fixes.dpatch 
	cernlib-319-work-around-imake-segfaults.dpatch 
	cernlib-320-support-ifort.dpatch 
	cernlib-321-support-gfortran.dpatch 
	cernlib-600-use-host.def-config-file.dpatch 
	cernlib-64test.patch 
	cernlib-701-patch-hbook-comis-Imakefiles.dpatch 
	cernlib-704-patch-code_kuip-higzcc-Imakefiles.dpatch 
	cernlib-800-implement-shared-library-rules-in-Imake.dpatch 
	cernlib-801-non-optimized-rule-uses-fPIC-g.dpatch 
	cernlib-803-link-binaries-dynamically.dpatch 
	cernlib-805-expunge-missing-mathlib-kernlib-symbols.dpatch 
	cernlib-806-bump-mathlib-and-dependents-sonames.dpatch 
	cernlib-deadpool.txt cernlib-debian-copyright.in 
	cernlib-enforce-FHS.diff cernlib-fedora_desktop.patch 
	cernlib-g77.spec cernlib-gxint-script.diff 
	cernlib-man_static.patch cernlib-ppc64test.patch 
	cernlib-remove-deadpool cernlib-script.patch 
	cernlib-segf_eudtest.patch cernlib-test.patch cernlib.README 
	cernlib.csh.in cernlib.m4 cernlib.sh.in 
	geant321-001-fix-missing-fluka.dpatch 
	geant321-003-geant-dummy-functions.dpatch 
	geant321-109-fix-broken-xsneut95.dat-link.dpatch 
	geant321-117-fix-optimizer-bug-in-gphot.dpatch 
	geant321-203-compile-geant-with-ertrak.dpatch 
	geant321-806-bump-mathlib-and-dependents-sonames.dpatch 
	mclibs-100-fix-isajet-manual-corruption.dpatch 
	mclibs-101-undefine-PPC.dpatch 
	mclibs-102-dont-optimize-some-code.dpatch 
	mclibs-204-compile-isajet-with-isasrt.dpatch 
	mclibs-206-herwig-uses-DBLE-not-REAL.dpatch 
	mclibs-305-use-POWERPC-not-PPC-as-test.dpatch 
	mclibs-309-define-dummy-herwig-routines.dpatch 
	mclibs-310-define-dummy-fowl-routines.dpatch 
	mclibs-312-skip-duplicate-gamma.dpatch 
	mclibs-321-support-gfortran.dpatch 
	mclibs-806-bump-mathlib-and-dependents-sonames.dpatch 
	mkdirhier npatchy-curdir.patch npatchy-np_flags.patch 
	patchy-insecure_tmp_use.diff patchy-p4comp.patch 
	patchy-perror.patch patchy-rceta.patch patchy-unpack-rceta 
	patchy-use_OPT.patch paw-102-dont-optimize-some-code.dpatch 
	paw-105-fix-obsolete-xmfontlistcreate-warning.dpatch 
	paw-108-quote-protect-comis-script.dpatch 
	paw-119-fix-compiler-warnings.dpatch 
	paw-120-fix-mlp-cdf-file.dpatch 
	paw-121-call-gfortran-in-cscrexec.dpatch 
	paw-200-comis-allow-special-chars-in-path.dpatch 
	paw-207-compile-temp-libs-with-fPIC.dpatch 
	paw-211-support-amd64-and-itanium.dpatch 
	paw-305-use-POWERPC-not-PPC-as-test.dpatch 
	paw-308-use-canonical-cfortran-location.dpatch 
	paw-313-comis-preserves-filename-case.dpatch 
	paw-320-support-ifort-and-gfortran.dpatch 
	paw-701-patch-hbook-comis-Imakefiles.dpatch 
	paw-706-use-external-xbae-and-xaw.dpatch 
	paw-801-non-optimized-rule-uses-fPIC-g.dpatch 
	paw-803-link-binaries-dynamically.dpatch 
	paw-804-workaround-for-comis-mdpool-struct-location.dpatch 
	paw-806-bump-mathlib-and-dependents-sonames.dpatch paw.README 
Log Message:
initial import


--- NEW FILE 002-fix-missing-mclibs.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 002-fix-missing-mclibs.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Deal with several of the MC libs having to be purged from source.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/mclibs/Imakefile /tmp/dpep.pmIy0R/cernlib-2005.05.09/src/mclibs/Imakefile
--- cernlib-2005.05.09/src/mclibs/Imakefile	1999-05-20 09:30:20.000000000 -0400
+++ /tmp/dpep.pmIy0R/cernlib-2005.05.09/src/mclibs/Imakefile	2005-06-08 15:39:37.783591646 -0400
@@ -2,9 +2,11 @@
 #define IHaveSubdirs
 #define PassCDebugFlags
 
-
-LIBDIRS= ariadne cojets eurodec herwig fritiof \ @@\
-	 isajet jetset lepto63 pdf photos pythia
+/* Pythia and Jetset are not under GPL, so we must remove references
+   to them and their dependents.  They have already been purged from
+   Debianized source code.  Also, re-order libs so that dependent ones
+   come after dependees. */
+LIBDIRS= cojets eurodec pdf photos herwig isajet
 
 SUBDIRS = $(LIBDIRS)
 
@@ -12,8 +14,8 @@
 
 InstallLibSubdirs($(LIBDIRS))
 
-INCLUDEDIRS= ariadne cojets eurodec herwig fritiof \ @@\
-	 isajet jetset lepto63 pdf pythia
+/* Again, purge Pythia, Jetset and dependents. */
+INCLUDEDIRS= cojets eurodec herwig isajet pdf
 
 InstallIncludeSubdirs($(INCLUDEDIRS))
 


--- NEW FILE 114-install-scripts-properly.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 114-install-scripts-properly.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Install scripts properly (i.e. don't try to strip them).

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/scripts/Imakefile cernlib-2005.05.09.dfsg/src/scripts/Imakefile
--- cernlib-2005.05.09.dfsg~/src/scripts/Imakefile	2004-07-29 10:17:08.000000000 -0400
+++ cernlib-2005.05.09.dfsg/src/scripts/Imakefile	2005-12-02 10:45:23.091782817 -0500
@@ -1,10 +1,10 @@
 
-InstallProgram(paw,$(CERN_BINDIR))
+InstallNamedProg(paw,paw,$(CERN_BINDIR))
 
 #if defined(CERNLIB_SHIFT)
 InstallNamedProg(cernlib_shift,cernlib,$(CERN_BINDIR))
 #else
-InstallProgram(cernlib,$(CERN_BINDIR))
+InstallNamedProg(cernlib,cernlib,$(CERN_BINDIR))
 #endif
 
-InstallProgram(gxint,$(CERN_BINDIR))
+InstallNamedProg(gxint,gxint,$(CERN_BINDIR))


--- NEW FILE 210-improve-cfortran-header-files.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 210-improve-cfortran-header-files.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Protect against multiple inclusion and add explicit dependency on
## DP: cfortran.h to the Cernlib C headers.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/cfortran/comis.h /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/comis.h
--- cernlib-2005.05.09/src/cfortran/comis.h	1999-10-29 07:41:26.000000000 -0400
+++ /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/comis.h	2005-06-10 12:51:30.985999665 -0400
@@ -1,3 +1,11 @@
+#ifndef _COMIS_H
+#define _COMIS_H
+#include <cfortran/cfortran.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 PROTOCCALLSFFUN1(INT,CSADDR,csaddr,STRING)
 #define	CSADDR(CHFILE) CCALLSFFUN1(CSADDR,csaddr,STRING,CHFILE)
 
@@ -30,3 +38,9 @@
 
 PROTOCCALLSFSUB2(CSTYPE,cstype,INT,PSTRING)
 #define CSTYPE(CADR,CHTYPE) CCALLSFSUB2(CSTYPE,cstype,INT,PSTRING,CADR,CHTYPE)
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef _COMIS_H */
diff -urNad cernlib-2005.05.09/src/cfortran/cspack.h /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/cspack.h
--- cernlib-2005.05.09/src/cfortran/cspack.h	1999-10-29 07:42:56.000000000 -0400
+++ /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/cspack.h	2005-06-10 12:51:31.013993690 -0400
@@ -1,5 +1,19 @@
+#ifndef _CSPACK_H
+#define _CSPACK_H
+#include <cfortran/cfortran.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 PROTOCCALLSFSUB2(CZPUTA,czputa,STRING,PINT)
 #define CZPUTA(CHMAIL,ISTAT) CCALLSFSUB2(CZPUTA,czputa,STRING,PINT,CHMAIL,ISTAT)
 
 PROTOCCALLSFSUB2(CZGETA,czgeta,PSTRING,PINT)
 #define CZGETA(CHMAIL,ISTAT) CCALLSFSUB2(CZGETA,czgeta,PSTRING,PINT,CHMAIL,ISTAT)
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef _CSPACK_H */
diff -urNad cernlib-2005.05.09/src/cfortran/geant315.h /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/geant315.h
--- cernlib-2005.05.09/src/cfortran/geant315.h	1996-05-15 05:24:06.000000000 -0400
+++ /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/geant315.h	2005-06-10 12:51:31.080979393 -0400
@@ -1,3 +1,11 @@
+#ifndef _GEANT315_H
+#define _GEANT315_H
+#include <cfortran/cfortran.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*------------------------------------------------------------------
 fortran filename   : /cern/new/src/cfs/geant315/abbrch.f
 ------------------------------------------------------------------*/
@@ -4797,3 +4805,9 @@
 
 #define ZEREGS() CCALLSFSUB0(ZEREGS,zeregs)
 
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef _GEANT315_H */
diff -urNad cernlib-2005.05.09/src/cfortran/geant321.h /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/geant321.h
--- cernlib-2005.05.09/src/cfortran/geant321.h	1996-05-15 05:24:07.000000000 -0400
+++ /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/geant321.h	2005-06-10 12:51:31.148964883 -0400
@@ -1,3 +1,11 @@
+#ifndef _GEANT321_H
+#define _GEANT321_H
+#include <cfortran/cfortran.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*------------------------------------------------------------------
 fortran filename   : abbrch.f
 ------------------------------------------------------------------*/
@@ -6099,3 +6107,9 @@
  PROTOCCALLSFFUN3(DOUBLE,XSEPRO,xsepro,DOUBLE,DOUBLE,DOUBLE)
 #define XSEPRO(A2,A3,A4)  CCALLSFFUN3(XSEPRO,xsepro,DOUBLE,DOUBLE,DOUBLE,A2,A3,A4)
 
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef _GEANT321_H */
diff -urNad cernlib-2005.05.09/src/cfortran/gen.h /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/gen.h
--- cernlib-2005.05.09/src/cfortran/gen.h	2005-06-10 12:51:00.965407158 -0400
+++ /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/gen.h	2005-06-10 12:51:31.190955921 -0400
@@ -1,3 +1,11 @@
+#ifndef _GEN_H
+#define _GEN_H
+#include <cfortran/cfortran.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Subroutines/Functions with COMPLEX not supported ***
 
 #define CBSJA(A1,A2,A3,A4,A5)  CCALLSFSUB5(CBSJA,cbsja,COMPLEX,FLOAT,INT,INT,PCOMPLEX,A1,A2,A3,A4,A5)
@@ -1489,3 +1497,9 @@
 
 PROTOCCALLSFSUB6(ZEROX,zerox,FLOAT,FLOAT,FLOAT,INT,FLOAT,INT)
 #define ZEROX(A1,A2,A3,A4,A5,A6)  CCALLSFSUB6(ZEROX,zerox,FLOAT,FLOAT,FLOAT,INT,FLOAT,INT,A1,A2,A3,A4,A5,A6)
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef _GEN_H */
diff -urNad cernlib-2005.05.09/src/cfortran/graflib.h /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/graflib.h
--- cernlib-2005.05.09/src/cfortran/graflib.h	1998-01-29 05:49:27.000000000 -0500
+++ /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/graflib.h	2005-06-10 12:51:31.220949519 -0400
@@ -1,2 +1,16 @@
-#include "higz.h"
-#include "hplot.h"
+#ifndef _GRAFLIB_H
+#define _GRAFLIB_H
+#include <cfortran/cfortran.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <higz.h>
+#include <hplot.h>
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef _GRAFLIB_H */
diff -urNad cernlib-2005.05.09/src/cfortran/jetset74.h /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/jetset74.h
--- cernlib-2005.05.09/src/cfortran/jetset74.h	1999-10-29 12:55:45.000000000 -0400
+++ /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/jetset74.h	2005-06-10 12:51:31.250943117 -0400
@@ -1,3 +1,11 @@
+#ifndef _JETSET74_H
+#define _JETSET74_H
+#include <cfortran/cfortran.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 PROTOCCALLSFFUN2(INT,KLU,klu,INT,INT)
 #define KLU(A2,A3)  CCALLSFFUN2(KLU,klu,INT,INT,A2,A3)
 
@@ -327,3 +335,9 @@
 
 PROTOCCALLSFSUB11(STRUCTM,structm,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,PDOUBLE)
 #define STRUCTM(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11)  CCALLSFSUB11(STRUCTM,structm,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,PDOUBLE,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11)
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef _JETSET74_H */
diff -urNad cernlib-2005.05.09/src/cfortran/kernlib.h /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/kernlib.h
--- cernlib-2005.05.09/src/cfortran/kernlib.h	2000-03-16 11:58:18.000000000 -0500
+++ /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/kernlib.h	2005-06-10 12:51:31.291934368 -0400
@@ -1,3 +1,11 @@
+#ifndef _KERNLIB_H
+#define _KERNLIB_H
+#include <cfortran/cfortran.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 PROTOCCALLSFFUN1(FLOAT,ALOGAM,alogam,FLOAT)
 #define ALOGAM(A2)  CCALLSFFUN1(ALOGAM,alogam,FLOAT,A2)
 
@@ -1512,3 +1520,9 @@
 
 PROTOCCALLSFSUB1(WORDSEP,wordsep,STRING)
 #define WORDSEP(A1)  CCALLSFSUB1(WORDSEP,wordsep,STRING,A1)
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef _KERNLIB_H */
diff -urNad cernlib-2005.05.09/src/cfortran/kuip.h /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/kuip.h
--- cernlib-2005.05.09/src/cfortran/kuip.h	2000-10-05 10:27:54.000000000 -0400
+++ /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/kuip.h	2005-06-10 12:51:31.319928394 -0400
@@ -1,3 +1,11 @@
+#ifndef _KUIP_H
+#define _KUIP_H
+#include <cfortran/cfortran.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 PROTOCCALLSFSUB3(KUCLOS,kuclos,INT,STRING,INT)
 #define KUCLOS(A1,A2,A3)    CCALLSFSUB3(KUCLOS,kuclos,INT,STRING,INT,A1,A2,A3)
 
@@ -6,3 +14,9 @@
 
 PROTOCCALLSFSUB0(KUWHAG,kuwhag)
 #define KUWHAG() CCALLSFSUB0(KUWHAG,kuwhag)
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef _KUIP_H */
diff -urNad cernlib-2005.05.09/src/cfortran/lapack.h /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/lapack.h
--- cernlib-2005.05.09/src/cfortran/lapack.h	2000-06-23 06:13:58.000000000 -0400
+++ /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/lapack.h	2005-06-10 12:51:31.348922205 -0400
@@ -1,2 +1,16 @@
+#ifndef _LAPACK_H
+#define _LAPACK_H
+#include <cfortran/cfortran.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 PROTOCCALLSFSUB11(DGELS,dgels,STRING,INT,INT,INT,DOUBLEV,INT,DOUBLEV,INT,DOUBLEV,INT,PINT)
 #define DGELS(TRANS,M,N,NRHS,A,LDA,B,LDB,WORK,LWORK,INFO) CCALLSFSUB11(DGELS,dgels,STRING,INT,INT,INT,DOUBLEV,INT,DOUBLEV,INT,DOUBLEV,INT,PINT,TRANS,M,N,NRHS,A,LDA,B,LDB,WORK,LWORK,INFO)
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef _LAPACK_H */
diff -urNad cernlib-2005.05.09/src/cfortran/lepto62.h /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/lepto62.h
--- cernlib-2005.05.09/src/cfortran/lepto62.h	1999-10-29 12:55:45.000000000 -0400
+++ /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/lepto62.h	2005-06-10 12:51:31.378915804 -0400
@@ -1,3 +1,11 @@
+#ifndef _LEPTO62_H
+#define _LEPTO62_H
+#include <cfortran/cfortran.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 PROTOCCALLSFFUN2(FLOAT,DCROSS,dcross,FLOAT,FLOAT)
 #define DCROSS(A2,A3)  CCALLSFFUN2(DCROSS,dcross,FLOAT,FLOAT,A2,A3)
 
@@ -174,3 +182,9 @@
 
 PROTOCCALLSFSUB0(RIWIBD,riwibd)
 #define RIWIBD() CCALLSFSUB0(RIWIBD,riwibd)
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef _LEPTO62_H */
diff -urNad cernlib-2005.05.09/src/cfortran/minuit.h /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/minuit.h
--- cernlib-2005.05.09/src/cfortran/minuit.h	1999-10-27 11:30:23.000000000 -0400
+++ /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/minuit.h	2005-06-10 12:51:31.407909615 -0400
@@ -1,3 +1,11 @@
+#ifndef _MINUIT_H
+#define _MINUIT_H
+#include <cfortran/cfortran.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
  *  Interface to minuit using cfortran.h
  *
@@ -190,3 +198,9 @@
 
 PROTOCCALLSFSUB0(STAND,stand)
 #define STAND() CCALLSFSUB0(STAND,stand)
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef _MINUIT_H */
diff -urNad cernlib-2005.05.09/src/cfortran/packlib.h /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/packlib.h
--- cernlib-2005.05.09/src/cfortran/packlib.h	1998-01-29 11:17:45.000000000 -0500
+++ /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/packlib.h	2005-06-10 12:51:31.436903427 -0400
@@ -1,4 +1,18 @@
-#include "hbook.h"
-#include "minuit.h"
-#include "kuip.h"
-#include "zebra.h"
+#ifndef _PACKLIB_H
+#define _PACKLIB_H
+#include <cfortran/cfortran.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <hbook.h>
+#include <minuit.h>
+#include <kuip.h>
+#include <zebra.h>
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef _PACKLIB_H */
diff -urNad cernlib-2005.05.09/src/cfortran/paw.h /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/paw.h
--- cernlib-2005.05.09/src/cfortran/paw.h	2000-10-05 10:27:55.000000000 -0400
+++ /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/paw.h	2005-06-10 12:51:31.464897452 -0400
@@ -1,6 +1,20 @@
+#ifndef _PAW_H
+#define _PAW_H
+#include <cfortran/cfortran.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 PROTOCCALLSFSUB2(PAW,paw,INT,INT)
 #define PAW(A1,A2)  CCALLSFSUB2(PAW,paw,INT,INT,A1,A2)
 
 PROTOCCALLSFSUB0(PAEXIT,paexit)
 #define PAEXIT() CCALLSFSUB0(PAEXIT,paexit)
 
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef _PAW_H */
diff -urNad cernlib-2005.05.09/src/cfortran/zebra.h /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/zebra.h
--- cernlib-2005.05.09/src/cfortran/zebra.h	1999-10-29 07:35:47.000000000 -0400
+++ /tmp/dpep.Al0dBQ/cernlib-2005.05.09/src/cfortran/zebra.h	2005-06-10 12:51:31.496890624 -0400
@@ -1,5 +1,19 @@
+#ifndef _ZEBRA_H
+#define _ZEBRA_H
+#include <cfortran/cfortran.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 PROTOCCALLSFSUB1(MZEBRA,mzebra,INT)
 #define MZEBRA(A1)    CCALLSFSUB1(MZEBRA,mzebra,INT,A1)
 
 PROTOCCALLSFSUB2(MZPAW,mzpaw,INT,STRING)
 #define MZPAW(A1,A2)  CCALLSFSUB2(MZPAW,mzpaw,INT,STRING,A1,A2)
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef _ZEBRA_H */


--- NEW FILE 306-patch-assert.h-for-makedepend.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 306-patch-assert.h-for-makedepend.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Include local copy of assert.h with a workaround for a bug of
## DP: makedepend (cf. Debian bug # 171908).

@DPATCH@
diff -urNad cernlib-2005.05.09/src/include/assert.h /tmp/dpep.9sKNsJ/cernlib-2005.05.09/src/include/assert.h
--- cernlib-2005.05.09/src/include/assert.h	1969-12-31 19:00:00.000000000 -0500
+++ /tmp/dpep.9sKNsJ/cernlib-2005.05.09/src/include/assert.h	2005-06-09 12:50:41.751880968 -0400
@@ -0,0 +1,153 @@
+#ifndef CERNLIB_LINUX
+# include "/usr/include/assert.h"
+#else
+
+/* Copyright (C) 1991,1992,1994-2001,2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/*
+ *	ISO C99 Standard: 7.2 Diagnostics	<assert.h>
+ */
+
+#ifdef	_ASSERT_H
+
+# undef	_ASSERT_H
+# undef	assert
+# undef __ASSERT_VOID_CAST
+
+# ifdef	__USE_GNU
+#  undef assert_perror
+# endif
+
+#endif /* assert.h	*/
+
+#define	_ASSERT_H	1
+#include <features.h>
+
+#if defined __cplusplus && __GNUC_PREREQ (2,95)
+# define __ASSERT_VOID_CAST static_cast<void>
+#else
+# define __ASSERT_VOID_CAST (void)
+#endif
+
+/* void assert (int expression);
+
+   If NDEBUG is defined, do nothing.
+   If not, and EXPRESSION is zero, print an error message and abort.  */
+
+#ifdef	NDEBUG
+
+# define assert(expr)		(__ASSERT_VOID_CAST (0))
+
+/* void assert_perror (int errnum);
+
+   If NDEBUG is defined, do nothing.  If not, and ERRNUM is not zero, print an
+   error message with the error text for ERRNUM and abort.
+   (This is a GNU extension.) */
+
+# ifdef	__USE_GNU
+#  define assert_perror(errnum)	(__ASSERT_VOID_CAST (0))
+# endif
+
+#else /* Not NDEBUG.  */
+
+#ifndef _ASSERT_H_DECLS
+#define _ASSERT_H_DECLS
+__BEGIN_DECLS
+
+/* This prints an "Assertion failed" message and aborts.  */
+extern void __assert_fail (__const char *__assertion, __const char *__file,
+			   unsigned int __line, __const char *__function)
+     __THROW __attribute__ ((__noreturn__));
+
+/* Likewise, but prints the error text for ERRNUM.  */
+extern void __assert_perror_fail (int __errnum, __const char *__file,
+				  unsigned int __line,
+				  __const char *__function)
+     __THROW __attribute__ ((__noreturn__));
+
+
+/* The following is not at all used here but needed for standard
+   compliance.  */
+extern void __assert (const char *__assertion, const char *__file, int __line)
+     __THROW __attribute__ ((__noreturn__));
+
+
+__END_DECLS
+#endif /* Not _ASSERT_H_DECLS */
+
+/* For the macro definition we use gcc's __builtin_expect if possible
+   to generate good code for the non-error case.  gcc 3.0 is a good
+   enough estimate for when the feature became available.  */
+# if __GNUC_PREREQ (3, 0)
+#  define assert(expr) \
+  (__ASSERT_VOID_CAST (__builtin_expect (!!(expr), 1) ? 0 :		      \
+		       (__assert_fail (__STRING(expr), __FILE__, __LINE__,    \
+				       __ASSERT_FUNCTION), 0)))
+# else
+#  define assert(expr) \
+  (__ASSERT_VOID_CAST ((expr) ? 0 :					      \
+		       (__assert_fail (__STRING(expr), __FILE__, __LINE__,    \
+				       __ASSERT_FUNCTION), 0)))
+# endif
+
+# ifdef	__USE_GNU
+#  if __GNUC_PREREQ (3, 0)
+#   define assert_perror(errnum) \
+  (__ASSERT_VOID_CAST (__builtin_expect (!(errnum), 1) ? 0 :		      \
+		       (__assert_perror_fail ((errnum), __FILE__, __LINE__,   \
+					      __ASSERT_FUNCTION), 0)))
+#  else
+#   define assert_perror(errnum) \
+  (__ASSERT_VOID_CAST (!(errnum) ? 0 :					      \
+		       (__assert_perror_fail ((errnum), __FILE__, __LINE__,   \
+					      __ASSERT_FUNCTION), 0)))
+#  endif
+# endif
+
+/* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'
+   which contains the name of the function currently being defined.
+   This is broken in G++ before version 2.6.
+   C9x has a similar variable called __func__, but prefer the GCC one since
+   it demangles C++ function names.  */
+
+/* The following commented-out line breaks makedepend (bug # 171908); a local
+ * patched version of assert.h is therefore included.
+ *   --Kevin McCarty, for Debian */
+/* # if defined __cplusplus ? __GNUC_PREREQ (2, 6) : __GNUC_PREREQ (2, 4) */
+
+/* begin fix to work around Debian Bug # 171908 */
+# if defined __cplusplus
+#  if __GNUC_PREREQ (2, 6)
+#   define __ASSERT_FUNCTION	__PRETTY_FUNCTION__
+#  endif
+# elif __GNUC_PREREQ (2, 4)
+/* end fix */
+
+#   define __ASSERT_FUNCTION	__PRETTY_FUNCTION__
+# else
+#  if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+#   define __ASSERT_FUNCTION	__func__
+#  else
+#   define __ASSERT_FUNCTION	((__const char *) 0)
+#  endif
+# endif
+
+#endif /* NDEBUG.  */
+
+#endif /* CERNLIB_LINUX */


--- NEW FILE 307-use-canonical-cfortran.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 307-use-canonical-cfortran.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Use the most recent version of cfortran.h and cfortran.doc from
## DP: Debian package of cfortran, version 4.4-6.

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/cfortran/cfortran.doc cernlib-2005.05.09.dfsg/src/cfortran/cfortran.doc
--- cernlib-2005.05.09.dfsg~/src/cfortran/cfortran.doc	1998-12-11 12:17:09.000000000 -0500
+++ cernlib-2005.05.09.dfsg/src/cfortran/cfortran.doc	2006-05-16 16:45:01.329802364 -0400
@@ -195,13 +195,13 @@
 HP9000> f77 -c cfortex.f
 HP9000> CC -o cfortest cfortest.c cfortex.o -lI77 -lF77 && cfortest
 
-HP0000> # If old-style f77 +800 compiled objects are required:
+HP9000> # If old-style f77 +800 compiled objects are required:
 HP9000> # #define hpuxFortran800
 HP9000> cc -c -Aa -DhpuxFortran800 cfortest.c
 HP9000> f77 +800 -o cfortest cfortest.o cfortex.f
 
 f2c> # In the following, 'CC' is any C compiler.
-f2c> f2c -R cfortex.f
+f2c> f2c cfortex.f
 f2c> CC -o cfortest -Df2cFortran cfortest.c cfortex.c -lf2c  &&  cfortest
 
 Portland Group $ # Presumably other C compilers also work.
@@ -533,9 +533,10 @@
 FORTRAN_REAL thus corresponds to FORTRAN's REAL on all machines, including t3e.
 
 
-o f2c
-  f2c, by default promotes REAL functions to double. cfortran.h does not (yet)
-support this, so the f2c -R option must be used to turn this promotion off.
+o f2c / g77
+  f2c and g77 by default promote REAL functions to double.  As of December 9,
+2005, the Debian package of cfortran supports this behavior, so the f2c -R
+option must *NOT* be used to turn this promotion off.
 
 o f2c
 [Thanks to Dario Autiero for pointing out the following.]
@@ -573,6 +574,11 @@
 #endif
 /* Last three lines are a work-around for the strange f2c naming feature. */
 
+o gfortran
+  gfortran behaves similarly to f2c and g77, EXCEPT that it does NOT by default
+promote REAL functions to double.  Therefore you should use -DgFortran instead
+of -Dg77Fortran or -Df2cFortran to let cfortran.h know about this difference.
+
 o NAG f90
   The Fortran 77 subset of Fortran 90 is supported. Extending cfortran.h to 
 interface C with all of Fortran 90 has not yet been examined.
@@ -643,7 +649,7 @@
    [For an ancient math.h on a 386 or sparc, get similar from a new math.h.]
    #ifdef mc68000     /* 5 lines Copyright (c) 1988 by Sun Microsystems, Inc. */
    #define FLOATFUNCTIONTYPE	int
-   #define RETURNFLOAT(x) 		return (*(int *)(&(x)))
+   #define RETURNFLOAT(x) 	return (*(int *)(&(x)))
    #define ASSIGNFLOAT(x,y)	*(int *)(&x) = y
    #endif
 
@@ -874,7 +880,7 @@
 works everywhere and would seem to be an obvious choice.
 
 
-3. <BYTE|DOUBLE|BYTE|DOUBLE|FLOAT|INT|LOGICAL|LONG|SHORT><V|VV|VVV|...>
+3. <BYTE|DOUBLE|FLOAT|INT|LOGICAL|LONG|SHORT><V|VV|VVV|...>
 
 cfortran.h encourages the exact specification of the type and dimension of
 array parameters because it allows the C compiler to detect errors in the
@@ -1835,7 +1841,7 @@
 
 Unlike all other C compilers supported by cfortran.h,
 'gcc -traditional' promotes to double all functions returning float
-as demonstrated bu the following example.
+as demonstrated by the following example.
 
 /* m.c */
 #include <stdio.h>
@@ -2017,8 +2023,9 @@
 
 THIS PACKAGE, I.E. CFORTRAN.H, THIS DOCUMENT, AND THE CFORTRAN.H EXAMPLE
 PROGRAMS ARE PROPERTY OF THE AUTHOR WHO RESERVES ALL RIGHTS. THIS PACKAGE AND
-THE CODE IT PRODUCES MAY BE FREELY DISTRIBUTED WITHOUT FEES, SUBJECT TO THE
-FOLLOWING RESTRICTIONS:
+THE CODE IT PRODUCES MAY BE FREELY DISTRIBUTED WITHOUT FEES, SUBJECT
+(AT YOUR CHOICE) EITHER TO THE GNU LIBRARY GENERAL PUBLIC LICENSE
+AT http://www.gnu.org/licenses/lgpl.html OR TO THE FOLLOWING RESTRICTIONS:
 - YOU MUST ACCOMPANY ANY COPIES OR DISTRIBUTION WITH THIS (UNALTERED) NOTICE.
 - YOU MAY NOT RECEIVE MONEY FOR THE DISTRIBUTION OR FOR ITS MEDIA 
   (E.G. TAPE, DISK, COMPUTER, PAPER.)
diff -urNad cernlib-2005.05.09.dfsg~/src/cfortran/cfortran.h cernlib-2005.05.09.dfsg/src/cfortran/cfortran.h
--- cernlib-2005.05.09.dfsg~/src/cfortran/cfortran.h	2002-09-11 13:05:51.000000000 -0400
+++ cernlib-2005.05.09.dfsg/src/cfortran/cfortran.h	2006-05-16 16:44:47.680553957 -0400
@@ -1,4 +1,4 @@
-/* cfortran.h  4.4_cernlib2002 */
+/* cfortran.h  4.4 */
 /* http://www-zeus.desy.de/~burow/cfortran/                   */
 /* Burkhard Burow  burow at desy.de                 1990 - 2002. */
 
@@ -11,11 +11,71 @@
    MODIFYING, COPYING AND DISTRIBUTING THE CFORTRAN.H PACKAGE.
 */
 
+/* The following modifications were made by the authors of CFITSIO or by me. 
+ * They are flagged below with CFITSIO, the author's initials, or KMCCARTY.
+ * PDW = Peter Wilson
+ * DM  = Doug Mink
+ * LEB = Lee E Brotzman
+ * MR  = Martin Reinecke
+ * WDP = William D Pence
+ * -- Kevin McCarty, for Debian (19 Dec. 2005) */
+
+/*******
+   Modifications:
+      Oct 1997: Changed symbol name extname to appendus (PDW/HSTX)
+                (Conflicted with a common variable name in FTOOLS)
+      Nov 1997: If g77Fortran defined, also define f2cFortran (PDW/HSTX)
+      Feb 1998: Let VMS see the NUM_ELEMS code. Lets programs treat
+                single strings as vectors with single elements
+      Nov 1999: If macintoxh defined, also define f2cfortran (for Mac OS-X)
+      Apr 2000: If WIN32 defined, also define PowerStationFortran and
+                VISUAL_CPLUSPLUS (Visual C++)
+      Jun 2000: If __GNUC__ and linux defined, also define f2cFortran
+                (linux/gcc environment detection)
+      Apr 2002: If __CYGWIN__ is defined, also define f2cFortran
+      Nov 2002: If __APPLE__ defined, also define f2cfortran (for Mac OS-X)
+
+      Nov 2003: If __INTEL_COMPILER or INTEL_COMPILER defined, also define
+                f2cFortran (KMCCARTY)
+      Dec 2005: If f2cFortran is defined, enforce REAL functions in FORTRAN
+                returning "double" in C.  This was one of the items on
+		Burkhard's TODO list. (KMCCARTY)
+      Dec 2005: Modifications to support 8-byte integers. (MR)
+		USE AT YOUR OWN RISK!
+      Feb 2006  Added logic to typedef the symbol 'LONGLONG' to an appropriate
+                intrinsic 8-byte integer datatype  (WDP)
+      Apr 2006: Modifications to support gfortran (and g77 with -fno-f2c flag)
+                since by default it returns "float" for FORTRAN REAL function.
+                (KMCCARTY)
+ *******/
+
 /* 
   Avoid symbols already used by compilers and system *.h:
   __ - OSF1 zukal06 V3.0 347 alpha, cc -c -std1 cfortest.c
 
- */
+*/
+
+/* 
+   Determine what 8-byte integer data type is available.
+  'long long' is now supported by most compilers, but older
+  MS Visual C++ compilers before V7.0 use '__int64' instead. (WDP)
+*/
+
+#ifndef LONGLONG_TYPE   /* this may have been previously defined */
+#if defined(_MSC_VER)   /* Microsoft Visual C++ */
+
+#if (_MSC_VER < 1300)   /* versions earlier than V7.0 do not have 'long long' */
+    typedef __int64 LONGLONG;
+#else                   /* newer versions do support 'long long' */
+    typedef long long LONGLONG; 
+#endif
+
+#else
+    typedef long long LONGLONG; 
+#endif
+
+#define LONGLONG_TYPE
+#endif  
 
 
 /* First prepare for the C compiler. */
@@ -75,7 +135,9 @@
 
 /* Remainder of cfortran.h depends on the Fortran compiler. */
 
-#if defined(CLIPPERFortran) || defined(pgiFortran)
+/* 11/29/2003 (KMCCARTY): add *INTEL_COMPILER symbols here */
+/* 04/05/2006 (KMCCARTY): add gFortran symbol here */
+#if defined(CLIPPERFortran) || defined(pgiFortran) || defined(__INTEL_COMPILER) || defined(INTEL_COMPILER) || defined(gFortran)
 #define f2cFortran
 #endif
 
@@ -90,6 +152,27 @@
                            Support f2c or f77 with gcc, vcc with f2c. 
                            f77 with vcc works, missing link magic for f77 I/O.*/
 #endif
+/* 04/13/00 DM (CFITSIO): Add these lines for NT */
+/*   with PowerStationFortran and and Visual C++ */
+#if defined(WIN32) && !defined(__CYGWIN__)
+#define PowerStationFortran   
+#define VISUAL_CPLUSPLUS
+#endif
+#if defined(g77Fortran)                        /* 11/03/97 PDW (CFITSIO) */
+#define f2cFortran
+#endif
+#if        defined(__CYGWIN__)                 /* 04/11/02 LEB (CFITSIO) */
+#define       f2cFortran 
+#endif
+#if        defined(__GNUC__) && defined(linux) /* 06/21/00 PDW (CFITSIO) */
+#define       f2cFortran 
+#endif
+#if defined(macintosh)                         /* 11/1999 (CFITSIO) */
+#define f2cFortran
+#endif
+#if defined(__APPLE__)                         /* 11/2002 (CFITSIO) */
+#define f2cFortran
+#endif
 #if defined(__hpux)             /* 921107: Use __hpux instead of __hp9000s300 */
 #define       hpuxFortran       /*         Should also allow hp9000s7/800 use.*/
 #endif
@@ -131,6 +214,7 @@
 #if !(defined(mipsFortran)||defined(DECFortran)||defined(vmsFortran)||defined(CONVEXFortran)||defined(PowerStationFortran)||defined(AbsoftUNIXFortran)||defined(AbsoftProFortran)||defined(SXFortran))
 /* If your compiler barfs on ' #error', replace # with the trigraph for #     */
  #error "cfortran.h:  Can't find your environment among:\
+    - GNU gcc (g77) on Linux.                                            \
     - MIPS cc and f77 2.0. (e.g. Silicon Graphics, DECstations, ...)     \
     - IBM AIX XL C and FORTRAN Compiler/6000 Version 01.01.0000.0000     \
     - VAX   VMS CC 3.1 and FORTRAN 5.4.                                  \
@@ -147,11 +231,14 @@
     - VAXUltrix: vcc,cc or gcc with f2c. gcc or cc with f77.             \
     -            f77 with vcc works; but missing link magic for f77 I/O. \
     -            NO fort. None of gcc, cc or vcc generate required names.\
-    - f2c    : Use #define    f2cFortran, or cc -Df2cFortran             \
+    - f2c/g77:   Use #define    f2cFortran, or cc -Df2cFortran           \
+    - gfortran:  Use #define    gFortran,   or cc -DgFortran             \
+                 (also necessary for g77 with -fno-f2c option)           \
     - NAG f90: Use #define NAGf90Fortran, or cc -DNAGf90Fortran          \
     - Absoft UNIX F77: Use #define AbsoftUNIXFortran or cc -DAbsoftUNIXFortran \
     - Absoft Pro Fortran: Use #define AbsoftProFortran \
-    - Portland Group Fortran: Use #define pgiFortran"
+    - Portland Group Fortran: Use #define pgiFortran \
+    - Intel Fortran: Use #define INTEL_COMPILER"
 /* Compiler must throw us out at this point! */
 #endif
 #endif
@@ -164,7 +251,8 @@
 
 /* Throughout cfortran.h we use: UN = Uppercase Name.  LN = Lowercase Name.   */
 
-#if defined(f2cFortran) || defined(NAGf90Fortran) || defined(DECFortran) || defined(mipsFortran) || defined(apolloFortran) || defined(sunFortran) || defined(CONVEXFortran) || defined(SXFortran) || defined(extname)
+/* "extname" changed to "appendus" below (CFITSIO) */
+#if defined(f2cFortran) || defined(NAGf90Fortran) || defined(DECFortran) || defined(mipsFortran) || defined(apolloFortran) || defined(sunFortran) || defined(CONVEXFortran) || defined(SXFortran) || defined(appendus)
 #define CFC_(UN,LN)            _(LN,_)      /* Lowercase FORTRAN symbols.     */
 #define orig_fcallsc(UN,LN)    CFC_(UN,LN)
 #else 
@@ -268,7 +356,8 @@
 #endif
 
 #ifndef apolloFortran
-#define COMMON_BLOCK_DEF(DEFINITION, NAME) DEFINITION NAME
+/* "extern" removed (CFITSIO) */
+#define COMMON_BLOCK_DEF(DEFINITION, NAME) /* extern */ DEFINITION NAME
 #define CF_NULL_PROTO
 #else                                         /* HP doesn't understand #elif. */
 /* Without ANSI prototyping, Apollo promotes float functions to double.    */
@@ -512,7 +601,7 @@
                     *( (F).dsc$l_m[0]=(F).dsc$bounds[0].dsc$l_u=(ELEMNO)  ),   \
   (F).dsc$a_a0    =  ( (F).dsc$a_pointer=(C) ) - (F).dsc$w_length          ,(F))
 
-#else
+#endif      /* PDW: 2/10/98 (CFITSIO) -- Let VMS see NUM_ELEMS definitions */
 #define _NUM_ELEMS      -1
 #define _NUM_ELEM_ARG   -2
 #define NUM_ELEMS(A)    A,_NUM_ELEMS
@@ -538,9 +627,14 @@
   if (i==(unsigned)num_term) break;
   else strv += elem_len-i;
 }
+if (0) {  /* to prevent not used warnings in gcc (added by ROOT) */
+   c2fstrv(0, 0, 0, 0); f2cstrv(0, 0, 0, 0); kill_trailing(0, 0);
+   vkill_trailing(0, 0, 0, 0); num_elem(0, 0, 0, 0);
+}
 return (int)num;
 }
-#endif
+/* #endif removed 2/10/98 (CFITSIO) */
+
 /*-------------------------------------------------------------------------*/
 
 /*           UTILITIES FOR C TO USE STRINGS IN FORTRAN COMMON BLOCKS       */
@@ -1318,6 +1412,7 @@
 #define     INTVVVVVVV_cfTYPE int
 #define LOGICALVVVVVVV_cfTYPE int
 #define    LONGVVVVVVV_cfTYPE long
+#define LONGLONGVVVVVVV_cfTYPE LONGLONG   /* added by MR December 2005 */
 #define   SHORTVVVVVVV_cfTYPE short
 #define          PBYTE_cfTYPE INTEGER_BYTE
 #define        PDOUBLE_cfTYPE DOUBLE_PRECISION 
@@ -1325,6 +1420,7 @@
 #define           PINT_cfTYPE int
 #define       PLOGICAL_cfTYPE int
 #define          PLONG_cfTYPE long
+#define      PLONGLONG_cfTYPE LONGLONG  /* added by MR December 2005 */
 #define         PSHORT_cfTYPE short
 
 #define CFARGS0(A,T,V,W,X,Y,Z) _3(T,_cf,A)
@@ -1342,6 +1438,7 @@
 #define            INT_cfINT(N,A,B,X,Y,Z)        DOUBLE_cfINT(N,A,B,X,Y,Z)
 #define        LOGICAL_cfINT(N,A,B,X,Y,Z)        DOUBLE_cfINT(N,A,B,X,Y,Z)
 #define           LONG_cfINT(N,A,B,X,Y,Z)        DOUBLE_cfINT(N,A,B,X,Y,Z)
+#define       LONGLONG_cfINT(N,A,B,X,Y,Z)        DOUBLE_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
 #define          SHORT_cfINT(N,A,B,X,Y,Z)        DOUBLE_cfINT(N,A,B,X,Y,Z)
 #define          PBYTE_cfINT(N,A,B,X,Y,Z)       PDOUBLE_cfINT(N,A,B,X,Y,Z)
 #define        PDOUBLE_cfINT(N,A,B,X,Y,Z) _(CFARGS,N)(A,PINT,B,X,Y,Z,0)
@@ -1349,6 +1446,7 @@
 #define           PINT_cfINT(N,A,B,X,Y,Z)       PDOUBLE_cfINT(N,A,B,X,Y,Z)
 #define       PLOGICAL_cfINT(N,A,B,X,Y,Z)       PDOUBLE_cfINT(N,A,B,X,Y,Z)
 #define          PLONG_cfINT(N,A,B,X,Y,Z)       PDOUBLE_cfINT(N,A,B,X,Y,Z)
+#define      PLONGLONG_cfINT(N,A,B,X,Y,Z)       PDOUBLE_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
 #define         PSHORT_cfINT(N,A,B,X,Y,Z)       PDOUBLE_cfINT(N,A,B,X,Y,Z)
 #define          BYTEV_cfINT(N,A,B,X,Y,Z)       DOUBLEV_cfINT(N,A,B,X,Y,Z)
 #define         BYTEVV_cfINT(N,A,B,X,Y,Z)      DOUBLEVV_cfINT(N,A,B,X,Y,Z)
@@ -1392,6 +1490,13 @@
 #define      LONGVVVVV_cfINT(N,A,B,X,Y,Z)   DOUBLEVVVVV_cfINT(N,A,B,X,Y,Z)
 #define     LONGVVVVVV_cfINT(N,A,B,X,Y,Z)  DOUBLEVVVVVV_cfINT(N,A,B,X,Y,Z)
 #define    LONGVVVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVVVV_cfINT(N,A,B,X,Y,Z)
+#define      LONGLONGV_cfINT(N,A,B,X,Y,Z)       DOUBLEV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define     LONGLONGVV_cfINT(N,A,B,X,Y,Z)      DOUBLEVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define    LONGLONGVVV_cfINT(N,A,B,X,Y,Z)     DOUBLEVVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define   LONGLONGVVVV_cfINT(N,A,B,X,Y,Z)    DOUBLEVVVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define  LONGLONGVVVVV_cfINT(N,A,B,X,Y,Z)   DOUBLEVVVVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define LONGLONGVVVVVV_cfINT(N,A,B,X,Y,Z)  DOUBLEVVVVVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define LONGLONGVVVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVVVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
 #define         SHORTV_cfINT(N,A,B,X,Y,Z)       DOUBLEV_cfINT(N,A,B,X,Y,Z)
 #define        SHORTVV_cfINT(N,A,B,X,Y,Z)      DOUBLEVV_cfINT(N,A,B,X,Y,Z)
 #define       SHORTVVV_cfINT(N,A,B,X,Y,Z)     DOUBLEVVV_cfINT(N,A,B,X,Y,Z)
@@ -1451,7 +1556,12 @@
 #define      BYTE_cfPU(A)   CFextern INTEGER_BYTE      FCALLSC_QUALIFIER A
 #define    DOUBLE_cfPU(A)   CFextern DOUBLE_PRECISION  FCALLSC_QUALIFIER A
 #if ! (defined(FLOATFUNCTIONTYPE)&&defined(ASSIGNFLOAT)&&defined(RETURNFLOAT))
+#if defined (f2cFortran) && ! defined (gFortran)
+/* f2c/g77 return double from FORTRAN REAL functions. (KMCCARTY, 2005/12/09) */
+#define     FLOAT_cfPU(A)   CFextern DOUBLE_PRECISION  FCALLSC_QUALIFIER A
+#else
 #define     FLOAT_cfPU(A)   CFextern FORTRAN_REAL      FCALLSC_QUALIFIER A
+#endif
 #else				   	                   
 #define     FLOAT_cfPU(A)   CFextern FLOATFUNCTIONTYPE FCALLSC_QUALIFIER A
 #endif				   	                   
@@ -1589,6 +1699,7 @@
 #define            INT_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define        LOGICAL_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,LOGICAL,A,B,C,D,E)
 #define           LONG_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define       LONGLONG_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
 #define          SHORT_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define          BYTEV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define         BYTEVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
@@ -1632,6 +1743,13 @@
 #define      LONGVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define     LONGVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define    LONGVVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define      LONGLONGV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define     LONGLONGVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define    LONGLONGVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define   LONGLONGVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define  LONGLONGVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define LONGLONGVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define LONGLONGVVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
 #define         SHORTV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define        SHORTVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define       SHORTVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
@@ -1645,6 +1763,7 @@
 #define           PINT_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define       PLOGICAL_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,PLOGICAL,A,B,C,D,E)
 #define          PLONG_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define      PLONGLONG_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
 #define         PSHORT_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define         STRING_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,STRING,A,B,C,D,E)
 #define        PSTRING_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,PSTRING,A,B,C,D,E)
@@ -1957,6 +2076,7 @@
 #define            INT_cfT(M,I,A,B,D) *A
 #define        LOGICAL_cfT(M,I,A,B,D)  F2CLOGICAL(*A)
 #define           LONG_cfT(M,I,A,B,D) *A
+#define       LONGLONG_cfT(M,I,A,B,D) *A /* added by MR December 2005 */
 #define          SHORT_cfT(M,I,A,B,D) *A
 #define          BYTEV_cfT(M,I,A,B,D)  A
 #define        DOUBLEV_cfT(M,I,A,B,D)  A
@@ -1964,6 +2084,7 @@
 #define           INTV_cfT(M,I,A,B,D)  A
 #define       LOGICALV_cfT(M,I,A,B,D)  A
 #define          LONGV_cfT(M,I,A,B,D)  A
+#define      LONGLONGV_cfT(M,I,A,B,D)  A /* added by MR December 2005 */
 #define         SHORTV_cfT(M,I,A,B,D)  A
 #define         BYTEVV_cfT(M,I,A,B,D)  (void *)A /* We have to cast to void *,*/
 #define        BYTEVVV_cfT(M,I,A,B,D)  (void *)A /* since we don't know the   */
@@ -2001,6 +2122,12 @@
 #define      LONGVVVVV_cfT(M,I,A,B,D)  (void *)A
 #define     LONGVVVVVV_cfT(M,I,A,B,D)  (void *)A
 #define    LONGVVVVVVV_cfT(M,I,A,B,D)  (void *)A
+#define     LONGLONGVV_cfT(M,I,A,B,D)  (void *)A /* added by MR December 2005 */
+#define    LONGLONGVVV_cfT(M,I,A,B,D)  (void *)A /* added by MR December 2005 */
+#define   LONGLONGVVVV_cfT(M,I,A,B,D)  (void *)A /* added by MR December 2005 */
+#define  LONGLONGVVVVV_cfT(M,I,A,B,D)  (void *)A /* added by MR December 2005 */
+#define LONGLONGVVVVVV_cfT(M,I,A,B,D)  (void *)A /* added by MR December 2005 */
+#define LONGLONGVVVVVVV_cfT(M,I,A,B,D)  (void *)A /* added by MR December 2005 */
 #define        SHORTVV_cfT(M,I,A,B,D)  (void *)A
 #define       SHORTVVV_cfT(M,I,A,B,D)  (void *)A
 #define      SHORTVVVV_cfT(M,I,A,B,D)  (void *)A
@@ -2013,6 +2140,7 @@
 #define           PINT_cfT(M,I,A,B,D)  A
 #define       PLOGICAL_cfT(M,I,A,B,D)  ((*A=F2CLOGICAL(*A)),A)
 #define          PLONG_cfT(M,I,A,B,D)  A
+#define      PLONGLONG_cfT(M,I,A,B,D)  A /* added by MR December 2005 */
 #define         PSHORT_cfT(M,I,A,B,D)  A
 #define          PVOID_cfT(M,I,A,B,D)  A
 #if defined(apolloFortran) || defined(hpuxFortran800) || defined(AbsoftUNIXFortran)
@@ -2083,12 +2211,18 @@
 #define     INT_cfFZ(UN,LN) int   FCALLSC_QUALIFIER fcallsc(UN,LN)(
 #define LOGICAL_cfFZ(UN,LN) int   FCALLSC_QUALIFIER fcallsc(UN,LN)(
 #define    LONG_cfFZ(UN,LN) long  FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#define LONGLONG_cfFZ(UN,LN) LONGLONG FCALLSC_QUALIFIER fcallsc(UN,LN)( /* added by MR December 2005 */
 #define   SHORT_cfFZ(UN,LN) short FCALLSC_QUALIFIER fcallsc(UN,LN)(
 #define    VOID_cfFZ(UN,LN) void  FCALLSC_QUALIFIER fcallsc(UN,LN)(
 #ifndef __CF__KnR
 /* The void is req'd by the Apollo, to make this an ANSI function declaration.
    The Apollo promotes K&R float functions to double. */
-#define   FLOAT_cfFZ(UN,LN) FORTRAN_REAL FCALLSC_QUALIFIER fcallsc(UN,LN)(void
+#if defined (f2cFortran) && ! defined (gFortran)
+/* f2c/g77 return double from FORTRAN REAL functions. (KMCCARTY, 2005/12/09) */
+#define FLOAT_cfFZ(UN,LN) DOUBLE_PRECISION FCALLSC_QUALIFIER fcallsc(UN,LN)(void
+#else
+#define FLOAT_cfFZ(UN,LN) FORTRAN_REAL FCALLSC_QUALIFIER fcallsc(UN,LN)(void
+#endif
 #ifdef vmsFortran
 #define  STRING_cfFZ(UN,LN) void  FCALLSC_QUALIFIER fcallsc(UN,LN)(fstring *AS
 #else
@@ -2104,7 +2238,12 @@
 #endif
 #else
 #if ! (defined(FLOATFUNCTIONTYPE)&&defined(ASSIGNFLOAT)&&defined(RETURNFLOAT))
+#if defined (f2cFortran) && ! defined (gFortran)
+/* f2c/g77 return double from FORTRAN REAL functions. (KMCCARTY, 2005/12/09) */
+#define   FLOAT_cfFZ(UN,LN) DOUBLE_PRECISION  FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#else
 #define   FLOAT_cfFZ(UN,LN) FORTRAN_REAL      FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#endif
 #else
 #define   FLOAT_cfFZ(UN,LN) FLOATFUNCTIONTYPE FCALLSC_QUALIFIER fcallsc(UN,LN)(
 #endif
@@ -2118,13 +2257,19 @@
 #define    BYTE_cfF(UN,LN)     BYTE_cfFZ(UN,LN)
 #define  DOUBLE_cfF(UN,LN)   DOUBLE_cfFZ(UN,LN)
 #ifndef __CF_KnR
+#if defined (f2cFortran) && ! defined (gFortran)
+/* f2c/g77 return double from FORTRAN REAL functions. (KMCCARTY, 2005/12/09) */
+#define   FLOAT_cfF(UN,LN)  DOUBLE_PRECISION FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#else
 #define   FLOAT_cfF(UN,LN)  FORTRAN_REAL FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#endif
 #else
 #define   FLOAT_cfF(UN,LN)    FLOAT_cfFZ(UN,LN)
 #endif
 #define     INT_cfF(UN,LN)      INT_cfFZ(UN,LN)
 #define LOGICAL_cfF(UN,LN)  LOGICAL_cfFZ(UN,LN)
 #define    LONG_cfF(UN,LN)     LONG_cfFZ(UN,LN)
+#define LONGLONG_cfF(UN,LN) LONGLONG_cfFZ(UN,LN) /* added by MR December 2005 */
 #define   SHORT_cfF(UN,LN)    SHORT_cfFZ(UN,LN)
 #define    VOID_cfF(UN,LN)     VOID_cfFZ(UN,LN)
 #define  STRING_cfF(UN,LN)   STRING_cfFZ(UN,LN),
@@ -2187,6 +2332,7 @@
 #define LOGICAL_cfI  return C2FLOGICAL(A0);
 #endif
 #define    LONG_cfI  return A0;
+#define LONGLONG_cfI  return A0; /* added by MR December 2005 */
 #define   SHORT_cfI  return A0;
 #define  STRING_cfI  return   ;
 #define    VOID_cfI  return   ;


--- NEW FILE 315-fixes-for-MacOSX.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 315-fixes-for-MacOSX.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Patch set (mostly due to Keisuke Fujii) to allow Cernlib to compile
## DP: and run on OS X.

@DPATCH@
diff -urNad cernlib-2006.dfsg~/src/Imakefile cernlib-2006.dfsg/src/Imakefile
--- cernlib-2006.dfsg~/src/Imakefile	2007-01-09 19:27:31.059892042 -0500
+++ cernlib-2006.dfsg/src/Imakefile	2007-01-09 19:27:33.049467233 -0500
@@ -7,8 +7,12 @@
 SUBDIRS= $(LIBDIRS) patchy cfortran
 
 #ifdef CERNLIB_UNIX
+#ifdef CERNLIB_MACOSX
+SUBDIRS:= $(SUBDIRS) scripts
+#else
 SUBDIRS:= $(SUBDIRS) scripts mgr
 #endif
+#endif
 
 InstallLibSubdirs($(LIBDIRS))
 
diff -urNad cernlib-2006.dfsg~/src/config/Imake.rules cernlib-2006.dfsg/src/config/Imake.rules
--- cernlib-2006.dfsg~/src/config/Imake.rules	2005-04-18 11:39:25.000000000 -0400
+++ cernlib-2006.dfsg/src/config/Imake.rules	2007-01-09 19:27:33.050467019 -0500
@@ -2171,7 +2171,7 @@
 #define CppScriptTarget(dst,src,defs,deplist)				@@\
 dst::  src deplist							@@\
 	RemoveFile($@)							@@\
-	$(CPP) defs <src | CppSedMagic >$@				@@\
+	$(CPP) defs src | CppSedMagic >$@				@@\
 	chmod a+x $@							@@\
 									@@\
 clean::									@@\
@@ -2203,7 +2203,7 @@
 #define CppFileTarget(dst,src,defs,deplist)				@@\
 dst::  src deplist							@@\
 	RemoveFile($@)							@@\
-	$(CPP) defs <src | CppSedMagic >$@				@@\
+	$(CPP) defs src | CppSedMagic >$@				@@\
 									@@\
 clean::									@@\
 	RemoveFiles(dst)
diff -urNad cernlib-2006.dfsg~/src/config/MacOSX.cf cernlib-2006.dfsg/src/config/MacOSX.cf
--- cernlib-2006.dfsg~/src/config/MacOSX.cf	2006-11-23 09:25:33.000000000 -0500
+++ cernlib-2006.dfsg/src/config/MacOSX.cf	2007-01-09 19:41:23.844091722 -0500
@@ -73,8 +73,12 @@
 #define	BuildDPMSExt	NO
 
 # define BuildXvExt     NO
-#define OptimizedCDebugFlags -O0 -g -pipe
-#define ExtraLoadFlags -L/usr/X11R6/lib
+
+#ifndef OptimizationLevel
+# define OptimizationLevel -O
+#endif
+#define OptimizedCDebugFlags OptimizationLevel -g -pipe
+#define ExtraLoadFlags -L/usr/X11R6/lib -L/sw/lib
 
 #define BuildExamples YES
 
@@ -87,9 +91,11 @@
 #define HasVoidSignalReturn YES
 
 #ifndef DependFlags
-#define DependFlags -I/usr/include/ansi -I/usr/include/bsd
+#define DependFlags -I/usr/include/ansi -I/usr/include/bsd -I/sw/include
 #endif
 
+#define StandardIncludes -I/sw/include
+
 #define InstallCmd	install	/* unlink old */
 
 /* #define ArCmd libtool -a -o */
@@ -103,7 +109,7 @@
 
 #define PrimaryScreenResolution 95	/* for 17 inch screen */
 
-#define ServerCDebugFlags -O0 -g -pipe
+#define ServerCDebugFlags OptimizationLevel -g -pipe
 
 /* #define HasGcc YES */
 #ifndef HasGcc
@@ -122,7 +128,7 @@
 #endif
 #endif
 #ifndef CcCmd
-#define CcCmd cc
+#define CcCmd cc -g
 #endif
 
 #define CppCmd        /usr/bin/cpp
@@ -133,25 +139,35 @@
 /* #define GLX_DIRECT_RENDERING */
 
 #define f2cFortran              YES
-#define FortranCmd              gfortran
+#define FortranCmd              gfortran -g
 #define XargsCmd                xargs
 #define FortranSaveFlags        /* -fno-automatic */ /* Everything static !? */
-#define OptimisedFortranFlags	-O0 -g -funroll-loops -fomit-frame-pointer \
+#define OptimisedFortranFlags	OptimizationLevel -g -funroll-loops \
 				-ftree-vectorize
-#define DefaultFCOptions        -fno-second-underscore
-/*#define CernlibSystem           -DCERNLIB_LINUX -DCERNLIB_UNIX -DCERNLIB_LNX \
-				-DCERNLIB_PPC -DCERNLIB_QMGLIBC \
-				-DCERNLIB_MACOSX -DCERNLIB_GFORTRAN */
+#define DefaultFCOptions        -fno-second-underscore OptimizationLevel
 
+#ifndef CernlibLocalDefines
+# define CernlibLocalDefines
+#endif
+#ifdef PpcDarwinArchitecture
+#define CernlibSystem           -DCERNLIB_LINUX -DCERNLIB_UNIX -DCERNLIB_LNX \
+				-DCERNLIB_PPC -DCERNLIB_QMGLIBC \
+				-DCERNLIB_MACOSX -DCERNLIB_GFORTRAN \
+				CernlibLocalDefines
+#else
 #define CernlibSystem           -DCERNLIB_LINUX -DCERNLIB_UNIX -DCERNLIB_LNX \
 				-DCERNLIB_QMGLIBC \
-				-DCERNLIB_MACOSX -DCERNLIB_GFORTRAN 
+				-DCERNLIB_MACOSX -DCERNLIB_GFORTRAN \
+				CernlibLocalDefines
+#endif
 
 /* #define CERNLIB_SHIFT NO */
 #define CERNLIB_LINUX
 #define CERNLIB_UNIX
 #define CERNLIB_LNX
-/*#define CERNLIB_PPC*/
+#ifdef PpcDarwinArchitecture
+# define CERNLIB_PPC
+#endif
 #define CERNLIB_QMGLIBC
 #define CERNLIB_MACOSX
 #define CERNLIB_GFORTRAN
diff -urNad cernlib-2006.dfsg~/src/config/MacOSX.rules cernlib-2006.dfsg/src/config/MacOSX.rules
--- cernlib-2006.dfsg~/src/config/MacOSX.rules	2006-09-04 08:32:56.000000000 -0400
+++ cernlib-2006.dfsg/src/config/MacOSX.rules	2007-01-09 15:47:15.542676000 -0500
@@ -28,18 +28,24 @@
 #endif
 
 
-
-
 /*
  * InstallSharedLibrary - generate rules to install the shared library.
+ * Edited 2003-05-09 by Kevin McCarty to add an install.shlib target.
  */
 #ifndef InstallSharedLibrary
 #define InstallSharedLibrary(libname,rev,dest)				@@\
-install:: Concat(lib,libname.dylib)					@@\
+.PHONY: install.shlib shlib/libname					@@\
+shlib/libname:: $(DESTDIR)dest/SharedLibraryTargetName(libname)		@@\
+									@@\
+install.shlib:: $(DESTDIR)dest/SharedLibraryTargetName(libname)		@@\
+									@@\
+$(DESTDIR)dest/SharedLibraryTargetName(libname): SharedLibraryTargetName(libname) @@\
 	MakeDir($(DESTDIR)dest)						@@\
-	$(INSTALL) $(INSTALLFLAGS) $(INSTBINFLAGS) Concat(lib,libname.dylib) $(DESTDIR)dest
-@@\
-
+	$(INSTALL) $(INSTALLFLAGS) $(INSTBINFLAGS) Concat(lib,libname.rev.dylib) $(DESTDIR)dest @@\
+	(T=`echo Concat($(DESTDIR)dest/lib,libname.rev.dylib) | sed 's/\.[^\.d]*\.dylib/\.dylib/'`;\ @@\
+		$(RM) $$T && $(LN) Concat(lib,libname.rev.dylib) $$T)	@@\
+	$(RM) Concat($(DESTDIR)dest/lib,libname.dylib)			@@\
+	$(LN) Concat(lib,libname.rev.dylib) Concat($(DESTDIR)dest/lib,libname.dylib)
 #endif /* InstallSharedLibrary */
 
 /*
diff -urNad cernlib-2006.dfsg~/src/config/site.def cernlib-2006.dfsg/src/config/site.def
--- cernlib-2006.dfsg~/src/config/site.def	2002-04-26 10:46:04.000000000 -0400
+++ cernlib-2006.dfsg/src/config/site.def	2007-01-09 19:27:33.051466806 -0500
@@ -99,9 +99,7 @@
 /*   if it is already defined and false, undef it! */
 /* do not use shift by default
 #if defined(CERNLIB_UNIX) && !defined(CERNLIB_WINNT)
-#if ! defined(CERNLIB_SHIFT)
-#define CERNLIB_SHIFT
-#elif  ! CERNLIB_SHIFT
+#if defined(CERNLIB_SHIFT) && !CERNLIB_SHIFT
 #undef CERNLIB_SHIFT
 #endif
 #endif
diff -urNad cernlib-2005.05.09.dfsg~/src/geant321/gxint/Imakefile cernlib-2005.05.09.dfsg/src/geant321/gxint/Imakefile
--- cernlib-2005.05.09.dfsg~/src/geant321/gxint/Imakefile	1997-01-29 11:37:40.000000000 -0500
+++ cernlib-2005.05.09.dfsg/src/geant321/gxint/Imakefile	2005-12-07 14:47:34.140148771 -0500
@@ -30,7 +30,7 @@
 
 gxint321.f:  gxint.F
 	RemoveFile($@)
-	$(CPP) $(FORTRANALLDEFMDEPEND) < $^ | sed -e '/^$$/d' | CppSedMagic >$@
+	FortranCmd -E $(FORTRANALLDEFMDEPEND) $^ | sed -e '/^$$/d' | CppSedMagic >$@
 
 install.lib:: $(CERN_LIBDIR)/gxint.f
 
diff -urNad cernlib-2005.05.09.dfsg~/src/mclibs/cojets/data/Imakefile cernlib-2005.05.09.dfsg/src/mclibs/cojets/data/Imakefile
--- cernlib-2005.05.09.dfsg~/src/mclibs/cojets/data/Imakefile	1996-03-27 04:31:06.000000000 -0500
+++ cernlib-2005.05.09.dfsg/src/mclibs/cojets/data/Imakefile	2005-12-07 14:47:34.141148558 -0500
@@ -1,11 +1,11 @@
 
 .SUFFIXES:
 
-CopyFile(cojets.cpp,cojets.cin)
+CopyFile(cojets.cpp,cojets.s)
 CopyFile(decay.cpp,decay.cin)
 CopyFile(table.cpp,table.cin)
 
-CppFileTarget(cojets.dat,cojets.cin,NullParameter,table.cin decay.cin)
+CppFileTarget(cojets.dat,cojets.s,-E -traditional,table.cin decay.cin)
 
 PackageDirFileTarget(cojets.dat)
 
diff -urNad cernlib-2005.05.09.dfsg~/src/mclibs/isajet/data/Imakefile cernlib-2005.05.09.dfsg/src/mclibs/isajet/data/Imakefile
--- cernlib-2005.05.09.dfsg~/src/mclibs/isajet/data/Imakefile	1996-03-27 04:33:19.000000000 -0500
+++ cernlib-2005.05.09.dfsg/src/mclibs/isajet/data/Imakefile	2005-12-07 14:47:34.141148558 -0500
@@ -1,9 +1,9 @@
 
 .SUFFIXES:
 
-CopyFile(decay.cpp,decay.cin)
+CopyFile(decay.cpp,decay.s)
 
-CppFileTarget(isajet.dat,decay.cin,NullParameter,NullParameter)
+CppFileTarget(isajet.dat,decay.s,-E -traditional ,NullParameter)
 
 PackageDirFileTarget(isajet.dat)
 


--- NEW FILE 700-remove-kernlib-from-packlib-Imakefile.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 700-remove-kernlib-from-packlib-Imakefile.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/Imakefile /tmp/dpep.VNPUUt/cernlib-2005.05.09/src/Imakefile
--- cernlib-2005.05.09/src/Imakefile	2005-06-10 16:46:36.495568752 -0400
+++ /tmp/dpep.VNPUUt/cernlib-2005.05.09/src/Imakefile	2005-06-10 16:50:33.508709032 -0400
@@ -2,7 +2,7 @@
 #define PassCDebugFlags
 
 
-LIBDIRS= packlib pawlib graflib mathlib geant321 mclibs phtools
+LIBDIRS= kernlib packlib pawlib graflib mathlib geant321 mclibs phtools
 
 SUBDIRS= $(LIBDIRS) patchy cfortran
 
@@ -23,5 +23,5 @@
 DelegateTarget(bin/kuipc,packlib)
 
 DelegateTarget(lib/packlib,packlib)
-DelegateTarget(lib/kernlib,packlib)
+DelegateTarget(lib/kernlib,kernlib)
 
diff -urNad cernlib-2005.05.09/src/packlib/Imakefile /tmp/dpep.VNPUUt/cernlib-2005.05.09/src/packlib/Imakefile
--- cernlib-2005.05.09/src/packlib/Imakefile	1997-10-02 10:09:19.000000000 -0400
+++ /tmp/dpep.VNPUUt/cernlib-2005.05.09/src/packlib/Imakefile	2005-06-10 16:48:25.928085636 -0400
@@ -4,7 +4,7 @@
 
 
 LIBDIRS= cspack epio fatmen ffread hbook hepdb kapack kuip \ @@\
-	 minuit zbook zebra kernlib
+	 minuit zbook zebra
 
 SUBDIRS= $(LIBDIRS)
 
@@ -17,14 +17,10 @@
 
 TestSubdirs($(LIBDIRS))
 
-#ifndef CERNLIB_VAXVMS
-
-InstallLibSubdirs(kernlib)
-
-#else
+#ifdef CERNLIB_VAXVMS
 
 SUBDIRS := $(SUBDIRS) vmslibfiles
-InstallLibSubdirs(kernlib vmslibfiles)
+InstallLibSubdirs(vmslibfiles)
 
 #endif
 


--- NEW FILE 702-patch-Imakefiles-for-packlib-mathlib.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 702-patch-Imakefiles-for-packlib-mathlib.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Hacks to Imakefiles to go along with the 702 shellscript for moving
## DP: files around.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/mathlib/gen/d/Imakefile /tmp/dpep.aVAPwe/cernlib-2005.05.09/src/mathlib/gen/d/Imakefile
--- cernlib-2005.05.09/src/mathlib/gen/d/Imakefile	2005-06-10 22:19:15.720962444 -0400
+++ /tmp/dpep.aVAPwe/cernlib-2005.05.09/src/mathlib/gen/d/Imakefile	2005-06-10 22:24:26.783925145 -0400
@@ -1,6 +1,8 @@
 DoIncludePackage(gen)
 #include "pilot.h"
 
+/* rgmlt*.F have been moved into packlib/hbook to remove circular dependencies.
+   --Kevin McCarty, for Debian. */
 SRCS_F=	arithm.F c128.F c256.F c512.F c64.F cauchy64.F cft.F cfstft.F \ @@\
 	rfstft.F cgauss.F d107d1.F d107r1.F d501l1.F d501l2.F d501n1.F \ @@\
         d501n2.F d501p1.F d501p2.F d501sf.F d700su.F d701bd.F \ @@\
@@ -10,14 +12,14 @@
         epditr.F epdje.F epdloc.F epdsrt.F epdtab.F errorf.F esolve.F \ @@\
 	fcn1.F fftrc.F fumili.F gauss.F i128.F i32.F i64.F linsq.F \ @@\
 	mconv.F mft.F minfc.F minsq.F monito.F newro.F old506.F radapt.F \ @@\
-	radmul.F rca.F rfrdh164.F rfrdh264.F rft.F rgmlt64.F rgquad.F \ @@\
+	radmul.F rca.F rfrdh164.F rfrdh264.F rft.F           rgquad.F \ @@\
 	rgs56p.F rgset.F riwiad.F riwibd.F rknys64.F rknysd.F rkstp.F \ @@\
 	rpa.F rps.F rrkstp.F rsa.F rtriint.F s128.F s256.F s512.F \ @@\
 	s64.F scal.F sgz.F simps.F synt.F traper.F triint.F vd01a.F
 
 #if defined(CERNLIB_DOUBLE)
 SRCS_F:= $(SRCS_F) cgauss64.F dgquad.F dgset.F gauss64.F minfc64.F \ @@\
-	rcauch.F rdeqbs.F rdeqmr.F rderiv.F rfrdh1.F rgmlt.F rkstp64.F \ @@\
+	rcauch.F rdeqbs.F rdeqmr.F rderiv.F rfrdh1.F         rkstp64.F \ @@\
 	simps64.F triint64.F 
 #if defined(CERNLIB_LINUX)
 /* -O3 optimization breaks in g77 3.2 */
@@ -26,7 +28,7 @@
 #endif
 #else
 SRCS_F:= $(SRCS_F) cgauss128.F cauchy.F cauchy128.F deqbs128.F deqmr128.F \ @@\
-	deriv128.F minfc128.F rfrdh128.F rgmlt128.F rkstp128.F simps128.F \ @@\
+	deriv128.F minfc128.F rfrdh128.F            rkstp128.F simps128.F \ @@\
 	triint128.F 
 #endif
 
diff -urNad cernlib-2005.05.09/src/mathlib/gen/Imakefile /tmp/dpep.aVAPwe/cernlib-2005.05.09/src/mathlib/gen/Imakefile
--- cernlib-2005.05.09/src/mathlib/gen/Imakefile	1996-10-02 12:09:45.000000000 -0400
+++ /tmp/dpep.aVAPwe/cernlib-2005.05.09/src/mathlib/gen/Imakefile	2005-06-10 22:20:55.683416711 -0400
@@ -8,7 +8,8 @@
 IMAKE_DEFINES=-DFortranDoesCpp=NO
 #endif
 
-LIBDIRS= a b c d divon e f g h j m n s u v x
+/* "n" subdir moved to packlib/hbook/  --Kevin McCarty, for Debian */
+LIBDIRS= a b c d divon e f g h j m   s u v x
 
 SUBDIRS= $(LIBDIRS) gen tests
 
diff -urNad cernlib-2005.05.09/src/mathlib/hbook/Imakefile /tmp/dpep.aVAPwe/cernlib-2005.05.09/src/mathlib/hbook/Imakefile
--- cernlib-2005.05.09/src/mathlib/hbook/Imakefile	1969-12-31 19:00:00.000000000 -0500
+++ /tmp/dpep.aVAPwe/cernlib-2005.05.09/src/mathlib/hbook/Imakefile	2004-06-30 21:54:11.000000000 -0400
@@ -0,0 +1,12 @@
+/* this Imakefile used to get hdiff to compile within the mathlib tree */
+
+#define IHaveSubdirs
+#define PassCDebugFlags
+
+LIBDIRS= hdiff
+SUBDIRS= $(LIBDIRS) hbook
+
+TopOfPackage(hbook)
+SubdirLibraryTarget(hbook,$(LIBDIRS))
+DoIncludePackage(hbook)
+InstallIncludeSubdirs(hbook)
diff -urNad cernlib-2005.05.09/src/mathlib/Imakefile /tmp/dpep.aVAPwe/cernlib-2005.05.09/src/mathlib/Imakefile
--- cernlib-2005.05.09/src/mathlib/Imakefile	2005-06-10 22:19:15.834937877 -0400
+++ /tmp/dpep.aVAPwe/cernlib-2005.05.09/src/mathlib/Imakefile	2005-06-10 22:20:05.279280394 -0400
@@ -3,7 +3,7 @@
 #define PassCDebugFlags 
 
 
-LIBDIRS= gen bvsl
+LIBDIRS= gen bvsl hbook /* hdiff stuff moved from packlib */
 
 /* Lapack is independent of Cernlib and should be installed as one of
    the build dependencies.
diff -urNad cernlib-2005.05.09/src/packlib/hbook/d/Imakefile /tmp/dpep.aVAPwe/cernlib-2005.05.09/src/packlib/hbook/d/Imakefile
--- cernlib-2005.05.09/src/packlib/hbook/d/Imakefile	1969-12-31 19:00:00.000000000 -0500
+++ /tmp/dpep.aVAPwe/cernlib-2005.05.09/src/packlib/hbook/d/Imakefile	2004-06-30 21:54:11.000000000 -0400
@@ -0,0 +1,25 @@
+/* this Imakefile is used to get some things from mathlib/gen/d to compile
+   within the packlib/hbook tree */
+
+DoIncludePackage(gen)
+#include "pilot.h"
+
+SRCS_F=	rgmlt64.F
+
+#if defined(CERNLIB_DOUBLE)
+SRCS_F:= $(SRCS_F) rgmlt.F
+#else
+SRCS_F:= $(SRCS_F) rgmlt128.F
+#endif
+
+#ifdef CERNLIB_HPUX
+FORTRANOPTIONS += -WF,-P
+#endif
+
+#if defined(CERNLIB_SGI)
+IMAKE_DEFINES=-DFortranDoesCpp=NO
+#endif
+
+FORTRANSAVEOPTION = FortranSaveFlags
+
+SubdirLibraryTarget(NullParameter,NullParameter)
diff -urNad cernlib-2005.05.09/src/packlib/hbook/Imakefile /tmp/dpep.aVAPwe/cernlib-2005.05.09/src/packlib/hbook/Imakefile
--- cernlib-2005.05.09/src/packlib/hbook/Imakefile	1997-04-28 04:21:23.000000000 -0400
+++ /tmp/dpep.aVAPwe/cernlib-2005.05.09/src/packlib/hbook/Imakefile	2005-06-10 22:26:27.063010420 -0400
@@ -2,7 +2,9 @@
 #define IHaveSubdirs
 #define PassCDebugFlags
 
-LIBDIRS= hdiff hmerge hquad chbook fpclassc \ @@\
+/* hdiff moved to mathlib to avoid circular DLL dependencies; "d" and "n"
+   moved here from mathlib for the same reasons */
+LIBDIRS= d n   hmerge hquad chbook fpclassc \ @@\
 	 hrz code hmcstat hntup
 
 #ifdef CERNLIB_VAX


--- NEW FILE 703-patch-code_motif-packlib-Imakefiles.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 703-patch-code_motif-packlib-Imakefiles.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fix up Imakefiles, etc. so that code_motif becomes a separate library
## DP: after moving it around in the patch 703 shell script.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/code_motif/Imakefile /tmp/dpep.mcTNBz/cernlib-2005.05.09/src/code_motif/Imakefile
--- cernlib-2005.05.09/src/code_motif/Imakefile	1996-12-10 10:20:59.000000000 -0500
+++ /tmp/dpep.mcTNBz/cernlib-2005.05.09/src/code_motif/Imakefile	2005-06-12 10:31:56.480928814 -0400
@@ -10,8 +10,10 @@
 	kuxxt.c mkdcmp.c mkdgra.c mkdpan.c mkmpan.c mkuip.c
 
 MotifDependantMakeVar(SRCS_C,$(MOTIF_SRCS_C))
-	
+
+/* Commented out since kmutil.c has been moved to packlib/kuip/code_kuip
 SRCS_C:= $(SRCS_C) kmutil.c
+*/
 
 #if defined(CERNLIB_VAXVMS)
 
@@ -22,4 +24,10 @@
  
 PACKAGE_INCLUDES := $(PACKAGE_INCLUDES) MotifIncludes X11Includes
 
-SubdirLibraryTarget(NullParameter,NullParameter)
+/* Top of package boilerplate to split this out as a separate library */
+
+TopOfPackage(packlib-lesstif)
+
+SubdirLibraryTarget(packlib-lesstif,NullParameter) 
+
+InstallLibrary(packlib-lesstif,$(CERN_LIBDIR))
diff -urNad cernlib-2005.05.09/src/Imakefile /tmp/dpep.mcTNBz/cernlib-2005.05.09/src/Imakefile
--- cernlib-2005.05.09/src/Imakefile	2005-06-12 10:31:54.221414133 -0400
+++ /tmp/dpep.mcTNBz/cernlib-2005.05.09/src/Imakefile	2005-06-12 10:32:20.947673659 -0400
@@ -2,7 +2,7 @@
 #define PassCDebugFlags
 
 
-LIBDIRS= kernlib packlib pawlib graflib mathlib geant321 mclibs phtools
+LIBDIRS= kernlib packlib code_motif pawlib graflib mathlib geant321 mclibs phtools
 
 SUBDIRS= $(LIBDIRS) patchy cfortran
 
diff -urNad cernlib-2005.05.09/src/packlib/kuip/code_kuip/Imakefile /tmp/dpep.mcTNBz/cernlib-2005.05.09/src/packlib/kuip/code_kuip/Imakefile
--- cernlib-2005.05.09/src/packlib/kuip/code_kuip/Imakefile	1999-11-24 04:52:07.000000000 -0500
+++ /tmp/dpep.mcTNBz/cernlib-2005.05.09/src/packlib/kuip/code_kuip/Imakefile	2005-06-12 10:31:56.480928814 -0400
@@ -3,7 +3,9 @@
 SRCS_C=	getline.c kalias.c kbrow.c kedit.c kexec.c khash.c kicon.c \ @@\
 	kienbr.c kipiaf.c kkern.c kmacro.c kmath.c kmenu.c kmisc.c \ @@\
 	kmodel.c kmterm.c kuinit.c kutrue.c kuvers.c kuwhag.c	   \ @@\
-	kuwhat.c kvect.c
+	kuwhat.c kvect.c \ @@\
+	kmutil.c
+	/* ^^ moved here from code_motif.  --Kevin McCarty */
 
 #ifdef CERNLIB_WINNT
 SRCS_C :=$(SRCS_C) kmutil0.c
diff -urNad cernlib-2005.05.09/src/packlib/kuip/Imakefile /tmp/dpep.mcTNBz/cernlib-2005.05.09/src/packlib/kuip/Imakefile
--- cernlib-2005.05.09/src/packlib/kuip/Imakefile	1997-11-28 12:26:56.000000000 -0500
+++ /tmp/dpep.mcTNBz/cernlib-2005.05.09/src/packlib/kuip/Imakefile	2005-06-12 10:31:56.480928814 -0400
@@ -4,11 +4,14 @@
 
 LIBDIRS= code_kuip 
 
+/* Commented out so that code_motif gives a separate shared library
+ * --Kevin McCarty
 #ifndef CERNLIB_WINNT
 LIBDIRS := $(LIBDIRS) code_motif
 #else
 LIBDIRS := $(LIBDIRS) code_windows
 #endif
+*/
 
 SUBDIRS= $(LIBDIRS) programs examples kuip
 


--- NEW FILE 705-patch-paw_motif-paw-Imakefiles.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 705-patch-paw_motif-paw-Imakefiles.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/Imakefile /tmp/dpep.Rec1V8/cernlib-2005.05.09/src/Imakefile
--- cernlib-2005.05.09/src/Imakefile	2005-06-13 16:04:27.418461884 -0400
+++ /tmp/dpep.Rec1V8/cernlib-2005.05.09/src/Imakefile	2005-06-13 16:04:48.698899728 -0400
@@ -2,7 +2,7 @@
 #define PassCDebugFlags
 
 
-LIBDIRS= kernlib packlib code_motif pawlib graflib mathlib geant321 mclibs phtools
+LIBDIRS= kernlib packlib code_motif pawlib paw_motif graflib mathlib geant321 mclibs phtools
 
 SUBDIRS= $(LIBDIRS) patchy cfortran
 
diff -urNad cernlib-2005.05.09/src/pawlib/paw/cdf/Imakefile /tmp/dpep.Rec1V8/cernlib-2005.05.09/src/pawlib/paw/cdf/Imakefile
--- cernlib-2005.05.09/src/pawlib/paw/cdf/Imakefile	1999-08-31 04:47:07.000000000 -0400
+++ /tmp/dpep.Rec1V8/cernlib-2005.05.09/src/pawlib/paw/cdf/Imakefile	2005-06-13 16:05:01.263206159 -0400
@@ -1,6 +1,6 @@
 #define IHaveCDF
 
-SRCS_CDF= pawcdf.cdf pamcdf.cdf mlpdef.cdf
+SRCS_CDF= pawcdf.cdf            mlpdef.cdf
 
 #ifdef CERNLIB_IBMRT
 /* Otherwise cc dies with internal compiler error on pawcdf. 
diff -urNad cernlib-2005.05.09/src/pawlib/paw/code/Imakefile /tmp/dpep.Rec1V8/cernlib-2005.05.09/src/pawlib/paw/code/Imakefile
--- cernlib-2005.05.09/src/pawlib/paw/code/Imakefile	2005-06-13 16:04:26.689618135 -0400
+++ /tmp/dpep.Rec1V8/cernlib-2005.05.09/src/pawlib/paw/code/Imakefile	2005-06-13 16:04:33.962059051 -0400
@@ -11,8 +11,8 @@
 	pautit.F pavect.F paw.F pawbrk.F pawdef.F pawfca.F \ @@\
 	pawfitz.F pawfop.F pawfu1.F pawfu2.F \ @@\
 	pawfu3.F pawfud.F pawfun.F pawfuy.F pawild.F pawins.F pawint.F \ @@\
-	pawint1.F pawint2.F pawint3.F pawint4.F pawintm.F \ @@\
-	pawjoj.F pawloc.F pawork.F pawpp.F pawrit.F pawrop.F \ @@\
+	pawint1.F pawint2.F pawint3.F pawint4.F           \ @@\
+	pawjoj.F pawloc.F pawork.F         pawrit.F pawrop.F \ @@\
 	pawsim.F pawusr.F pawuwf.F paxcut.F pazdz.F pazfz.F pazrz.F \ @@\
 	pchain.F pchclo.F pchncd.F pchrop.F pcnext.F pfclos.F \ @@\
 	pfhigz.F pfindc.F pfindf.F pfindf1.F pfindv.F pfinit.F pflog.F \ @@\
diff -urNad cernlib-2005.05.09/src/pawlib/paw/Imakefile /tmp/dpep.Rec1V8/cernlib-2005.05.09/src/pawlib/paw/Imakefile
--- cernlib-2005.05.09/src/pawlib/paw/Imakefile	2000-06-27 11:27:03.000000000 -0400
+++ /tmp/dpep.Rec1V8/cernlib-2005.05.09/src/pawlib/paw/Imakefile	2005-06-13 16:04:33.962059051 -0400
@@ -9,6 +9,9 @@
 
 LIBDIRS= code cpaw cdf ntuple mlpfit
 
+/* Comment out this whole section; Motif code has been moved to
+   paw_motif at top level.  -- Kevin McCarty */
+#if 0
 #ifndef CERNLIB_WINNT
 LIBDIRS :=$(LIBDIRS) $(MOTIF_DIRS) $(PAWPP_DIRS)
 #endif
@@ -22,6 +25,7 @@
 MotifDependantMakeVar(PAWPP_DIRS,xbaevms)
 LIBDIRS := $(LIBDIRS) $(PAWPP_DIRS)
 #endif
+#endif
 
 SUBDIRS= $(LIBDIRS) programs piafs hbpiaf stagerd paw
 
diff -urNad cernlib-2005.05.09/src/paw_motif/cdf/Imakefile /tmp/dpep.Rec1V8/cernlib-2005.05.09/src/paw_motif/cdf/Imakefile
--- cernlib-2005.05.09/src/paw_motif/cdf/Imakefile	1969-12-31 19:00:00.000000000 -0500
+++ /tmp/dpep.Rec1V8/cernlib-2005.05.09/src/paw_motif/cdf/Imakefile	2005-06-13 16:04:33.963058837 -0400
@@ -0,0 +1,5 @@
+#define IHaveCDF
+
+SRCS_CDF= pamcdf.cdf
+
+SubdirLibraryTarget(NullParameter,NullParameter)
diff -urNad cernlib-2005.05.09/src/paw_motif/code/Imakefile /tmp/dpep.Rec1V8/cernlib-2005.05.09/src/paw_motif/code/Imakefile
--- cernlib-2005.05.09/src/paw_motif/code/Imakefile	1969-12-31 19:00:00.000000000 -0500
+++ /tmp/dpep.Rec1V8/cernlib-2005.05.09/src/paw_motif/code/Imakefile	2005-06-13 16:04:33.963058837 -0400
@@ -0,0 +1,7 @@
+SRCS_F=	pawintm.F pawpp.F
+
+DoIncludePackage(paw)
+#include "pilot.h"
+
+SubdirLibraryTarget(NullParameter,NullParameter)
+
diff -urNad cernlib-2005.05.09/src/paw_motif/Imakefile /tmp/dpep.Rec1V8/cernlib-2005.05.09/src/paw_motif/Imakefile
--- cernlib-2005.05.09/src/paw_motif/Imakefile	2000-06-27 11:27:03.000000000 -0400
+++ /tmp/dpep.Rec1V8/cernlib-2005.05.09/src/paw_motif/Imakefile	2005-06-13 16:04:33.963058837 -0400
@@ -7,7 +7,7 @@
 MotifDependantMakeVar(MOTIF_DIRS,cmotif fmotif fpanelsc)
 MotifDependantMakeVar(PAWPP_DIRS,fpanelsf tree uimx)
 
-LIBDIRS= code cpaw cdf ntuple mlpfit
+LIBDIRS= code cdf
 
 #ifndef CERNLIB_WINNT
 LIBDIRS :=$(LIBDIRS) $(MOTIF_DIRS) $(PAWPP_DIRS)
@@ -23,19 +23,11 @@
 LIBDIRS := $(LIBDIRS) $(PAWPP_DIRS)
 #endif
 
-SUBDIRS= $(LIBDIRS) programs piafs hbpiaf stagerd paw
-
-#if defined CERNLIB_WINNT
-SUBDIRS := $(LIBDIRS) programs
-#endif
-
-TopOfPackage(paw)
-
-SubdirLibraryTarget(paw,$(LIBDIRS))
+SUBDIRS= $(LIBDIRS)
 
-InstallBinSubdirs(programs)
+TopOfPackage(pawlib-lesstif)
 
-TestSubdirs(test)
+SubdirLibraryTarget(pawlib-lesstif,$(LIBDIRS))
 
-InstallIncludeSubdirs(paw)
+InstallLibrary(pawlib-lesstif,$(CERN_LIBDIR))
 


--- NEW FILE 802-create-shared-libraries.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 802-create-shared-libraries.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Actually implement the rules to create shared libraries.

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/Imakefile cernlib-2005.05.09.dfsg/src/Imakefile
--- cernlib-2005.05.09.dfsg~/src/Imakefile	2005-12-01 15:19:24.191267776 +0000
+++ cernlib-2005.05.09.dfsg/src/Imakefile	2005-12-01 15:20:10.310483251 +0000
@@ -2,7 +2,7 @@
 #define PassCDebugFlags
 
 
-LIBDIRS= kernlib packlib code_motif pawlib paw_motif graflib mathlib geant321 mclibs phtools
+LIBDIRS= kernlib packlib mathlib graflib code_motif mclibs phtools pawlib paw_motif geant321
 
 SUBDIRS= $(LIBDIRS) patchy cfortran
 
@@ -15,6 +15,7 @@
 #endif
 
 InstallLibSubdirs($(LIBDIRS))
+InstallSharedLibSubdirs($(LIBDIRS))
 
 INCLUDEDIRS= $(LIBDIRS) cfortran
 
diff -urNad cernlib-2005.05.09.dfsg~/src/code_motif/Imakefile cernlib-2005.05.09.dfsg/src/code_motif/Imakefile
--- cernlib-2005.05.09.dfsg~/src/code_motif/Imakefile	2005-12-01 15:19:24.062295137 +0000
+++ cernlib-2005.05.09.dfsg/src/code_motif/Imakefile	2005-12-01 15:19:31.186783665 +0000
@@ -31,3 +31,4 @@
 SubdirLibraryTarget(packlib-lesstif,NullParameter) 
 
 InstallLibrary(packlib-lesstif,$(CERN_LIBDIR))
+InstallSharedLibrary(packlib-lesstif,$(LIB_SONAME).$(CERN_LEVEL),$(CERN_SHLIBDIR))
diff -urNad cernlib-2005.05.09.dfsg~/src/geant321/Imakefile cernlib-2005.05.09.dfsg/src/geant321/Imakefile
--- cernlib-2005.05.09.dfsg~/src/geant321/Imakefile	2005-12-01 15:19:23.018516575 +0000
+++ cernlib-2005.05.09.dfsg/src/geant321/Imakefile	2005-12-01 15:19:31.186783665 +0000
@@ -26,6 +26,7 @@
 
 InstallLibrary(geant321,$(CERN_LIBDIR))
 InstallLibraryAlias(geant321,geant,$(CERN_LIBDIR))
+InstallSharedLibrary(geant321,$(LIB_SONAME).$(CERN_LEVEL),$(CERN_SHLIBDIR))
 
 /* Fluka removed from Debian source package for copyright reasons. */
 /*
diff -urNad cernlib-2005.05.09.dfsg~/src/geant321/gparal/Imakefile cernlib-2005.05.09.dfsg/src/geant321/gparal/Imakefile
--- cernlib-2005.05.09.dfsg~/src/geant321/gparal/Imakefile	1996-12-19 14:19:18.000000000 +0000
+++ cernlib-2005.05.09.dfsg/src/geant321/gparal/Imakefile	2005-12-01 15:19:31.186783665 +0000
@@ -10,6 +10,7 @@
 SubdirLibraryTarget(geant321_parallel,NullParameter)
 
 InstallLibrary(geant321_parallel,$(CERN_LIBDIR))
+InstallSharedLibrary(geant321_parallel,$(LIB_SONAME).$(CERN_LEVEL),$(CERN_SHLIBDIR))
 
 CopyFile(../gbase/grun.F,grun.F)
 
diff -urNad cernlib-2005.05.09.dfsg~/src/graflib/Imakefile cernlib-2005.05.09.dfsg/src/graflib/Imakefile
--- cernlib-2005.05.09.dfsg~/src/graflib/Imakefile	2001-12-11 15:06:28.000000000 +0000
+++ cernlib-2005.05.09.dfsg/src/graflib/Imakefile	2005-12-01 15:19:31.186783665 +0000
@@ -11,9 +11,12 @@
 
 SubdirLibraryTarget(graflib,$(LIBDIRS))
 
-InstallLibrary(graflib,$(CERN_LIBDIR))
-
 InstallLibSubdirs(higz)
+InstallSharedLibSubdirs(higz)
+
+/* these lines follow the above because graflib depends on grafX11 */
+InstallLibrary(graflib,$(CERN_LIBDIR))
+InstallSharedLibrary(graflib,$(LIB_SONAME).$(CERN_LEVEL),$(CERN_SHLIBDIR))
 
 TestSubdirs(higz)
 
diff -urNad cernlib-2005.05.09.dfsg~/src/graflib/higz/Imakefile cernlib-2005.05.09.dfsg/src/graflib/higz/Imakefile
--- cernlib-2005.05.09.dfsg~/src/graflib/higz/Imakefile	1997-09-02 13:34:47.000000000 +0000
+++ cernlib-2005.05.09.dfsg/src/graflib/higz/Imakefile	2005-12-01 15:19:31.186783665 +0000
@@ -13,6 +13,7 @@
 SubdirLibraryTarget(grafX11,$(LIBDIRS))
 
 InstallLibrary(grafX11,$(CERN_LIBDIR))
+InstallSharedLibrary(grafX11,$(LIB_SONAME).$(CERN_LEVEL),$(CERN_SHLIBDIR))
 
 TestSubdirs(examples)
 
diff -urNad cernlib-2005.05.09.dfsg~/src/kernlib/Imakefile cernlib-2005.05.09.dfsg/src/kernlib/Imakefile
--- cernlib-2005.05.09.dfsg~/src/kernlib/Imakefile	2002-04-26 14:37:20.000000000 +0000
+++ cernlib-2005.05.09.dfsg/src/kernlib/Imakefile	2005-12-01 15:19:31.187783453 +0000
@@ -14,6 +14,7 @@
 
 InstallLibrary(kernlib,$(CERN_LIBDIR))
 InstallLibraryAlias(kernlib,kernlib-shift,$(CERN_LIBDIR))
+InstallSharedLibrary(kernlib,$(LIB_SONAME).$(CERN_LEVEL),$(CERN_SHLIBDIR))
 
 test::	LibraryTargetName(kernlib)
 
diff -urNad cernlib-2005.05.09.dfsg~/src/mathlib/Imakefile cernlib-2005.05.09.dfsg/src/mathlib/Imakefile
--- cernlib-2005.05.09.dfsg~/src/mathlib/Imakefile	2005-12-01 15:19:24.005307227 +0000
+++ cernlib-2005.05.09.dfsg/src/mathlib/Imakefile	2005-12-01 15:19:31.187783453 +0000
@@ -19,6 +19,7 @@
 SubdirLibraryTarget(mathlib,$(LIBDIRS))
 
 InstallLibrary(mathlib,$(CERN_LIBDIR))
+InstallSharedLibrary(mathlib,$(LIB_SONAME).$(CERN_LEVEL),$(CERN_SHLIBDIR))
 
 InstallIncludeSubdirs($(LIBDIRS))
 
diff -urNad cernlib-2005.05.09.dfsg~/src/mclibs/Imakefile cernlib-2005.05.09.dfsg/src/mclibs/Imakefile
--- cernlib-2005.05.09.dfsg~/src/mclibs/Imakefile	2005-12-01 15:19:22.512623901 +0000
+++ cernlib-2005.05.09.dfsg/src/mclibs/Imakefile	2005-12-01 15:19:31.187783453 +0000
@@ -13,6 +13,7 @@
 TestSubdirs($(LIBDIRS))
 
 InstallLibSubdirs($(LIBDIRS))
+InstallSharedLibSubdirs($(LIBDIRS))
 
 /* Again, purge Pythia, Jetset and dependents. */
 INCLUDEDIRS= cojets eurodec herwig isajet pdf
diff -urNad cernlib-2005.05.09.dfsg~/src/mclibs/cojets/Imakefile cernlib-2005.05.09.dfsg/src/mclibs/cojets/Imakefile
--- cernlib-2005.05.09.dfsg~/src/mclibs/cojets/Imakefile	1996-05-06 20:06:50.000000000 +0000
+++ cernlib-2005.05.09.dfsg/src/mclibs/cojets/Imakefile	2005-12-01 15:19:31.187783453 +0000
@@ -12,6 +12,7 @@
 SubdirLibraryTarget(cojets,$(LIBDIRS))
 
 InstallLibrary(cojets,$(CERN_LIBDIR))
+InstallSharedLibrary(cojets,$(LIB_SONAME).$(CERN_LEVEL),$(CERN_SHLIBDIR))
 
 SubdirDataFile($(LIBRARY),cojets.dat,data)
 
diff -urNad cernlib-2005.05.09.dfsg~/src/mclibs/eurodec/Imakefile cernlib-2005.05.09.dfsg/src/mclibs/eurodec/Imakefile
--- cernlib-2005.05.09.dfsg~/src/mclibs/eurodec/Imakefile	1996-05-06 20:06:55.000000000 +0000
+++ cernlib-2005.05.09.dfsg/src/mclibs/eurodec/Imakefile	2005-12-01 15:19:31.187783453 +0000
@@ -12,6 +12,7 @@
 SubdirLibraryTarget(eurodec,$(LIBDIRS))
 
 InstallLibrary(eurodec,$(CERN_LIBDIR))
+InstallSharedLibrary(eurodec,$(LIB_SONAME).$(CERN_LEVEL),$(CERN_SHLIBDIR))
 
 SubdirDataFile($(LIBRARY),eurodec.dat,data)
 
diff -urNad cernlib-2005.05.09.dfsg~/src/mclibs/herwig/Imakefile cernlib-2005.05.09.dfsg/src/mclibs/herwig/Imakefile
--- cernlib-2005.05.09.dfsg~/src/mclibs/herwig/Imakefile	1997-01-06 17:06:41.000000000 +0000
+++ cernlib-2005.05.09.dfsg/src/mclibs/herwig/Imakefile	2005-12-01 15:19:31.187783453 +0000
@@ -10,6 +10,7 @@
 
 InstallLibrary(herwig59,$(CERN_LIBDIR))
 InstallLibraryAlias(herwig59,herwig,$(CERN_LIBDIR))
+InstallSharedLibrary(herwig59,$(LIB_SONAME).$(CERN_LEVEL),$(CERN_SHLIBDIR))
 
 TestSubdirs(test)
 
diff -urNad cernlib-2005.05.09.dfsg~/src/mclibs/isajet/Imakefile cernlib-2005.05.09.dfsg/src/mclibs/isajet/Imakefile
--- cernlib-2005.05.09.dfsg~/src/mclibs/isajet/Imakefile	2001-10-08 14:03:02.000000000 +0000
+++ cernlib-2005.05.09.dfsg/src/mclibs/isajet/Imakefile	2005-12-01 15:19:31.187783453 +0000
@@ -12,6 +12,7 @@
 SubdirLibraryTarget(isajet758,$(LIBDIRS))
 
 InstallLibrary(isajet758,$(CERN_LIBDIR))
+InstallSharedLibrary(isajet758,$(LIB_SONAME).$(CERN_LEVEL),$(CERN_SHLIBDIR))
 
 SubdirDataFile($(LIBRARY),isajet.dat,data)
 
diff -urNad cernlib-2005.05.09.dfsg~/src/mclibs/pdf/Imakefile cernlib-2005.05.09.dfsg/src/mclibs/pdf/Imakefile
--- cernlib-2005.05.09.dfsg~/src/mclibs/pdf/Imakefile	2000-05-29 14:49:59.000000000 +0000
+++ cernlib-2005.05.09.dfsg/src/mclibs/pdf/Imakefile	2005-12-01 15:19:31.188783241 +0000
@@ -15,6 +15,7 @@
 SubdirLibraryTarget(pdflib804,spdf npdf)
 
 InstallLibrary(pdflib804,$(CERN_LIBDIR))
+InstallSharedLibrary(pdflib804,$(LIB_SONAME).$(CERN_LEVEL),$(CERN_SHLIBDIR))
 
 TestSubdirs(tpdf)
 
diff -urNad cernlib-2005.05.09.dfsg~/src/mclibs/photos/Imakefile cernlib-2005.05.09.dfsg/src/mclibs/photos/Imakefile
--- cernlib-2005.05.09.dfsg~/src/mclibs/photos/Imakefile	1999-03-26 10:52:23.000000000 +0000
+++ cernlib-2005.05.09.dfsg/src/mclibs/photos/Imakefile	2005-12-01 15:19:31.188783241 +0000
@@ -15,6 +15,7 @@
 SubdirLibraryTarget(photos202,code)
 
 InstallLibrary(photos202,$(CERN_LIBDIR))
+InstallSharedLibrary(photos202,$(LIB_SONAME).$(CERN_LEVEL),$(CERN_SHLIBDIR))
 
 TestSubdirs(test)
 
diff -urNad cernlib-2005.05.09.dfsg~/src/packlib/Imakefile cernlib-2005.05.09.dfsg/src/packlib/Imakefile
--- cernlib-2005.05.09.dfsg~/src/packlib/Imakefile	2005-12-01 15:19:23.885332680 +0000
+++ cernlib-2005.05.09.dfsg/src/packlib/Imakefile	2005-12-01 15:19:31.188783241 +0000
@@ -14,6 +14,7 @@
 
 InstallLibrary(packlib,$(CERN_LIBDIR))
 InstallLibraryAlias(packlib,packlib-shift,$(CERN_LIBDIR))
+InstallSharedLibrary(packlib,$(LIB_SONAME).$(CERN_LEVEL),$(CERN_SHLIBDIR))
 
 TestSubdirs($(LIBDIRS))
 
diff -urNad cernlib-2005.05.09.dfsg~/src/paw_motif/Imakefile cernlib-2005.05.09.dfsg/src/paw_motif/Imakefile
--- cernlib-2005.05.09.dfsg~/src/paw_motif/Imakefile	2005-12-01 15:19:24.192267563 +0000
+++ cernlib-2005.05.09.dfsg/src/paw_motif/Imakefile	2005-12-01 15:19:31.188783241 +0000
@@ -30,4 +30,5 @@
 SubdirLibraryTarget(pawlib-lesstif,$(LIBDIRS))
 
 InstallLibrary(pawlib-lesstif,$(CERN_LIBDIR))
+InstallSharedLibrary(pawlib-lesstif,$(LIB_SONAME).$(CERN_LEVEL),$(CERN_SHLIBDIR))
 
diff -urNad cernlib-2005.05.09.dfsg~/src/pawlib/Imakefile cernlib-2005.05.09.dfsg/src/pawlib/Imakefile
--- cernlib-2005.05.09.dfsg~/src/pawlib/Imakefile	1996-10-01 14:12:23.000000000 +0000
+++ cernlib-2005.05.09.dfsg/src/pawlib/Imakefile	2005-12-01 15:19:31.188783241 +0000
@@ -11,6 +11,7 @@
 SubdirLibraryTarget(pawlib,$(LIBDIRS))
 
 InstallLibrary(pawlib,$(CERN_LIBDIR))
+InstallSharedLibrary(pawlib,$(LIB_SONAME).$(CERN_LEVEL),$(CERN_SHLIBDIR))
 
 InstallIncludeSubdirs($(LIBDIRS))
 
diff -urNad cernlib-2005.05.09.dfsg~/src/phtools/Imakefile cernlib-2005.05.09.dfsg/src/phtools/Imakefile
--- cernlib-2005.05.09.dfsg~/src/phtools/Imakefile	1996-11-14 16:44:33.000000000 +0000
+++ cernlib-2005.05.09.dfsg/src/phtools/Imakefile	2005-12-01 15:19:31.189783029 +0000
@@ -11,7 +11,7 @@
 SubdirLibraryTarget(phtools,$(LIBDIRS))
 
 InstallLibrary(phtools,$(CERN_LIBDIR))
-InstallSharedLibrary(phtools,$(CERN_LEVEL),$(CERN_SHLIBDIR))
+InstallSharedLibrary(phtools,$(LIB_SONAME).$(CERN_LEVEL),$(CERN_SHLIBDIR))
 
 TestSubdirs(wicoexam)
 


--- NEW FILE cernlib-102-dont-optimize-some-code.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 102-dont-optimize-some-code.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Don't allow the compiler to optimize several files that cause trouble
## DP: (either compiler crash or broken code generation).

@DPATCH@
diff -urNad cernlib-2005.05.09/src/mathlib/gen/d/Imakefile /tmp/dpep.hNz5sX/cernlib-2005.05.09/src/mathlib/gen/d/Imakefile
--- cernlib-2005.05.09/src/mathlib/gen/d/Imakefile	1996-06-12 11:25:38.000000000 -0400
+++ /tmp/dpep.hNz5sX/cernlib-2005.05.09/src/mathlib/gen/d/Imakefile	2005-06-09 11:14:52.470486750 -0400
@@ -19,6 +19,11 @@
 SRCS_F:= $(SRCS_F) cgauss64.F dgquad.F dgset.F gauss64.F minfc64.F \ @@\
 	rcauch.F rdeqbs.F rdeqmr.F rderiv.F rfrdh1.F rgmlt.F rkstp64.F \ @@\
 	simps64.F triint64.F 
+#if defined(CERNLIB_LINUX)
+/* -O3 optimization breaks in g77 3.2 */
+SpecialFortranLibObjectRule(rderiv,rderiv,-O0,NullParameter)
+SpecialFortranLibObjectRule(rfrdh1,rfrdh1,-O0,NullParameter)
+#endif
 #else
 SRCS_F:= $(SRCS_F) cgauss128.F cauchy.F cauchy128.F deqbs128.F deqmr128.F \ @@\
 	deriv128.F minfc128.F rfrdh128.F rgmlt128.F rkstp128.F simps128.F \ @@\
@@ -37,6 +42,16 @@
 IMAKE_DEFINES=-DFortranDoesCpp=NO
 #endif
 
+#if defined(CERNLIB_LINUX)
+/* -O3 optimization breaks in g77 3.2 */
+SpecialFortranLibObjectRule(rknysd,rknysd,-O0,NullParameter)
+SpecialFortranLibObjectRule(old506,old506,-O0,NullParameter)
+
+/* -O1 -fno-automatic optimization creates wrong code in g77 2.95, 3.3, 3.4
+   due to x86 chip extended precision, cf. http://bugs.debian.org/290438 */
+SpecialFortranLibObjectRule(radmul,radmul,-O0,NullParameter)
+#endif
+
 FORTRANSAVEOPTION = FortranSaveFlags
 
 SubdirLibraryTarget(NullParameter,NullParameter)
diff -urNad cernlib-2005.05.09/src/mathlib/gen/e/Imakefile /tmp/dpep.hNz5sX/cernlib-2005.05.09/src/mathlib/gen/e/Imakefile
--- cernlib-2005.05.09/src/mathlib/gen/e/Imakefile	1996-05-01 09:21:54.000000000 -0400
+++ /tmp/dpep.hNz5sX/cernlib-2005.05.09/src/mathlib/gen/e/Imakefile	2005-06-09 11:16:07.058731880 -0400
@@ -12,6 +12,11 @@
 
 #if defined(CERNLIB_DOUBLE)
 SRCS_F:= $(SRCS_F) chsum.F dchebn.F rchecf.F rcspln.F
+#if defined(CERNLIB_LINUX)
+/* -O3 optimization breaks in g77 3.2 */
+SpecialFortranLibObjectRule(rchecf,rchecf,-O0,NullParameter)
+SpecialFortranLibObjectRule(rcspln,rcspln,-O0,NullParameter)
+#endif
 #else
 SRCS_F:= $(SRCS_F) chsum128.F rchebn.F rcspln128.F
 #endif
diff -urNad cernlib-2005.05.09/src/packlib/kernlib/kernnum/c204fort/Imakefile /tmp/dpep.hNz5sX/cernlib-2005.05.09/src/packlib/kernlib/kernnum/c204fort/Imakefile
--- cernlib-2005.05.09/src/packlib/kernlib/kernnum/c204fort/Imakefile	1996-06-10 06:20:57.000000000 -0400
+++ /tmp/dpep.hNz5sX/cernlib-2005.05.09/src/packlib/kernlib/kernnum/c204fort/Imakefile	2005-06-09 11:09:34.621022534 -0400
@@ -14,6 +14,11 @@
 FDEBUGFLAGS=+O1
 #endif
 
+#if defined(CERNLIB_LINUX)
+/* -O3 optimization breaks in g77 3.2 */
+SpecialFortranLibObjectRule(muller,muller,-O0,NullParameter)
+#endif
+
 FORTRANSAVEOPTION = FortranSaveFlags
 
 SubdirLibraryTarget(NullParameter,NullParameter)
diff -urNad cernlib-2005.05.09/src/packlib/kernlib/kernnum/g900fort/Imakefile /tmp/dpep.hNz5sX/cernlib-2005.05.09/src/packlib/kernlib/kernnum/g900fort/Imakefile
--- cernlib-2005.05.09/src/packlib/kernlib/kernnum/g900fort/Imakefile	1996-06-12 06:04:36.000000000 -0400
+++ /tmp/dpep.hNz5sX/cernlib-2005.05.09/src/packlib/kernlib/kernnum/g900fort/Imakefile	2005-06-09 11:10:40.068274255 -0400
@@ -4,6 +4,11 @@
 FDEBUGFLAGS=NoOpFortranDebugFlags
 #endif
 
+#if defined(CERNLIB_LINUX)
+/* -O3 optimization breaks in g77 3.2 */
+SpecialFortranLibObjectRule(ranget,ranget,-O0,NullParameter)
+#endif
+
 FORTRANSAVEOPTION=FortranSaveFlags
 
 SubdirLibraryTarget(NullParameter,NullParameter)


--- NEW FILE cernlib-103-ignore-overly-long-macro-in-gen.h.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 103-ignore-overly-long-macro-in-gen.h.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Comment out macro in cfortran/gen.h with too many arguments for cfortran
## DP: to accept.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/cfortran/gen.h /tmp/dpep.weQ8Dc/cernlib-2005.05.09/src/cfortran/gen.h
--- cernlib-2005.05.09/src/cfortran/gen.h	2000-06-23 06:13:58.000000000 -0400
+++ /tmp/dpep.weQ8Dc/cernlib-2005.05.09/src/cfortran/gen.h	2005-06-09 11:43:16.729842789 -0400
@@ -1123,10 +1123,10 @@
 
 PROTOCCALLSFSUB3(NAMEZB,namezb,FLOAT,INT,INT)
 #define NAMEZB(A1,A2,A3)  CCALLSFSUB3(NAMEZB,namezb,FLOAT,INT,INT,A1,A2,A3)
-
+/*
 PROTOCCALLSFSUB29(NEWPTQ,newptq,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,PDOUBLE,PDOUBLE,DOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PINT,PINT)
 #define NEWPTQ(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,A25,A26,A27,A28,A29)  CCALLSFSUB29(NEWPTQ,newptq,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,PDOUBLE,PDOUBLE,DOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PDOUBLE,PINT,PINT,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,A25,A26,A27,A28,A29)
-
+*/
 PROTOCCALLSFSUB9(NEWRO,newro,INT,INT,INT,FLOAT,PFLOAT,FLOATV,FLOATV,FLOATV,FLOATV)
 #define NEWRO(A1,A2,A3,A4,A5,A6,A7,A8,A9)  CCALLSFSUB9(NEWRO,newro,INT,INT,INT,FLOAT,PFLOAT,FLOATV,FLOATV,FLOATV,FLOATV,A1,A2,A3,A4,A5,A6,A7,A8,A9)
 


--- NEW FILE cernlib-104-fix-undefined-insertchar-warning.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 104-fix-undefined-insertchar-warning.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Correct Lesstif warning about undefined InsertChar.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/packlib/kuip/programs/kxterm/kuipio.c /tmp/dpep.XJ5w0K/cernlib-2005.05.09/src/packlib/kuip/programs/kxterm/kuipio.c
--- cernlib-2005.05.09/src/packlib/kuip/programs/kxterm/kuipio.c	1996-03-08 10:33:04.000000000 -0500
+++ /tmp/dpep.XJ5w0K/cernlib-2005.05.09/src/packlib/kuip/programs/kxterm/kuipio.c	2005-06-09 14:36:52.509109480 -0400
@@ -573,7 +573,7 @@
                         EditMenu,
                         RES_CONVERT( XmNlabelString, "Copy" ),
                         RES_CONVERT( XmNmnemonic, "C" ),
-                        XmNaccelerator, "Ctrl<Key>InsertChar",
+                        XmNaccelerator, "Ctrl<Key>Insert",
                         RES_CONVERT( XmNacceleratorText, "Ctrl+Ins" ),
                         NULL );
         UxPutContext( copyButton, (char *) UxKuipIoContext );
@@ -585,7 +585,7 @@
                         EditMenu,
                         RES_CONVERT( XmNlabelString, "Paste" ),
                         RES_CONVERT( XmNmnemonic, "P" ),
-                        XmNaccelerator, "Shift<Key>InsertChar",
+                        XmNaccelerator, "Shift<Key>Insert",
                         RES_CONVERT( XmNacceleratorText, "Shift+Ins" ),
                         NULL );
         UxPutContext( pasteButton, (char *) UxKuipIoContext );


--- NEW FILE cernlib-105-fix-obsolete-xmfontlistcreate-warning.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 105-fix-obsolete-xmfontlistcreate-warning.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fix Lesstif warning about use of obsolete XmFontListCreate() function

@DPATCH@
diff -urNad cernlib-2005.05.09/src/packlib/kuip/code_motif/mkuip.c /tmp/dpep.kv7bf1/cernlib-2005.05.09/src/packlib/kuip/code_motif/mkuip.c
--- cernlib-2005.05.09/src/packlib/kuip/code_motif/mkuip.c	1996-10-24 08:13:41.000000000 -0400
+++ /tmp/dpep.kv7bf1/cernlib-2005.05.09/src/packlib/kuip/code_motif/mkuip.c	2005-06-09 14:39:00.831812710 -0400
@@ -776,6 +776,7 @@
  ***********************************************************************/
 static void init_data ()
 {
+  /* This function edited not to use obsolete function XmFontListCreate() */
     int k;
 
     km_charset = XmSTRING_DEFAULT_CHARSET;
@@ -792,8 +793,11 @@
        if (help_font_struct == NULL)
            printf ("%s Warning: Font loaded for HELP (%s) is NULL \n",
                    main_prompt, srec.Help_font);
-       else
-           help_font = XmFontListCreate (help_font_struct,km_charset);
+       else {
+	   XmFontListEntry entry = XmFontListEntryCreate(
+	       km_charset, XmFONT_IS_FONT, (XtPointer)help_font_struct );
+           help_font = XmFontListAppendEntry( NULL, entry );
+       }
    }
 
    /*


--- NEW FILE cernlib-106-fix-paw++-menus-in-lesstif.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 106-fix-paw++-menus-in-lesstif.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fix odd behavior of Paw++ menus when compiled against Lesstif.  The
## DP: problem is that Paw++ Motif code does some awfully weird things that
## DP: Lesstif doesn't support; cf. http://bugs.debian.org/270862 .

@DPATCH@
diff -urNad cernlib-2005.05.09/src/packlib/kuip/code_motif/mkuip.c /tmp/dpep.KorIaA/cernlib-2005.05.09/src/packlib/kuip/code_motif/mkuip.c
--- cernlib-2005.05.09/src/packlib/kuip/code_motif/mkuip.c	2005-06-09 14:41:14.451377612 -0400
+++ /tmp/dpep.KorIaA/cernlib-2005.05.09/src/packlib/kuip/code_motif/mkuip.c	2005-06-09 14:41:22.929573007 -0400
@@ -1066,7 +1066,7 @@
 {
     int narg;
     Arg arglist[2];
-    Widget id_pdm;
+    Widget id_pdm, id_pdm_shell;
     Widget PdMenu[15];
 
     /*
@@ -1076,8 +1076,19 @@
     UxKuipBrowserContext = (_UxCkuipBrowser *)UxGetContext(parent);
 
     /*  create pulldown_menu */
-    id_pdm = XmCreatePulldownMenu (browserMenu,"OptionsPdMenu",arglist,0);
-
+    id_pdm_shell = XtVaCreatePopupShell ("OptionsPdMenu_shell",
+	xmMenuShellWidgetClass, browserMenu,
+	XmNwidth, 1,
+	XmNheight, 1,
+	XmNallowShellResize, TRUE,
+	XmNoverrideRedirect, TRUE,
+	NULL );
+    id_pdm = XtVaCreateWidget( "OptionsPdMenu",
+	xmRowColumnWidgetClass,
+	id_pdm_shell,
+	XmNrowColumnType, XmMENU_PULLDOWN,
+	NULL );
+/*  id_pdm = XmCreatePulldownMenu (browserMenu,"OptionsPdMenu",arglist,0); */
 
     /* create pulldown_menu_entry "Options" */
     XtVaCreateManagedWidget( "optionsMenu",
@@ -1091,7 +1102,7 @@
 /*  create list of push_buttons and separators for menu "Option"             */
 /*  create pulldown_menu for "Raise Window" (with list of appl. shells)       */
     narg = 0;
-#if XmREVISION == 99 /* problem with REVISION 2 ! */
+#if XmVERSION > 1 || XmREVISION >= 2
     XtSetArg(arglist[narg], XmNtearOffModel, XmTEAR_OFF_ENABLED); narg++;
 #endif
     kuipControlShellM = XmCreatePulldownMenu
@@ -1312,9 +1323,7 @@
 static void create_command_menu(parent)
    Widget parent;
 {
-    Widget id_pdme, id_pdm;
-    Arg    arglist[2];
-    int    narg;
+    Widget id_pdme, id_pdm, id_pdm_shell;
 
     /*
      *   find and restore the context for Browser
@@ -1323,12 +1332,26 @@
     UxKuipBrowserContext = (_UxCkuipBrowser *)UxGetContext(parent);
 
     /* create pulldown_menu_entry "Commands" for all commands */
-    narg = 0;
+
+    id_pdm_shell = XtVaCreatePopupShell ("CommandsPdMenu_shell",
+	xmMenuShellWidgetClass, browserMenu,
+	XmNwidth, 1,
+	XmNheight, 1,
+	XmNallowShellResize, TRUE,
+	XmNoverrideRedirect, TRUE,
+	NULL );
+    
+    id_pdm = XtVaCreateWidget( "CommandsPdMenu",
+	xmRowColumnWidgetClass,
+	id_pdm_shell,
+	XmNrowColumnType, XmMENU_PULLDOWN,
 #if XmVERSION > 1 || XmREVISION >= 2
-    XtSetArg(arglist[narg], XmNtearOffModel, XmTEAR_OFF_ENABLED); narg++;
+	XmNtearOffModel, XmTEAR_OFF_ENABLED,
 #endif
-    id_pdm = XmCreatePulldownMenu
-                     (browserMenu, "CommandsPdMenu", arglist, narg);
+	NULL );
+      
+/*      XmCreatePulldownMenu
+                     (browserMenu, "CommandsPdMenu", arglist, narg); */
 
     id_pdme = XtVaCreateManagedWidget( "id_pdme",
                         xmCascadeButtonGadgetClass, browserMenu,
@@ -1927,7 +1950,7 @@
    if (kuipControlShellM != NULL) XtDestroyWidget (kuipControlShellM);
 
    narg = 0;
-#if XmREVISION == 99 /* problem with REVISION 2 ! */
+#if XmVERSION > 1 || XmREVISION >= 2
    XtSetArg(arglist[narg], XmNtearOffModel, XmTEAR_OFF_ENABLED); narg++;
 #endif
    kuipControlShellM = XmCreatePulldownMenu


--- NEW FILE cernlib-107-define-strdup-macro-safely.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 107-define-strdup-macro-safely.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: In some cases strdup() and strndup() are macros, causing a build
## DP: failure.  Ensure any such macros are undefined before redeclaring them.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/packlib/kuip/kuip/kstring.h /tmp/dpep.ieQnkg/cernlib-2005.05.09/src/packlib/kuip/kuip/kstring.h
--- cernlib-2005.05.09/src/packlib/kuip/kuip/kstring.h	1997-03-14 12:16:39.000000000 -0500
+++ /tmp/dpep.ieQnkg/cernlib-2005.05.09/src/packlib/kuip/kuip/kstring.h	2005-06-09 14:58:22.446739916 -0400
@@ -32,6 +32,9 @@
 
 extern char* strrstr( const char* str1, const char* str2 );
 
+#ifdef strdup
+# undef strdup /* otherwise the next function declaration may bomb */
+#endif
 #define strdup Strdup           /* prototype without const */
 extern char* strdup( const char* str );
 
@@ -46,6 +49,10 @@
                      const char* str4 );
 extern char* str5dup( const char* str1, const char* str2, const char* str3,
                      const char* str4, const char* str5 );
+
+#ifdef strndup
+# undef strndup /* otherwise the next function declaration may bomb */
+#endif
 extern char* strndup( const char* buf, size_t n );
 extern char* stridup( int i );
 


--- NEW FILE cernlib-110-ignore-included-lapack-rule.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 110-ignore-included-lapack-rule.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Comment out rule requiring liblapack in a subdirectory of mathlib code.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/mathlib/Imakefile /tmp/dpep.Ib8j9x/cernlib-2005.05.09/src/mathlib/Imakefile
--- cernlib-2005.05.09/src/mathlib/Imakefile	1999-11-09 12:07:49.000000000 -0500
+++ /tmp/dpep.Ib8j9x/cernlib-2005.05.09/src/mathlib/Imakefile	2005-06-10 11:24:47.771309475 -0400
@@ -5,9 +5,12 @@
 
 LIBDIRS= gen bvsl
 
+/* Lapack is independent of Cernlib and should be installed as one of
+   the build dependencies.
 #ifndef WIN32
  LIBDIRS := $(LIBDIRS) lapack
 #endif
+*/
 
 SUBDIRS= $(LIBDIRS)
 


--- NEW FILE cernlib-111-fix-kuesvr-install-location.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 111-fix-kuesvr-install-location.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fix install location of kuesvr binary.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/packlib/kuip/programs/kuesvr/Imakefile /tmp/dpep.ZmakmH/cernlib-2005.05.09/src/packlib/kuip/programs/kuesvr/Imakefile
--- cernlib-2005.05.09/src/packlib/kuip/programs/kuesvr/Imakefile	1996-03-11 10:43:22.000000000 -0500
+++ /tmp/dpep.ZmakmH/cernlib-2005.05.09/src/packlib/kuip/programs/kuesvr/Imakefile	2005-06-10 12:03:32.706178628 -0400
@@ -1,4 +1,4 @@
 
 NormalProgramTarget(kuesvr,kuesvr.o,NullParameter,NullParameter,NullParameter)
 
-InstallProgram(kuesvr,$(CERN)/$(CERN_LEVEL)/bin)
+InstallProgram(kuesvr,$(CERN_BINDIR))


--- NEW FILE cernlib-112-remove-nonexistent-prototypes-from-gen.h.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 112-remove-nonexistent-prototypes-from-gen.h.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Remove prototypes from gen.h of functions that don't exist in mathlib.
## DP: Because of the way cfortran works, their existence otherwise causes
## DP: linking failures in third-party code.

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/cfortran/gen.h cernlib-2005.05.09.dfsg/src/cfortran/gen.h
--- cernlib-2005.05.09.dfsg~/src/cfortran/gen.h	2006-05-16 10:35:41.400252625 -0400
+++ cernlib-2005.05.09.dfsg/src/cfortran/gen.h	2006-05-16 10:37:14.159452693 -0400
@@ -84,10 +84,10 @@
 
 PROTOCCALLSFFUN1(FLOAT,ALGAMA,algama,FLOAT)
 #define ALGAMA(A2)  CCALLSFFUN1(ALGAMA,algama,FLOAT,A2)
-
+/*
 PROTOCCALLSFFUN1(FLOAT,QLGAMA,qlgama,FLOAT)
 #define QLGAMA(A2)  CCALLSFFUN1(QLGAMA,qlgama,FLOAT,A2)
-
+*/
 PROTOCCALLSFFUN1(DOUBLE,DLGAMA,dlgama,DOUBLE)
 #define DLGAMA(A2)  CCALLSFFUN1(DLGAMA,dlgama,DOUBLE,A2)
 
@@ -141,10 +141,10 @@
 
 PROTOCCALLSFFUN5(DOUBLE,DCAUCH,dcauch,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE)
 #define DCAUCH(A2,A3,A4,A5,A6)  CCALLSFFUN5(DCAUCH,dcauch,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,A2,A3,A4,A5,A6)
-
+/*
 PROTOCCALLSFFUN6(DOUBLE,CHEBQU,chebqu,DOUBLE,DOUBLE,DOUBLE,PDOUBLE,INT,DOUBLE)
 #define CHEBQU(A2,A3,A4,A5,A6,A7)  CCALLSFFUN6(CHEBQU,chebqu,DOUBLE,DOUBLE,DOUBLE,PDOUBLE,INT,DOUBLE,A2,A3,A4,A5,A6,A7)
-
+*/
 PROTOCCALLSFFUN2(FLOAT,CHISIN,chisin,FLOAT,INT)
 #define CHISIN(A2,A3)  CCALLSFFUN2(CHISIN,chisin,FLOAT,INT,A2,A3)
 
@@ -204,13 +204,13 @@
 
 PROTOCCALLSFFUN3(DOUBLE,DVDOT,dvdot,INT,DOUBLEV,DOUBLEV)
 #define DVDOT(A2,A3,A4)  CCALLSFFUN3(DVDOT,dvdot,INT,DOUBLEV,DOUBLEV,A2,A3,A4)
-
+/*
 PROTOCCALLSFFUN2(DOUBLE,E401BD,e401bd,DOUBLE,DOUBLE)
 #define E401BD(A2,A3)  CCALLSFFUN2(E401BD,e401bd,DOUBLE,DOUBLE,A2,A3)
 
 PROTOCCALLSFFUN2(FLOAT,ELIN1,elin1,FLOAT,FLOAT)
 #define ELIN1(A2,A3)  CCALLSFFUN2(ELIN1,elin1,FLOAT,FLOAT,A2,A3)
-
+*/
 PROTOCCALLSFFUN1(FLOAT,ERF,erf,FLOAT)
 #define ERF(A2)  CCALLSFFUN1(ERF,erf,FLOAT,A2)
 
@@ -237,13 +237,13 @@
 
 PROTOCCALLSFFUN2(FLOAT,FREARG,frearg,FLOAT,FLOAT)
 #define FREARG(A2,A3)  CCALLSFFUN2(FREARG,frearg,FLOAT,FLOAT,A2,A3)
-
+/*
 PROTOCCALLSFFUN3(FLOAT,FRED2,fred2,FLOAT,FLOAT,FLOAT)
 #define FRED2(A2,A3,A4)  CCALLSFFUN3(FRED2,fred2,FLOAT,FLOAT,FLOAT,A2,A3,A4)
 
 PROTOCCALLSFFUN1(FLOAT,FRED3,fred3,FLOAT)
 #define FRED3(A2)  CCALLSFFUN1(FRED3,fred3,FLOAT,A2)
-
+*/
 PROTOCCALLSFFUN1(FLOAT,FREQ,freq,FLOAT)
 #define FREQ(A2)  CCALLSFFUN1(FREQ,freq,FLOAT,A2)
 
@@ -270,10 +270,10 @@
 
 PROTOCCALLSFFUN1(FLOAT,GAMMA,gamma,FLOAT)
 #define GAMMA(A2)  CCALLSFFUN1(GAMMA,gamma,FLOAT,A2)
-
+/*
 PROTOCCALLSFFUN1(FLOAT,QGAMMA,qgamma,FLOAT)
 #define QGAMMA(A2)  CCALLSFFUN1(QGAMMA,qgamma,FLOAT,A2)
-
+*/
 PROTOCCALLSFFUN1(DOUBLE,DGAMMA,dgamma,DOUBLE)
 #define DGAMMA(A2)  CCALLSFFUN1(DGAMMA,dgamma,DOUBLE,A2)
 
@@ -297,16 +297,16 @@
 
 PROTOCCALLSFFUN4(FLOAT,GAUSS,gauss,ROUTINE,FLOAT,FLOAT,FLOAT)
 #define GAUSS(A2,A3,A4,A5)  CCALLSFFUN4(GAUSS,gauss,ROUTINE,FLOAT,FLOAT,FLOAT,A2,A3,A4,A5)
-
+/*
 PROTOCCALLSFFUN4(FLOAT,QGAUSS,qgauss,ROUTINE,FLOAT,FLOAT,FLOAT)
 #define QGAUSS(A2,A3,A4,A5)  CCALLSFFUN4(QGAUSS,qgauss,ROUTINE,FLOAT,FLOAT,FLOAT,A2,A3,A4,A5)
-
+*/
 PROTOCCALLSFFUN4(DOUBLE,DGAUSS,dgauss,ROUTINE,DOUBLE,DOUBLE,DOUBLE)
 #define DGAUSS(A2,A3,A4,A5)  CCALLSFFUN4(DGAUSS,dgauss,ROUTINE,DOUBLE,DOUBLE,DOUBLE,A2,A3,A4,A5)
-
+/*
 PROTOCCALLSFFUN6(DOUBLE,GPINDP,gpindp,DOUBLE,DOUBLE,DOUBLE,PDOUBLE,DOUBLE,INT)
 #define GPINDP(A2,A3,A4,A5,A6,A7)  CCALLSFFUN6(GPINDP,gpindp,DOUBLE,DOUBLE,DOUBLE,PDOUBLE,DOUBLE,INT,A2,A3,A4,A5,A6,A7)
-
+*/
 PROTOCCALLSFFUN2(INT,IGET,iget,INTV,INT)
 #define IGET(A2,A3)  CCALLSFFUN2(IGET,iget,INTV,INT,A2,A3)
 
@@ -321,10 +321,10 @@
 
 PROTOCCALLSFFUN3(INT,LKKSPL,lkkspl,DOUBLE,DOUBLEV,INT)
 #define LKKSPL(A2,A3,A4)  CCALLSFFUN3(LKKSPL,lkkspl,DOUBLE,DOUBLEV,INT,A2,A3,A4)
-
+/*
 PROTOCCALLSFFUN4(INT,LOCHAR,lochar,INTV,INT,INTV,INT)
 #define LOCHAR(A2,A3,A4,A5)  CCALLSFFUN4(LOCHAR,lochar,INTV,INT,INTV,INT,A2,A3,A4,A5)
-
+*/
 PROTOCCALLSFFUN2(INT,MAXFZE,maxfze,FLOATV,INT)
 #define MAXFZE(A2,A3)  CCALLSFFUN2(MAXFZE,maxfze,FLOATV,INT,A2,A3)
 
@@ -339,10 +339,10 @@
 
 PROTOCCALLSFFUN2(INT,NDIGIT,ndigit,DOUBLE,DOUBLE)
 #define NDIGIT(A2,A3)  CCALLSFFUN2(NDIGIT,ndigit,DOUBLE,DOUBLE,A2,A3)
-
+/*
 PROTOCCALLSFFUN1(INT,NEAR1,near1,FLOAT)
 #define NEAR1(A2)  CCALLSFFUN1(NEAR1,near1,FLOAT,A2)
-
+*/
 PROTOCCALLSFFUN1(INT,NIC311,nic311,FLOAT)
 #define NIC311(A2)  CCALLSFFUN1(NIC311,nic311,FLOAT,A2)
 


--- NEW FILE cernlib-115-rsrtnt64-goto-outer-block.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 115-rsrtnt64-goto-outer-block.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Avoid weird jump assignments on g77/ia64 as well as with gfortran
## DP: to avoid breakage during linking step on Itanium.
## DP: Also, following Harald Vogt, change indicators of line continuation
## DP: from "1" -> "&" to be compatible with gfortran.

@DPATCH@
diff -urNad cernlib-2006.dfsg~/src/mathlib/gen/b/rsrtnt64.F cernlib-2006.dfsg/src/mathlib/gen/b/rsrtnt64.F
--- cernlib-2006.dfsg~/src/mathlib/gen/b/rsrtnt64.F	2006-09-15 05:34:52.000000000 -0400
+++ cernlib-2006.dfsg/src/mathlib/gen/b/rsrtnt64.F	2007-01-09 16:27:13.488797346 -0500
@@ -56,7 +56,7 @@
       IF(LLL) GO TO 9
 
       LLL=K .GE. 0 .OR. K .EQ. -1 .AND. U*V .NE. 0
-     1             .OR. K .LE. -2 .AND. U*V .GT. 0
+     &             .OR. K .LE. -2 .AND. U*V .GT. 0
       IF(.NOT.LLL) GO TO 9
 
       DELTA=4*A*C-B**2
@@ -120,7 +120,7 @@
         ENDIF
        ELSE
         IF(N .EQ. 1) THEN
-#if !defined(CERNLIB_GFORTRAN)
+#if (!defined(CERNLIB_GFORTRAN)) && !defined(__ia64__)
          ASSIGN 11 TO JMP1
          GO TO 10
 #else
@@ -141,7 +141,7 @@
           G2=A*C
           H3=G1-16*G2
           H=(((H1*V-H2)*V+H3)*RT(V)-((H1*U-H2)*U+H3)*RT(U)-
-     1       (HF*G1-18*G2)*B*H)/(24*C**3)
+     &       (HF*G1-18*G2)*B*H)/(24*C**3)
          ENDIF
         ELSE
          IF(DELTA .EQ. 0) THEN
@@ -181,7 +181,7 @@
            H=2*((H1+B*U)/RT(U)-(H1+B*V)/RT(V))/DELTA
            LB1=11
           ELSEIF(K .EQ. 2) THEN
-#if !defined(CERNLIB_GFORTRAN)
+#if (!defined(CERNLIB_GFORTRAN)) && !defined(__ia64__)
            ASSIGN 12 TO JMP1
            GO TO 10
 #else
@@ -191,7 +191,7 @@
            H2=2*A*B
            H=(((H1*U-H2)/RT(U)-(H1*V-H2)/RT(V))/DELTA+H)/C
           ELSEIF(K .EQ. 3) THEN
-#if !defined(CERNLIB_GFORTRAN)
+#if (!defined(CERNLIB_GFORTRAN)) && !defined(__ia64__)
            ASSIGN 13 TO JMP1
            GO TO 10
 #else
@@ -203,7 +203,7 @@
            H2=B*(10*G1-G2)
            H3=A*(8*G1-G2)
            H=(2*(((H1*V+H2)*V+H3)/RT(V)-((H1*U+H2)*U+H3)/RT(U))/
-     1       DELTA-3*B*H)/(2*C**2)
+     &       DELTA-3*B*H)/(2*C**2)
           ENDIF
          ENDIF
         ENDIF
@@ -232,7 +232,7 @@
         ENDIF
        ELSE
         IF(N .EQ. 1) THEN
-#if !defined(CERNLIB_GFORTRAN)
+#if (!defined(CERNLIB_GFORTRAN)) && !defined(__ia64__)
          ASSIGN 21 TO JMP2
          GO TO 20
 #else
@@ -246,7 +246,7 @@
           H1=6*B
           H2=4*A
           H=((H1*V-H2)*RT(V)/V**2-(H1*U-H2)*RT(U)/U**2+
-     1       (3*B**2-H2*C)*H)/(8*A**2)
+     &       (3*B**2-H2*C)*H)/(8*A**2)
          ENDIF
         ELSE
          IF(DELTA .EQ. 0) THEN
@@ -276,7 +276,7 @@
            IF(U. LT. -X0) H=-H
           ENDIF
          ELSE
-#if !defined(CERNLIB_GFORTRAN)
+#if (!defined(CERNLIB_GFORTRAN)) && !defined (__ia64__)
           ASSIGN 22 TO JMP2
           GO TO 20
 #else
@@ -293,7 +293,7 @@
            H2=(G1-10*G2)*B
            H3=A*DELTA
            H=(((H1*V+H2-H3/V)/RT(V)-(H1*U+H2-H3/U)/RT(U))/DELTA
-     1       -3*HF*B*H)/A**2
+     &       -3*HF*B*H)/A**2
           ELSEIF(K .EQ. -3) THEN
            G1=A*DELTA
            G2=A*C
@@ -304,19 +304,19 @@
            H3=(G4-62*G2)*G3+24*G2**2
            H4=B*C*(G4-52*G2)
            H=((((H2-H1/V)/V-H3-H4*V)/RT(V)-((H2-H1/U)/U-H3-H4*U)/RT(U))
-     1        /DELTA+HF*(G4-12*G2)*H)/(4*A**3)
+     &        /DELTA+HF*(G4-12*G2)*H)/(4*A**3)
           ENDIF
          ENDIF
         ENDIF
        ENDIF
       ENDIF
-#if !defined(CERNLIB_GFORTRAN)
+#if (!defined(CERNLIB_GFORTRAN)) && !defined(__ia64__)
       GO TO 9
 
    10 C2=2*C
       IF(DELTA .GT. 0 .OR. DELTA .LT. 0 .AND. C .GT. 0) THEN
        H=LOG(ABS((2*SQRT(C*P(V))+C2*V+B)/
-     1           (2*SQRT(C*P(U))+C2*U+B)))/SQRT(C)
+     &           (2*SQRT(C*P(U))+C2*U+B)))/SQRT(C)
       ELSEIF(DELTA .EQ. 0) THEN
        H=ABS(LOG(ABS((C2*V+B)/(C2*U+B))))/SQRT(C)
       ELSE
@@ -341,7 +341,7 @@
        A2=2*A
        IF(DELTA .GT. 0 .OR. DELTA .LT. 0 .AND. A .GT. 0) THEN
         H=LOG(ABS((-2*SQRT(A*P(V))+B*V+A2)*U/
-     1           ((-2*SQRT(A*P(U))+B*U+A2)*V)))/SQRT(A)
+     &           ((-2*SQRT(A*P(U))+B*U+A2)*V)))/SQRT(A)
        ELSEIF(DELTA .EQ. 0) THEN
         H=LOG(ABS((B*U+A2)*V/((B*V+A2)*U)))/SQRT(A)
         IF(U*V .GT. 0) H=SIGN(H,U)


--- NEW FILE cernlib-116-fix-fconc64-spaghetti-code.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 116-fix-fconc64-spaghetti-code.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Work around FTBFS on ia64 with recent binutils, apparently caused
## DP: by assignment of goto labels in this file.

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/mathlib/gen/c/fconc64.F cernlib-2005.05.09.dfsg/src/mathlib/gen/c/fconc64.F
--- cernlib-2005.05.09.dfsg~/src/mathlib/gen/c/fconc64.F	1996-04-01 10:02:04.000000000 -0500
+++ cernlib-2005.05.09.dfsg/src/mathlib/gen/c/fconc64.F	2005-12-12 12:58:23.885981128 -0500
@@ -190,15 +190,167 @@
       A=HF*((HF-FM)-TI)
       B=HF*((HF-FM)+TI)
       C=HF
-      ASSIGN 1 TO JP
-      GO TO 20
+   20 IF(LTA) THEN
+       Y=-X1
+       Y2=Y**2
+       Y3=Y*Y2
+       W(1)=A+1
+       W(2)=A+2
+       W(3)=B+1
+       W(4)=B+2
+       W(5)=C+1
+       W(6)=C*W(5)
+       W(7)=A+B
+       W(8)=A*B
+       W(9)=(W(8)/C)*Y
+       W(10)=W(1)*W(3)
+       W(11)=W(2)*W(4)
+       W(12)=1+(W(11)/(W(5)+W(5)))*Y
+       W(13)=W(7)-6
+       W(14)=W(7)+6
+       W(15)=2-W(8)
+       W(16)=W(15)-W(7)-W(7)
+
+       V(0)=1
+       V(1)=1+(W(10)/(C+C))*Y
+       V(2)=W(12)+(W(10)*W(11)/(12*W(6)))*Y2
+       U(0)=1
+       U(1)=V(1)-W(9)
+       U(2)=V(2)-W(9)*W(12)+(W(8)*W(10)/(W(6)+W(6)))*Y2
+
+       R=1
+       DO 21 N = 3,NMAX
+       FN=N
+       RR=R
+       H(1)=FN-1
+       H(2)=FN-2
+       H(3)=FN-3
+       H(4)=FN+FN
+       H(5)=H(4)-3
+       H(6)=H(5)+H(5)
+       H(7)=4*(H(4)-1)*H(5)
+       H(8)=8*H(5)**2*(H(4)-5)
+       H(9)=3*FN**2
+       W(1)=A+H(1)
+       W(2)=A+H(2)
+       W(3)=B+H(1)
+       W(4)=B+H(2)
+       W(5)=C+H(1)
+       W(6)=C+H(2)
+       W(7)=C+H(3)
+       W(8)=H(2)-A
+       W(9)=H(2)-B
+       W(10)=H(1)-C
+       W(11)=W(1)*W(3)
+       W(12)=W(5)*W(6)
+
+       W(17)=1+((H(9)+W(13)*FN+W(16))/(H(6)*W(5)))*Y
+       W(18)=-((W(11)*W(10)/H(6)+(H(9)-W(14)*FN+W(15))*W(11)*Y/H(7))/
+     1          W(12))*Y
+       W(19)=(W(2)*W(11)*W(4)*W(8)*W(9)/(H(8)*W(7)*W(12)))*Y3
+       V(3)=W(17)*V(2)+W(18)*V(1)+W(19)*V(0)
+       U(3)=W(17)*U(2)+W(18)*U(1)+W(19)*U(0)
+       R=U(3)/V(3)
+       IF(ABS(R-RR) .LT. EPS) GO TO 1
+       DO 22 J = 1,3
+       V(J-1)=V(J)
+   22  U(J-1)=U(J)
+   21  CONTINUE
+      ELSE
+       W(1)=X1*A*B/C
+       R=1+W(1)
+       DO 23 N = 1,NMAX
+       FN=N
+       RR=R
+       W(1)=W(1)*X1*(A+FN)*(B+FN)/((C+FN)*(FN+1))
+       R=R+W(1)
+       IF(ABS(R-RR) .LT. EPS) GO TO 1
+   23  CONTINUE
+      END IF
+      GO TO 24
     1 R1=R
       R1=R1/ABS(CGM(A+HF))**2
       A=HF*((TH-FM)-TI)
       B=HF*((TH-FM)+TI)
       C=TH
-      ASSIGN 2 TO JP
-      GO TO 20
+  120 IF(LTA) THEN
+       Y=-X1
+       Y2=Y**2
+       Y3=Y*Y2
+       W(1)=A+1
+       W(2)=A+2
+       W(3)=B+1
+       W(4)=B+2
+       W(5)=C+1
+       W(6)=C*W(5)
+       W(7)=A+B
+       W(8)=A*B
+       W(9)=(W(8)/C)*Y
+       W(10)=W(1)*W(3)
+       W(11)=W(2)*W(4)
+       W(12)=1+(W(11)/(W(5)+W(5)))*Y
+       W(13)=W(7)-6
+       W(14)=W(7)+6
+       W(15)=2-W(8)
+       W(16)=W(15)-W(7)-W(7)
+
+       V(0)=1
+       V(1)=1+(W(10)/(C+C))*Y
+       V(2)=W(12)+(W(10)*W(11)/(12*W(6)))*Y2
+       U(0)=1
+       U(1)=V(1)-W(9)
+       U(2)=V(2)-W(9)*W(12)+(W(8)*W(10)/(W(6)+W(6)))*Y2
+
+       R=1
+       DO 121 N = 3,NMAX
+       FN=N
+       RR=R
+       H(1)=FN-1
+       H(2)=FN-2
+       H(3)=FN-3
+       H(4)=FN+FN
+       H(5)=H(4)-3
+       H(6)=H(5)+H(5)
+       H(7)=4*(H(4)-1)*H(5)
+       H(8)=8*H(5)**2*(H(4)-5)
+       H(9)=3*FN**2
+       W(1)=A+H(1)
+       W(2)=A+H(2)
+       W(3)=B+H(1)
+       W(4)=B+H(2)
+       W(5)=C+H(1)
+       W(6)=C+H(2)
+       W(7)=C+H(3)
+       W(8)=H(2)-A
+       W(9)=H(2)-B
+       W(10)=H(1)-C
+       W(11)=W(1)*W(3)
+       W(12)=W(5)*W(6)
+
+       W(17)=1+((H(9)+W(13)*FN+W(16))/(H(6)*W(5)))*Y
+       W(18)=-((W(11)*W(10)/H(6)+(H(9)-W(14)*FN+W(15))*W(11)*Y/H(7))/
+     1          W(12))*Y
+       W(19)=(W(2)*W(11)*W(4)*W(8)*W(9)/(H(8)*W(7)*W(12)))*Y3
+       V(3)=W(17)*V(2)+W(18)*V(1)+W(19)*V(0)
+       U(3)=W(17)*U(2)+W(18)*U(1)+W(19)*U(0)
+       R=U(3)/V(3)
+       IF(ABS(R-RR) .LT. EPS) GO TO 2
+       DO 122 J = 1,3
+       V(J-1)=V(J)
+  122  U(J-1)=U(J)
+  121  CONTINUE
+      ELSE
+       W(1)=X1*A*B/C
+       R=1+W(1)
+       DO 123 N = 1,NMAX
+       FN=N
+       RR=R
+       W(1)=W(1)*X1*(A+FN)*(B+FN)/((C+FN)*(FN+1))
+       R=R+W(1)
+       IF(ABS(R-RR) .LT. EPS) GO TO 2
+  123  CONTINUE
+      END IF
+      GO TO 24
     2 R2=R
       FC=RPI*(R1-2*X*R2/ABS(CGM(A-HF))**2)
       IF(LM1) FC=2*FC/SQRT(1-X1)
@@ -209,8 +361,84 @@
       A=(HF+FM)-TI
       B=(HF+FM)+TI
       C=FM+1
-      ASSIGN 3 TO JP
-      GO TO 20
+  220 IF(LTA) THEN
+       Y=-X1
+       Y2=Y**2
+       Y3=Y*Y2
+       W(1)=A+1
+       W(2)=A+2
+       W(3)=B+1
+       W(4)=B+2
+       W(5)=C+1
+       W(6)=C*W(5)
+       W(7)=A+B
+       W(8)=A*B
+       W(9)=(W(8)/C)*Y
+       W(10)=W(1)*W(3)
+       W(11)=W(2)*W(4)
+       W(12)=1+(W(11)/(W(5)+W(5)))*Y
+       W(13)=W(7)-6
+       W(14)=W(7)+6
+       W(15)=2-W(8)
+       W(16)=W(15)-W(7)-W(7)
+
+       V(0)=1
+       V(1)=1+(W(10)/(C+C))*Y
+       V(2)=W(12)+(W(10)*W(11)/(12*W(6)))*Y2
+       U(0)=1
+       U(1)=V(1)-W(9)
+       U(2)=V(2)-W(9)*W(12)+(W(8)*W(10)/(W(6)+W(6)))*Y2
+
+       R=1
+       DO 221 N = 3,NMAX
+       FN=N
+       RR=R
+       H(1)=FN-1
+       H(2)=FN-2
+       H(3)=FN-3
+       H(4)=FN+FN
+       H(5)=H(4)-3
+       H(6)=H(5)+H(5)
+       H(7)=4*(H(4)-1)*H(5)
+       H(8)=8*H(5)**2*(H(4)-5)
+       H(9)=3*FN**2
+       W(1)=A+H(1)
+       W(2)=A+H(2)
+       W(3)=B+H(1)
+       W(4)=B+H(2)
+       W(5)=C+H(1)
+       W(6)=C+H(2)
+       W(7)=C+H(3)
+       W(8)=H(2)-A
+       W(9)=H(2)-B
+       W(10)=H(1)-C
+       W(11)=W(1)*W(3)
+       W(12)=W(5)*W(6)
+
+       W(17)=1+((H(9)+W(13)*FN+W(16))/(H(6)*W(5)))*Y
+       W(18)=-((W(11)*W(10)/H(6)+(H(9)-W(14)*FN+W(15))*W(11)*Y/H(7))/
+     1          W(12))*Y
+       W(19)=(W(2)*W(11)*W(4)*W(8)*W(9)/(H(8)*W(7)*W(12)))*Y3
+       V(3)=W(17)*V(2)+W(18)*V(1)+W(19)*V(0)
+       U(3)=W(17)*U(2)+W(18)*U(1)+W(19)*U(0)
+       R=U(3)/V(3)
+       IF(ABS(R-RR) .LT. EPS) GO TO 3
+       DO 222 J = 1,3
+       V(J-1)=V(J)
+  222  U(J-1)=U(J)
+  221  CONTINUE
+      ELSE
+       W(1)=X1*A*B/C
+       R=1+W(1)
+       DO 223 N = 1,NMAX
+       FN=N
+       RR=R
+       W(1)=W(1)*X1*(A+FN)*(B+FN)/((C+FN)*(FN+1))
+       R=R+W(1)
+       IF(ABS(R-RR) .LT. EPS) GO TO 3
+  223  CONTINUE
+      END IF
+      GO TO 24
     3 FC=R
       IF(LM1) FC=SIGN(HF,1-X)*(TAU**2+HF**2)*SQRT(ABS(X**2-1))*FC
       GO TO 99
@@ -220,15 +448,7 @@
       A=HF*((HF-FM)-TI)
       B=HF*((TH-FM)-TI)
       C=1-TI
-      ASSIGN 4 TO JP
-      GO TO 20
-    4 R1=EXP((TI-HF)*LOG(X+X)+CLG(1+TI)-CLG((TH-FM)+TI))*
-     1        R*((HF-FM)+TI)/TI
-      FC=RPW*R1
-      IF(LM1) FC=FC/SQRT(1-X1)
-      GO TO 99
-
-   20 IF(LTA) THEN
+  320 IF(LTA) THEN
        Y=-X1
        Y2=Y**2
        Y3=Y*Y2
@@ -257,7 +477,7 @@
        U(2)=V(2)-W(9)*W(12)+(W(8)*W(10)/(W(6)+W(6)))*Y2
 
        R=1
-       DO 21 N = 3,NMAX
+       DO 321 N = 3,NMAX
        FN=N
        RR=R
        H(1)=FN-1
@@ -289,23 +509,29 @@
        V(3)=W(17)*V(2)+W(18)*V(1)+W(19)*V(0)
        U(3)=W(17)*U(2)+W(18)*U(1)+W(19)*U(0)
        R=U(3)/V(3)
-       IF(ABS(R-RR) .LT. EPS) GO TO JP, (1,2,3,4)
-       DO 22 J = 1,3
+       IF(ABS(R-RR) .LT. EPS) GO TO 4
+       DO 322 J = 1,3
        V(J-1)=V(J)
-   22  U(J-1)=U(J)
-   21  CONTINUE
+  322  U(J-1)=U(J)
+  321  CONTINUE
       ELSE
        W(1)=X1*A*B/C
        R=1+W(1)
-       DO 23 N = 1,NMAX
+       DO 323 N = 1,NMAX
        FN=N
        RR=R
        W(1)=W(1)*X1*(A+FN)*(B+FN)/((C+FN)*(FN+1))
        R=R+W(1)
-       IF(ABS(R-RR) .LT. EPS) GO TO JP, (1,2,3,4)
-   23  CONTINUE
+       IF(ABS(R-RR) .LT. EPS) GO TO 4
+  323  CONTINUE
       END IF
-      FC=0
+      GO TO 24
+    4 R1=EXP((TI-HF)*LOG(X+X)+CLG(1+TI)-CLG((TH-FM)+TI))*
+     1        R*((HF-FM)+TI)/TI
+      FC=RPW*R1
+      IF(LM1) FC=FC/SQRT(1-X1)
+      GO TO 99
+   24 FC=0
       WRITE(ERRTXT,102) X
       CALL MTLPRT(NAME,'C331.2',ERRTXT)
 #if defined(CERNLIB_DOUBLE)


--- NEW FILE cernlib-118-rename-mathlib-common-blocks.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 118-rename-mathlib-common-blocks.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Rename badly named common blocks to work around #374978.

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/mathlib/gen/d/d510si.inc cernlib-2005.05.09.dfsg/src/mathlib/gen/d/d510si.inc
--- cernlib-2005.05.09.dfsg~/src/mathlib/gen/d/d510si.inc	1996-04-01 10:02:21.000000000 -0500
+++ cernlib-2005.05.09.dfsg/src/mathlib/gen/d/d510si.inc	2006-06-28 10:15:11.526165542 -0400
@@ -10,4 +10,4 @@
 * d510si.inc
 *
       COMMON/D510SI/Z(2485),G(100),DA(100),ENDFLG,NA,INDFLG(5)
-      COMMON/DF/DF(100),/X/X(10)
+      COMMON/D510DF/DF(100),/D510X/X(10)


--- NEW FILE cernlib-119-fix-compiler-warnings.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 119-fix-compiler-warnings.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fix numerous minor compiler warnings.  Patch from Harald Vogt,
## DP: 2006-07-20.

@DPATCH@
diff -urNad cernlib-2005.dfsg~/src/graflib/dzdoc/dzdkern/dzdcod.F cernlib-2005.dfsg/src/graflib/dzdoc/dzdkern/dzdcod.F
--- cernlib-2005.dfsg~/src/graflib/dzdoc/dzdkern/dzdcod.F	1996-03-04 11:12:56.000000000 -0500
+++ cernlib-2005.dfsg/src/graflib/dzdoc/dzdkern/dzdcod.F	2006-09-06 19:53:39.375157506 -0400
@@ -90,7 +90,9 @@
               CALL DZDPLN(LUN,' ',99)
           ELSE
 *            do MZBOOKS
-              CALL DZDCO1(CHBANK,3,CHOINT,' ',LUN)
+*            bad Fotran convention, add dummy IFI,ILI arguments in this case
+ccc              CALL DZDCO1(CHBANK,3,CHOINT,' ',LUN)
+              CALL DZDCO1(CHBANK,3,CHOINT,' ',LUN,IFI,ILI)
 *             finish line with bookings
               CALL DZDPLN(LUN,' ',99)
           ENDIF
diff -urNad cernlib-2005.dfsg~/src/graflib/higz/higzcc/gifencode.c cernlib-2005.dfsg/src/graflib/higz/higzcc/gifencode.c
--- cernlib-2005.dfsg~/src/graflib/higz/higzcc/gifencode.c	1996-02-14 08:10:25.000000000 -0500
+++ cernlib-2005.dfsg/src/graflib/higz/higzcc/gifencode.c	2006-09-06 19:53:39.376157293 -0400
@@ -12,6 +12,7 @@
 /*-- Author :    E.Chernyaev   19/01/94*/
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #ifdef __STDC__
 #define ARGS(alist) alist
diff -urNad cernlib-2005.dfsg~/src/graflib/higz/higzcc/imgpickpalette.c cernlib-2005.dfsg/src/graflib/higz/higzcc/imgpickpalette.c
--- cernlib-2005.dfsg~/src/graflib/higz/higzcc/imgpickpalette.c	1998-11-13 08:19:53.000000000 -0500
+++ cernlib-2005.dfsg/src/graflib/higz/higzcc/imgpickpalette.c	2006-09-06 19:53:39.376157293 -0400
@@ -30,6 +30,7 @@
 #if defined(CERNLIB_GIF)
 #include <X11/Xlib.h>
 #include <stdio.h>
+#include <stdlib.h>
 
 void CollectImageColors(unsigned long, unsigned long **, int *, int *);
 int FindColor(unsigned long, unsigned long *, int);
diff -urNad cernlib-2005.dfsg~/src/graflib/higz/higzcc/rotated.c cernlib-2005.dfsg/src/graflib/higz/higzcc/rotated.c
--- cernlib-2005.dfsg~/src/graflib/higz/higzcc/rotated.c	1998-01-30 10:22:04.000000000 -0500
+++ cernlib-2005.dfsg/src/graflib/higz/higzcc/rotated.c	2006-09-06 19:53:39.377157080 -0400
@@ -35,7 +35,9 @@
 #include <X11/Xutil.h>
 #include <X11/Xatom.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <math.h>
+#include <string.h>
 
 /* ************************************************************************ *
  *
@@ -482,10 +484,10 @@
 
     /* get a rotated bitmap */
     item=XRotRetrieveFromCache(dpy, font, angle, text, align);
-    if(item==NULL) return (int)NULL;
+    if(item==NULL) return 0;
 
     /* this gc has similar properties to the user's gc */
-    my_gc=XCreateGC(dpy, drawable, NULL, 0);
+    my_gc=XCreateGC(dpy, drawable, 0, NULL);
     XCopyGC(dpy, gc, GCForeground|GCBackground|GCFunction|GCPlaneMask,
             my_gc);
 
@@ -549,7 +551,7 @@
 
         empty_stipple=XCreatePixmap(dpy, drawable, 1, 1, 1);
 
-        depth_one_gc=XCreateGC(dpy, empty_stipple, NULL, 0);
+        depth_one_gc=XCreateGC(dpy, empty_stipple, 0, NULL);
         XSetForeground(dpy, depth_one_gc, 0);
         XFillRectangle(dpy, empty_stipple, depth_one_gc, 0, 0, 2, 2);
 
@@ -605,7 +607,7 @@
                    item->cols_out, item->rows_out, 1);
 
                 /* create a GC */
-                depth_one_gc=XCreateGC(dpy, new_bitmap, NULL, 0);
+                depth_one_gc=XCreateGC(dpy, new_bitmap, 0, NULL);
                 XSetForeground(dpy, depth_one_gc, 1);
                 XSetBackground(dpy, depth_one_gc, 0);
 
@@ -705,7 +707,7 @@
     DEBUG_PRINT1("**\nHorizontal text.\n");
 
     /* this gc has similar properties to the user's gc (including stipple) */
-    my_gc=XCreateGC(dpy, drawable, NULL, 0);
+    my_gc=XCreateGC(dpy, drawable, 0, NULL);
     XCopyGC(dpy, gc,
           GCForeground|GCBackground|GCFunction|GCStipple|GCFillStyle|
           GCTileStipXOrigin|GCTileStipYOrigin|GCPlaneMask, my_gc);
@@ -918,7 +920,7 @@
                   item->cols_out, item->rows_out, 1);
 
       /* depth one gc */
-      depth_one_gc=XCreateGC(dpy, item->bitmap, NULL, 0);
+      depth_one_gc=XCreateGC(dpy, item->bitmap, 0, NULL);
       XSetBackground(dpy, depth_one_gc, 0);
       XSetForeground(dpy, depth_one_gc, 1);
 
@@ -1032,7 +1034,7 @@
              item->cols_in, item->rows_in, 1);
 
     /* create a GC for the bitmap */
-    font_gc=XCreateGC(dpy, canvas, NULL, 0);
+    font_gc=XCreateGC(dpy, canvas, 0, NULL);
     XSetBackground(dpy, font_gc, 0);
     XSetFont(dpy, font_gc, font->fid);
 
diff -urNad cernlib-2005.dfsg~/src/graflib/higz/higzcc/x11int.c cernlib-2005.dfsg/src/graflib/higz/higzcc/x11int.c
--- cernlib-2005.dfsg~/src/graflib/higz/higzcc/x11int.c	2000-07-08 02:19:30.000000000 -0400
+++ cernlib-2005.dfsg/src/graflib/higz/higzcc/x11int.c	2006-09-06 19:53:39.378156868 -0400
@@ -1172,8 +1172,8 @@
  */
       cws->drawing        = cws->window;
       cws->buffer         = (Drawable)NULL;
-      cws->double_buffer  = (int)NULL;
-      cws->clip           = (int)NULL;
+      cws->double_buffer  = 0;
+      cws->clip           = 0;
       cws->width          = wval;
       cws->height         = hval;
 
@@ -1509,7 +1509,7 @@
 void
   ixclsds()
 {
-  int Motif = (int)NULL;
+  int Motif = 0;
   int i;
 
   if (display == NULL) return;
@@ -1529,12 +1529,12 @@
   for ( i = 0; i < MAXCOL; i++ ) {
     if( colors[i].defined == 1 ) {
       colors[i].defined = 0;
-      XFreeColors(display, colormap, &colors[i].pixel, 1, (int)NULL);
+      XFreeColors(display, colormap, &colors[i].pixel, 1, 0);
     }
   }
 
 #if !defined(CERNLIB_TK_WINDOWS)
-  if(display != NULL && Motif == (int)NULL) XCloseDisplay( display );
+  if(display != NULL && Motif == 0) XCloseDisplay( display );
 #endif
   display = NULL;
   cws     = NULL;
@@ -1567,7 +1567,7 @@
 
   XFlush( display );
 
-  cws->open = (int)NULL;
+  cws->open = 0;
 
   for( wid = 0; wid < MAXWN; wid++ )
     if( windows[wid].open ) {
@@ -1886,7 +1886,7 @@
   int i;
 
   tws       = &windows[*wid];
-  tws->clip = (int)NULL;
+  tws->clip = 0;
 
   for( i = 0; i < MAXGC; i++ )
     XSetClipMask( display, gclist[i], None );
@@ -1916,9 +1916,9 @@
     xcol.flags = DoRed || DoGreen || DoBlue;
     if( colors[*cindex].defined == 1 ) {
       colors[*cindex].defined = 0;
-      XFreeColors(display, colormap, &colors[*cindex].pixel, 1, (int)NULL);
+      XFreeColors(display, colormap, &colors[*cindex].pixel, 1, 0);
     }
-    if( XAllocColor( display, colormap, &xcol ) != (Status)NULL ) {
+    if( XAllocColor( display, colormap, &xcol ) != (Status)0 ) {
       colors[*cindex].defined = 1;
       colors[*cindex].pixel   = xcol.pixel;
       colors[*cindex].red     = *r;
diff -urNad cernlib-2005.dfsg~/src/packlib/cspack/sysreq/log.c cernlib-2005.dfsg/src/packlib/cspack/sysreq/log.c
--- cernlib-2005.dfsg~/src/packlib/cspack/sysreq/log.c	2003-09-02 08:47:16.000000000 -0400
+++ cernlib-2005.dfsg/src/packlib/cspack/sysreq/log.c	2006-09-06 19:53:39.378156868 -0400
@@ -28,6 +28,7 @@
 #include <stdio.h>              /* standard input/output definitions    */
 #if !defined(vms)
 #include <fcntl.h>              /* file control                         */
+#include <string.h>             /* string manipulation functions        */
 #else
 #include <stdlib.h>             /* general utility definitions          */
 #include <unixio.h>             /* VMS's unix-emulation I/O             */
diff -urNad cernlib-2005.dfsg~/src/packlib/cspack/sysreq/netreq.c cernlib-2005.dfsg/src/packlib/cspack/sysreq/netreq.c
--- cernlib-2005.dfsg~/src/packlib/cspack/sysreq/netreq.c	1996-03-08 10:44:25.000000000 -0500
+++ cernlib-2005.dfsg/src/packlib/cspack/sysreq/netreq.c	2006-09-06 19:53:39.379156655 -0400
@@ -25,6 +25,7 @@
 #include <netinet/in.h> /* Internet data types                          */
 #include <arpa/inet.h>  /* Arpa internet routines                       */
 #include <stdio.h>      /* Standard Input/Output                        */
+#include <string.h>     /* string manipulation functions                */
 #if defined(vms)
 #include <pwd_vms.h>
 #else
diff -urNad cernlib-2005.dfsg~/src/packlib/cspack/sysreq/serror.c cernlib-2005.dfsg/src/packlib/cspack/sysreq/serror.c
--- cernlib-2005.dfsg~/src/packlib/cspack/sysreq/serror.c	1998-08-25 08:44:52.000000000 -0400
+++ cernlib-2005.dfsg/src/packlib/cspack/sysreq/serror.c	2006-09-06 19:53:39.379156655 -0400
@@ -177,7 +177,7 @@
         else {
 #if !defined(vms)
                 if ((n>0) && (n<sys_nerr)) {
-                        return(sys_errlist[n]);
+                        return((char*)sys_errlist[n]);
                 }
                 else {
                         (void) sprintf(buf,"%s: %d\n",
diff -urNad cernlib-2005.dfsg~/src/packlib/cspack/sysreq/socket.c cernlib-2005.dfsg/src/packlib/cspack/sysreq/socket.c
--- cernlib-2005.dfsg~/src/packlib/cspack/sysreq/socket.c	1998-08-25 08:44:55.000000000 -0400
+++ cernlib-2005.dfsg/src/packlib/cspack/sysreq/socket.c	2006-09-06 19:53:39.379156655 -0400
@@ -144,7 +144,10 @@
 #include <errno.h>
 #include <setjmp.h>
 #include <signal.h>
+
+#if !defined(linux)
 extern char* malloc();
+#endif /* linux */
  
 #if defined(vms)
 #if defined(TWG) && (TWG == 1)
@@ -412,7 +415,7 @@
 s_errmsg()                              /* return last error message    */
 {
 #if !defined(vms)
-        return(sys_errlist[errno]);
+        return((char*)sys_errlist[errno]);
 #else /* vms */
 #if defined(MULTINET) && (MULTINET == 1)
         return(vms_errno_string());
diff -urNad cernlib-2005.dfsg~/src/packlib/cspack/sysreq/sysreq.h cernlib-2005.dfsg/src/packlib/cspack/sysreq/sysreq.h
--- cernlib-2005.dfsg~/src/packlib/cspack/sysreq/sysreq.h	1996-03-08 10:44:26.000000000 -0500
+++ cernlib-2005.dfsg/src/packlib/cspack/sysreq/sysreq.h	2006-09-06 19:53:39.380156442 -0400
@@ -88,7 +88,7 @@
  */
  
 #ifndef VM
-extern char     *malloc();              /* Memory allocation            */
+#include <stdlib.h>                     /* standard C library defs      */
 #endif  /* VM */
 extern char     *getenv();              /* Get environment info         */
  
diff -urNad cernlib-2005.dfsg~/src/packlib/cspack/sysreq/xdr.c cernlib-2005.dfsg/src/packlib/cspack/sysreq/xdr.c
--- cernlib-2005.dfsg~/src/packlib/cspack/sysreq/xdr.c	1996-03-08 10:44:26.000000000 -0500
+++ cernlib-2005.dfsg/src/packlib/cspack/sysreq/xdr.c	2006-09-06 19:53:39.380156442 -0400
@@ -52,7 +52,7 @@
 #endif /* min */
  
 #ifndef VM
-extern char *malloc();
+#include <stdlib.h>             /* standard C library defs              */
 #endif /* VM */
  
 #ifdef VM
diff -urNad cernlib-2005.dfsg~/src/packlib/cspack/tcpaw/Imakefile cernlib-2005.dfsg/src/packlib/cspack/tcpaw/Imakefile
--- cernlib-2005.dfsg~/src/packlib/cspack/tcpaw/Imakefile	1999-01-15 08:59:12.000000000 -0500
+++ cernlib-2005.dfsg/src/packlib/cspack/tcpaw/Imakefile	2006-09-06 19:53:39.380156442 -0400
@@ -49,4 +49,9 @@
 #endif
 #endif
 
+#if defined(CERNLIB_LINUX) && defined(__GNUC__)
+  /*  This is to avoid warnings in code not used for linux */
+CCOPTIONS+=-trigraphs
+#endif
+
 SubdirLibraryTarget(NullParameter,NullParameter)
diff -urNad cernlib-2005.dfsg~/src/packlib/cspack/tcpaw/tcpaw.c cernlib-2005.dfsg/src/packlib/cspack/tcpaw/tcpaw.c
--- cernlib-2005.dfsg~/src/packlib/cspack/tcpaw/tcpaw.c	2005-04-18 11:39:28.000000000 -0400
+++ cernlib-2005.dfsg/src/packlib/cspack/tcpaw/tcpaw.c	2006-09-06 19:53:53.133231056 -0400
@@ -301,6 +301,7 @@
 #ifndef IBMRT
 /*  this is a kludge, one ought to fix the "prototypes" in this file */
 #include <string.h>
+#include <stdlib.h> /* needed for linux gcc4 */
 #endif  /* IBMRT */
 #endif /* WIN32 */
 #endif /* IBM */
@@ -478,7 +479,7 @@
 #endif /* VMS */
  
 #ifdef AUTHENT
-        unsigned char idbuf[100];
+        char idbuf[100];
         char  usbuf[20], pwbuf[20];
         char *user = usbuf, *passwd = pwbuf;
         register int i, len;
@@ -487,7 +488,7 @@
 #ifdef SOCKETS
         struct hostent *hp;             /* host info for remote host */
         struct sockaddr_in peeraddr_in; /* for peer socket address */
-        int    peerlen;
+        unsigned    peerlen;
 #endif /* SOCKETS */
 
 #ifdef WIN32
@@ -521,7 +522,7 @@
 #ifdef SOCKETS
         memset ((char *)&peeraddr_in, 0, sizeof(struct sockaddr_in));
         peerlen = sizeof(peeraddr_in);
-        if (getpeername(s, &peeraddr_in, &peerlen) == SOCKET_ERROR) {
+        if (getpeername(s, (struct sockaddr *)&peeraddr_in, &peerlen) == SOCKET_ERROR) {
 #ifdef LOGFILE
                 fprintf(logfile, "%s: getpeername failed\n", Prog_Name);
 #endif /* LOGFILE */
@@ -658,7 +659,7 @@
 SOCKET *isock, *osock;
 {
 #ifdef AUTHENT
-        unsigned char idbuf[100];
+        char idbuf[100];
         char  usbuf[20], pwbuf[20];
         char *user = usbuf, *passwd = pwbuf;
         register int i, len;
@@ -727,7 +728,7 @@
         unsigned short sport = *port;   /* VM */
 
 #if defined ( _WIN32) && defined (AUTHENT)
-        unsigned char idbuf[100];
+        char idbuf[100];
         char  usbuf[20], pwbuf[20];
         char *user = usbuf, *passwd = pwbuf;
         register int i, len;
@@ -800,7 +801,7 @@
         }
 #endif
   /* Bind the listen address to the socket. */
-        if (bind(ls, &myaddr_in, sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
+        if (bind(ls, (struct sockaddr *)&myaddr_in, sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
 #if defined(IBM) || defined(_WIN32)
             tcperror("server_sock_setup: bind(ls,...)");
 #else
@@ -829,7 +830,7 @@
                 exit(1);
         }
         addrlen = sizeof(struct sockaddr_in);
-        s = accept(ls, &peeraddr_in, &addrlen);
+        s = accept(ls, (struct sockaddr *)&peeraddr_in, (socklen_t *)&addrlen);
         if ( s == INVALID_SOCKET) {
                 fprintf(stderr, "%s: accept error\n", "server_sock_setup");
                 return(-1);
@@ -984,7 +985,7 @@
  char *user = NULL, *passwd = NULL;
  int port;
 #if defined(AUTHENT) 
-  unsigned char idbuf[100];
+  char idbuf[100];
 #endif /* AUTHENT */
  
 #ifdef VMS
@@ -1290,7 +1291,7 @@
   /* Try to connect to the remote server at the address
    * which was just built into peeraddr.
    */
-        if (connect(s, &peeraddr_in, sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
+        if (connect(s, (struct sockaddr *)&peeraddr_in, sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
 #ifndef _WIN32
             close(s);
 #else
@@ -1313,7 +1314,7 @@
         }
  
         addrlen = sizeof(struct sockaddr_in);
-        if (getsockname(s, &myaddr_in, &addrlen) == SOCKET_ERROR) {
+        if (getsockname(s, (struct sockaddr *)&myaddr_in, (socklen_t *)&addrlen) == SOCKET_ERROR) {
 #if defined(IBM) || defined(_WIN32)
             tcperror("client_sock_setup");
 #else
@@ -2688,7 +2689,7 @@
                              ((struct in_addr *)(hp->h_addr))->s_addr;
 /*              bcopy(hp->h_addr, (caddr_t)&sin.sin_addr, hp->h_length); */
         }
-        if (connect(s, &sin, sizeof(struct sockaddr_in)) == SOCKET_ERROR ) {
+        if (connect(s, (struct sockaddr *)&sin, sizeof(struct sockaddr_in)) == SOCKET_ERROR ) {
 #ifndef _WIN32
                 if (errno == ECONNREFUSED && timo <= 16) {
                         (void) close(s);
@@ -3352,7 +3353,7 @@
                              ((struct in_addr *)(hp->h_addr))->s_addr;
 /*              bcopy(hp->h_addr, (caddr_t)&sin.sin_addr, hp->h_length); */
         }
-        if (connect(s, &sin, sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
+        if (connect(s, (struct sockaddr *)&sin, sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
 #ifndef WIN32
                 if (errno == ECONNREFUSED && timo <= 16) {
                         (void) close(s);
@@ -3486,7 +3487,7 @@
 }
  
 getstr(sock,buf, cnt, errmesg)
-int     *sock;
+int     sock;
 char    *buf;
 int     cnt;              /* sizeof() the char array */
 char    *errmesg;         /* in case error message required */
diff -urNad cernlib-2005.dfsg~/src/packlib/fatmen/fmc/faexit.c cernlib-2005.dfsg/src/packlib/fatmen/fmc/faexit.c
--- cernlib-2005.dfsg~/src/packlib/fatmen/fmc/faexit.c	1997-09-02 08:56:52.000000000 -0400
+++ cernlib-2005.dfsg/src/packlib/fatmen/fmc/faexit.c	2006-09-06 19:53:39.381156230 -0400
@@ -27,6 +27,7 @@
 void faexit(icode)
 #endif
 #if defined(CERNLIB_QX_SC)
+#include <stdlib.h>                     /* standard C library defs      */
 void faexit_(icode)
 #endif
 int *icode;
diff -urNad cernlib-2005.dfsg~/src/packlib/kernlib/kerngen/ccgen/abend.c cernlib-2005.dfsg/src/packlib/kernlib/kerngen/ccgen/abend.c
--- cernlib-2005.dfsg~/src/packlib/kernlib/kerngen/ccgen/abend.c	1997-02-04 12:34:12.000000000 -0500
+++ cernlib-2005.dfsg/src/packlib/kernlib/kerngen/ccgen/abend.c	2006-09-06 19:53:39.382156017 -0400
@@ -19,6 +19,7 @@
   CERN PROGLIB# Z035    ABEND           .VERSION KERNFOR  4.31  911111
 */
 #if defined(CERNLIB_QX_SC)
+#include <stdlib.h>
 void type_of_call abend_()
 #endif
 #if defined(CERNLIB_QXNO_SC)
diff -urNad cernlib-2005.dfsg~/src/packlib/kernlib/kerngen/ccgen/ctimef.c cernlib-2005.dfsg/src/packlib/kernlib/kerngen/ccgen/ctimef.c
--- cernlib-2005.dfsg~/src/packlib/kernlib/kerngen/ccgen/ctimef.c	1997-02-04 12:34:14.000000000 -0500
+++ cernlib-2005.dfsg/src/packlib/kernlib/kerngen/ccgen/ctimef.c	2006-09-06 19:53:39.382156017 -0400
@@ -24,6 +24,8 @@
      STIME  decoded time string of length 24 (CHARACTER*24 STIME)
 */
 #if defined(CERNLIB_QX_SC)
+#include <stdlib.h>
+#include <string.h>
 void type_of_call ctimef_(clock, stime)
 #endif
 #if defined(CERNLIB_QXNO_SC)
diff -urNad cernlib-2005.dfsg~/src/packlib/kernlib/kerngen/ccgen/exitf.c cernlib-2005.dfsg/src/packlib/kernlib/kerngen/ccgen/exitf.c
--- cernlib-2005.dfsg~/src/packlib/kernlib/kerngen/ccgen/exitf.c	1997-02-04 12:34:16.000000000 -0500
+++ cernlib-2005.dfsg/src/packlib/kernlib/kerngen/ccgen/exitf.c	2006-09-06 19:53:39.382156017 -0400
@@ -19,6 +19,7 @@
   CERN PROGLIB# Z035    EXITF           .VERSION KERNFOR  4.39  940228
 */
 #if defined(CERNLIB_QX_SC)
+#include <stdlib.h>
 void type_of_call exitf_(st)
 #endif
 #if defined(CERNLIB_QXNO_SC)
diff -urNad cernlib-2005.dfsg~/src/packlib/kernlib/kerngen/ccgen/getwdi.c cernlib-2005.dfsg/src/packlib/kernlib/kerngen/ccgen/getwdi.c
--- cernlib-2005.dfsg~/src/packlib/kernlib/kerngen/ccgen/getwdi.c	1997-09-02 10:26:36.000000000 -0400
+++ cernlib-2005.dfsg/src/packlib/kernlib/kerngen/ccgen/getwdi.c	2006-09-06 19:53:39.382156017 -0400
@@ -29,6 +29,7 @@
       ISLATE(1) returns its lenth NTEXT
 */
 #include <stdio.h>
+#include <stdlib.h>
 #ifdef WIN32
 #include <direct.h>
 # ifndef getcwd
@@ -58,7 +59,7 @@
 #endif
       int  *lgname;
 {
-      char *malloc();
+/*    char *malloc();  - see above "#include <stdlib.h>"  */
       char *ptalc, *pttext;
       int  fchput();
       int  nalc;
diff -urNad cernlib-2005.dfsg~/src/packlib/kernlib/kerngen/ccgen/lstati.c cernlib-2005.dfsg/src/packlib/kernlib/kerngen/ccgen/lstati.c
--- cernlib-2005.dfsg~/src/packlib/kernlib/kerngen/ccgen/lstati.c	1997-02-04 12:34:35.000000000 -0500
+++ cernlib-2005.dfsg/src/packlib/kernlib/kerngen/ccgen/lstati.c	2006-09-06 19:53:39.382156017 -0400
@@ -26,6 +26,7 @@
   Fortran interface routine to lstat
 */
 #include <stdio.h>
+#include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include "kerngen/fortchar.h"
@@ -56,7 +57,7 @@
       ptname = fchtak(fname,*lgname);
       if (ptname == NULL)          goto out1;
 
-      buf = (struct stat *) malloc(sizeof (struct stat));
+      buf = malloc(sizeof (struct stat));
       if (buf == NULL)             goto out2;
 
       istat = lstat(ptname, buf);
diff -urNad cernlib-2005.dfsg~/src/packlib/kernlib/kerngen/ccgen/sigprnt.c cernlib-2005.dfsg/src/packlib/kernlib/kerngen/ccgen/sigprnt.c
--- cernlib-2005.dfsg~/src/packlib/kernlib/kerngen/ccgen/sigprnt.c	1997-02-04 12:34:42.000000000 -0500
+++ cernlib-2005.dfsg/src/packlib/kernlib/kerngen/ccgen/sigprnt.c	2006-09-06 19:53:39.383155804 -0400
@@ -34,7 +34,7 @@
 #ifndef CERNLIB_WINNT
       sigset_t   oldmask;
 
-      sigprocmask (NULL, NULL, &oldmask);
+      sigprocmask ( 0, NULL, &oldmask);
 
       printf (" blocked signals are: %x\n", oldmask);
 #else
diff -urNad cernlib-2005.dfsg~/src/packlib/kernlib/kerngen/ccgen/stati.c cernlib-2005.dfsg/src/packlib/kernlib/kerngen/ccgen/stati.c
--- cernlib-2005.dfsg~/src/packlib/kernlib/kerngen/ccgen/stati.c	1997-09-02 10:26:39.000000000 -0400
+++ cernlib-2005.dfsg/src/packlib/kernlib/kerngen/ccgen/stati.c	2006-09-06 19:53:39.383155804 -0400
@@ -26,6 +26,7 @@
   Fortran interface routine to stat
 */
 #include <stdio.h>
+#include <stdlib.h>
 #if defined(CERNLIB_QMVAX)||defined(CERNLIB_QMOS9)
 #include <types.h>
 #include <stat.h>
@@ -72,7 +73,7 @@
       if (ptname == NULL)          goto out1;
 
 #ifndef WIN32
-      buf = (struct stat *) malloc(sizeof (struct stat));
+      buf = malloc(sizeof (struct stat));
 #else
       buf = (struct _stat *) malloc(sizeof (struct _stat));
 #endif
diff -urNad cernlib-2005.dfsg~/src/packlib/kernlib/kerngen/ccgen/timel.c cernlib-2005.dfsg/src/packlib/kernlib/kerngen/ccgen/timel.c
--- cernlib-2005.dfsg~/src/packlib/kernlib/kerngen/ccgen/timel.c	1997-02-04 12:34:47.000000000 -0500
+++ cernlib-2005.dfsg/src/packlib/kernlib/kerngen/ccgen/timel.c	2006-09-06 19:53:39.383155804 -0400
@@ -30,6 +30,7 @@
 #include <sys/param.h>
 #include <sys/time.h>
 #include <sys/resource.h>
+#include <unistd.h>     /* For ia64... */
 
 #ifndef CLOCKS_PER_SEC
 #define  CLOCKS_PER_SEC CLK_TCK
diff -urNad cernlib-2005.dfsg~/src/packlib/kernlib/kerngen/ccgenu/fchtak.c cernlib-2005.dfsg/src/packlib/kernlib/kerngen/ccgenu/fchtak.c
--- cernlib-2005.dfsg~/src/packlib/kernlib/kerngen/ccgenu/fchtak.c	1996-02-15 12:49:40.000000000 -0500
+++ cernlib-2005.dfsg/src/packlib/kernlib/kerngen/ccgenu/fchtak.c	2006-09-06 19:53:39.383155804 -0400
@@ -16,6 +16,7 @@
       return the memory pointer
 */
 #include <stdio.h>
+#include <stdlib.h>
 #include "kerngen/fortchar.h"
 char *fchtak(ftext,lgtext)
 #if defined(CERNLIB_QMCRY)
@@ -26,7 +27,7 @@
 #endif
       int  lgtext;
 {
-      char *malloc();
+      /*    char *malloc();  - see above "#include <stdlib.h>"  */
       char *ptalc, *ptuse;
       char *utext;
       int  nalc;
diff -urNad cernlib-2005.dfsg~/src/packlib/kuip/code_kuip/getline.c cernlib-2005.dfsg/src/packlib/kuip/code_kuip/getline.c
--- cernlib-2005.dfsg~/src/packlib/kuip/code_kuip/getline.c	1998-08-25 08:47:32.000000000 -0400
+++ cernlib-2005.dfsg/src/packlib/kuip/code_kuip/getline.c	2006-09-06 19:53:39.384155592 -0400
@@ -585,7 +585,7 @@
 
 static void
   gl_puts(buf)
-char *buf;
+const char *buf;
 {
 /*
     int len = strlen(buf);
@@ -1351,7 +1351,7 @@
 
 static char *
   hist_save(p)
-char *p;
+const char *p;
 /* makes a copy of the string */
 {
     char *s;
diff -urNad cernlib-2005.dfsg~/src/packlib/kuip/code_motif/iconwidget.c cernlib-2005.dfsg/src/packlib/kuip/code_motif/iconwidget.c
--- cernlib-2005.dfsg~/src/packlib/kuip/code_motif/iconwidget.c	1996-03-08 10:33:10.000000000 -0500
+++ cernlib-2005.dfsg/src/packlib/kuip/code_motif/iconwidget.c	2006-09-06 19:53:39.384155592 -0400
@@ -284,7 +284,7 @@
     Boolean      in = (iw->icon.armed && really) ||
                       iw->icon.shadow_type == XmSHADOW_IN;
 
-    if ((iw->primitive.shadow_thickness) > 0 && XtIsRealized (iw)) {
+    if ((iw->primitive.shadow_thickness) > 0 && XtIsRealized ((Widget)iw)) {
         _XmDrawShadow (XtDisplay (iw), XtWindow (iw),
                        in ? iw->primitive.bottom_shadow_GC :
                             iw->primitive.top_shadow_GC,
@@ -372,7 +372,7 @@
 #endif
 
     if (iw->icon.armed)
-       DrawShadow ((Widget) iw, True);
+       DrawShadow (iw, True);
 }
 
 /************************************************************************


--- NEW FILE cernlib-120-fix-gets-usage-in-kuipc.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 120-fix-gets-usage-in-kuipc.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fix usage of gets() in kuipc.  Thanks to Harald Vogt, 2006-07-20.

@DPATCH@
diff -urNad cernlib-2005.dfsg~/src/packlib/kuip/programs/kuipc/kuipcc.c cernlib-2005.dfsg/src/packlib/kuip/programs/kuipc/kuipcc.c
--- cernlib-2005.dfsg~/src/packlib/kuip/programs/kuipc/kuipcc.c	2000-03-27 09:13:17.000000000 -0500
+++ cernlib-2005.dfsg/src/packlib/kuip/programs/kuipc/kuipcc.c	2006-09-06 18:57:58.483212039 -0400
@@ -354,10 +354,13 @@
     }
   }
   else {
+    /* avoid the usage of gets - possible buffer overrun */
     fprintf( stderr, "Enter CDF input file name: " );
-    gets( ifile );
+    fgets( ifile, sizeof ifile, stdin );
+    strcpy( strstr( ifile, "\n"), "\0");
     fprintf( stderr, "Enter definition output file name: " );
-    gets( ofile );
+    fgets( ofile, sizeof ofile, stdin );
+    strcpy( strstr( ofile, "\n"), "\0");
   }
 
   if( !explicit ) {


--- NEW FILE cernlib-121-fix-mathlib-test-case-c209m.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 121-fix-mathlib-test-case-c209m.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fix off-by-one bug in test case c209m.  Courtesy Harald Vogt.

@DPATCH@
diff -urNad cernlib-2005.dfsg~/src/mathlib/gen/tests/c209m.F cernlib-2005.dfsg/src/mathlib/gen/tests/c209m.F
--- cernlib-2005.dfsg~/src/mathlib/gen/tests/c209m.F	1996-04-01 10:01:13.000000000 -0500
+++ cernlib-2005.dfsg/src/mathlib/gen/tests/c209m.F	2006-09-06 19:05:30.359047318 -0400
@@ -16,7 +16,7 @@
 #include "gen/defc64.inc"
      +   TEST(NT,NT),A(0:NT),ROOT(NT),SUM
 C     R is the estimated radius of a circle centered at a root
-      DIMENSION    R(NT),RES(NT)
+      DIMENSION    R(NT+1),RES(NT)
       LOGICAL   INR2(NT,NT)
       PARAMETER (MAXFUN=50000)
       PARAMETER (TSTERR=5D-8)


--- NEW FILE cernlib-122-fix-cdf-file-syntax-errors.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 122-fix-cdf-file-syntax-errors.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fix some lines in CDF file descriptions that were accidentally
## DP: commented out by virtue of beginning with a '*' character.

@DPATCH@
diff -urNad cernlib-2006.dfsg.2~/src/packlib/cspack/programs/zftp/zftpcdf.cdf cernlib-2006.dfsg.2/src/packlib/cspack/programs/zftp/zftpcdf.cdf
--- cernlib-2006.dfsg.2~/src/packlib/cspack/programs/zftp/zftpcdf.cdf	1996-03-08 10:44:20.000000000 -0500
+++ cernlib-2006.dfsg.2/src/packlib/cspack/programs/zftp/zftpcdf.cdf	2007-04-21 18:56:29.000000000 -0400
@@ -388,8 +388,8 @@
 CHOPT 'CHOPT' C D=' '
 >Guidance
 Transfer all files matching the specified remote file name
-to the local system. The file name given may contain
-*, to match one or more characters, or %, to match a single
+to the local system. The file name given may contain *,
+to match one or more characters, or %, to match a single
 character.
 .
 By default the transfer is performed
@@ -397,9 +397,9 @@
 .
 e.g.
 .
-*.PAM         --> GETP
-*.CETA, *.CET --> GETB, LRECL=3600
-*.CMZ,  *.RZ  --> GETRZ
+ *.PAM         --> GETP
+ *.CETA, *.CET --> GETB, LRECL=3600
+ *.CMZ,  *.RZ  --> GETRZ
 .
 Options are passed to the appropriate transfer routine.
 >Action MGET
@@ -413,17 +413,18 @@
 CHOPT 'CHOPT' C D=' '
 >Guidance
 Transfer all files matching the specified local file name
-to the remote system. The file name given may contain
-*, to match one or more characters, or %, to match a single
+to the remote system. The file name given may contain *,
+to match one or more characters, or %, to match a single
 character.
+.
 By default the transfer is performed
 using PUTA, unless the file name has a known extension.
 .
 e.g.
 .
-*.PAM         --> GETP
-*.CETA, *.CET --> GETB, LRECL=3600
-*.CMZ,  *.RZ  --> GETRZ
+ *.PAM         --> GETP
+ *.CETA, *.CET --> GETB, LRECL=3600
+ *.CMZ,  *.RZ  --> GETRZ
 .
 e.g.
 .
diff -urNad cernlib-2006.dfsg.2~/src/packlib/fatmen/programs/fmkuip/fmcdf.cdf cernlib-2006.dfsg.2/src/packlib/fatmen/programs/fmkuip/fmcdf.cdf
--- cernlib-2006.dfsg.2~/src/packlib/fatmen/programs/fmkuip/fmcdf.cdf	1997-01-07 06:20:31.000000000 -0500
+++ cernlib-2006.dfsg.2/src/packlib/fatmen/programs/fmkuip/fmcdf.cdf	2007-04-21 18:58:52.000000000 -0400
@@ -324,8 +324,8 @@
 >Command SEARCH
 >Guidance
 Use the SEARCH command to print the generic names of files which
-match the specified criteria. Character fields may include the
-* or % wild cards.
+match the specified criteria. Character fields may include the *
+or % wild cards.
 .
 e.g. SEARCH * VID=I* # search current working directory for entries
 # with VID's beginning with I.
@@ -432,7 +432,7 @@
 If no wild-cards are present in the pathname, the characters /*
 are automatically appended. To zoom down a tree starting with
 .
-*ALLD, use ZOOM *ALLD/*
+ *ALLD, use ZOOM *ALLD/*
 .
 >MENU \FMDATA
 >Guidance


--- NEW FILE cernlib-123-extern-memmove-only-if-not-macro.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 123-extern-memmove-only-if-not-macro.dpatch by  <pertusus at free.fr>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Declare memmove() only if it is not already defined as a macro.

@DPATCH@
diff -urNad cernlib-2006.dfsg.2~/src/packlib/kuip/kuip/kstring.h cernlib-2006.dfsg.2/src/packlib/kuip/kuip/kstring.h
--- cernlib-2006.dfsg.2~/src/packlib/kuip/kuip/kstring.h	2007-04-21 19:21:26.000000000 -0400
+++ cernlib-2006.dfsg.2/src/packlib/kuip/kuip/kstring.h	2007-04-21 19:22:20.000000000 -0400
@@ -21,8 +21,10 @@
  */
 
 #ifndef WIN32
+#ifndef memmove
 extern void* memmove( void* dst, const void* src, size_t n );
 #endif
+#endif
 
 /* GF. make conform to kkern.c#if !defined(__convexc__)*/
 #ifndef HAVE_STRCASECMP


--- NEW FILE cernlib-201-update-kuip-helper-apps.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 201-update-kuip-helper-apps.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Instead of "ghostview" and "lp", call the more modern helper apps
## DP: "gv" and "lpr" from KUIP.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/packlib/kuip/code_kuip/kuinit.c /tmp/dpep.WCaWVF/cernlib-2005.05.09/src/packlib/kuip/code_kuip/kuinit.c
--- cernlib-2005.05.09/src/packlib/kuip/code_kuip/kuinit.c	2003-02-13 09:25:23.000000000 -0500
+++ /tmp/dpep.WCaWVF/cernlib-2005.05.09/src/packlib/kuip/code_kuip/kuinit.c	2005-06-09 12:34:49.057760462 -0400
@@ -249,7 +249,7 @@
     host_psviewer = getenv( "PSVIEWER" );
   if( host_psviewer == NULL ) {
 #ifdef UNIX
-    host_psviewer = "ghostview";
+    host_psviewer = "gv";
 #endif
 #ifdef vms
     host_psviewer = "VIEW/FORM=PS/INTERFACE=DECWINDOWS";
@@ -277,7 +277,7 @@
 # if defined(MSDOS) || defined(CERNLIB_WINNT)
   ku_exel( "/KUIP/SET_SHOW/HOST_PRINTER 'print $*'" );
 # else
-  ku_exel( "/KUIP/SET_SHOW/HOST_PRINTER 'lp $*'" );
+  ku_exel( "/KUIP/SET_SHOW/HOST_PRINTER 'lpr $*'" );
 # endif
 #else
   ku_exel( "/KUIP/SET_SHOW/HOST_PRINTER 'XPRINT $*'" );
diff -urNad cernlib-2005.05.09/src/packlib/kuip/code_kuip/kuipcdf.cdf /tmp/dpep.WCaWVF/cernlib-2005.05.09/src/packlib/kuip/code_kuip/kuipcdf.cdf
--- cernlib-2005.05.09/src/packlib/kuip/code_kuip/kuipcdf.cdf	1997-09-25 10:02:25.000000000 -0400
+++ /tmp/dpep.WCaWVF/cernlib-2005.05.09/src/packlib/kuip/code_kuip/kuipcdf.cdf	2005-06-09 12:35:59.499480148 -0400
@@ -925,7 +925,7 @@
 The startup value can be defined by the environment variables
 'KUIPPSVIEWER' or 'PSVIEWER'.
 .
-On Unix workstations it is by default set to 'ghostview'.
+On Unix workstations it is by default set to 'gv'.
 On VAX/VMS the default commands is 'VIEW/FORM=PS/INTERFACE=DECWINDOWS'.
 
 >Action kxhostpsviewer%C


--- NEW FILE cernlib-202-fix-includes-in-minuit-example.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 202-fix-includes-in-minuit-example.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: minuit-main example should have <> instead of "" around include files.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/cfortran/Examples/minuit-main.c /tmp/dpep.SuauEf/cernlib-2005.05.09/src/cfortran/Examples/minuit-main.c
--- cernlib-2005.05.09/src/cfortran/Examples/minuit-main.c	2001-04-18 04:56:22.000000000 -0400
+++ /tmp/dpep.SuauEf/cernlib-2005.05.09/src/cfortran/Examples/minuit-main.c	2005-06-09 13:22:59.567224997 -0400
@@ -15,8 +15,8 @@
  *          Gunter Folger <Gunter.Folger at cern.ch>
  */
 
-#include "cfortran.h"
-#include "minuit.h"
+#include <cfortran.h>
+#include <minuit.h>
 #define Ncont 20
 int main()
 {


--- NEW FILE cernlib-205-max-path-length-to-256.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 205-max-path-length-to-256.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Set max path length to 256 in Hbook.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/packlib/hbook/hbook/hcdire.inc /tmp/dpep.ceXWNa/cernlib-2005.05.09/src/packlib/hbook/hbook/hcdire.inc
--- cernlib-2005.05.09/src/packlib/hbook/hbook/hcdire.inc	2003-02-07 07:13:37.000000000 -0500
+++ /tmp/dpep.ceXWNa/cernlib-2005.05.09/src/packlib/hbook/hbook/hcdire.inc	2005-06-09 15:20:49.541661646 -0400
@@ -20,7 +20,7 @@
 *
 *CMZ :  4.20/03 28/07/93  09.33.32  by  Rene Brun
 *-- Author :
-      PARAMETER (NLPATM=100, MXFILES=50, LENHFN=128)
+      PARAMETER (NLPATM=100, MXFILES=50, LENHFN=256)
       COMMON /HCDIRN/NLCDIR,NLNDIR,NLPAT,ICDIR,NCHTOP,ICHTOP(MXFILES)
      +              ,ICHTYP(MXFILES),ICHLUN(MXFILES)
       CHARACTER*16   CHNDIR,    CHCDIR,    CHPAT    ,CHTOP


--- NEW FILE cernlib-208-fix-redundant-packlib-dependencies.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 208-fix-redundant-packlib-dependencies.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Remove some redundancy in the libraries listed to be linked against.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/graflib/dzdoc/dzedit/Imakefile /tmp/dpep.ZL6s2h/cernlib-2005.05.09/src/graflib/dzdoc/dzedit/Imakefile
--- cernlib-2005.05.09/src/graflib/dzdoc/dzedit/Imakefile	1996-05-09 10:32:43.000000000 -0400
+++ /tmp/dpep.ZL6s2h/cernlib-2005.05.09/src/graflib/dzdoc/dzedit/Imakefile	2005-06-10 11:54:49.270360036 -0400
@@ -20,7 +20,7 @@
 NeedTcpipLib
 #endif
 
-CernlibFortranProgramTarget(dzeX11,dzedit.o,$(PACKAGE_LIB),$(PACKAGE_LIB),graflib/X11 packlib)
+CernlibFortranProgramTarget(dzeX11,dzedit.o,libdzdoc.a,libdzdoc.a,graflib/X11 packlib)
 
 InstallProgram(dzeX11,$(CERN_BINDIR))
 InstallScript(dzedit,$(CERN_BINDIR))
diff -urNad cernlib-2005.05.09/src/packlib/cspack/programs/zftp/Imakefile /tmp/dpep.ZL6s2h/cernlib-2005.05.09/src/packlib/cspack/programs/zftp/Imakefile
--- cernlib-2005.05.09/src/packlib/cspack/programs/zftp/Imakefile	1996-04-16 04:09:49.000000000 -0400
+++ /tmp/dpep.ZL6s2h/cernlib-2005.05.09/src/packlib/cspack/programs/zftp/Imakefile	2005-06-10 11:55:33.872780414 -0400
@@ -14,6 +14,6 @@
 
 NeedTcpipLib
 
-CernlibFortranProgramTarget(zftp,zftp.o,$(PACKAGE_LIB),$(PACKAGE_LIB),packlib)
+CernlibFortranProgramTarget(zftp,zftp.o,libzftplib.a,libzftplib.a,packlib)
 
 InstallProgram(zftp,$(CERN_BINDIR))
diff -urNad cernlib-2005.05.09/src/packlib/cspack/programs/zs/Imakefile /tmp/dpep.ZL6s2h/cernlib-2005.05.09/src/packlib/cspack/programs/zs/Imakefile
--- cernlib-2005.05.09/src/packlib/cspack/programs/zs/Imakefile	1996-05-05 05:40:20.000000000 -0400
+++ /tmp/dpep.ZL6s2h/cernlib-2005.05.09/src/packlib/cspack/programs/zs/Imakefile	2005-06-10 11:56:23.109221943 -0400
@@ -31,10 +31,10 @@
 
 DefinePackageLibrary(zservlib)
 
-CernlibFortranProgramTarget(zserv,zs.o,$(PACKAGE_LIB),$(PACKAGE_LIB),packlib)
+CernlibFortranProgramTarget(zserv,zs.o,libzservlib.a,libzservlib.a,packlib)
 
 InstallProgram(zserv,$(CERN_BINDIR))
 
-CernlibFortranProgramTarget(pawserv,zs.o,$(PACKAGE_LIB),$(PACKAGE_LIB),packlib)
+CernlibFortranProgramTarget(pawserv,zs.o,libzservlib.a,libzservlib.a,packlib)
 
 InstallProgram(pawserv,$(CERN_BINDIR))
diff -urNad cernlib-2005.05.09/src/packlib/fatmen/programs/fmkuip/Imakefile /tmp/dpep.ZL6s2h/cernlib-2005.05.09/src/packlib/fatmen/programs/fmkuip/Imakefile
--- cernlib-2005.05.09/src/packlib/fatmen/programs/fmkuip/Imakefile	1996-11-05 04:32:29.000000000 -0500
+++ /tmp/dpep.ZL6s2h/cernlib-2005.05.09/src/packlib/fatmen/programs/fmkuip/Imakefile	2005-06-10 11:56:54.779438847 -0400
@@ -28,6 +28,6 @@
 NeedSysexe
 #endif
 
-CernlibFortranProgramTarget(fatmen,fatmen.o,$(PACKAGE_LIB),$(PACKAGE_LIB),packlib)
+CernlibFortranProgramTarget(fatmen,fatmen.o,libfmkuip.a,libfmkuip.a,packlib)
 
 InstallProgram(fatmen,$(CERN_BINDIR))
diff -urNad cernlib-2005.05.09/src/packlib/hepdb/programs/hepdb/Imakefile /tmp/dpep.ZL6s2h/cernlib-2005.05.09/src/packlib/hepdb/programs/hepdb/Imakefile
--- cernlib-2005.05.09/src/packlib/hepdb/programs/hepdb/Imakefile	1996-04-02 05:03:43.000000000 -0500
+++ /tmp/dpep.ZL6s2h/cernlib-2005.05.09/src/packlib/hepdb/programs/hepdb/Imakefile	2005-06-10 11:57:39.794807919 -0400
@@ -17,6 +17,6 @@
 SpecialFortranObjectRule(hepdb,hepdb,'-WF,-P',NullParameter)
 #endif
 
-CernlibFortranProgramTarget(hepdb,hepdb.o,$(PACKAGE_LIB),$(PACKAGE_LIB),packlib)
+CernlibFortranProgramTarget(hepdb,hepdb.o,libdbmodule.a,libdbmodule.a,packlib)
 
 InstallProgram(hepdb,$(CERN_BINDIR))
diff -urNad cernlib-2005.05.09/src/packlib/kuip/programs/kxterm/Imakefile /tmp/dpep.ZL6s2h/cernlib-2005.05.09/src/packlib/kuip/programs/kxterm/Imakefile
--- cernlib-2005.05.09/src/packlib/kuip/programs/kxterm/Imakefile	1996-04-18 12:33:08.000000000 -0400
+++ /tmp/dpep.ZL6s2h/cernlib-2005.05.09/src/packlib/kuip/programs/kxterm/Imakefile	2005-06-10 12:00:35.355791756 -0400
@@ -21,6 +21,6 @@
 #endif
 
 
-CernlibCcProgramTarget(kxterm,kxterm.o,$(PACKAGE_LIB),$(PACKAGE_LIB),$(CLIBS))
+CernlibCcProgramTarget(kxterm,kxterm.o,libkxtlib.a,libkxtlib.a,$(CLIBS))
 
 InstallProgram(kxterm,$(CERN_BINDIR))


--- NEW FILE cernlib-209-ignore-unneeded-headers-in-kmutil.c.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 209-ignore-unneeded-headers-in-kmutil.c.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Comment out header files not actually needed in kmutil.c.
## DP: (This will be helpful when we move this file elsewhere to be part of
## DP: the Lesstif-dependent library split out from packlib.)

@DPATCH@
diff -urNad cernlib-2005.05.09/src/packlib/kuip/code_motif/kmutil.c /tmp/dpep.BncUU7/cernlib-2005.05.09/src/packlib/kuip/code_motif/kmutil.c
--- cernlib-2005.05.09/src/packlib/kuip/code_motif/kmutil.c	1996-03-08 10:33:09.000000000 -0500
+++ /tmp/dpep.BncUU7/cernlib-2005.05.09/src/packlib/kuip/code_motif/kmutil.c	2005-06-10 12:06:07.198547576 -0400
@@ -20,12 +20,13 @@
 /******************************************************************************/
 
 #include "kuip/kuip.h"
+/* commented out, since this file doesn't need these includes. --Kevin McCarty
 #include "kuip/kfor.h"
 #include "kuip/kmenu.h"
 
 #include "mkutda.h"
 #include "kuip/mkutfu.h"
-
+*/
 
 /***********************************************************************
  *                                                                     *


***** Error reading new file: [Errno 2] No such file or directory: 'cernlib-211-support-amd64-and-itanium.dpatch'

--- NEW FILE cernlib-211-support-digital-alpha.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 211-support-digital-alpha.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Try to also support alpha architecture in chkloc()

@DPATCH@
diff -urNad cernlib-2005.dfsg~/src/packlib/kernlib/kerngen/ccgen/lp64gs/chkloc.c cernlib-2005.dfsg/src/packlib/kernlib/kerngen/ccgen/lp64gs/chkloc.c
--- cernlib-2005.dfsg~/src/packlib/kernlib/kerngen/ccgen/lp64gs/chkloc.c	2006-09-06 20:48:39.151588934 -0400
+++ cernlib-2005.dfsg/src/packlib/kernlib/kerngen/ccgen/lp64gs/chkloc.c	2006-09-06 20:53:30.206708584 -0400
@@ -35,13 +35,20 @@
      data segments upwards. All addresses here are expected to be in
      the data segment area.                                                   */
 
+  /* K. McCarty: On Alpha, on the other hand, I couldn't find any docs for the
+     Linux segmentation for virtual memory.  Judging by a test machine
+     (escher.debian.org), the data section starts slightly above 0x120010000.
+     On the other hand the stack grows downward from 0x120000000. */
+
    const unsigned long mask=0xffffffff00000000;
    static unsigned long limit=0x00000000ffffffff;
    unsigned long jadr=((unsigned long) iadr & mask);
-#if !defined (__ia64__)
-    if ( jadr != 0x0000000000000000) {
-#else
+#if defined (__ia64__)
     if ( jadr != 0x6000000000000000) {
+#elif defined (__alpha__)
+    if ( jadr != 0x0000000100000000) {
+#else  /* amd64 */
+    if ( jadr != 0) {
 #endif
       fprintf(stderr, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
       fprintf(stderr, "LOCB/LOCF: address %p exceeds the 32 bit address space\n", iadr);


--- NEW FILE cernlib-300-skip-duplicate-lenocc.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 300-skip-duplicate-lenocc.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Only compile one of the two "lenocc()" functions.

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/packlib/kernlib/kerngen/ccgen/Imakefile cernlib-2005.05.09.dfsg/src/packlib/kernlib/kerngen/ccgen/Imakefile
--- cernlib-2005.05.09.dfsg~/src/packlib/kernlib/kerngen/ccgen/Imakefile	2002-09-19 16:44:52.000000000 +0000
+++ cernlib-2005.05.09.dfsg/src/packlib/kernlib/kerngen/ccgen/Imakefile	2005-11-28 19:59:28.690293288 +0000
@@ -19,7 +19,9 @@
 SRCS_C += apofsz.c
 #endif
 
-#if defined(CERNLIB_WINNT)
+#if defined(CERNLIB_WINNT) || defined(CERNLIB_LINUX)
+/* Do not use lenocc.c in Linux; favor packlib/kernlib/kerngen/tcgen/lenocc.F
+ * instead.  --Kevin McCarty, for Debian */
 SRCS_C += lnblnk.c
 #endif
 
@@ -29,7 +31,7 @@
 
 #if defined(CERNLIB_DECS) || defined(CERNLIB_QMVAOS) \
  || defined(CERNLIB_HPUX) || defined(CERNLIB_IBMRT) || defined(CERNLIB_IBMRTD) \
- || defined(CERNLIB_OS9)  || defined(CERNLIB_LINUX)
+ || defined(CERNLIB_OS9)
 SRCS_C += lenocc.c lnblnk.c
 #endif
 


--- NEW FILE cernlib-303-shadow-passwords-supported.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 303-shadow-passwords-supported.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Allow Cern's server code to read from /etc/shadow.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/packlib/cspack/tcpaw/tcpaw.c /tmp/dpep.KyLyTI/cernlib-2005.05.09/src/packlib/cspack/tcpaw/tcpaw.c
--- cernlib-2005.05.09/src/packlib/cspack/tcpaw/tcpaw.c	2005-04-18 11:39:28.000000000 -0400
+++ /tmp/dpep.KyLyTI/cernlib-2005.05.09/src/packlib/cspack/tcpaw/tcpaw.c	2005-06-08 16:55:00.088372396 -0400
@@ -28,6 +28,9 @@
  *
  */
 #include "cspack/pilot.h"
+#if defined(CERNLIB_LINUX) && ! defined(CERNLIB_MACOSX)
+#define SHADOW_SUPPORT /* for Debian */
+#endif
 #if !defined(CERNLIB_IBM)||defined(CERNLIB_TCPSOCK)
 /*N.B. Must define sequence TCPLOG if a log file is required, e.g.*/
 /*#define LOGFILE "disk$dd:-ben.socks-serv.log"*/ /* VMS    */
@@ -231,7 +234,7 @@
 #endif /* OSK */
 #endif /* AUTHENT */
  
-#ifdef linux_softland
+#if defined(linux_softland) || defined(SHADOW_SUPPORT)
 #include <shadow.h>
 #endif /* linux_softland */
  
@@ -1780,10 +1783,10 @@
         union wait ret;
 #endif /* APOPWD1 */
  
-        char   *xpasswd, *crypt();
+        char   *xpasswd, *encrypted, *crypt();
         struct passwd *pw;
  
-#ifdef linux_softland
+#if defined(linux_softland) || defined(SHADOW_SUPPORT)
         struct spwd *spwd;
 #endif /* linux_softland */
  
@@ -1798,6 +1801,7 @@
                 reply("Unknown user %s.\n", user);
                 return(-2);
         }
+	encrypted = pw->pw_passwd;
  
 #ifdef linux_softland
         spwd = getspnam(user);
@@ -1805,6 +1809,29 @@
                 reply("User %s has illegal shadow password\n",user);
                 return(-2);
         }
+	encrypted = spwd->sp_pwdp;
+
+#elif defined(SHADOW_SUPPORT)
+	/* shadow passwords may not be enabled in Debian, so must check */
+	{
+		FILE *test = fopen("/etc/shadow", "r");
+		if (test) {
+			fclose(test);
+			spwd = getspnam(user);
+			if (spwd == NULL) {
+				reply("User %s has illegal shadow password\n",
+				      user);
+				return(-2);
+			}
+			encrypted = spwd->sp_pwdp;
+		}
+		else if (errno == EACCES) {
+			reply("Server has insufficient permissions to "
+			      "read /etc/shadow file\n");
+			return(-2);
+		}
+	}
+
 #endif /* linux_softland */
  
 #ifdef APOPWD1
@@ -1850,15 +1877,16 @@
 #else
  
 #ifdef linux_softland
-            xpasswd = pw_encrypt(pass,spwd->sp_pwdp);
+            xpasswd = pw_encrypt(pass, encrypted);
 #else
-            xpasswd = crypt(pass, pw->pw_passwd);
+            xpasswd = crypt(pass, encrypted);
 #endif /* linux_softland */
+
             /* The strcmp does not catch null passwords! */
-#ifdef linux_softland
-            if (spwd->sp_pwdp == '\0' || strcmp(xpasswd,spwd->sp_pwdp)) {
+#if defined(linux_softland) || defined(SHADOW_SUPPORT)
+            if (*encrypted == '\0' || strcmp(xpasswd,spwd->sp_pwdp)) {
 #else
-            if (*pw->pw_passwd == '\0' || strcmp(xpasswd,pw->pw_passwd)) {
+            if (*encrypted == '\0' || strcmp(xpasswd,pw->pw_passwd)) {
 #endif /* linux_softland */
  
 #endif /* AFS */


***** Error reading new file: [Errno 2] No such file or directory: 'cernlib-304-update-Imake-config-files.dpatch'

--- NEW FILE cernlib-308-use-canonical-cfortran-location.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 308-use-canonical-cfortran-location.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: All code compiled at Cernlib build-time should look for cfortran.h
## DP: at <cfortran/cfortran.h>.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/graflib/higz/higzcc/tkhigz.c /tmp/dpep.d3syqe/cernlib-2005.05.09/src/graflib/higz/higzcc/tkhigz.c
--- cernlib-2005.05.09/src/graflib/higz/higzcc/tkhigz.c	1996-02-14 08:10:26.000000000 -0500
+++ /tmp/dpep.d3syqe/cernlib-2005.05.09/src/graflib/higz/higzcc/tkhigz.c	2005-06-09 13:13:22.079711057 -0400
@@ -39,7 +39,7 @@
  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  */
 
-#include "higz/cfortran.h"
+#include <cfortran/cfortran.h>
 #if !defined(VMS) && !defined(_WINDOWS)
 #include "higz/tkConfig.h"
 #endif


--- NEW FILE cernlib-311-skip-duplicate-qnext.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 311-skip-duplicate-qnext.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Don't compile in redundant versions of qnext.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/packlib/kernlib/kerngen/tcgenc/Imakefile /tmp/dpep.5v33rR/cernlib-2005.05.09/src/packlib/kernlib/kerngen/tcgenc/Imakefile
--- cernlib-2005.05.09/src/packlib/kernlib/kerngen/tcgenc/Imakefile	1998-03-05 08:17:18.000000000 -0500
+++ /tmp/dpep.5v33rR/cernlib-2005.05.09/src/packlib/kernlib/kerngen/tcgenc/Imakefile	2005-06-09 14:28:05.755053006 -0400
@@ -1,5 +1,6 @@
+/* don't compile qnexte.F --Kevin*/
 SRCS_F= abend.F accessf.F exitf.F \ @@\
-	intrac.F jumpxn.F lnblnk.F locb.F locf.F qnexte.F unlinkf.F
+	intrac.F jumpxn.F lnblnk.F locb.F locf.F unlinkf.F
 
 #ifndef CERNLIB_OS9
 SRCS_F := $(SRCS_F) timed.F timel.F timex.F 
diff -urNad cernlib-2005.05.09/src/packlib/zebra/qutil/Imakefile /tmp/dpep.5v33rR/cernlib-2005.05.09/src/packlib/zebra/qutil/Imakefile
--- cernlib-2005.05.09/src/packlib/zebra/qutil/Imakefile	1996-03-06 05:47:15.000000000 -0500
+++ /tmp/dpep.5v33rR/cernlib-2005.05.09/src/packlib/zebra/qutil/Imakefile	2005-06-09 14:28:05.755053006 -0400
@@ -1,6 +1,7 @@
+/* don't compile qnext.F --Kevin*/
 SRCS_F=	 izbcd.F izbcdt.F izbcdv.F izchav.F izhnum.F lzbyt.F \ @@\
 	lzfind.F lzfval.F lzlast.F lzlong.F nzbank.F nzfind.F nzlong.F \ @@\
-	qnext.F zhtoi.F zitoh.F zkrak.F zkrakn.F znumid.F zpress.F \ @@\
+	zhtoi.F zitoh.F zkrak.F zkrakn.F znumid.F zpress.F \ @@\
 	zshunt.F zsort.F zsorth.F zsorti.F zsorv.F zsorvh.F zsorvi.F \ @@\
 	ztopsy.F
 


--- NEW FILE cernlib-313-comis-preserves-filename-case.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 313-comis-preserves-filename-case.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Have COMIS preserve filename case when interpreting FORTRAN code.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/packlib/kuip/code_kuip/kuinit.c /tmp/dpep.GROFhd/cernlib-2005.05.09/src/packlib/kuip/code_kuip/kuinit.c
--- cernlib-2005.05.09/src/packlib/kuip/code_kuip/kuinit.c	2003-02-13 09:25:23.000000000 -0500
+++ /tmp/dpep.GROFhd/cernlib-2005.05.09/src/packlib/kuip/code_kuip/kuinit.c	2005-06-09 15:24:32.751560586 -0400
@@ -200,6 +200,14 @@
   ku_exel( "/KUIP/SET_SHOW/COLUMNS -1" );
   ku_exel( "/KUIP/SET_SHOW/DOLLAR 'ON'" );
 
+#if defined(UNIX) && (defined(WINNT) || !defined(MSDOS))
+/* Correct the default behavior of converting filenames to lower-case
+ * on a case-sensitive operating system... Not that I'm bitter or anything.
+ * --Kevin McCarty, for Debian
+ */
+  ku_exel( "/KUIP/SET_SHOW/FILECASE 'KEEP'" );
+#endif
+
   host_editor = getenv( "KUIPEDITOR" );
   if( host_editor == NULL )
     host_editor = getenv( "EDITOR" );
diff -urNad cernlib-2005.05.09/src/packlib/kuip/code_kuip/kuipcdf.cdf /tmp/dpep.GROFhd/cernlib-2005.05.09/src/packlib/kuip/code_kuip/kuipcdf.cdf
--- cernlib-2005.05.09/src/packlib/kuip/code_kuip/kuipcdf.cdf	1997-09-25 10:02:25.000000000 -0400
+++ /tmp/dpep.GROFhd/cernlib-2005.05.09/src/packlib/kuip/code_kuip/kuipcdf.cdf	2005-06-09 15:23:49.276738602 -0400
@@ -1064,11 +1064,12 @@
 .
 This command has only an effect on Unix systems to select whether filenames
 are kept as entered on the command line.
-The startup value is 'CONVERT', i.e. filenames are converted to lowercase.
+The startup value is 'KEEP', i.e. filename cases are preserved.  With
+the 'CONVERT' setting, filenames are converted to lowercase.
 .
 On other systems filenames are always converted to uppercase.
 .
-The 'RESTORE' option set the conversion mode to the value effective
+The 'RESTORE' option sets the conversion mode to the value effective
 before the last FILECASE KEEP/CONVERT command.
 E.g. the sequence
      FILECASE KEEP; EDIT Read.Me; FILECASE RESTORE


--- NEW FILE cernlib-318-additional-gcc-3.4-fixes.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 318-additional-gcc-3.4-fixes.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Additional fixes for gcc 3.4, courtesy of Andreas Jochens.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/packlib/kuip/code_motif/iconwidget.c /tmp/dpep.f5SU0N/cernlib-2005.05.09/src/packlib/kuip/code_motif/iconwidget.c
--- cernlib-2005.05.09/src/packlib/kuip/code_motif/iconwidget.c	1996-03-08 10:33:10.000000000 -0500
+++ /tmp/dpep.f5SU0N/cernlib-2005.05.09/src/packlib/kuip/code_motif/iconwidget.c	2005-06-14 12:33:43.511482468 -0400
@@ -35,7 +35,7 @@
 void    _XmHighlightBorder ();
 void   _XmUnhighlightBorder ();
 #ifndef __APPLE__
-void   _XmDrawShadow ();
+/* void   _XmDrawShadow (); */
 #endif
 
 /* Motif1.1 ( except apollo, hpux has _XmPrimitive... with two args only


--- NEW FILE cernlib-319-work-around-imake-segfaults.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 319-work-around-imake-segfaults.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: If at first Imake doesn't succeed, try, try again.
## DP: (Hideous workaround for non-deterministic imake segfaults on hppa.)

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/config/Imake.rules cernlib-2005.05.09.dfsg/src/config/Imake.rules
--- cernlib-2005.05.09.dfsg~/src/config/Imake.rules	2006-01-02 10:35:09.050384887 -0500
+++ cernlib-2005.05.09.dfsg/src/config/Imake.rules	2006-01-02 10:38:18.693611381 -0500
@@ -1296,7 +1296,11 @@
 	$(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR) \		@@\
 	             -DPackageTop=$(PACKAGETOP)	\			@@\
 		     -DPackageName=$(PACKAGE_NAME) \			@@\
-		     imakeflags -f $<
+		     imakeflags -f $< || \				@@\
+		$(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR) \	@@\
+	             -DPackageTop=$(PACKAGETOP)	\			@@\
+		     -DPackageName=$(PACKAGE_NAME) \			@@\
+		     imakeflags -f $< || exit 1
 
 #endif /* BuildMakefileTarget */
 
@@ -2127,7 +2131,11 @@
 			ImakeSubCmdHelper -DTOPDIR=$$imaketop \		@@\
 			-DCURDIR=$$curdir$$i \				@@\
 			-DPackageTop=$(PACKAGETOP) \			@@\
-			-DPackageName=$(PACKAGE_NAME); \		@@\
+			-DPackageName=$(PACKAGE_NAME) || \		@@\
+			ImakeSubCmdHelper -DTOPDIR=$$imaketop \		@@\
+			-DCURDIR=$$curdir$$i \				@@\
+			-DPackageTop=$(PACKAGETOP) \			@@\
+			-DPackageName=$(PACKAGE_NAME) || exit 1; \	@@\
 		fi; \							@@\
 		$(MAKE) $(MFLAGS) Makefiles; \				@@\
 		cd $$newtop; \						@@\
@@ -2322,7 +2330,12 @@
 			-DCURDIR=$$curdir$$i \				@@\
 			-DPackageTop=$(PACKAGETOP) \			@@\
 			-DPackageName=$(PACKAGE_NAME) \			@@\
-			-f $$imakefile; \				@@\
+			-f $$imakefile || \				@@\
+			ImakeSubCmdHelper -DTOPDIR=$$imaketop \		@@\
+			-DCURDIR=$$curdir$$i \				@@\
+			-DPackageTop=$(PACKAGETOP) \			@@\
+			-DPackageName=$(PACKAGE_NAME) \			@@\
+			-f $$imakefile || exit 1; \			@@\
 		fi; \							@@\
 	fi;
 #endif


--- NEW FILE cernlib-320-support-ifort.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 320-support-ifort.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Support compilation with Intel's ifort compiler.

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/config/linux.cf cernlib-2005.05.09.dfsg/src/config/linux.cf
--- cernlib-2005.05.09.dfsg~/src/config/linux.cf	2006-07-05 14:40:47.890234094 -0400
+++ cernlib-2005.05.09.dfsg/src/config/linux.cf	2006-07-05 14:41:49.656893427 -0400
@@ -446,8 +446,8 @@
 #  define OptimisedFortranFlags  -O -mp1 -fp_port
 #  define NoOpFortranDebugFlags  -O0
 #  define DefaultFCOptions       
-#  define CernlibSystem          CernlibDefaultDefines
- 
+#  define CernlibSystem          CernlibDefaultDefines -DCERNLIB_INTELIFC
+#  define CERNLIB_INTELIFC 
 #else
 
 # ifdef HasIntelefc
diff -urNad cernlib-2005.05.09.dfsg~/src/packlib/kuip/programs/kxterm/Imakefile cernlib-2005.05.09.dfsg/src/packlib/kuip/programs/kxterm/Imakefile
--- cernlib-2005.05.09.dfsg~/src/packlib/kuip/programs/kxterm/Imakefile	2006-07-05 14:40:47.633289557 -0400
+++ cernlib-2005.05.09.dfsg/src/packlib/kuip/programs/kxterm/Imakefile	2006-07-05 14:42:42.088557013 -0400
@@ -14,6 +14,9 @@
 
 #if defined(CERNLIB_UNIX)
 CLIBS= -G Motif kernlib
+# if defined(CERNLIB_INTELIFC)
+CLIBS= $(CLIBS) -nofor_main
+# endif
 #endif
 
 #if defined(CERNLIB_VAXVMS)


--- NEW FILE cernlib-321-support-gfortran.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 321-support-gfortran.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Support compilation with gfortran.  Patch thanks to Harald Vogt

@DPATCH@
diff -urNad cernlib-2006.dfsg.2~/src/mathlib/gen/c/rteq464.F cernlib-2006.dfsg.2/src/mathlib/gen/c/rteq464.F
--- cernlib-2006.dfsg.2~/src/mathlib/gen/c/rteq464.F	1996-04-01 10:01:53.000000000 -0500
+++ cernlib-2006.dfsg.2/src/mathlib/gen/c/rteq464.F	2007-04-21 19:45:12.000000000 -0400
@@ -45,7 +45,16 @@
          MT=3
          Z(1)=SQRT(SQRT(-D))
          Z(2)=-Z(1)
+#if !defined(CERNLIB_GFORTRAN)
          Z(3)=SQRT(-Z(1)**2)
+#else
+*        Using gfortran the following sqrt yields an inconsistent result
+*        if the imaginary part is a "negative zero"
+*        gfortran is conform with the Fortran ISO 2003 standard (1.6.1)
+*        Therefore if the imaginary part is a "negative zero" 
+*        it must be replaced by a "positive zero" to be consistent
+         if (imag(-z(1)**2) .eq. 0) z(3)=SQRT(real(-z(1)**2)+i*0)
+#endif
          Z(4)=-Z(3)
         ENDIF
         DC=(-R12*D)**3
@@ -94,9 +103,21 @@
        W1=SQRT(U(K1)+I*0)
        W2=SQRT(U(K2)+I*0)
       ELSE
+#if !defined(CERNLIB_GFORTRAN)
        MT=3
        W1=SQRT(U(2)+I*U(3))
        W2=SQRT(U(2)-I*U(3))
+#else
+*      For gfortran see above
+       MT=3
+       IF (U(3) .NE. 0.)  THEN
+         W1=SQRT(U(2)+I*U(3))
+         W2=SQRT(U(2)-I*U(3))
+       ELSE
+         W1=SQRT(U(2)+I*0)
+         W2=W1
+       ENDIF
+#endif
       ENDIF
       W3=0
       IF(W1*W2 .NE. 0) W3=-Q/(8*W1*W2)
diff -urNad cernlib-2006.dfsg.2~/src/mathlib/gen/v/nranf.F cernlib-2006.dfsg.2/src/mathlib/gen/v/nranf.F
--- cernlib-2006.dfsg.2~/src/mathlib/gen/v/nranf.F	1996-04-01 10:02:54.000000000 -0500
+++ cernlib-2006.dfsg.2/src/mathlib/gen/v/nranf.F	2007-04-21 19:45:12.000000000 -0400
@@ -14,10 +14,12 @@
       VECTOR(I) = RNDM(I)
   100 CONTINUE
       RETURN
-      ENTRY NRANIN (V)
+      END
+      SUBROUTINE NRANIN (V)
       CALL RDMIN(V)
       RETURN
-      ENTRY NRANUT (V)
+      END
+      SUBROUTINE NRANUT (V)
       CALL RDMOUT(V)
       RETURN
       END
diff -urNad cernlib-2006.dfsg.2~/src/packlib/hbook/chbook/Imakefile cernlib-2006.dfsg.2/src/packlib/hbook/chbook/Imakefile
--- cernlib-2006.dfsg.2~/src/packlib/hbook/chbook/Imakefile	1999-11-15 08:25:58.000000000 -0500
+++ cernlib-2006.dfsg.2/src/packlib/hbook/chbook/Imakefile	2007-04-21 19:45:12.000000000 -0400
@@ -13,7 +13,19 @@
 #endif
 
 #if defined(CERNLIB_LINUX)
+EXTRA_DEFINES := $(EXTRA_DEFINES) -D_SVID_SOURCE
+#endif
+
+#if defined(CERNLIB_LINUX) && !defined(CERNLIB_QMLXIA64)
+EXTRA_DEFINES := $(EXTRA_DEFINES) -Df2cFortran
+#endif
+
+#if defined(CERNLIB_QMLXIA64) 
+#if defined(CERNLIB_GFORTRAN)
+EXTRA_DEFINES := $(EXTRA_DEFINES) -DgFortran
+#else
 EXTRA_DEFINES := $(EXTRA_DEFINES) -Df2cFortran
 #endif
+#endif
 
 SubdirLibraryTarget(NullParameter,NullParameter)
diff -urNad cernlib-2006.dfsg.2~/src/packlib/kernlib/kerngen/unix/gfortgs/Imakefile cernlib-2006.dfsg.2/src/packlib/kernlib/kerngen/unix/gfortgs/Imakefile
--- cernlib-2006.dfsg.2~/src/packlib/kernlib/kerngen/unix/gfortgs/Imakefile	2006-09-04 08:32:59.000000000 -0400
+++ cernlib-2006.dfsg.2/src/packlib/kernlib/kerngen/unix/gfortgs/Imakefile	2007-04-21 19:45:41.000000000 -0400
@@ -1,6 +1,6 @@
 
-SRCS_F= irndm.F qnext.F rdmin.F
+SRCS_F= irndm.F qnext.F rdmin.F getarg.F
 
-SRCS_C= lshift.c ishftr.c getarg.c
+SRCS_C= lshift.c ishftr.c /* getarg.c */
 
 SubdirLibraryTarget(NullParameter,NullParameter)
diff -urNad cernlib-2006.dfsg.2~/src/packlib/kernlib/kerngen/unix/gfortgs/getarg.F cernlib-2006.dfsg.2/src/packlib/kernlib/kerngen/unix/gfortgs/getarg.F
--- cernlib-2006.dfsg.2~/src/packlib/kernlib/kerngen/unix/gfortgs/getarg.F	1969-12-31 19:00:00.000000000 -0500
+++ cernlib-2006.dfsg.2/src/packlib/kernlib/kerngen/unix/gfortgs/getarg.F	2007-04-21 19:48:39.000000000 -0400
@@ -0,0 +1,19 @@
+*     Wrapper GETARG routine for gfortran,
+*     originally written by Harald Vogt <hvogt at ifh.de>
+*
+      SUBROUTINE GETARG (JARG, CHARG)
+*     The following stuff is required to use gfortrans inline routine GETARG
+*     It is required to avoid the calling GETARG here which conflicts
+*     to the Fortran rules
+      CHARACTER    CHARG*(*)
+      CALL MYGETARG (JARG, CHARG)
+      END
+
+      SUBROUTINE MYGETARG (JARG, CHARG)
+      CHARACTER    CHARG*(*)
+*     gfortran translates the following line to a call
+*     to its library routine _gfortran_getarg_i4
+*     therefore it will not clash in the linking step
+      CALL GETARG (JARG, CHARG)
+      END
+ 


--- NEW FILE cernlib-600-use-host.def-config-file.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 600-use-host.def-config-file.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/config/site.def cernlib-2005.05.09.dfsg/src/config/site.def
--- cernlib-2005.05.09.dfsg~/src/config/site.def	2002-04-26 10:46:04.000000000 -0400
+++ cernlib-2005.05.09.dfsg/src/config/site.def	2006-07-05 10:25:00.691451379 -0400
@@ -71,9 +71,9 @@
 
 #define HasFortran YES
 
-/*
+
 #include <host.def>
-*/
+
 
 /*
 #ifndef HasGcc2

cernlib-64test.patch:

--- NEW FILE cernlib-64test.patch ---
--- cernlib-2006/2006/src/packlib/Imakefile.64test	2007-04-22 18:31:11.000000000 +0200
+++ cernlib-2006/2006/src/packlib/Imakefile	2007-04-23 08:48:31.000000000 +0200
@@ -16,7 +16,7 @@
 InstallLibraryAlias(packlib,packlib-shift,$(CERN_LIBDIR))
 InstallSharedLibrary(packlib,$(LIB_SONAME).$(CERN_LEVEL),$(CERN_SHLIBDIR))
 
-TestSubdirs($(LIBDIRS))
+TestSubdirs(cspack epio fatmen hepdb kapack minuit)
 
 #ifdef CERNLIB_VAXVMS
 
--- cernlib-2006/2006/src/kernlib/Imakefile.64test	2007-04-22 16:53:02.000000000 +0200
+++ cernlib-2006/2006/src/kernlib/Imakefile	2007-04-22 16:53:45.000000000 +0200
@@ -18,6 +18,6 @@
 
 test::	LibraryTargetName(kernlib)
 
-TestSubdirs($(SUBDIRS))
+TestSubdirs(kernbit kerngen umon)
 
 InstallIncludeSubdirs($(LIBDIRS))


--- NEW FILE cernlib-701-patch-hbook-comis-Imakefiles.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 701-patch-hbook-comis-Imakefiles.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fix up makefiles after moving hkfill.F and hkf1q.F in the other
## DP: 701 dpatch (a shell script).

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/packlib/hbook/code/Imakefile cernlib-2005.05.09.dfsg/src/packlib/hbook/code/Imakefile
--- cernlib-2005.05.09.dfsg~/src/packlib/hbook/code/Imakefile	1997-09-02 09:09:01.000000000 -0400
+++ cernlib-2005.05.09.dfsg/src/packlib/hbook/code/Imakefile	2005-12-07 14:59:31.519940694 -0500
@@ -19,8 +19,8 @@
 	hgn.F hgnf.F hgnpar.F hgstat.F hhipar.F hhxye.F hi.F \ @@\
 	hictoi.F hid1.F hid2.F hidall.F hidopt.F hidpos.F hie.F  \ @@\
 	hif.F hij.F hije.F hijxy.F hindex.F hinprx.F hinteg.F  \ @@\
-	hipak1.F histdo.F histgo.F hix.F hkf1.F hkf1q.F hkf2.F  \ @@\
-	hkff1.F hkff2.F hkffi1.F hkfi1.F hkfil2.F hkfill.F hkfilpf.F \ @@\
+	hipak1.F histdo.F histgo.F hix.F hkf1.F         hkf2.F  \ @@\
+	hkff1.F hkff2.F hkffi1.F hkfi1.F hkfil2.F          hkfilpf.F \ @@\
 	hkind.F hknul1.F hknuli.F hlabel.F hlabeq.F hlabnb.F \ @@\
 	hlattr.F hlccmp.F hldir.F hldir1.F hldir2.F hldirt.F \ @@\
 	hlgnxt.F hlhcmp.F hlimit.F hllsq.F hlnext.F hlocat.F \ @@\


--- NEW FILE cernlib-704-patch-code_kuip-higzcc-Imakefiles.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 704-patch-code_kuip-higzcc-Imakefiles.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Patch Imakefiles after moving kuwhag.c from packlib to grafX11.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/graflib/higz/higzcc/Imakefile /tmp/dpep.IDWarm/cernlib-2005.05.09/src/graflib/higz/higzcc/Imakefile
--- cernlib-2005.05.09/src/graflib/higz/higzcc/Imakefile	1998-11-16 04:36:53.000000000 -0500
+++ /tmp/dpep.IDWarm/cernlib-2005.05.09/src/graflib/higz/higzcc/Imakefile	2005-06-13 09:45:37.637201936 -0400
@@ -1,7 +1,7 @@
 DoIncludePackage(higz)
 #include "pilot.h"
 
-SRCS_C=	igvers.c
+SRCS_C=	igvers.c kuwhag.c /* <-- moved here from packlib/kuip/code_kuip */
 
 #if defined(CERNLIB_FALCO) && !defined(CERNLIB_VAX)
 SRCS_C := $(SRCS_C) falint.c 
diff -urNad cernlib-2005.05.09/src/packlib/kuip/code_kuip/Imakefile /tmp/dpep.IDWarm/cernlib-2005.05.09/src/packlib/kuip/code_kuip/Imakefile
--- cernlib-2005.05.09/src/packlib/kuip/code_kuip/Imakefile	2005-06-13 09:44:00.536042728 -0400
+++ /tmp/dpep.IDWarm/cernlib-2005.05.09/src/packlib/kuip/code_kuip/Imakefile	2005-06-13 09:44:41.448261682 -0400
@@ -2,7 +2,7 @@
 
 SRCS_C=	getline.c kalias.c kbrow.c kedit.c kexec.c khash.c kicon.c \ @@\
 	kienbr.c kipiaf.c kkern.c kmacro.c kmath.c kmenu.c kmisc.c \ @@\
-	kmodel.c kmterm.c kuinit.c kutrue.c kuvers.c kuwhag.c	   \ @@\
+	kmodel.c kmterm.c kuinit.c kutrue.c kuvers.c         	   \ @@\
 	kuwhat.c kvect.c \ @@\
 	kmutil.c
 	/* ^^ moved here from code_motif.  --Kevin McCarty */


--- NEW FILE cernlib-800-implement-shared-library-rules-in-Imake.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 800-implement-shared-library-rules-in-Imake.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Implement macros for shared libraries on Linux in the Imake cfg files.

@DPATCH@
diff -urNad cernlib-2006.dfsg.2~/src/config/Imake.rules cernlib-2006.dfsg.2/src/config/Imake.rules
--- cernlib-2006.dfsg.2~/src/config/Imake.rules	2007-04-25 23:32:50.000000000 -0400
+++ cernlib-2006.dfsg.2/src/config/Imake.rules	2007-04-25 23:32:52.000000000 -0400
@@ -904,6 +904,8 @@
  * InstallSharedLibrary - generate rules to install the indicated sharable 
  * Library
  */
+/* Commented out because this appears to be overriding the definition
+ * in lnxLib.rules --Kevin McCarty, 16 May 2002
 #undef InstallSharedLibrary
 #ifndef InstallSharedLibrary
 #define InstallSharedLibrary(libname,rev,dest)				@@\
@@ -917,7 +919,8 @@
 	$(INSTALL) $(INSTALLFLAGS) $(INSTLIBFLAGS)  $< $@		@@\
 	RemoveFile($<)							@@\
 	$(LN) $@ $<
-#endif /* InstallSharedLibrary */
+#endif InstallSharedLibrary
+*/
 
 /*
  * InstallLinkKitLibrary - rule to install Link Kit library.
@@ -1967,6 +1970,15 @@
 #endif /* InstallSubdirs */
 
 /*
+ * InstallSharedLibSubdirs - generate rules to recursively install shared
+ * libraries.  Added by Kevin McCarty for Debian, 15 May 2002
+ */
+#ifndef InstallSharedLibSubdirs
+#define InstallSharedLibSubdirs(dirs) \
+NamedTargetSubdirs(install.shlib,dirs,"installing",DESTDIR=$(DESTDIR),install.shlib)
+#endif /* InstallSharedLibSubdirs */
+
+/*
  * InstallBinSubdirs - generate rules to recursively install programs and
  *		       scripts
  */
@@ -2354,9 +2366,12 @@
  */
 #ifndef DefinePackageLibrary
 #define DefinePackageLibrary(locallib) \
+/* commented out since these will be .so files. -Kevin */		@@\
+/*									@@\
 ifeq ($(strip $(PACKAGE_LIB)),)						@@\
 PACKAGE_LIB=$(TOP)$(PACKAGETOP)/LibraryTargetName($(PACKAGE_NAME))	@@\
 endif									@@\
+*/									@@\
 ifneq (locallib,)							@@\
 override PACKAGE_LIB:= LibraryTargetName(locallib) $(PACKAGE_LIB)	@@\
 									@@\
diff -urNad cernlib-2006.dfsg.2~/src/config/biglib.rules cernlib-2006.dfsg.2/src/config/biglib.rules
--- cernlib-2006.dfsg.2~/src/config/biglib.rules	2000-04-19 06:51:01.000000000 -0400
+++ cernlib-2006.dfsg.2/src/config/biglib.rules	2007-04-25 23:33:16.000000000 -0400
@@ -227,7 +227,7 @@
 	RanLibrary($@)
 #endif
 
-#if defined(HPArchitecture)
+#if defined(HPArchitecture) && !defined(LinuxArchitecture)
 
 #ifndef SharedLibraryTargetName
 #define SharedLibraryTargetName(name)Concat(lib,name.sl)
@@ -264,7 +264,7 @@
 	@date
 #endif
 
-#elif defined(AlphaArchitecture)
+#elif defined(AlphaArchitecture) && !defined(LinuxArchitecture)
 
 #ifndef SharedLibraryTargetName
 #define SharedLibraryTargetName(name)Concat(lib,name.so)
@@ -281,6 +281,45 @@
 	@date
 #endif
 
+#elif defined(LinuxArchitecture) /* added by Kevin McCarty
+				    for Debian, 15 May 2002 */
+#ifndef SharedLibraryTargetName
+#define SharedLibraryTargetName(name)Concat(lib,name.so.$(LIB_SONAME).$(CERN_LEVEL))
+#endif
+
+#ifndef SharedLibrarySonameName
+#define SharedLibrarySonameName(name)Concat(lib,name.so.$(LIB_SONAME)$(TOOL_SONAME))
+#endif
+
+#ifndef SharedLibraryBuild
+#define SharedLibraryBuild(libname,version)				@@\
+SharedLibraryTargetName(libname): version/objects.list			@@\
+	@echo rebuild version library $@ in $(CURRENT_DIR)		@@\
+	@$(RM) $@							@@\
+	@date								@@\
+	@$(FCLINK) -shared -Wl,-soname=SharedLibrarySonameName(libname)\ @@\
+		-o $@ `cat version/objects.list` `cernlib -v "" -dy libname\ @@\
+		| sed s/Concat(-l,libname)//g`				@@\
+	@date
+#endif
+
+#elif defined(DarwinArchitecture) /* added by Kevin McCarty
+				      for fink, 10 May 2003 */
+#ifndef SharedLibraryTargetName
+#define SharedLibraryTargetName(name)Concat(lib,name.$(LIB_SONAME).$(CERN_LEVEL).dylib)
+#endif
+
+#ifndef SharedLibraryBuild
+#define SharedLibraryBuild(libname,version)				@@\
+SharedLibraryTargetName(libname): version/objects.list			@@\
+	@echo rebuild version library $@ in $(CURRENT_DIR)		@@\
+	@$(RM) $@							@@\
+	@/usr/bin/libtool -dynamic -o $@ -compatibility_version $(LIB_SONAME) \ @@\
+		`cat version/objects.list` `cernlib -v "" -dy libname	\ @@\
+		| sed s/Concat(-l,libname)//g`				@@\
+	@date
+#endif
+
 #elif 1 
 #ifndef SharedLibraryBuild
 #define SharedLibraryBuild(libname,version)				@@\
diff -urNad cernlib-2006.dfsg.2~/src/config/lnxLib.rules cernlib-2006.dfsg.2/src/config/lnxLib.rules
--- cernlib-2006.dfsg.2~/src/config/lnxLib.rules	1995-12-20 10:26:45.000000000 -0500
+++ cernlib-2006.dfsg.2/src/config/lnxLib.rules	2007-04-25 23:33:16.000000000 -0400
@@ -43,6 +43,9 @@
 #ifndef PositionIndependentCplusplusFlags
 #define PositionIndependentCplusplusFlags -fPIC
 #endif
+#ifndef PositionIndependentFortranFlags
+#define PositionIndependentFortranFlags -fPIC
+#endif
 
 /*
  * InstallSharedLibrary - generate rules to install the shared library.
@@ -50,13 +53,20 @@
  */
 #ifndef InstallSharedLibrary
 #define	InstallSharedLibrary(libname,rev,dest)				@@\
-install:: Concat(lib,libname.so.rev) 					@@\
+.PHONY: install.shlib shlib/libname					@@\
+shlib/libname:: $(DESTDIR)dest/SharedLibraryTargetName(libname)		@@\
+									@@\
+install.shlib:: $(DESTDIR)dest/SharedLibraryTargetName(libname)		@@\
+									@@\
+$(DESTDIR)dest/SharedLibraryTargetName(libname): SharedLibraryTargetName(libname) @@\
 	MakeDir($(DESTDIR)dest)						@@\
-	$(INSTALL) $(INSTALLFLAGS) $(INSTBINFLAGS) Concat(lib,libname.so.rev) $(DESTDIR)dest @@\
-	(T=`echo Concat($(DESTDIR)dest/lib,libname.so.rev) | sed 's/\.[^\.]*$$//'`;\
-		$(RM) $$T && $(LN) Concat(lib,libname.so.rev) $$T)	@@\
+	$(INSTALL) $(INSTALLFLAGS) $(INSTLIBFLAGS) SharedLibraryTargetName(libname) $(DESTDIR)dest @@\
+	$(RM) SharedLibrarySonameName(libname) \
+		&& $(LN) SharedLibraryTargetName(libname) $(DESTDIR)dest/SharedLibrarySonameName(libname)	@@\
 	$(RM) Concat($(DESTDIR)dest/lib,libname.so)			@@\
-	$(LN) Concat(lib,libname.so.rev) Concat($(DESTDIR)dest/lib,libname.so)
+	$(LN) SharedLibraryTargetName(libname) Concat($(DESTDIR)dest/lib,libname.so) @@\
+	$(RM) $<                                                        @@\
+	$(LN) $@ $<
 #endif /* InstallSharedLibrary */
 
 /*


--- NEW FILE cernlib-801-non-optimized-rule-uses-fPIC-g.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 801-non-optimized-rule-uses-fPIC-g.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Ensure that special rules for creating non-optimized object files
## DP: use -fPIC for files that go into shared libs, and -g for all files.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/config/fortran.rules /tmp/dpep.gResDB/cernlib-2005.05.09/src/config/fortran.rules
--- cernlib-2005.05.09/src/config/fortran.rules	1997-05-30 12:25:18.000000000 -0400
+++ /tmp/dpep.gResDB/cernlib-2005.05.09/src/config/fortran.rules	2005-06-09 10:37:19.092244331 -0400
@@ -345,9 +345,9 @@
 
 #ifndef SpecialFortranLibObjectRule
 #define SpecialFortranLibObjectRule(baseobj,basedep,options,cppoptions)	@@\
-SpecialFortranArchiveObjectRule(baseobj,basedep,options,cppoptions)	@@\
-SpecialFortranSharedObjectRule(baseobj,basedep,options,cppoptions)	@@\
-SpecialFortranDebugObjectRule(baseobj,basedep,options,cppoptions)
+SpecialFortranArchiveObjectRule(baseobj,basedep,options -g,cppoptions)	    @@\
+SpecialFortranSharedObjectRule(baseobj,basedep,options -g -fPIC,cppoptions) @@\
+SpecialFortranDebugObjectRule(baseobj,basedep,options -g,cppoptions)
 #endif
 
 #ifndef SpecialFortranArchiveObjectRule


--- NEW FILE cernlib-803-link-binaries-dynamically.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 803-link-binaries-dynamically.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Link binaries dynamically against Cern libraries.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/config/fortran.rules /tmp/dpep.E9pQlc/cernlib-2005.05.09/src/config/fortran.rules
--- cernlib-2005.05.09/src/config/fortran.rules	2005-06-13 15:26:19.991403858 -0400
+++ /tmp/dpep.E9pQlc/cernlib-2005.05.09/src/config/fortran.rules	2005-06-13 15:26:23.699609849 -0400
@@ -189,13 +189,13 @@
  */
 #ifndef CernlibDependLibrary
 #define CernlibDependLibrary(cernlibs)\
-$(filter-out +%,$(filter-out -%,$(shell cernlib cernlibs)))
+$(filter-out +%,$(filter-out -%,$(shell cernlib -dy cernlibs)))
 #endif
 
 /* Helper to use cernlib command
  */
 #ifndef CernlibCmd
-#define CernlibCmd(libraries)cernlib libraries
+#define CernlibCmd(libraries)cernlib -dy libraries
 #endif
 /*
  * CernlibFortranProgramTarget - rule to link fortran program using
@@ -207,7 +207,7 @@
 ProgramTargetName(program): SetWin32ObjSuffix(objects) deplibs CernlibDependLibrary(cernlibs)	@@\
 	RemoveTargetProgram($@)						@@\
 	@echo "Linking with cern libraries"				@@\
-	@cernlib cernlibs						@@\
+	@cernlib -dy cernlibs						@@\
 	CernlibFortranLinkRule($@,$(FCLDOPTIONS),objects,locallibs $(LDLIBS),CernlibCmd(cernlibs)) @@\
 									@@\
 clean::									@@\
@@ -233,8 +233,8 @@
 ProgramTargetName(program): objects deplibs CernlibDependLibrary(cernlibs) @@\
 	RemoveTargetProgram($@)						@@\
 	@echo "Linking with cern libraries"				@@\
-	@cernlib cernlibs						@@\
-	CernlibLinkRule($@,$(LDOPTIONS),objects,locallibs $(LDLIBS),cernlib cernlibs) @@\
+	@cernlib -dy cernlibs						@@\
+	CernlibLinkRule($@,$(LDOPTIONS),objects,locallibs $(LDLIBS),cernlib -dy cernlibs) @@\
 									@@\
 clean::									@@\
 	RemoveFile(ProgramTargetName(program))				@@\
diff -urNad cernlib-2005.05.09/src/packlib/kuip/programs/kxterm/Imakefile /tmp/dpep.E9pQlc/cernlib-2005.05.09/src/packlib/kuip/programs/kxterm/Imakefile
--- cernlib-2005.05.09/src/packlib/kuip/programs/kxterm/Imakefile	2005-06-13 15:26:18.903636773 -0400
+++ /tmp/dpep.E9pQlc/cernlib-2005.05.09/src/packlib/kuip/programs/kxterm/Imakefile	2005-06-13 15:26:23.699609849 -0400
@@ -13,14 +13,14 @@
 DefinePackageLibrary(kxtlib)
 
 #if defined(CERNLIB_UNIX)
-CLIBS= -G Motif kernlib
+CLIBS= -G Motif -u Xm
 # if defined(CERNLIB_INTELIFC)
 CLIBS= $(CLIBS) -nofor_main
 # endif
 #endif
 
 #if defined(CERNLIB_VAXVMS)
-CLIBS= graflib/motif packlib kernlib
+CLIBS= -G Motif Xm
 #endif
 
 


--- NEW FILE cernlib-805-expunge-missing-mathlib-kernlib-symbols.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 805-expunge-missing-mathlib-kernlib-symbols.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Remove some unreferenced symbols from mathlib and kernlib and add
## DP: dummy symbols where needed.

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/mathlib/gen/d/Imakefile cernlib-2005.05.09.dfsg/src/mathlib/gen/d/Imakefile
--- cernlib-2005.05.09.dfsg~/src/mathlib/gen/d/Imakefile	2006-05-16 10:42:32.921420791 -0400
+++ cernlib-2005.05.09.dfsg/src/mathlib/gen/d/Imakefile	2006-05-16 10:46:11.446026937 -0400
@@ -2,7 +2,13 @@
 #include "pilot.h"
 
 /* rgmlt*.F have been moved into packlib/hbook to remove circular dependencies.
+   old506.F is removed since it is equivalent to obsolete code under
+   packlib/minuit.  dummy.c contains dummy callback functions so the code
+   can function when built as a shared library.
    --Kevin McCarty, for Debian. */
+
+SRCS_C= dummy.c
+
 SRCS_F=	arithm.F c128.F c256.F c512.F c64.F cauchy64.F cft.F cfstft.F \ @@\
 	rfstft.F cgauss.F d107d1.F d107r1.F d501l1.F d501l2.F d501n1.F \ @@\
         d501n2.F d501p1.F d501p2.F d501sf.F d700su.F d701bd.F \ @@\
@@ -11,7 +17,7 @@
         epdchn.F epdcj.F epde1.F epdecc.F epdfix.F epdin.F \ @@\
         epditr.F epdje.F epdloc.F epdsrt.F epdtab.F errorf.F esolve.F \ @@\
 	fcn1.F fftrc.F fumili.F gauss.F i128.F i32.F i64.F linsq.F \ @@\
-	mconv.F mft.F minfc.F minsq.F monito.F newro.F old506.F radapt.F \ @@\
+	mconv.F mft.F minfc.F minsq.F monito.F newro.F          radapt.F \ @@\
 	radmul.F rca.F rfrdh164.F rfrdh264.F rft.F           rgquad.F \ @@\
 	rgs56p.F rgset.F riwiad.F riwibd.F rknys64.F rknysd.F rkstp.F \ @@\
 	rpa.F rps.F rrkstp.F rsa.F rtriint.F s128.F s256.F s512.F \ @@\
diff -urNad cernlib-2005.05.09.dfsg~/src/mathlib/gen/d/dummy.c cernlib-2005.05.09.dfsg/src/mathlib/gen/d/dummy.c
--- cernlib-2005.05.09.dfsg~/src/mathlib/gen/d/dummy.c	1969-12-31 19:00:00.000000000 -0500
+++ cernlib-2005.05.09.dfsg/src/mathlib/gen/d/dummy.c	2006-05-16 11:36:09.331168663 -0400
@@ -0,0 +1,54 @@
+/* Dummy file to avoid undefined symbols in the library */
+/* Kevin McCarty, 16 May 2006 */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/* Want the dummy functions to be weakly defined so they may be overridden
+ * without error. */
+
+#define kludge(x)    #x
+#define stringify(x) kludge(x)
+#define underline(x) dummy_ ## x
+
+#define DUMMY(UPPERNAME, fortranname_, returntype, exitcode, docs) \
+static returntype underline(fortranname_)() \
+        { print_dummy(#UPPERNAME, docs, exitcode); } \
+void fortranname_() \
+	__attribute__ ((weak, alias (stringify(underline(fortranname_))) ))
+
+static void print_dummy(const char *function, const char * docs, int exitcode)
+{
+  fprintf(stderr, "mathlib: Now in dummy %s routine.\n", function);
+  fprintf(stderr,
+          "If you see this message, you %s define your own such routine.\n",
+	  exitcode ? "must" : "may wish to");
+  if (docs)
+    fprintf(stderr,
+	  "For details, the CERN writeup that can be found at\n"
+	  "%s\n"
+	  "may be helpful.\n", docs);
+  if (exitcode)
+    exit(exitcode);
+}
+
+static char d151docs[] = "http://preprints.cern.ch/cgi-bin/setlink?base=preprint&categ=cern&id=IT-ASD-D151";
+static char d300docs[] = "http://preprints.cern.ch/cgi-bin/setlink?base=preprint&categ=cern&id=IT-ASD-D300";
+static char d510docs[] = "http://wwwasdoc.web.cern.ch/wwwasdoc/shortwrupsdir/d510/top.html";
+
+/* User-defined callback functions and subroutines */
+
+/* D151: DIVONNE: multidimensional integration */
+DUMMY(DFUN, dfun_, double, EXIT_FAILURE, d151docs);
+
+/* D300: elliptic partial differential equation callbacks */
+DUMMY(GETCO, getco_, void, EXIT_FAILURE, d300docs);
+DUMMY(USER1, user1_, void, 0, d300docs);
+DUMMY(USER2, user2_, void, 0, d300docs);
+
+/* D510: fitting likelihood functions (obsolete; use MINUIT instead!) */
+DUMMY(FUNCT, funct_, double, EXIT_FAILURE, d510docs);
+
+/* No docs for MINSQ / LINSQ?  Not clear what CERN package they come from. */
+DUMMY(FCN, fcn_, void, EXIT_FAILURE, 0);
+


--- NEW FILE cernlib-806-bump-mathlib-and-dependents-sonames.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 806-bump-mathlib-and-dependents-sonames.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Bump so versions of mathlib and dependents since it is now compiled
## DP: against liblapack3 instead of liblapack2.

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/mathlib/Imakefile cernlib-2005.05.09.dfsg/src/mathlib/Imakefile
--- cernlib-2005.05.09.dfsg~/src/mathlib/Imakefile	2005-11-23 15:49:19.723162159 +0000
+++ cernlib-2005.05.09.dfsg/src/mathlib/Imakefile	2005-11-23 15:49:27.431512287 +0000
@@ -2,6 +2,7 @@
 #define IHaveSubdirs
 #define PassCDebugFlags 
 
+export LIB_SONAME := 2
 
 LIBDIRS= gen bvsl hbook /* hdiff stuff moved from packlib */
 


--- NEW FILE cernlib-deadpool.txt ---
# This file lists all the files that were removed from the Cernlib source
# for copyright reasons.  Given is the file or directory to delete
# relative to $CERN_ROOT/src/.

# --Kevin McCarty, 23 Nov 2005

# Authors of Pythia/Jetset did NOT give permission to release
# their code under GPL.  CERN should have checked this more carefully!!!
car/jetset74.car
cmz/jetset74.cmz
mclibs/jetset/
mclibs/pythia/

# Removal of Pythia/Jetset also necessitates removal of Fritiof, Lepto, Ariadne
mclibs/fritiof/
mclibs/ariadne/
mclibs/ariadne_407/
mclibs/lepto63/

# The same applies to GEANT-FLUKA; see for instance the comments at
# the web site http://www.fluka.org/Faq.html
car/geanf.car
car/geanf321.car
cmz/geanf.cmz
cmz/geanf321.cmz
geant321/data/flukaaf.dat
geant321/block/
geant321/fiface/
geant321/fluka/
geant321/miface/gfmfin.F
geant321/miface/gfmdis.F
geant321/peanut/
geant321/geant321/aadat.inc
geant321/geant321/auxpar.inc
geant321/geant321/balanc.inc
geant321/geant321/bamjcm.inc
geant321/geant321/cmsres.inc
geant321/geant321/comcon.inc
geant321/geant321/corinc.inc
geant321/geant321/dblprc.inc
geant321/geant321/decayc.inc
geant321/geant321/decayc2.inc
geant321/geant321/depnuc.inc
geant321/geant321/dimpar.inc
geant321/geant321/eva0.inc
geant321/geant321/eva1.inc
geant321/geant321/fheavy.inc
geant321/geant321/finlsp.inc
geant321/geant321/finlsp2.inc
geant321/geant321/finlsp3.inc
geant321/geant321/finpar.inc
geant321/geant321/finpar2.inc
geant321/geant321/finuc.inc
geant321/geant321/finuc2.inc
geant321/geant321/finuct.inc
geant321/geant321/hadflg.inc
geant321/geant321/hadpar.inc
geant321/geant321/higfis.inc
geant321/geant321/inpdat.inc
geant321/geant321/inpdat2.inc
geant321/geant321/inpflg.inc
geant321/geant321/iounit.inc
geant321/geant321/isotop.inc
geant321/geant321/labcos.inc
geant321/geant321/mapa.inc
geant321/geant321/metlsp.inc
geant321/geant321/nucdat.inc
geant321/geant321/nucgeo.inc
geant321/geant321/nuclev.inc
geant321/geant321/nucpar.inc
geant321/geant321/nucstf.inc
geant321/geant321/paprop.inc
geant321/geant321/parevt.inc
geant321/geant321/parnuc.inc
geant321/geant321/part.inc
geant321/geant321/part2.inc
geant321/geant321/part3.inc
geant321/geant321/qquark.inc
geant321/geant321/reac.inc
geant321/geant321/redver.inc
geant321/geant321/resnuc.inc
geant321/geant321/split.inc
geant321/geant321/xsepar.inc

# Other problematic files (mostly on VMS or obsolete archs)
graflib/higz/igold/golini.F
packlib/cspack/sysreq/pwd_vms.h
packlib/cspack/sysreq/sgtty.h
packlib/cspack/vmsc/
packlib/fatmen/scripts/unix/ctab_root.dat
packlib/kernlib/kernbit/z037/astdoc.F
packlib/kernlib/kernbit/z037/fiopat.s
pawlib/comis/comis/dlfcn.inc
pawlib/comis/deccc/dlfcn.c
pawlib/comis/obsolete/rsibm/
pawlib/paw/stagerd/bftp.c


--- NEW FILE cernlib-debian-copyright.in ---
This package was debianized by Kevin B. McCarty <kmccarty at debian.org>.
It was downloaded from the web page
http://wwwinfo.cern.ch/asd/cernlib/download/2005_source/tar/


COPYRIGHT
---------

Cernlib is copyright (C) CERN and others.  As of this writing (13 Jan 2005),
the web page http://wwwinfo.cern.ch/asd/cernlib/conditions.html (which gives
the terms under which Cernlib may be used) states:

  CERNLIB Availability

  (C) Copyright CERN except where explicitly stated otherwise. Permission to
  use and/or redistribute this work is granted under the terms of the GNU
  General Public License. FLUKA routines included in GEANT3 are joint copyright
  of INFN and CERN and are not licensed under the GPL: permission to use and/or
  redistribute outside GEANT3 should be negotiated. The software and
  documentation made available under the terms of this license are provided
  with no warranty.

  Last modified: 18-March-2004

On Debian systems, the complete text of the GNU General Public License can be
found in the file `/usr/share/common-licenses/GPL'.

The aforementioned FLUKA routines have been excised from the Cernlib source
code and binary packages distributed by Debian.  It should also be noted
that the above license supersedes the non-free license stated in the file
located at

  /usr/share/doc/libpdflib804-2-dev/pdfdoc.txt.gz  (package libpdflib804-2-dev)
  cernlib-$VERSION/src/mclibs/pdf/doc/pdfdoc.dat   (unpacked Debian source).


EXCEPTIONS
----------

Some source files of Cernlib are provided (in parts, or in entirety) under
different licenses which are compatible with the GPL.  See the table and
licenses below for details.  (File paths are relative to the directory
cernlib-$VERSION/src/ after running "debian/rules unpack".)  Most of the
differences in the licenses below are only in the exact wordings.  The
"Package(s)" column lists the binary Debian packages in which each piece of
code is compiled or otherwise included.

Copyright codes are as follows:

LGPL	- Library GPL
BSD	- BSD style license
NO AD	- BSD style license with negative advertising clause

Package codes are as follows:

Dev   = most development packages
Kx    = kxterm
Graf  = libgrafx11-1, libgrafx11-1-dev, paw, paw++
Pack  = libpacklib1, libpacklib1-dev, paw, paw++
KuiM  = libpacklib1-lesstif, libpacklib1-lesstif-dev, paw, paw++
Paw++ = libpawlib2-lesstif, libpawlib2-lesstif-dev, paw++
Src   = [not included in binary packages, only source package]

File(s)					Package(s)	License type	Owner
-------					----------	------------	-----
cfortran/*				Dev		LGPL [1]	[a]
graflib/higz/higzcc/rotated.c		Graf		BSD [3]		[b]
graflib/higz/higzcc/tkhigz.c		Graf		BSD [4]		[c]
packlib/cspack/sysreq/telnet.h		Pack		BSD [2]		[c]
packlib/kuip/code_kuip/getline.c	Pack		BSD [5]		[d]
packlib/kuip/code_motif/icbox.h		KuiM		NO AD [6]	[e]
packlib/kuip/code_motif/icboxp.h	KuiM		NO AD [6]	[e]
packlib/kuip/code_motif/iconbox.c	KuiM		NO AD [6]	[e]
packlib/kuip/code_motif/iconwidget.c	KuiM		NO AD [7]	[f]
packlib/kuip/code_motif/icwid.h		KuiM		NO AD [7]	[f]
packlib/kuip/code_motif/icwidp.h	KuiM		NO AD [7]	[f]
packlib/kuip/code_motif/kuxxt.c		KuiM		NO AD [8]	[g]
packlib/kuip/code_motif/mkuxxt.h	KuiM		NO AD [8]	[g]
packlib/kuip/programs/kxterm/uxxt.c	Kx		NO AD [8]	[g]
packlib/kuip/programs/kxterm/uxxt.h	Kx		NO AD [8]	[g]
pawlib/paw/hmotif/uxxt.h		Paw++		NO AD [8]	[g]
pawlib/paw/paw/tree.h			Paw++		BSD [9]		[h]
pawlib/paw/tree/tree.c			Paw++		BSD [9]		[h]
pawlib/paw/tree/treep.h			Paw++		BSD [9]		[h]
pawlib/paw/xbae/caption.c		Paw++		NO AD [10]	[i]
pawlib/paw/xbae/caption.h		Paw++		NO AD [10]	[i]
pawlib/paw/xbae/captionp.h		Paw++		NO AD [10]	[i]
pawlib/paw/xbae/cell.c			Paw++		NO AD [11]	[j]
pawlib/paw/xbae/cell.h			Paw++		NO AD [11]	[j]
pawlib/paw/xbae/cellp.h			Paw++		NO AD [11]	[j]
pawlib/paw/xbae/clip.c			Paw++		NO AD [10]	[i]
pawlib/paw/xbae/clip.h			Paw++		NO AD [10]	[i]
pawlib/paw/xbae/clipp.h			Paw++		NO AD [10]	[i]
pawlib/paw/xbae/matrix.c		Paw++		NO AD [10]	[i]
pawlib/paw/xbae/matrix.h		Paw++		NO AD [10]	[i]
pawlib/paw/xbae/matrixp.h		Paw++		NO AD [10]	[i]
pawlib/paw/xbae/version.c		Paw++		NO AD [10]	[i]
pawlib/paw/xbaevms/caption.c		Src		NO AD [10]	[i]
pawlib/paw/xbaevms/caption.h		Src		NO AD [10]	[i]
pawlib/paw/xbaevms/captionp.h		Src		NO AD [10]	[i]
pawlib/paw/xbaevms/clip.c		Src		NO AD [10]	[i]
pawlib/paw/xbaevms/clip.h		Src		NO AD [10]	[i]
pawlib/paw/xbaevms/clipp.h		Src		NO AD [10]	[i]
pawlib/paw/xbaevms/matrix.c		Src		NO AD [10]	[i]
pawlib/paw/xbaevms/matrix.h		Src		NO AD [10]	[i]
pawlib/paw/xbaevms/matrixp.h		Src		NO AD [10]	[i]
pawlib/paw/xbaevms/version.c		Src		NO AD [10]	[i]


Exception copyright holders
---------------------------

[a] Burkhard Burow, <burow at desy.de>,
    http://www-zeus.desy.de/~burow/cfortran/index.htm

[b] Alan Richardson, <mppa3 at syma.sussex.ac.uk>, and O. Couet

[c] The Regents of the University of California

[d] Chris Thewalt, <thewalt at ce.berkeley.edu>

[e] Alphonse A. Rademakers, <rdm at cernvm.cern.ch>,
    CN/AS Division
    CERN, European Organization for Nuclear Research
    1123 Geneve, Switzerland

[f] Addison-Wesley Publishing Company

[g] Visual Edge Software Ltd.

[h] Massachusetts Institute of Technology and Prentice Hall

[i] Bell Communications Research, Inc. (Bellcore)

[j] Q. Frank Xia, <qx at math.columbia.edu>


Exception license details
-------------------------

[1] On Debian systems, the complete text of the GNU Library General Public
    License can be found in the file `/usr/share/common-licenses/LGPL-2'.

[2] On Debian systems, the complete text of the BSD License
    can be found in the file `/usr/share/common-licenses/BSD'.

[3] xvertext 5.0, Copyright (c) 1993 Alan Richardson (mppa3 at uk.ac.sussex.syma)
    Alignment definition modified by O.Couet.
    Mods IBM/VM by O.Couet.

    Permission to use, copy, modify, and distribute this software and its
    documentation for any purpose and without fee is hereby granted, provided
    that the above copyright notice appear in all copies and that both the
    copyright notice and this permission notice appear in supporting
    documentation.  All work developed as a consequence of the use of
    this program should duly acknowledge such use. No representations are
    made about the suitability of this software for any purpose.  It is
    provided "as is" without express or implied warranty.

[4] Copyright (c) 1991-1993 The Regents of the University of California.
    All rights reserved.

    Permission is hereby granted, without written agreement and without
    license or royalty fees, to use, copy, modify, and distribute this
    software and its documentation for any purpose, provided that the
    above copyright notice and the following two paragraphs appear in
    all copies of this software.

    IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
    DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
    OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
    CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
    ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
    PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

[5] Copyright (C) 1991, 1992 by Chris Thewalt (thewalt at ce.berkeley.edu)

    Permission to use, copy, modify, and distribute this software
    for any purpose and without fee is hereby granted, provided
    that the above copyright notices appear in all copies and that both the
    copyright notice and this permission notice appear in supporting
    documentation.  This software is provided "as is" without express or
    implied warranty.

[6] Copyright 1992 Alphonse A. Rademakers

    Permission to use, copy, modify, distribute, and sell this software
    and its documentation for any purpose is hereby granted without
    fee, provided that the above copyright notice appears in all copies
    and that both that copyright notice and this permission notice
    appear in supporting documentation, and that the name of
    Alphonse A. Rademakers or CERN not be used in advertising or
    publicity pertaining to distribution of the software without
    specific, written prior permission.  Alphonse A. Rademakers and
    CERN make no representations about the suitability of this software
    for any purpose.  It is provided "as is" without express or implied
    warranty.

    Alphonse A. Rademakers and CERN disclaim all warranties with
    regard to this software, including all implied warranties of
    merchantability and fitness, in no event shall
    Alphonse A. Rademakers or CERN be liable for any special, indirect
    or consequential damages or any damages whatsoever resulting from
    loss of use, data or profits, whether in an action of contract,
    negligence or other tortious action, arising out of or in
    connection with the use or performance of this software.

    [Debian maintainer's note: Although the files with this copyright are
    described as "based on ideas by Thomas Berlage" (see next entry), a
    comparison with the original IconBox code of Thomas Berlage, available by
    FTP at (e.g.) ftp://ftp.x.org/R5contrib/berlage.motif.tar.Z , shows that
    they were written from scratch.]

[7] Copyright 1991 Addison-Wesley Publishing Company

    Permission to use, copy, modify, distribute, and sell this software and its
    documentation for any purpose is hereby granted without fee, provided that
    the above copyright notice appear in all copies and that both that
    copyright notice and this permission notice appear in supporting
    documentation, and that the name of Addison-Wesley not be used in
    advertising or publicity pertaining to distribution of the software without
    specific, written prior permission.  Addison-Wesley makes no representations
    about the suitability of this software for any purpose.  It is provided 
    as is" without express or implied warranty.

    ADDISON-WESLEY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
    INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
    SHALL ADDISON-WESLEY BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
    DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
    PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
    ACTION, ARISING OUT OF OR IN  CONNECTION WITH THE USE OR PERFORMANCE OF
    THIS SOFTWARE.

    Berlage: OSF/MOTIF: CONCEPTS AND PROGRAMMING

    ISBN 0 201 55792 4

    To order please contact your local Addison-Wesley office.

    [Debian maintainer's note: The COPYRIGHT file referred to by the files
    iconwidget.c, icwid.h, and icwidp.h, and quoted above, is not included in
    the Cernlib source code.  It, along with the original versions of those
    files (named IconWidget.c, IconWidget.h, and IconWidgetP.h, respectively),
    may be found in the materials distributed with the book _OSF/Motif:
    Concepts and Programming_, by Thomas Berlage, (C) 1991 Addison-Wesley
    Publishing Company, or downloadable by FTP from (e.g.)
    ftp://ftp.x.org/R5contrib/berlage.motif.tar.Z .]

[8] Copyright (c) 1991, Visual Edge Software Ltd.

    ALL  RIGHTS  RESERVED.   Permission to use, copy, modify, and
    distribute  this  software  and its documentation for any purpose
    and  without  fee  is  hereby  granted,  provided  that the above
    copyright  notice  appear  in  all  copies  and  that  both  that
    copyright  notice and this permission notice appear in supporting
    documentation,  and that  the name of Visual Edge Software not be
    used  in advertising  or publicity  pertaining to distribution of
    the software without specific, written prior permission. The year
    included in the notice is the year of the creation of the work.

[9] Copyright 1990 Massachusetts Institute of Technology
    Copyright 1989 Prentice Hall

    Permission to use, copy, modify, and distribute this software for any
    purpose and without fee is hereby granted, provided that the above
    copyright notice appear in all copies and that both the copyright notice
    and this permission notice appear in supporting documentation.

    M.I.T., Prentice Hall and the authors disclaim all warranties with regard
    to this software, including all implied warranties of merchantability and
    fitness.  In no event shall M.I.T., Prentice Hall or the authors be liable
    for any special, indirect or cosequential damages or any damages whatsoever
    resulting from loss of use, data or profits, whether in an action of
    contract, negligence or other tortious action, arising out of or in
    connection with the use or performance of this software.

[10] Copyright(c) 1992 Bell Communications Research, Inc. (Bellcore)
                            All rights reserved

     Permission to use, copy, modify and distribute this material for
     any purpose and without fee is hereby granted, provided that the
     above copyright notice and this permission notice appear in all
     copies, and that the name of Bellcore not be used in advertising
     or publicity pertaining to this material without the specific,
     prior written permission of an authorized representative of
     Bellcore.

     BELLCORE MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES, EX-
     PRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE, INCLUDING, BUT
     NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
     FITNESS FOR ANY PARTICULAR PURPOSE, AND THE WARRANTY AGAINST IN-
     FRINGEMENT OF PATENTS OR OTHER INTELLECTUAL PROPERTY RIGHTS.  THE
     SOFTWARE IS PROVIDED "AS IS", AND IN NO EVENT SHALL BELLCORE OR
     ANY OF ITS AFFILIATES BE LIABLE FOR ANY DAMAGES, INCLUDING ANY
     LOST PROFITS OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES RELAT-
     ING TO THE SOFTWARE.

[11] Copyright(C) Q. Frank Xia (qx at math.columbia.edu), 1994.

                           All Rights Reserved
  
     Permission to use, copy, modify, and distribute this software and its
     documentation for any purpose and without fee is hereby granted,
     provided that the above copyright notice appear in all copies and that
     both that copyright notice and this permission notice appear in
     supporting documentation, and that the name of Q. Frank Xia not be
     used in advertising or publicity pertaining to distribution of the
     software without specific, written prior permission.

     This software is provided as-is and without any warranty of any kind.


DELETIA
-------

The following files and directories have been removed from the Debian source
package of Cernlib due to license ambiguities or incompatibilities with the GPL
(e.g. positive BSD advertising clause).  If needed, they may be found in the
upstream source tarballs.  Please see the README.Debian files for libmathlib2,
montecarlo-base, and libgeant321-2 packages for more information on obtaining
the Ariadne, Fluka, Fritiof, Jetset, Lepto, and Pythia libraries.

DEADPOOL_LIST_GOES_HERE

cernlib-enforce-FHS.diff:

--- NEW FILE cernlib-enforce-FHS.diff ---
diff -ur ../original-cernlib-source/src/geant321/miface/gmorin.F src/geant321/miface/gmorin.F
--- ../original-cernlib-source/src/geant321/miface/gmorin.F     Mon Sep 30 10:26:05 1996
+++ src/geant321/miface/gmorin.F     Tue Oct 22 07:27:55 2002
@@ -112,7 +112,7 @@
          OPEN(UNIT=MICROS,FILE=XSFILE, STATUS='OLD',READONLY)
 #endif
 #if defined(CERNLIB_UNIX)||defined(CERNLIB_CRAY)
-         XSFILE = 'xsneut95.dat'
+         XSFILE = 'DATADIR/xsneut95.dat'
          INQUIRE(FILE=XSFILE,EXIST=EXISTS)
          IF(.NOT.EXISTS) THEN
             CHROOT=' '

cernlib-fedora_desktop.patch:

--- NEW FILE cernlib-fedora_desktop.patch ---
--- cernlib-2006/paw-2.14.04.dfsg.2/debian/add-ons/misc/paw++.desktop.fedora_desktop	2007-04-14 23:41:45.000000000 +0200
+++ cernlib-2006/paw-2.14.04.dfsg.2/debian/add-ons/misc/paw++.desktop	2007-04-14 23:44:39.000000000 +0200
@@ -7,5 +7,5 @@
 Comment[en_GB]=Analyse and graphically present experimental data
 Type=Application
 Exec=paw++
-Icon=paw48x48
-Categories=Application;Physics;Science;
+Icon=paw
+Categories=Physics;Science;Graphics;


--- NEW FILE cernlib-g77.spec ---
%if 0%{?fedora}
%if "%fedora" > "6"
%bcond_with gfortran
%else
%bcond_without gfortran
%endif
%if "%fedora" <= "3" 
%define old_lapack_name 1
%endif
%if "%fedora" <= "4"
%define monolithic_X 1
%endif
%if "%fedora" <= "6"
%define g77_default_compiler 1
%endif
%endif

%if 0%{?rhel}
%if "%rhel" <= "4"
# set to 1 if the optflags are compatible with what g77 wants. This should
# be true for the releases that use gcc < 4. For newer releases the
# optflags are for gfortran and should be filtered out if g77 is used
%define optflags_for_g77 1
%define old_lapack_name 1
%define monolithic_X 1
# this is set to 1 if g77 has to be used for the cernlib package without
# suffix.
%define g77_default_compiler 1
# these are not defined, they need to be defined here
%define with()         %{expand:%%{?with_%{1}:1}%%{!?with_%{1}:0}}
%define without()      %{expand:%%{?with_%{1}:0}%%{!?with_%{1}:1}}
%define bcond_with()           %{expand:%%{?_with_%{1}:%%global with_%{1} 1}}
%define bcond_without()        %{expand:%%{!?_without_%{1}:%%global with_%{1} 1}}
%endif
%if "%rhel" > "4"
%bcond_with gfortran
%else
%bcond_without gfortran
%endif
%endif


# compiler is used to disambiguate package names and executables
%if %{with gfortran}
# allows to use a suffix for the library different from the suffix
# for the utilities
# %%define utils_suffix -gfortran
%if 0%{?g77_default_compiler}
%define compiler -gfortran
%define utils_suffix -gfortran
%endif
%else
%if ! 0%{?g77_default_compiler}
%define compiler -g77
%define utils_suffix -g77
%endif
# no compat prefix, the utilities compiled with gfortran are non functionnal
# see Bug 241416
#%%define compat compat-
%endif
# verdir is the directory used for libraries and replaces the version 
# in some files and file names
%define verdir %{version}%{?compiler}
# data files should be the same and therefore parallel installable

Name:          %{?compat}cernlib%{?compiler}
Version:       2006
Release:       17%{?dist}
Summary:       General purpose CERN library
Group:         Development/Libraries
# As explained in the cernlib on debian FAQ, cfortran can be considered LGPL.
# http://borex.princeton.edu/~kmccarty/faq.html#44
License:       GPL/LGPL
URL:           http://cernlib.web.cern.ch/cernlib/
# mandrake
#BuildRequires: libxorg-x11-devel lesstif-devel libblas3-devel liblapack3-devel
#BuildRequires: gcc-g77
#Requires:      libxorg-x11-devel lesstif-devel libblas3-devel liblapack3-devel
# fedora core

%if 0%{?old_lapack_name}
BuildRequires: lapack blas
%else
BuildRequires: lapack-devel blas-devel
%endif

%if 0%{?monolithic_X}
BuildRequires: xorg-x11-devel 
%else
BuildRequires: imake libXaw-devel
# workaround #173530
BuildRequires: libXau-devel
%endif

# indirectly requires lesstif or openmotif and X libs
BuildRequires: xbae-devel 

# for patchy build scripts
BuildRequires: tcsh
BuildRequires: gawk

BuildRequires: desktop-file-utils

%if %{with gfortran}
BuildRequires: gcc-gfortran
%else
BuildRequires: /usr/bin/g77
%endif
BuildRoot:     %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

# these sources are different from the upstream sources as files with 
# GPL incompatible licences are removed. You can use cernlib-remove-deadpool
# and cernlib-deadpool.txt to recreate them from the upstream
# In a directory with the cernlib sources, issue 
# sh cernlib-remove-deadpool 

# source is now monolithic
#Source0: http://wwwasd.web.cern.ch/wwwasd/cernlib/download/2006_source/tar/2006_src.tar.gz
Source0: 2006_src-free.tar.gz

# The patchy version 4 sources. Mattias Ellert gave it so me in a mail.
Source17: patchy.tar.gz
# this is modified with regard with what Mattias gave me. Indeed the file
# containing some other files (p4inceta) was in fortran unformatted format, 
# I believe it is what caused a segfault of rceta on the ppc platform.
# I have recreated the patchy.tar.gz from Mattias tarball by running
# sh patchy-unpack-rceta
Source203: patchy-unpack-rceta 

# Shell scripts that go in /etc/profile.d
Source100: cernlib.sh.in
Source105: cernlib.csh.in
# m4 macros for autoconf
Source101: cernlib.m4
# README file for paw slightly modified from the debian
Source102: paw.README
# README file that lists the changes done in the package
Source103: cernlib.README
# mkdirhier is used to create directories. Taken from xorg-x11
Source104: mkdirhier
# Files that can be used in the SOURCE directory to remove files with
# GPL incompatible licences from upstream sources
Source200: cernlib-remove-deadpool
Source201: cernlib-deadpool.txt
# copyright.in from the non split debian patchset
Source203: cernlib-debian-copyright.in

# debian patchsets
Patch100001: http://ftp.debian.org/debian/pool/main/c/cernlib/cernlib_2006.dfsg.2-1.diff.gz
Patch100002: http://ftp.debian.org/debian/pool/main/p/paw/paw_2.14.04.dfsg.2-1.diff.gz
Patch100003: http://ftp.debian.org/debian/pool/main/m/mclibs/mclibs_2006.dfsg.2-1.diff.gz
Patch100004: http://ftp.debian.org/debian/pool/main/g/geant321/geant321_3.21.14.dfsg-5.diff.gz
# change file to directory to DATADIR
Patch1100: cernlib-enforce-FHS.diff
Patch1: geant321-001-fix-missing-fluka.dpatch
# mclibs debian split also remove other packages from LIBDIRS
Patch2: 002-fix-missing-mclibs.dpatch
Patch3: geant321-003-geant-dummy-functions.dpatch
Patch100: mclibs-100-fix-isajet-manual-corruption.dpatch
Patch101: mclibs-101-undefine-PPC.dpatch
Patch10201: cernlib-102-dont-optimize-some-code.dpatch
Patch10202: paw-102-dont-optimize-some-code.dpatch
Patch10203: mclibs-102-dont-optimize-some-code.dpatch
Patch103: cernlib-103-ignore-overly-long-macro-in-gen.h.dpatch
Patch104: cernlib-104-fix-undefined-insertchar-warning.dpatch
Patch10501: cernlib-105-fix-obsolete-xmfontlistcreate-warning.dpatch 
Patch10502: paw-105-fix-obsolete-xmfontlistcreate-warning.dpatch 
Patch106: cernlib-106-fix-paw++-menus-in-lesstif.dpatch
Patch107: cernlib-107-define-strdup-macro-safely.dpatch
Patch108: paw-108-quote-protect-comis-script.dpatch
# use xsneut95.dat from the archive
Patch109: geant321-109-fix-broken-xsneut95.dat-link.dpatch
Patch110: cernlib-110-ignore-included-lapack-rule.dpatch
Patch111: cernlib-111-fix-kuesvr-install-location.dpatch
Patch112: cernlib-112-remove-nonexistent-prototypes-from-gen.h.dpatch
# a workaround for cups. Applied in doubt.
# removed in 2006
#Patch113: cernlib-113-cups-postscript-fix.dpatch
# it is the same in all source packages...
Patch114: 114-install-scripts-properly.dpatch
Patch115: cernlib-115-rsrtnt64-goto-outer-block.dpatch
Patch116: cernlib-116-fix-fconc64-spaghetti-code.dpatch
Patch117: geant321-117-fix-optimizer-bug-in-gphot.dpatch
Patch118: cernlib-118-rename-mathlib-common-blocks.dpatch
Patch11901: cernlib-119-fix-compiler-warnings.dpatch
Patch11902: paw-119-fix-compiler-warnings.dpatch
Patch12001: cernlib-120-fix-gets-usage-in-kuipc.dpatch 
Patch12002: paw-120-fix-mlp-cdf-file.dpatch
Patch12101: cernlib-121-fix-mathlib-test-case-c209m.dpatch
Patch12102: paw-121-call-gfortran-in-cscrexec.dpatch
Patch122: cernlib-122-fix-cdf-file-syntax-errors.dpatch
Patch123: cernlib-123-extern-memmove-only-if-not-macro.dpatch
Patch200: paw-200-comis-allow-special-chars-in-path.dpatch
Patch201: cernlib-201-update-kuip-helper-apps.dpatch
Patch202: cernlib-202-fix-includes-in-minuit-example.dpatch
Patch203: geant321-203-compile-geant-with-ertrak.dpatch
Patch204: mclibs-204-compile-isajet-with-isasrt.dpatch
Patch205: cernlib-205-max-path-length-to-256.dpatch
Patch206: mclibs-206-herwig-uses-DBLE-not-REAL.dpatch
Patch207: paw-207-compile-temp-libs-with-fPIC.dpatch
# without that patch the binaries are linked with something like
# libzftplib.a /builddir/build/BUILD/cernlib-2005/2005/build/packlib/cspack/programs/zftp/libzftplib.a
Patch208: cernlib-208-fix-redundant-packlib-dependencies.dpatch
Patch209: cernlib-209-ignore-unneeded-headers-in-kmutil.c.dpatch
# in debian split the patches are specific for paw geant and mclibs but
# not cernlib. Here we keeep the cernlib one since it contains all the others
Patch210: 210-improve-cfortran-header-files.dpatch
# split in newer debian patchset
# in debian split there is a common part at the beginning of the patch
# 
# obsolete in 2006:
# 211-support-amd64-and-itanium corresponds with a merge of
# cernlib-211-support-amd64-and-itanium.dpatch
# paw-211-support-amd64-and-itanium.dpatch
# 
# in 2006
# paw-211-support-amd64-and-itanium.dpatch has the common part removed
Patch21101: cernlib-211-support-amd64-and-itanium.dpatch
Patch21102: paw-211-support-amd64-and-itanium.dpatch
Patch2111: cernlib-211-support-digital-alpha.dpatch
Patch300: cernlib-300-skip-duplicate-lenocc.dpatch
# Use another approach, see cernlib-enforce-FHS
# Patch33: 301-datafiles-comply-with-FHS.dpatch
# use cernlib-gxint-script.diff instead and sed for paw and dzedit.script
# Patch34: 302-scripts-comply-with-FHS.dpatch
Patch303: cernlib-303-shadow-passwords-supported.dpatch
Patch304: cernlib-304-update-Imake-config-files.dpatch
Patch30501: paw-305-use-POWERPC-not-PPC-as-test.dpatch
Patch30502: mclibs-305-use-POWERPC-not-PPC-as-test.dpatch
# the bug in /usr/include/assert.h seems to be present in FC-4. So a local
# version is provided in that patch. Will have to look at newer glibc-headers
# packages
# it is the same in all packages in cernlib split
Patch306: 306-patch-assert.h-for-makedepend.dpatch
# it is the same in all packages in cernlib split
Patch307: 307-use-canonical-cfortran.dpatch
Patch30801: cernlib-308-use-canonical-cfortran-location.dpatch
Patch30802: paw-308-use-canonical-cfortran-location.dpatch
Patch309: mclibs-309-define-dummy-herwig-routines.dpatch
Patch310: mclibs-310-define-dummy-fowl-routines.dpatch
# The zebra qnexte is a fake, removing it remove an unneeded dependency.
# the other qnext don't seem to be the same code? They are duplicate symbols
# anyway so one must be removed
Patch311: cernlib-311-skip-duplicate-qnext.dpatch
Patch312: mclibs-312-skip-duplicate-gamma.dpatch
# It is a departure from upstream. Apply, but may revert if not agreed.  
Patch31301: cernlib-313-comis-preserves-filename-case.dpatch
Patch31302: paw-313-comis-preserves-filename-case.dpatch
# fixed in 2006
#Patch314: cernlib-314-permit-using-regcomp-for-re_comp.dpatch
# first chunk of the patches are the same in the split cernlib
Patch315: 315-fixes-for-MacOSX.dpatch

Patch318: cernlib-318-additional-gcc-3.4-fixes.dpatch
# certainly not needed, but who knows?
Patch319: cernlib-319-work-around-imake-segfaults.dpatch
Patch32001: cernlib-320-support-ifort.dpatch
Patch32002: paw-320-support-ifort-and-gfortran.dpatch
Patch32101: cernlib-321-support-gfortran.dpatch
Patch32102: mclibs-321-support-gfortran.dpatch

# use host.def for gfortran 
Patch600: cernlib-600-use-host.def-config-file.dpatch
# in cernlib debian split also remove other packages from LIBDIRS
Patch700: 700-remove-kernlib-from-packlib-Imakefile.dpatch
Patch70101: cernlib-701-patch-hbook-comis-Imakefiles.dpatch
Patch70102: paw-701-patch-hbook-comis-Imakefiles.dpatch
Patch702: 702-patch-Imakefiles-for-packlib-mathlib.dpatch
# I would have preferred not to move the motif code to toplevel...
# in cernlib debian split also remove other packages from LIBDIRS
Patch703: 703-patch-code_motif-packlib-Imakefiles.dpatch
Patch704: cernlib-704-patch-code_kuip-higzcc-Imakefiles.dpatch
# I would have preferred not to move the motif code to toplevel...
# in paw debian split also remove other packages from LIBDIRS
Patch705: 705-patch-paw_motif-paw-Imakefiles.dpatch
Patch706: paw-706-use-external-xbae-and-xaw.dpatch

Patch800: cernlib-800-implement-shared-library-rules-in-Imake.dpatch
Patch80101: cernlib-801-non-optimized-rule-uses-fPIC-g.dpatch
Patch80102: paw-801-non-optimized-rule-uses-fPIC-g.dpatch
# in cernlib debian split also remove other packages from LIBDIRS
# otherwise patches are cleanly split
Patch802: 802-create-shared-libraries.dpatch
# in the original cernlib kxterm is built with the C compiler, which cause
# a failure if compiled with the cernlib debian script as -lg2c isn't found. 
# It is corrected in
Patch80301: cernlib-803-link-binaries-dynamically.dpatch
Patch80302: paw-803-link-binaries-dynamically.dpatch
# 803 depends on 
# 208-fix-redundant-packlib-dependencies.dpatch

# no idea about what this does
Patch804: paw-804-workaround-for-comis-mdpool-struct-location.dpatch
Patch805: cernlib-805-expunge-missing-mathlib-kernlib-symbols.dpatch 
# not needed but keep sync with debian, that'll avoid bumping sonames
Patch80601: cernlib-806-bump-mathlib-and-dependents-sonames.dpatch
Patch80602: paw-806-bump-mathlib-and-dependents-sonames.dpatch
Patch80603: geant321-806-bump-mathlib-and-dependents-sonames.dpatch
Patch80604: mclibs-806-bump-mathlib-and-dependents-sonames.dpatch

# change the cernlib script such that -llapack -lblas is used instead of 
# cernlib lapack
# depend explicitely on libkernlib now that it is out of packlib
# use lesstif-pawlib and lesstif-packlib
# use external Xbae and Xaw
# the modified script is renamed cernlib-static later and the debian cernlib
# script is used instead.
Patch1200: cernlib-script.patch
# don't stop if the CERN variable isn't defined
Patch1201: cernlib-gxint-script.diff
# not needed in 2006
#Patch1203: cernlib-hwuli2_use_dimag.diff 
#Patch1204: cernlib-hwhiga_use_dimag.diff
# modify the cernlib man page to fit with the distribution
Patch1206: cernlib-man_static.patch
# modify the debian cernlib paw desktop file icon name
Patch1207: cernlib-fedora_desktop.patch
# fix tests Imakefiles
Patch1208: cernlib-test.patch
# don't recurse in eurodec for tests because the testcase segfaults
Patch1210: cernlib-segf_eudtest.patch
# kernlib/kernnum packlib/{ffread hbook kuip zbook zebra} test error on 64 bit
# packlib/{ffread hbook kuip} segfaults on ppc64
Patch1211: cernlib-64test.patch


# patchy 4
# not applied as it has allready been done by the sed one-liner in 
# patchy-unpack-rceta
Patch1500: patchy-rceta.patch

Patch1501: patchy-insecure_tmp_use.diff
#Patch1502: patchy-fcasplit.patch
# build fixes
Patch1503: patchy-p4comp.patch
# use the flags in the the p4boot.sh script and have fcasplit handle
# enough command line arguments (this fcasplit is not shipped)
Patch1507: patchy-use_OPT.patch

# patchy 5 (included in cernlib)
# correct build, use optflags and have fcasplit handle
# enough command line arguments (this fcasplit is shipped)
Patch1504: npatchy-np_flags.patch
#Patch1505: patchy-perror.patch
# in yexpand don't put temporary files in HOME, but in current directory
Patch1506: npatchy-curdir.patch

%description
CERN program library is a large collection of general purpose libraries
and modules maintained and offered on the CERN. Most of these programs 
were developed at CERN and are therefore oriented towards the needs of a 
physics research laboratory that is general mathematics, data analysis, 
detectors simulation, data-handling etc... applicable to a wide range 
of problems.

The main and devel packages are parallel installable, but not the helper
scripts from the utils subpackage.

%package devel
Summary:       General purpose CERN library development package 

%if 0%{?old_lapack_name}
Requires:       lapack blas
%else
Requires:       lapack-devel blas-devel
%endif

# Motif and X devel libs are indirectly required through xbae
Requires: xbae-devel

%if 0%{?monolithic_X}
Requires:      xorg-x11-devel
%else
# workaround #173530
Requires:      libXau-devel
Requires:      libXaw-devel
%endif
Requires:      %{name} = %{version}-%{release}
Group:         Development/Libraries

# for the m4 macro directory ownership
Requires: automake

%description devel
CERN program library is a large collection of general purpose libraries
and modules maintained and offered on the CERN. Most of these programs 
were developed at CERN and are therefore oriented towards the needs of a 
physics research laboratory that is general mathematics, data analysis, 
detectors simulation, data-handling etc... applicable to a wide range 
of problems.

The cernlib-devel package contains the header files and symlinks needed  
to develop programs that use the CERN library using dynamic libraries.

Static libraries are in %{name}-static.

%package static
Summary:       General purpose CERN library static libraries
Group:         Development/Libraries
Requires:  %{name}-devel = %{version}-%{release}

%description static
CERN program library is a large collection of general purpose libraries
and modules maintained and offered on the CERN. Most of these programs 
were developed at CERN and are therefore oriented towards the needs of a 
physics research laboratory that is general mathematics, data analysis, 
detectors simulation, data-handling etc... applicable to a wide range 
of problems.

The %{name}-static package contains the static cernlib libraries.

%package utils
Summary:   CERN library compilation and environment setting scripts
Group:     Applications/System
Requires:  %{name}-devel = %{version}-%{release}
Requires:  %{name}-static = %{version}-%{release}

%description utils
CERN library compilation and environment setting scripts.

This package will conflict with other versions, therefore if you 
want to have different compile script and different environments for 
different versions of the library you have to set them by hand.

%package -n %{?compat}paw%{?utils_suffix}
Group: Applications/Engineering
Summary: A program for the analysis and presentation of data

%description -n %{?compat}paw%{?utils_suffix}
PAW is conceived as an instrument to assist physicists in the analysis and 
presentation of their data. It provides interactive graphical presentation 
and statistical or mathematical analysis, working on objects familiar to 
physicists like histograms, event files (Ntuples), vectors, etc. PAW is 
based on several components of the CERN Program Library.

%package -n %{?compat}geant321%{?compiler}
Summary:  Particle detector description and simulation tool
Group:    Applications/Engineering
Requires: %{name}-devel = %{version}-%{release}
Requires: %{name}-utils = %{version}-%{release}

%description -n %{?compat}geant321%{?compiler}
Geant simulates the passage of subatomic particles through matter, for 
instance, particle detectors. For maximum flexibility, Geant simulations 
are performed by linking Fortran code supplied by the user with the Geant 
libraries, then running the resulting executable.

This package includes gxint, the script used to perform this linking step. 

%package -n %{?compat}kuipc%{?utils_suffix}
Summary:  Cernlib's Kit for a User Interface Package (KUIP) compiler
Group:    Development/Languages
Requires: %{name}-devel = %{version}-%{release}

%description -n %{?compat}kuipc%{?utils_suffix}
KUIPC, the Kit for a User Interface Package Compiler, is a tool to simplify 
the writing of a program's user interface code. It takes as input a Command 
Definition File (CDF) that describes the commands to be understood by the 
program, and outputs C or FORTRAN code that makes the appropriate function 
calls to set up the user interface. This code can then be compiled and linked 
with the rest of the program. Since the generated code uses KUIP routines, 
the program must also be linked against the Packlib library that contains them.

%package packlib
Group: Applications/Archiving
Summary: I/O, network and other utilities from the cernlib

%description packlib
I/O, network and miscalleneous utilities based on the CERN Program 
Library. 
According to the responsible of the cernlib debian package, some
of these utilities may have security flaws.

%package -n %{?compat}patchy%{?utils_suffix}
Group: Applications/Archiving
Summary: The patchy utilities

%description -n %{?compat}patchy%{?utils_suffix}
Utilities for extracting sources from patchy cards and cradles.


%prep

echo 'Building cernlib %{verdir}'

%setup -q -c 
# patchy4
%setup -q -T -D -a 17

# patch patchy 4 installer fortran generator script
# actually it is unusefull, because the unpacking has been done
# offline, see comment above.
#%patch -P 1500

%patch -P 1501

# unpack the patchy version 4 sources is done offline,
# see comment above
#pushd patchy
#        ./rceta.sh
#popd

#%patch -P 1502 -b .use_OPT
%patch -P 1503
%patch -P 1507 -p1 -b .use_OPT

# adapt static script to modular X, use system libs and follow debian split
%patch -P 1200 -p1 -b .script
# patches for man page
%patch -P 1206 -p1 -b .man_static

# debian patchesets
%patch -P 100001 -p0
%patch -P 100002 -p0
%patch -P 100003 -p0
%patch -P 100004 -p0 
%patch -P 1207 -p1 -b .fedora_desktop

cp -p cernlib-2006.dfsg.2/debian/add-ons/bin/cernlib.in .

cd %{version}
%patch -P 1100 -p2
%patch -P 1 -p1
%patch -P 2 -p1
%patch -P 3 -p1
%patch -P 100 -p1
%patch -P 101 -p1
# miscompilation and ICE with optimized code should be fixed with gfortran
# there is still some code with -O0 from upstream, they are kept as-is
%if ! %{with gfortran}
%patch -P 10201 -p1
%patch -P 10202 -p1
%patch -P 10203 -p1
%endif
%patch -P 103 -p1
%patch -P 104 -p1
%patch -P 10501 -p1
%patch -P 10502 -p1
%patch -P 106 -p1
%patch -P 107 -p1
%patch -P 108 -p1
%patch -P 109 -p1
%patch -P 110 -p1
%patch -P 111 -p1
%patch -P 112 -p1
#%patch -P 113 -p1
%patch -P 114 -p1
%patch -P 115 -p1
%patch -P 116 -p1
%patch -P 117 -p1
%patch -P 118 -p1
%patch -P 11901 -p1
%patch -P 11902 -p1
%patch -P 12001 -p1
%patch -P 12002 -p1
%patch -P 12101 -p1
%patch -P 12102 -p1
%patch -P 122 -p1
%patch -P 123 -p1
%patch -P 200 -p1
%patch -P 201 -p1
%patch -P 202 -p1
%patch -P 203 -p1
%patch -P 204 -p1
%patch -P 205 -p1
%patch -P 206 -p1
%patch -P 207 -p1
%patch -P 208 -p1
%patch -P 209 -p1
%patch -P 210 -p1
%patch -P 21101 -p1
%patch -P 21102 -p1
%patch -P 2111 -p1
%patch -P 300 -p1
#%patch -P 301 -p1
#%patch -P 302 -p1
%patch -P 303 -p1
%patch -P 304 -p1
%patch -P 30501 -p1
%patch -P 30502 -p1
%patch -P 306 -p1
%patch -P 307 -p1
%patch -P 30801 -p1
%patch -P 30802 -p1
%patch -P 309 -p1
%patch -P 310 -p1
%patch -P 311 -p1
%patch -P 312 -p1
%patch -P 31301 -p1
%patch -P 31302 -p1
#%patch -P 314 -p1
%patch -P 315 -p1

# copy a paw include file to include directory (debian
# 317-copy-converter.h-to-installed-headers-dir.sh.dpatch)
# not in 2006
#cp src/pawlib/paw/tree/converter.h src/pawlib/paw/paw/

%patch -P 318 -p1
%patch -P 319 -p1
%patch -P 32001 -p1
%patch -P 32002 -p1
%patch -P 32101 -p1
%patch -P 32102 -p1

%patch -P 600 -p1

# move kernlib out of packlib (debian 700-move-kernlib-to-top-level.sh.dpatch)
mv src/packlib/kernlib src/kernlib

%patch -P 700 -p1

# move hkf1q.F and hkfill.F out of packlib/hbook and into
# pawlib/comis where they obviously belong (it even says so in the files!)
# (debian 701-move-packlib-hkfill-to-comis.sh.dpatch)
pushd src
                mv packlib/hbook/code/hkf1q.F  pawlib/comis/code/
                mv packlib/hbook/code/hkfill.F pawlib/comis/code/
                # these files also need some headers to go with them:
                mkdir pawlib/comis/hbook
                cp -p packlib/hbook/hbook/pilot.h    pawlib/comis/hbook/
                cp -p packlib/hbook/hbook/hcbook.inc pawlib/comis/hbook/
                cp -p packlib/hbook/hbook/hcbits.inc pawlib/comis/hbook/
                cp -p packlib/hbook/hbook/hcfast.inc pawlib/comis/hbook/
popd

%patch -P 70101 -p1
%patch -P 70102 -p1

# Must create dirs before applying following patch. 
# Corresponds with 702-fix-packlib-mathlib-circular-mess.sh.dpatch

pushd src
                # Hdiff depends upon a bunch of mathlib files; move it into
                # mathlib.
                mkdir mathlib/hbook
                mv packlib/hbook/hdiff mathlib/hbook/
                cp -r packlib/hbook/hbook mathlib/hbook/

                # Meanwhile, other packlib files depend upon these mathlib
                # files which are easily moved:
                mkdir packlib/hbook/d
                mv mathlib/gen/d/rgmlt*.F packlib/hbook/d/
                mv mathlib/gen/n          packlib/hbook/
                cp -r mathlib/gen/gen     packlib/hbook/
popd

%patch -P 702 -p1

# Script to move packlib/kuip/code_motif to top level, splitting it out
# from packlib.  But keep kmutil.c in packlib, it's otherwise used.
# debian 703-move-code_motif-to-top-level.sh.dpatch

pushd src
                mv packlib/kuip/code_motif/kmutil.c packlib/kuip/code_kuip/
                mv packlib/kuip/code_motif          ./
                cp -r packlib/kuip/kuip             code_motif/
popd

%patch -P 703 -p1

# Script to move the file kuwhag.c from packlib/kuip/code_kuip/kuwhag.c
# into graflib/higz/higzcc.  It appears to be the only file in code_kuip
# that depends upon grafX11 and libX11, so it fits in better here.
# debian 704-move-kuwhag.c-to-grafX11.sh.dpatch

pushd src
                mv packlib/kuip/code_kuip/kuwhag.c graflib/higz/higzcc/
                cp -r packlib/kuip/kuip            graflib/higz/
popd

%patch -P 704 -p1

# Script to move Lesstif-dependent Paw code into its own library.
# debian 705-move-paw++-code-to-top-level.sh.dpatch

pushd src
                mkdir paw_motif
                mv pawlib/paw/?motif pawlib/paw/fpanels? paw_motif/
                mv pawlib/paw/tree pawlib/paw/uimx pawlib/paw/xbae* paw_motif/
                cp -p pawlib/paw/Imakefile paw_motif/
                
                mkdir paw_motif/code
                mv pawlib/paw/code/pawpp.F   paw_motif/code/
                mv pawlib/paw/code/pawintm.F paw_motif/code/

                mkdir paw_motif/cdf
                mv pawlib/paw/cdf/pamcdf.cdf paw_motif/cdf/

                cp -pr pawlib/paw/paw paw_motif/
                cp -pr pawlib/paw/hpaw paw_motif/
popd

%patch -P 705 -p1
%patch -P 706 -p1

%patch -P 800 -p1
%patch -P 80101 -p1
%patch -P 80102 -p1
%patch -P 802 -p1
%patch -P 80301 -p1
%patch -P 80302 -p1

# Shell script to link pawlib/comis/comis into the top-level include directory.
# debian 804-link-to-comis-includes.sh.dpatch
pushd src
                ln -s ../pawlib/comis/comis include/comis
popd

%patch -P 804 -p1
%patch -P 805 -p1
%patch -P 80601 -p1
%patch -P 80602 -p1
%patch -P 80603 -p1
%patch -P 80604 -p1

%patch -P 1504 -p2 -b .np_flags
#%patch -P 1505 -p1
%patch -P 1506 -p2 -b .curdir

%patch -P 1201
#%patch -P 1203
#%patch -P 1204
%patch -P 1208 -p2 -b .test
%patch -P 1210 -p2 -b .segf_eudtest

%ifarch x86_64 ppc64
%patch -P 1211 -p2 -b .64test
%endif

# remove CVS directories
find . -depth -type d -name CVS -exec rm -rf {} ';' 

# unset executable bit on source files
chmod a-x src/kernlib/kerngen/ccgencf/cfstati.c \
  src/cfortran/cfortran.*

# remove empty header file not needed anywhere to shut up rpmlint
rm src/pawlib/paw/ntuple/dbmalloc.h

%build

CERN=$RPM_BUILD_DIR/%{name}-%{version}
CERN_LEVEL=%{version}
CERN_ROOT=$CERN/$CERN_LEVEL
CVSCOSRC=$CERN/$CERN_LEVEL/src
PATH=$CERN_ROOT/bin:$PATH

export CERN
export CERN_LEVEL
export CERN_ROOT 
export CVSCOSRC
export PATH

LIB_SONAME=1
export LIB_SONAME

# add something in the soname to avoid binaries linked against g77-compiled
# library to be linked against gfortran-compiled libraries, as the ABI is 
# incompatible for functions.
%if %{with gfortran}
TOOL_SONAME=_gfortran
export TOOL_SONAME
%endif

# set the CERN and CERN_LEVEL environment variables in shell scripts
# meant to go to /etc/profile.d
sed -e 's/==CERN_LEVEL==/%{verdir}/' -e 's:==CERN==:%{_libdir}/cernlib:' %{SOURCE100} > cernlib-%{verdir}.sh
sed -e 's/==CERN_LEVEL==/%{verdir}/' -e 's:==CERN==:%{_libdir}/cernlib:' %{SOURCE105} > cernlib-%{verdir}.csh

cp -p %{SOURCE101} .
cp -p %{SOURCE102} .
cp -p %{SOURCE103} .

# Regenerate the copyright file (from non split debian/rules)
grep -v DEADPOOL_LIST_GOES_HERE %{SOURCE203} > debian-copyright
sed -e 's/#.*//g' -e '/^[[:space:]]*$$/d' %{SOURCE201} | \
    sort | uniq >> debian-copyright

cd $CERN_ROOT

# substitude the right defaults in the scripts
sed -i.paths -e 's:"/cern":"%{_libdir}/cernlib/":' -e 's:"pro":"%{verdir}":' \
   src/scripts/paw src/scripts/cernlib src/graflib/dzdoc/dzedit/dzedit.script

sed -i -e 's:"/cern":"%{_libdir}/cernlib/":' -e 's:"pro":"%{verdir}":' \
   ../patchy/ylist ../patchy/yindex

# substitute version in gxint with the right version
# substitute includedir in gxint to conform to FHS, and gxint.o to gxint.f
# and substitue the name of the cernlib link script
sed -i -e 's/"pro"/%{version}/' -e 's:\${CERN}/\${ver}/lib/gxint\${gvs}\.\$_o:%{_includedir}/cernlib/\${ver}/gxint.f:' \
  -e 's/`cernlib /cernlib%{?compiler} /' \
  src/scripts/gxint 

# substitute DATADIR in source files to conform to FHS
sed -i -e 's:DATADIR:%{_datadir}/cernlib/%{version}:' \
  src/geant321/miface/gmorin.F 
# don't correct datadir in test files or header used in tests
#src/mclibs/cojets/test/test.F src/mclibs/eurodec/eurodec/eufiles.inc src/mclibs/isajet/test/isajett.F

# substitute bindir in ylist and yindex to conform to FHS
sed -i -e 's:\$CERN/patchy/\$PATCHY_VERSION/bin:%{_bindir}:' ../patchy/ylist ../patchy/yindex

# Create the build directory structure
mkdir -p build bin lib shlib

# rename the cernlib script cernlib-static
mv src/scripts/cernlib src/scripts/cernlib-static
%{__install} -p -m755 src/scripts/cernlib-static bin/cernlib-static

# use the debian cernlib script for dynamic libraries support.
# remove -lg2c to the link commands, because libg2c.so isn't available, 
# it is found by g77/gfortran if needed.
# don't add %{_libdir} to the directory searched in for libraries, 
# since it is already in the list.
sed -e 's:@PREFIX@:%{_prefix}:g' \
  -e 's:@CERN@:%{_libdir}/cernlib:g' \
  -e 's:@VERSION@:%{verdir}:g' \
  -e 's:@LIBPREFIX@::g' \
  -e 's/-lg2c//' \
  ../cernlib.in > src/scripts/cernlib
# to remove reference to monolithic X directories
#  -e 's/-L\$XDIR\(64\)\? //' \
#  -e 's:-L/usr/X11R6/lib\(64\)\? ::' \
#  -e 's:/usr/X11R6/lib\(64\)\? ::g' \
#
chmod 0755 src/scripts/cernlib
touch -r ../cernlib.in src/scripts/cernlib

# install mkdirhier which is needed to make directories
%{__install} -p -m755 %{SOURCE104} bin/

# set FC_OPTFLAGS and FC_COMPILER based on compiler used
%if %{with gfortran}
FC_OPTFLAGS="%{optflags}"
FC_COMPILER=gfortran
%else
%if 0%{?optflags_for_g77}
FC_OPTFLAGS="%{optflags}"
%else
# optflags are different for g77, so we remove problematic flags
FC_OPTFLAGS=`echo "%optflags" | sed -e 's/-mtune=[^ ]\+//' -e 's/-fstack-protector//' -e 's/--param=ssp-buffer-size=[^ ]\+//'`
%endif
FC_COMPILER=g77
%endif

PATHSAVE=$PATH
# Build patchy version 4
pushd ../patchy
%if %{with gfortran}
        sed -i.gfortran -e 's/f77/gfortran/' fcasplit.f p4boot.sh
%endif
        sed -i.optflags -e 's/FOPT \+=.*/FOPT = "'"$FC_OPTFLAGS"'"/' \
                 -e 's/COPT  \+=.*/COPT = "%{optflags}"/' p4boot.sh
#        export PATH="$CERN/patchy:$CERN/patchy/p4sub:$PATH" 
        export PATH=".:..:$PATH" 
        p4boot.sh 0
popd
export PATH=$PATHSAVE

# pass informations to the build system through host.def
echo '#define DefaultCDebugFlags %{optflags}' >> ${CVSCOSRC}/config/host.def

%if %{with gfortran}
echo '#define Hasgfortran YES' >> ${CVSCOSRC}/config/host.def
%endif
echo "#define FortranDebugFlags $FC_OPTFLAGS" >> ${CVSCOSRC}/config/host.def
# keep timestamps
echo "#define InstallCmd %{__install} -p" >> ${CVSCOSRC}/config/host.def
# don't strip executables
echo "#define InstPgmFlags -m 0755" >> ${CVSCOSRC}/config/host.def

# Create the top level Makefile with imake
cd $CERN_ROOT/build
$CVSCOSRC/config/imake_boot

# Install kuipc and the scripts (cernlib, paw and gxint) in $CERN_ROOT/bin

#  %{?_smp_mflags} breaks the builds
make bin/kuipc
make scripts/Makefile
cd scripts
make install.bin

# Install the libraries

cd $CERN_ROOT/build
make
make install.shlib
chmod a+x ../shlib/*.so.*

# Build dynamic paw
cd $CERN_ROOT/build/pawlib
make install.bin
cd $CERN_ROOT/
mv bin/pawX11 bin/pawX11.dynamic
mv bin/paw++ bin/paw++.dynamic

# Build static paw
$FC_COMPILER $FC_OPTFLAGS $CERN_ROOT/build/pawlib/paw/programs/0pamain.o \
  `cernlib -G X11 pawlib` -Wl,-E -o bin/pawX11
$FC_COMPILER $FC_OPTFLAGS $CERN_ROOT/build/pawlib/paw/programs/0pamainm.o \
  `cernlib -G Motif pawlib` -Wl,-E -o bin/paw++

# Build packlib
cd $CERN_ROOT/build/packlib
make install.bin

cd $CERN_ROOT/build/graflib
make install.bin

# bootstrap npatchy
mkdir -p $CERN_ROOT/build/p5boot
cd $CERN_ROOT/build/p5boot
cp -p -r $CERN_ROOT/src/p5boot/* .
# there is a main program in this file, so the file is removed.
rm p5lib/nsynopt.f
$FC_COMPILER $FC_OPTFLAGS -o nypatchy nypatchy.f p5lib/*.f  $CERN_ROOT/lib/libkernlib.a
ln -s $CERN_ROOT/build/p5boot/nypatchy $CERN_ROOT/bin/ypatchy

# Build npatchy
%if %{with gfortran}
        sed -i.gfortran -e 's/g77/gfortran/' $CERN_ROOT/src/patchy/fcasplit.F
%endif
cd $CERN_ROOT/build
make patchy/Makefile
cd patchy
# we cannot use %%{?_smp_mflags} because fcasplit is used after being
# built, and during the fcasplit installation (which is done in parallel 
# with the build) it is removed and replaced by a symlink, and if it 
# takes time the link may not be there on time. 
# At least that's my understanding of the failure.
make install.bin

# it is not completly obvious that it is better to use patchy 4 for 
# ypatchy, but that's what we do. In any case it should be replaced by a
# link to the final npatchy
rm $CERN_ROOT/bin/ypatchy

%install

rm -rf %{buildroot}

%{__install} -d -m755 %{buildroot}%{_sysconfdir}/profile.d
%{__install} -p -m644 cernlib-%{verdir}.sh %{buildroot}%{_sysconfdir}/profile.d
%{__install} -p -m644 cernlib-%{verdir}.csh %{buildroot}%{_sysconfdir}/profile.d

%{__install} -d -m755 cfortran/Examples
%{__install} -p -m644 %{version}/src/cfortran/Examples/*.c cfortran/Examples/

%{__install} -d -m755 %{buildroot}%{_datadir}/aclocal
%{__install} -p -m644 cernlib.m4 %{buildroot}%{_datadir}/aclocal/cernlib.m4

# copy patchy executables in bin. Keep the timestamps for the scripts.
%{__install} -d -m755 %{buildroot}%{_bindir}/
find patchy -name y* -a -perm -755 -exec %{__install} -p -m755 {} %{buildroot}%{_bindir} ';'

cd %{version}
%{__install} -d -m755 %{buildroot}%{_libdir}/cernlib/%{verdir}/lib
%{__install} -d -m755 %{buildroot}%{_datadir}/cernlib/%{version}
%{__install} -d -m755 %{buildroot}%{_includedir}/cernlib/%{version}
%{__install} -d -m755 %{buildroot}%{_includedir}/cernlib/%{version}/cfortran

%{__install} -p -m644 lib/*.dat %{buildroot}%{_datadir}/cernlib/%{version}
%{__install} -p -m644 lib/gxint321.f %{buildroot}%{_includedir}/cernlib/%{version}
%{__install} -p -m644 src/cfortran/*.h %{buildroot}%{_includedir}/cernlib/%{version}/

%{__install} -p -m755 bin/* %{buildroot}%{_bindir}/


# avoid name conflicts for files in bin
# first move cernlib and gxint scripts out of the way
for file in cernlib cernlib-static gxint; do
   mv %{buildroot}%{_bindir}/$file $file%{?compiler}
done

# then modify utilities names
if [ 'z%{?utils_suffix}' != 'z' ]; then
   for file in %{buildroot}%{_bindir}/*; do
      mv $file ${file}%{utils_suffix}
   done
fi
# move gxint and cernlib scripts back
mv cernlib%{?compiler} cernlib-static%{?compiler} gxint%{?compiler} \
   %{buildroot}%{_bindir}/

# add a link to pawX11 and dzeX11 from %{_libdir}/cernlib/%{verdir}/bin
%{__install} -d -m755 %{buildroot}%{_libdir}/cernlib/%{verdir}/bin/
%{__ln_s} %{_bindir}/pawX11%{?utils_suffix} %{buildroot}%{_libdir}/cernlib/%{verdir}/bin/pawX11
%{__ln_s} %{_bindir}/dzeX11%{?utils_suffix} %{buildroot}%{_libdir}/cernlib/%{verdir}/bin/dzeX11

# to preserve symlinks and timestamps
(cd lib && tar cf - *.a) | (cd %{buildroot}%{_libdir}/cernlib/%{verdir}/lib && tar xf -)
(cd shlib && tar cf - *.so*) | (cd %{buildroot}%{_libdir}/cernlib/%{verdir}/lib && tar xf -)

rm %{buildroot}%{_bindir}/mkdirhier*

# add links for cfortran header files in the top include directory
pushd %{buildroot}%{_includedir}/cernlib/%{version}
for file in *.h; do
   %{__ln_s} ../$file cfortran/$file
done
%{__ln_s} gxint321.f gxint.f
popd

cd src
# install include directories for the cernlib libraries
base_include=%{buildroot}%{_includedir}/cernlib/%{version}
for dir in `cat ../../*/debian/add-ons/includelist.txt`; do
   basedir=`basename $dir`
   rm -rf $base_include/$basedir
   cp -Rp $dir $base_include/
done

# substitute the path in installed eufiles.inc, not in in-source
# file, because in-source the relative path is required for test
sed -i -e 's:eurodec.dat:%{_datadir}/cernlib/%{version}/eurodec.dat:' \
  %{buildroot}%{_includedir}/cernlib/%{version}/eurodec/eufiles.inc

# install the tree.h and converter.h include files redirecting to 
# system headers
%{__install} -p -m644 ../../paw-2.14.04.dfsg.2/debian/add-ons/paw/*.h %{buildroot}%{_includedir}/cernlib/%{version}/paw

%{__install} -d -m755 %{buildroot}/etc/ld.so.conf.d
echo %{_libdir}/cernlib/%{verdir}/lib > %{buildroot}/etc/ld.so.conf.d/cernlib-%{verdir}-%{_arch}.conf

%{__install} -d -m755 %{buildroot}/%{_mandir}/man1
%{__install} -p -m644 man/man1/cernlib.1 %{buildroot}/%{_mandir}/man1/cernlib-static.1
for cernlib_manpage in cernlib.1 kxterm.1 dzedit.1 dzeX11.1 kuipc.1 kuesvr.1 zftp.1 gxint.1 paw.1 paw++.1 pawX11.1; do
	%{__install} -p -m644 ../../*/debian/add-ons/manpages/$cernlib_manpage %{buildroot}/%{_mandir}/man1/
done

%{__install} -d -m755 %{buildroot}/%{_mandir}/man8
for cernlib_manpage in pawserv.8 zserv.8; do
	%{__install} -p -m644 ../../*/debian/add-ons/manpages/$cernlib_manpage %{buildroot}/%{_mandir}/man8/
done

%{__install} -d -m755 %{buildroot}/%{_datadir}/X11/app-defaults
%{__install} -p -m644 ../../*/debian/add-ons/app-defaults/* %{buildroot}/%{_datadir}/X11/app-defaults/

sed -e 's/Exec=paw++/Exec=paw++%{?utils_suffix}/' -e 's/PAW++/PAW++%{?utils_suffix}/' \
 ../../paw*/debian/add-ons/misc/paw++.desktop > paw++%{?utils_suffix}.desktop
desktop-file-install --vendor="fedora"               \
  --dir=%{buildroot}/%{_datadir}/applications         \
  paw++%{?utils_suffix}.desktop


%{__install} -d -m755 %{buildroot}/%{_datadir}/pixmaps
%{__install} -d -m755 %{buildroot}/%{_datadir}/icons/hicolor/{48x48,32x32}/apps/
%{__install} -p -m644 ../../*/debian/add-ons/icons/*.xpm %{buildroot}/%{_datadir}/pixmaps/
%{__install} -p -m644 ../../paw*/debian/add-ons/icons/paw32x32.xpm %{buildroot}/%{_datadir}/icons/hicolor/32x32/apps/paw.xpm
%{__install} -p -m644 ../../paw*/debian/add-ons/icons/paw48x48.xpm %{buildroot}/%{_datadir}/icons/hicolor/48x48/apps/paw.xpm

find %{buildroot}%{_includedir}/cernlib/%{version} -name Imakefile -exec rm -f \{\} \;
rm %{buildroot}%{_includedir}/cernlib/%{version}/ntuple/*.c


%check
CERN=$RPM_BUILD_DIR/%{name}-%{version}
CERN_LEVEL=%{version}
CERN_ROOT=$CERN/$CERN_LEVEL
CVSCOSRC=$CERN/$CERN_LEVEL/src
PATH=$CERN_ROOT/bin:$PATH

export CERN
export CERN_LEVEL
export CERN_ROOT
export CVSCOSRC
export PATH

export LD_LIBRARY_PATH=$CERN_ROOT/shlib/

# cannot make out-of build test because of the data files
cd $CERN_ROOT/build

# no test in code_motif paw_motif scripts patchy pawlib
test_dirs='graflib mclibs kernlib mathlib packlib phtools'

%ifnarch x86_64 ppc64
test_dirs="$test_dirs geant321"
%endif

for dir in $test_dirs; do
make -C $dir test
done


%clean
rm -rf %{buildroot}

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%post -n %{?compat}paw%{?utils_suffix}
touch --no-create %{_datadir}/icons/hicolor || :
%{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || :

%postun -n %{?compat}paw%{?utils_suffix}
touch --no-create %{_datadir}/icons/hicolor || :
%{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || :

%files
%defattr(-,root,root,-)
%doc cernlib.README debian-copyright
%doc geant321-3.21.14.dfsg/debian/debhelper/geant321.README.debian 
%doc mclibs-2006.dfsg.2/debian/debhelper/libpdflib804-2-dev.README.debian
%doc mclibs-2006.dfsg.2/debian/debhelper/montecarlo-base.README.debian
%doc cernlib-2006.dfsg.2/debian/add-ons/vim/
/etc/ld.so.conf.d/*
%dir %{_libdir}/cernlib/
%dir %{_libdir}/cernlib/%{verdir}
%dir %{_libdir}/cernlib/%{verdir}/lib
%dir %{_libdir}/cernlib/%{verdir}/bin
%{_libdir}/cernlib/%{verdir}/lib/*.so.*
%{_datadir}/cernlib/

# the utils and devel are separated to have the possibility to install
# parallel versions of the library
%files devel
%defattr(-,root,root,-)
%doc cfortran paw-*/debian/add-ons/misc/comis-64bit-example.F
%{_libdir}/cernlib/%{verdir}/lib/*.so
%{_includedir}/cernlib/
%{_datadir}/aclocal/cernlib.m4

%files static
%defattr(-,root,root,-)
%{_libdir}/cernlib/%{verdir}/lib/*.a

%files utils
%defattr(-,root,root,-)
%{_bindir}/cernlib*%{?compiler}
%{_sysconfdir}/profile.d/cernlib-%{verdir}.sh
%{_sysconfdir}/profile.d/cernlib-%{verdir}.csh
%{_mandir}/man1/cernlib*.1*

%files -n %{?compat}paw%{?utils_suffix}
%defattr(-,root,root,-)
%doc paw.README
%{_bindir}/paw++%{?utils_suffix}
%{_bindir}/paw%{?utils_suffix}
%{_bindir}/pawX11%{?utils_suffix}
%{_bindir}/pawX11.dynamic%{?utils_suffix}
%{_bindir}/paw++.dynamic%{?utils_suffix}
# paw doesn't explicitly depend on the main package, so it owns the dirs
%dir %{_libdir}/cernlib/%{verdir}
%dir %{_libdir}/cernlib/%{verdir}/bin
%{_libdir}/cernlib/%{verdir}/bin/pawX11
%{_datadir}/X11/app-defaults/*Paw++
%{_datadir}/icons/hicolor/
%{_mandir}/man1/paw*.1*
%{_datadir}/applications/*paw*.desktop
%{_datadir}/pixmaps/paw*.xpm

%files -n %{?compat}geant321%{?compiler}
%defattr(-,root,root,-)
%{_bindir}/gxint%{?compiler}
%{_datadir}/X11/app-defaults/*Geant++
%{_mandir}/man1/gxint.1*

%files -n %{?compat}kuipc%{?utils_suffix}
%defattr(-,root,root,-)
%{_bindir}/kuipc%{?utils_suffix}
%{_mandir}/man1/kuipc.1*

%files packlib
%defattr(-,root,root,-)
%doc cernlib-2006.dfsg.2/debian/debhelper/zftp.README.debian
%{_bindir}/cdbackup%{?utils_suffix}
%{_bindir}/cdserv%{?utils_suffix}
%{_bindir}/dzedit%{?utils_suffix}
# packlib doesn't explicitly depend on the main package, so it owns the dirs
%dir %{_libdir}/cernlib/%{verdir}
%dir %{_libdir}/cernlib/%{verdir}/bin
%{_libdir}/cernlib/%{verdir}/bin/dzeX11
%{_bindir}/dzeX11%{?utils_suffix}
%{_bindir}/fatmen%{?utils_suffix}
%{_bindir}/fatsrv%{?utils_suffix}
%{_bindir}/kuesvr%{?utils_suffix}
%{_bindir}/zserv%{?utils_suffix}
%{_bindir}/cdmake%{?utils_suffix}
%{_bindir}/fatnew%{?utils_suffix}
%{_bindir}/pawserv%{?utils_suffix}
%{_bindir}/cdmove%{?utils_suffix}
%{_bindir}/fatback%{?utils_suffix}
%{_bindir}/fatsend%{?utils_suffix}
%{_bindir}/hepdb%{?utils_suffix}
%{_bindir}/kxterm%{?utils_suffix}
%{_bindir}/zftp%{?utils_suffix}
%{_datadir}/X11/app-defaults/KXterm
%{_datadir}/pixmaps/kxterm*.xpm
%{_mandir}/man1/kxterm.1* 
%{_mandir}/man1/dze*.1*
%{_mandir}/man1/kuesvr.1* 
%{_mandir}/man1/zftp.1*
%{_mandir}/man8/*.8*

%files -n %{?compat}patchy%{?utils_suffix}
%defattr(-,root,root,-)
%{_bindir}/fcasplit%{?utils_suffix}
%{_bindir}/nycheck%{?utils_suffix}
%{_bindir}/nydiff%{?utils_suffix}
%{_bindir}/nyindex%{?utils_suffix}
%{_bindir}/nylist%{?utils_suffix}
%{_bindir}/nymerge%{?utils_suffix}
%{_bindir}/nypatchy%{?utils_suffix}
%{_bindir}/nyshell%{?utils_suffix}
%{_bindir}/nysynopt%{?utils_suffix}
%{_bindir}/nytidy%{?utils_suffix}
%{_bindir}/yexpand%{?utils_suffix}
%{_bindir}/ycompar%{?utils_suffix}
%{_bindir}/yedit%{?utils_suffix}
%{_bindir}/yfrceta%{?utils_suffix}
%{_bindir}/yindex%{?utils_suffix}
%{_bindir}/yindexb%{?utils_suffix}
%{_bindir}/ylist%{?utils_suffix}
%{_bindir}/ylistb%{?utils_suffix}
%{_bindir}/ypatchy%{?utils_suffix}
%{_bindir}/ysearch%{?utils_suffix}
%{_bindir}/yshift%{?utils_suffix}
%{_bindir}/ytobcd%{?utils_suffix}
%{_bindir}/ytobin%{?utils_suffix}
%{_bindir}/ytoceta%{?utils_suffix}


%changelog
* Sun Aug  5 2007 Patrice Dumas <pertusus at free.fr> 2006-17
- remove old patches
- remove 'binaries' from the main lib summary

* Wed Jul 25 2007 Patrice Dumas <pertusus at free.fr> 2006-16
- add rhel conditionals
- bring back support for monolithic X
- don't build anything in parallel

* Sun May 27 2007 Patrice Dumas <pertusus at free.fr> 2006-15
- split out static libraries, as per FESCO decision

* Sat May 26 2007 Patrice Dumas <pertusus at free.fr> 2006-14
- add link to $CERN_ROOT/bin/dzeX11
- use %%{name} in the Requires
- Provides %%{name}-static
- allow utilities to have another suffix than libs. This allows to 
  have the utilities compiled with g77 and the default libraries compiled
  with gfortran

* Wed May 23 2007 Patrice Dumas <pertusus at free.fr> 2006-13
- remove reference to %%{_libdir} and X11R6 path in cernlib script
- apply cernlib-static script patch
- add packlib-lesstif only if Motif driver is selected. This driver
  is selected in the default case for geant321 and pawlib
- build and ship the graflib utilities

* Mon May 14 2007 Patrice Dumas <pertusus at free.fr> 2006-11
- disable the same tests on ppc64 than on x86_64

* Mon May 14 2007 Patrice Dumas <pertusus at free.fr> 2006-10.1
- packlib/{ffread,hbook} test segfaults on ppc64

* Sun May 13 2007 Patrice Dumas <pertusus at free.fr> 2006-9
- add a compat prefix when built with g77
- new debian patcheset

* Tue Apr 24 2007 Patrice Dumas <pertusus at free.fr> 2006-8
- change the soname with gfortran after coordination with debian maintainer

* Tue Apr 24 2007 Patrice Dumas <pertusus at free.fr> 2006-7
- use real cernlib lib location in cernlib debian script, don't assume
  that they are in %%_prefix, it is not the case on fedora

* Mon Apr 23 2007 Patrice Dumas <pertusus at free.fr> 2006-6
- package compiled with g77 is parallel installable with gfortran 
  compiled package

* Sun Apr 22 2007 Patrice Dumas <pertusus at free.fr> 2006-5.4
- packlib/ffread, packlib/hbook, packlib/kuip, packlib/zbook, packlib/zebra 
  tests fail on x86_64, exclude the tests on this arch
- kernbit/kernnum test fails on x86_64, exclude the test on this arch

* Sun Apr 22 2007 Patrice Dumas <pertusus at free.fr> 2006-3
- geant321 test fails on x86_64, exclude the test on this arch

* Sun Apr 22 2007 Patrice Dumas <pertusus at free.fr> 2006-2
- don't do a parallel build for npatchy

* Fri Apr 13 2007 Patrice Dumas <pertusus at free.fr> 2006-1
- update to cernlib 2006
- build with gfortran
- use system Xbae and Xaw
- ship man pages, app-defaults, icons and paw++ desktop file (from debian)
- run tests
- use optflags in patchy4
- bootstrap npatchy with p5boot (instead of using patchy4)
- fix npatchy build

* Tue Dec 19 2006 Patrice Dumas <pertusus at free.fr> 2005-27
- add support for gfortran (not enabled, lshift missing in fedora gfortran)
- use fedora compiler flags when possible
- use %%{optflags} and %%{buildroot}

* Mon Sep 11 2006 Patrice Dumas <pertusus at free.fr> 2005-26
- update to newer debian patchsets (paw and cernlib)
- remove gfortran related patches integrated in the debian 
  patchsets

* Fri Sep  1 2006 Patrice Dumas <pertusus at free.fr> 2005-25
- update to newer source split debian patchsets
- don't set the exec bits on file installed in /etc/profile.d/

* Thu Aug 31 2006 Patrice Dumas <pertusus at free.fr> - 2005-22
- add -q to %%setup
- rebuild against lesstif for FC6

* Wed May 24 2006 Patrice Dumas <pertusus at free.fr> - 2005-21
- compile paw statically against the cernlib (paw binaries dynamically 
  compiled against the cernlib are still shiped). Fix 192866

* Wed May 17 2006 Patrice Dumas <pertusus at free.fr> - 2005-20
- use new debian patchset. Fix 191631

* Tue Apr 13 2006 Patrice Dumas <pertusus at free.fr> - 2005-19
- add a patch to yexpand, to avoid using $HOME.

* Tue Apr 13 2006 Patrice Dumas <pertusus at free.fr> - 2005-17
- npatchy don't build on ppc.

* Wed Apr 12 2006 Patrice Dumas <pertusus at free.fr> - 2005-16
- unpack patchy offline because the files are within an unformatted
  fortran file which won't be right on all the arches.

* Tue Apr 11 2006 Patrice Dumas <pertusus at free.fr> - 2005-15.1
- add conditionals in spec to have only one for all fedora versions.

* Tue Apr 11 2006 Patrice Dumas <pertusus at free.fr> - 2005-14
- add patchy version 4 and build cernlib patchy. From Mattias Ellert.
- update to newer debian patchset

* Thu Feb 16 2006 Patrice Dumas <pertusus at free.fr> - 2005-13
- rebuild for fc5

* Tue Jan 17 2006 Patrice Dumas <pertusus at free.fr> - 2005-12.1
- attempt a rebuild against newer openmotif

* Tue Dec 20 2005 Patrice Dumas <pertusus at free.fr> - 2005-11.4
- add a symlink from /usr/lib/cernlib/2005/bin/pawX11 to /usr/bin/pawX11
- fix gxint

* Tue Dec 20 2005 Patrice Dumas <pertusus at free.fr> - 2005-10
- add file in /etc/ld.so.conf.d required for dynamic linking

* Wed Dec 14 2005 Patrice Dumas <pertusus at free.fr> - 2005-9.1
- use new debian patchset

* Fri Dec  9 2005 Patrice Dumas <pertusus at free.fr> - 2005-8.1
- use new debian patchset
- enable 64 bit fixes patch

* Fri Dec  2 2005 Patrice Dumas <pertusus at free.fr> - 2005-7
- use updated beta debian patchset
- remove the BSD in the licence because there is no library nor binary
  under a BSD licence and someone could get the idea that there is 
  some dual BSD/GPL licenced binaries or libraries. The LGPL is kept
  because of cfortran

* Tue Nov 29 2005 Patrice Dumas <pertusus at free.fr> - 2005-6.1
- update with newer debian patchset for cernlib, fix licence issues
- don't use the include.tar.gz source, instead get include files from
  the source files
- build shared libraries
- simplify the scripts modifications
- add BuildRequires: libXau-devel to workaround #173530

* Tue Nov 15 2005 Patrice Dumas <pertusus at free.fr> - 2005-4
- add a .csh file
- correct defaults in cernlib scripts

* Sun Sep 11 2005 Patrice Dumas <pertusus at free.fr> - 2005-3
- add rm -rf %%{buildroot}

* Thu Sep  1 2005 Patrice Dumas <pertusus at free.fr> - 2005-2
- minor update of cernlib.README
- modify the cernlib script patch to use /usr/X11R6/lib64 if existing

* Tue Jun 09 2005 Patrice Dumas <pertusus at free.fr> - 2005-1
- full rewrite of the spec file from Scientific Linux
- use some ideas and many patches from debian cernlib

cernlib-gxint-script.diff:

--- NEW FILE cernlib-gxint-script.diff ---
--- src/scripts/gxint-old	2005-11-23 23:11:08.000000000 +0100
+++ src/scripts/gxint	2005-11-29 11:42:30.000000000 +0100
@@ -103,15 +103,8 @@
    echo "gxint_Warning: no user program specified"
 fi
  
- 
- 
-if [ -z "$CERN" ] ; then
-  if [ ! -d /cern ]; then
-   echo "gxint_Error: shell variable CERN must be set or /cern must exist"
-   exit 1
-  fi
-  CERN="/cern" ; export CERN
-fi
+# not used after the sed one liner in the spec file 
+if [ -z "$CERN" ] ; then CERN="/usr"; fi
  
 if [ "$drv" = "/GKS" ] ; then
   if [ -z "$GKSR" ] ; then

cernlib-man_static.patch:

--- NEW FILE cernlib-man_static.patch ---
--- cernlib-2006/2006/src/man/man1/cernlib.1.man_static	1998-05-19 18:32:03.000000000 +0200
+++ cernlib-2006/2006/src/man/man1/cernlib.1	2007-04-14 00:59:29.000000000 +0200
@@ -1,18 +1,18 @@
-.TH cernlib 1 "$Date: 1998/05/19 16:32:03 $" "CERN Program Library"
+.TH cernlib-static 1 "$Date: 1998/05/19 16:32:03 $" "CERN Program Library"
 "CERNlib commands" 
 .ds )H Cern Program Library
-.ds ]W cernlib
+.ds ]W cernlib-static
 .SH NAME
-cernlib \- get libraries needed to link with CERN Program Library
+cernlib-static \- get libraries needed to link with CERN Program Library
 .SH SYNOPSIS
-.B cernlib
+.B cernlib-static
 .RI [options]
 .I library[/version]
 .I ...
 
 .SH DESCRIPTION
 
-.B cernlib
+.B cernlib-static
 writes to standard output a list of object libraries needed to link 
 a program with the given 
 .I library(s)
@@ -27,7 +27,7 @@
 
 .SS Options
 
-.B cernlib 
+.B cernlib-static 
 recognizes the following options:
 
 .TP 11
@@ -52,6 +52,10 @@
 obsolete option. Ignored.
 
 .TP 11
+.B -l
+Don't link against system lapack and blas.
+
+.TP 11
 .B -u
 do 
 .B not
@@ -73,7 +77,7 @@
 
 .SS USAGE
 
-.B cernlib 
+.B cernlib-static 
 expects to find the CERNlib directory tree in /cern; if your system does
 not have this, set the environment variable CERN to contain the name of the
 root directory for the CERNlib tree.
@@ -91,16 +95,16 @@
 .SS EXAMPLES
 
 As 
-.B cernlib
+.B cernlib-static
 writes the list of libraries to standard output, using it as a command will 
-show the list of libraries generated by cernlib. Also, it can be used like
+show the list of libraries generated by cernlib-static. Also, it can be used like
 other commands in the command line surrounded by back quotes(`). 
 At CERN you should use the hepf77 command to link on your system as this
 gives the compiler parameters which are compatible with Cernlib  
 (in particular for xlf on IBM/RS6000 and fort77 on HP/UX ) 
 you could type:
 .RS 5
-hepf77 your.o `cernlib`
+hepf77 your.o `cernlib-static`
 .RE
 to link your object file with routines from packlib and kernlib; you need 
 not specify packlib, as this is added automatically. Also all
@@ -108,7 +112,7 @@
 If your application uses graflib and the Motif interface, the command would
 be:
 .RS 5
-hepf77 your.o `cernlib graflib/Motif`
+hepf77 your.o `cernlib-static graflib/Motif`
 .RE
 Again packlib need not be specified.
 .PP
@@ -117,15 +121,15 @@
 .RS 5
  .profile for sh, ksh or similar
 .RS 5
-CERNLIB=`cernlib graflib`; export CERNLIB
+CERNLIB=`cernlib-static graflib`; export CERNLIB
 .RE
  .login for users of csh of similar
 .RS 5
-setenv CERNLIB "`cernlib graflib`"
+setenv CERNLIB "`cernlib-static graflib`"
 .RE
 .RE
 The CERNLIB variable can then be used in the link command instead of
-calling the cernlib command.
+calling the cernlib-static command.
 
 .SS BUGS
 
@@ -141,7 +145,7 @@
 
 .SS FILES
 
-The cernlib command is available in the /cern/pro/bin directory 
+The cernlib-static command is available in the /cern/pro/bin directory 
 in the CERNlib tree. 
 
 .SS CONTACT Address
@@ -153,5 +157,5 @@
 Your report must state which version of CERNlib you are using, or the output of
 the command:
 .RS 5
-what `which cernlib`
+what `which cernlib-static`
 .RE

cernlib-ppc64test.patch:

--- NEW FILE cernlib-ppc64test.patch ---
--- cernlib-2006/2006/src/packlib/Imakefile.ppc64test	2007-05-14 10:26:14.000000000 +0200
+++ cernlib-2006/2006/src/packlib/Imakefile	2007-05-14 12:08:52.000000000 +0200
@@ -16,7 +16,7 @@ InstallLibrary(packlib,$(CERN_LIBDIR))
 InstallLibraryAlias(packlib,packlib-shift,$(CERN_LIBDIR))
 InstallSharedLibrary(packlib,$(LIB_SONAME).$(CERN_LEVEL),$(CERN_SHLIBDIR))
 
-TestSubdirs($(LIBDIRS))
+TestSubdirs(cspack epio fatmen hepdb kapack kuip minuit zbook zebra)
 
 #ifdef CERNLIB_VAXVMS
 


--- NEW FILE cernlib-remove-deadpool ---
#!/bin/sh

set -e
cd .

file=2006_src.tar.gz
result=2006_src-free.tar.gz
echo Unpacking compressed source from $file...
tar xzf $file
for dir in `tr '/' ' ' < ./cernlib-deadpool.txt | awk '{print $1}' \
	| sed -e 's/#.*//g' -e '/$^/d' | sort | uniq` ; do
#	version=`ls -1 | head -n 1`
	version=2006
	echo Removing files with bad copyright from $dir module...
	for badfile in `grep '^'$dir ./cernlib-deadpool.txt \
			| sed 's/\#.*$//g'` ; do
		path=$version/src/$badfile
		[ -e "$path" ] || echo "Skipping non-existent $path ..."
		rm -rf $version/src/$badfile
	done
done
echo Repacking $result.
rm -f $result
tar czf $result $version
rm -rf $version
echo Done.

exit 0


cernlib-script.patch:

--- NEW FILE cernlib-script.patch ---
diff -up cernlib-2006/2006/src/pawlib/paw/programs/paw.script cernlib-2006/2006/src/pawlib/paw/programs/paw
diff -up cernlib-2006/2006/src/graflib/dzdoc/dzedit/dzedit.script cernlib-2006/2006/src/graflib/dzdoc/dzedit/dzedit
diff -up cernlib-2006/2006/src/scripts/cernlib.script cernlib-2006/2006/src/scripts/cernlib
--- cernlib-2006/2006/src/scripts/cernlib.script	2006-12-07 14:26:55.000000000 +0100
+++ cernlib-2006/2006/src/scripts/cernlib	2007-07-25 21:00:54.000000000 +0200
@@ -16,12 +16,17 @@
   [ -z "$CERN_LEVEL" ] && gver="pro" || gver="$CERN_LEVEL"
  
   _P=0  ; _p=0 ;   _u=0 ; Gsys=""
+  #default is to use dynamic lapack
+  _l=1 ;
+  dynlapack=0;
+  dynxbae=0;
   while [ $# -gt 0 ]
   do case $1 in
        -G) Gsys=$2   ; shift ;;
        -P) _P=1              ;;
        -s) _s="is an obsolete option"     ;;
        -u) _u=1 ; _p=1       ;;
+       -l) _l=0              ;;
        -v) gver=$2   ; shift ;;
        --) shift ; break     ;;
         *)         break     ;;
@@ -46,14 +51,38 @@
       [ $# -eq 2 -a $1 != "graflib" ] && lver=$2
       dir=$CERN/$lver/lib
          ln=$1
-      if [ $1 = "kernlib" -o $1 = "packlib" ] ; then
+      if [ $1 = "kernlib" ]; then
          _p=1
       fi
+      if [ $1 = "packlib" -o $1 = "packlib-lesstif" ]; then
+         _p=1
+         ln="packlib.a $dir/libkernlib"
+         [ $1 = "packlib-lesstif" -o z"$Gsys" = 'zMotif' ] && ln="packlib-lesstif.a $dir/lib$ln"
+      fi
+
+      if [ $1 = "geant321" -o $1 = "pawlib" -o $1 = "packlib-lesstif" ]; then
+         [ -z "$Gsys" ] && Gsys="Motif"
+      fi
          [ $1 = "genlib"  ] && ln="mathlib.a $dir/libphtools"
          [ $1 = "bvsl"    ] && ln="mathlib"
          [ $1 = "mpalib"  ] && ln="mathlib"
-         [ $1 = "lapack"  ] && ln="lapack3.a $dir/libblas"
-	 [ $1 = "pawlib"  ] && ln="pawlib.a $dir/liblapack3.a $dir/libblas"
+         if [ $_l -eq 0 ] ; then
+           if [ $1 = "pawlib"  ]; then 
+              ln="pawlib-lesstif.a $dir/libpawlib.a $dir/liblapack3.a $dir/libblas"
+              dynxbae=1
+           fi
+           [ $1 = "lapack"  ] && ln="lapack3.a $dir/libblas"
+         else
+           if [ $1 = "pawlib"  ] ; then 
+              ln="pawlib-lesstif.a $dir/libpawlib"
+              dynxbae=1
+              dynlapack=1
+           fi
+           if [ $1 = "lapack"  ] ; then
+              ln=""
+              dynlapack=1
+           fi
+         fi
          [ $1 = "pythia"  ] && ln="jetset"
       if [ $1 = "GKS" -o $1 = "gks" ] ; then
          drv="X11" ; glib="$1" ; dir="$CERN/gks/$lver/lib"
@@ -69,10 +98,14 @@
          [ $drv = "Motif" ] && drv="X11"
          ln="$ln.a $dir/libgraf$drv"
       fi
-         CERNLIB="$CERNLIB $dir/lib$ln.a"
+      [ -n "$ln" ] && CERNLIB="$CERNLIB $dir/lib$ln.a"
   done
-  [ $_p -eq 0 ] && CERNLIB="$CERNLIB $CERN/$gver/lib/libpacklib.a"
-
+  if [ $_p -eq 0 ]; then 
+       if [ z"$Gsys" = "zMotif" ]; then
+           CERNLIB="$CERNLIB $CERN/$gver/lib/libpacklib-lesstif.a"
+       fi
+       CERNLIB="$CERNLIB $CERN/$gver/lib/libpacklib.a $CERN/$gver/lib/libkernlib.a"
+  fi
 #  get system name
   [ -d /NextAdmin ] && Msys="NeXT" || Msys=`uname -s`
   case $Msys in
@@ -81,7 +114,6 @@
                 ;;
           *)    ;;
   esac
-
  
   if [ -n "$Gsys" ] ; then
      case $Msys in
@@ -110,10 +142,12 @@
                SYSGGL="-lfgl -lgl_s -lm -lbsd" ;
                SYSGMOTIF="-lXm -lXt -lX11 -lPW"
 	       ;;
-      Linux)   [ -d /usr/X386/lib ] && SYSGX11="-L/usr/X386/lib -lX11"
-	       [ -d /usr/X11/lib ] && SYSGX11="-L/usr/X11/lib -lX11"
-	       [ -d /usr/X11R6/lib ] && SYSGX11="-L/usr/X11R6/lib -lX11"
-	       [ -d /usr/X11R6/lib ] && SYSGMOTIF="-L/usr/X11R6/lib -lXm -lXt -lXp -lXext -lX11"
+      Linux)   SYSGX11="-lX11"
+	       SYSGMOTIF="-lXm -lXt -lXp -lXext -lX11"
+	       [ -d /usr/X11R6/lib ] && SYSGX11="-L/usr/X11R6/lib $SYSGX11"
+	       [ -d /usr/X11R6/lib64 ] && SYSGX11="-L/usr/X11R6/lib64 $SYSGX11"
+	       [ -d /usr/X11R6/lib ] && SYSGMOTIF="-L/usr/X11R6/lib $SYSGMOTIF"
+	       [ -d /usr/X11R6/lib64 ] && SYSGMOTIF="-L/usr/X11R6/lib64 $SYSGMOTIF"
 	       [ `uname -m` = ppc ] && SYSGMOTIF="$SYSGMOTIF -lSM -lICE -lXpm"
 	       ;;
       Darwin)  [ -d /usr/X11R6/lib ] && SYSGX11="-L/usr/X11R6/lib -lX11"
@@ -150,7 +184,11 @@
                SYSGMOTIF="-L/usr/lib/X11 -lXm -lXt -lX11 -lm" ;;
      esac
  
+  if [ $_u -eq 0 ] ; then
+     [ $dynxbae = 1 ] && CERNLIB="$CERNLIB -lXbae -lXm -lXaw"
+  fi
             [ -z "$SYSGX11" ]   && SYSGX11="-lX11"
+
      case $Gsys in
        X11) CERNLIB="$CERNLIB $SYSGX11" ;;
      Motif) [ -z "$SYSGMOTIF" ] && SYSGMOTIF="-lXm -lXt $SYSGX11" ;
@@ -212,6 +250,9 @@
      if [ "$Msys" = "Linux" ] ; then
         CERNLIB="$CERNLIB -lnsl -lcrypt -ldl"
      fi
+     if [ $dynlapack = 1 ] ; then
+         CERNLIB="$CERNLIB -llapack -lblas"
+     fi
      if [ "$Msys" = "Darwin" ] ; then
 	 CERNLIB1="$CERNLIB -L/usr/local/lib/system -lcompat -ldl"
      fi
diff -up cernlib-2006/2006/src/patchy/yexpand.script cernlib-2006/2006/src/patchy/yexpand

cernlib-segf_eudtest.patch:

--- NEW FILE cernlib-segf_eudtest.patch ---
--- cernlib-2006/2006/src/mclibs/Imakefile.segf_eudtest	2007-04-21 13:08:47.000000000 +0200
+++ cernlib-2006/2006/src/mclibs/Imakefile	2007-04-21 13:09:58.000000000 +0200
@@ -10,7 +10,8 @@
 
 SUBDIRS = $(LIBDIRS)
 
-TestSubdirs($(LIBDIRS))
+/* eurodec test program segfaults */
+TestSubdirs(cojets pdf photos herwig isajet)
 
 InstallLibSubdirs($(LIBDIRS))
 InstallSharedLibSubdirs($(LIBDIRS))

cernlib-test.patch:

--- NEW FILE cernlib-test.patch ---
--- cernlib-2006/2006/src/geant321/examples/gexam2/Imakefile.test	1997-04-10 17:33:20.000000000 +0200
+++ cernlib-2006/2006/src/geant321/examples/gexam2/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -13,7 +13,7 @@
 
 DefinePackageLibrary(NullParameter)
 
-CernlibFortranProgramTarget(exam2,$(OBJS),$(PACKAGE_LIB),$(PACKAGE_LIB),graflib packlib)
+CernlibFortranProgramTarget(exam2,$(OBJS),NullParameter,NullParameter,graflib packlib geant321)
 
 TestTarget(exam2,gexam2.dat,gexam2.input)
 
--- cernlib-2006/2006/src/geant321/examples/gexam1/Imakefile.test	1997-04-10 17:33:14.000000000 +0200
+++ cernlib-2006/2006/src/geant321/examples/gexam1/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -3,7 +3,7 @@
 
 DefinePackageLibrary(NullParameter)
 
-CernlibFortranProgramTarget(exam1,$(OBJS),$(PACKAGE_LIB),$(PACKAGE_LIB),graflib packlib)
+CernlibFortranProgramTarget(exam1,$(OBJS),NullParameter,NullParameter,graflib packlib geant321)
 
 TestTarget(exam1,gexam1.dat,gexam1.input)
 
--- cernlib-2006/2006/src/geant321/examples/gexam3/Imakefile.test	1997-04-10 17:33:34.000000000 +0200
+++ cernlib-2006/2006/src/geant321/examples/gexam3/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -3,7 +3,7 @@
 
 DefinePackageLibrary(NullParameter)
 
-CernlibFortranProgramTarget(exam3,$(OBJS),$(PACKAGE_LIB),$(PACKAGE_LIB),graflib packlib)
+CernlibFortranProgramTarget(exam3,$(OBJS),NullParameter,NullParameter,graflib packlib geant321)
 
 TestTarget(exam3,gexam3.dat,gexam3.input)
 
--- cernlib-2006/2006/src/geant321/examples/gexam5/Imakefile.test	1997-04-10 17:33:38.000000000 +0200
+++ cernlib-2006/2006/src/geant321/examples/gexam5/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -3,7 +3,7 @@
 
 DefinePackageLibrary(NullParameter)
 
-CernlibFortranProgramTarget(exam5,$(OBJS),$(PACKAGE_LIB),$(PACKAGE_LIB),graflib packlib)
+CernlibFortranProgramTarget(exam5,$(OBJS),NullParameter,NullParameter,graflib packlib geant321)
 
 TestTarget(exam5,gexam5.dat,gexam5.input)
 
--- cernlib-2006/2006/src/geant321/examples/Imakefile.test	1996-03-06 18:31:38.000000000 +0100
+++ cernlib-2006/2006/src/geant321/examples/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -1,7 +1,10 @@
 #define IHaveSubdirs
 #define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)' /* for NamedMakeSubdirs */
 
+/* gexam4 needs fluka
 SUBDIRS= gexam1 gexam2 gexam3 gexam4 gexam5
+*/
+SUBDIRS= gexam1 gexam2 gexam3 gexam5
 
 TestSubdirs($(SUBDIRS))
 
--- cernlib-2006/2006/src/geant321/examples/gexam4/Imakefile.test	1997-04-10 17:33:37.000000000 +0200
+++ cernlib-2006/2006/src/geant321/examples/gexam4/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -14,7 +14,7 @@
 
 DefinePackageLibrary(NullParameter)
 
-CernlibFortranProgramTarget(exam4,$(OBJS),$(PACKAGE_LIB),$(PACKAGE_LIB),graflib packlib)
+CernlibFortranProgramTarget(exam4,$(OBJS),NullParameter,NullParameter,graflib packlib geant321)
 
 TestTarget(exam4,gexam4.dat,gexam4.input)
 
--- cernlib-2006/2006/src/packlib/hbook/tests/Imakefile.test	1996-02-20 16:46:41.000000000 +0100
+++ cernlib-2006/2006/src/packlib/hbook/tests/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -1,6 +1,6 @@
 #if 0
 /* this is not yet understood */
-CernlibFortranProgramTarget(hbtest,test_fp.o,$(PACKAGE_LIB),$(PACKAGE_LIB),NullParameter)
+CernlibFortranProgramTarget(hbtest,test_fp.o,NullParameter,NullParameter,packlib)
 
 
 TestTarget(hbtest)
--- cernlib-2006/2006/src/packlib/hbook/examples/Imakefile.test	1996-02-20 16:46:21.000000000 +0100
+++ cernlib-2006/2006/src/packlib/hbook/examples/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -5,11 +5,11 @@
 
 DefinePackageLibrary(hbtlib)
 
-CernlibFortranProgramTarget(hbtest,hexam.o,$(PACKAGE_LIB),$(PACKAGE_LIB),NullParameter)
+CernlibFortranProgramTarget(hbtest,hexam.o,libhbtlib.a,libhbtlib.a,packlib)
 
-CernlibFortranProgramTarget(hbdiff,htdiffb.o,$(PACKAGE_LIB),$(PACKAGE_LIB),mathlib)
+CernlibFortranProgramTarget(hbdiff,htdiffb.o,libhbtlib.a,libhbtlib.a,mathlib)
 
-CernlibFortranProgramTarget(hmerge,hmerg.o hmergin.o,$(PACKAGE_LIB),$(PACKAGE_LIB),mathlib)
+CernlibFortranProgramTarget(hmerge,hmerg.o hmergin.o,libhbtlib.a,libhbtlib.a,mathlib)
 
 TestTarget(hbtest,NullParameter,NullParameter)
 TestTarget(hbdiff,NullParameter,NullParameter)
--- cernlib-2006/2006/src/packlib/kuip/examples/Imakefile.test	1996-10-02 17:37:00.000000000 +0200
+++ cernlib-2006/2006/src/packlib/kuip/examples/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -5,7 +5,7 @@
 
 DefinePackageLibrary(NullParameter)
 
-CernlibFortranProgramTarget(ktest,$(OBJS),$(PACKAGE_LIB),$(PACKAGE_LIB),graflib packlib kernlib)
+CernlibFortranProgramTarget(ktest,$(OBJS),NullParameter,NullParameter,graflib packlib kernlib)
 
 TestTarget(ktest,NullParameter,ktest.inp)
 
--- cernlib-2006/2006/src/packlib/kapack/test/Imakefile.test	1996-12-02 16:29:51.000000000 +0100
+++ cernlib-2006/2006/src/packlib/kapack/test/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -1,7 +1,7 @@
 
 DefinePackageLibrary(NullParameter)
 
-CernlibFortranProgramTarget(kapack,test1.o,$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
+CernlibFortranProgramTarget(kapack,test1.o,NullParameter,NullParameter,kernlib packlib)
 
 /* the kapack test, or better kamake asks for a file name only in unix.
  *  on VMS, the file is opened on unit 11, resulting in for011.dat
--- cernlib-2006/2006/src/packlib/minuit/examples/Imakefile.test	1997-10-23 19:04:15.000000000 +0200
+++ cernlib-2006/2006/src/packlib/minuit/examples/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -9,6 +9,6 @@
 FDEBUGFLAGS=NoOpFortranDebugFlags
 #endif
 
-CernlibFortranProgramTarget(minuit,$(OBJS),$(PACKAGE_LIB),$(PACKAGE_LIB),NullParameter)
+CernlibFortranProgramTarget(minuit,$(OBJS),NullParameter,NullParameter,packlib)
 
 TestTarget(minuit,NullParameter,NullParameter)
--- cernlib-2006/2006/src/packlib/epio/tests/ptest2/Imakefile.test	1996-03-08 16:21:45.000000000 +0100
+++ cernlib-2006/2006/src/packlib/epio/tests/ptest2/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -10,9 +10,9 @@
 SpecialFortranObjectRule(main_32,main,NullParameter,-DCERNLIB_PH32BIT)
 SpecialFortranObjectRule(test2_32,test2,NullParameter,-DCERNLIB_PH32BIT)
 
-CernlibFortranProgramTarget(ptest2_16,$(OBJS_16) $(OBJS_CO),$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
+CernlibFortranProgramTarget(ptest2_16,$(OBJS_16) $(OBJS_CO),NullParameter,NullParameter,kernlib packlib)
 
-CernlibFortranProgramTarget(ptest2_32,$(OBJS_32) $(OBJS_CO),$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
+CernlibFortranProgramTarget(ptest2_32,$(OBJS_32) $(OBJS_CO),NullParameter,NullParameter,kernlib packlib)
 
 TestTarget(ptest2_32,NullParameter,NullParameter)
 
--- cernlib-2006/2006/src/packlib/epio/tests/ptest3/Imakefile.test	1996-03-08 16:21:46.000000000 +0100
+++ cernlib-2006/2006/src/packlib/epio/tests/ptest3/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -12,9 +12,9 @@
 
 DefinePackageLibrary(NullParameter)
 
-CernlibFortranProgramTarget(ptest3_16,$(OBJS_16) $(OBJS_CO),$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
+CernlibFortranProgramTarget(ptest3_16,$(OBJS_16) $(OBJS_CO),NullParameter,NullParameter,kernlib packlib)
 
-CernlibFortranProgramTarget(ptest3_32,$(OBJS_32) $(OBJS_CO),$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
+CernlibFortranProgramTarget(ptest3_32,$(OBJS_32) $(OBJS_CO),NullParameter,NullParameter,kernlib packlib)
 
 TestTarget(ptest3_32,NullParameter,NullParameter)
 
--- cernlib-2006/2006/src/packlib/epio/tests/ptest1/Imakefile.test	1996-03-08 16:21:45.000000000 +0100
+++ cernlib-2006/2006/src/packlib/epio/tests/ptest1/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -11,9 +11,9 @@
 
 DefinePackageLibrary(NullParameter)
 
-CernlibFortranProgramTarget(ptest1_16,$(OBJS_16) $(OBJS_CO),$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
+CernlibFortranProgramTarget(ptest1_16,$(OBJS_16) $(OBJS_CO),NullParameter,NullParameter,kernlib packlib)
 
-CernlibFortranProgramTarget(ptest1_32,$(OBJS_32) $(OBJS_CO),$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
+CernlibFortranProgramTarget(ptest1_32,$(OBJS_32) $(OBJS_CO),NullParameter,NullParameter,kernlib packlib)
 
 TestTarget(ptest1_32,NullParameter,NullParameter)
 
--- cernlib-2006/2006/src/packlib/zbook/test/Imakefile.test	1996-03-12 09:13:30.000000000 +0100
+++ cernlib-2006/2006/src/packlib/zbook/test/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -5,6 +5,6 @@
 
 SubdirLibraryTarget(zbookt,NullParameter)
 
-CernlibFortranProgramTarget(zexam,zexam.o,$(PACKAGE_LIB),$(PACKAGE_LIB),packlib)
+CernlibFortranProgramTarget(zexam,zexam.o,libzbookt.a,libzbookt.a,packlib)
 
 TestTarget(zexam,NullParameter,NullParameter)
--- cernlib-2006/2006/src/packlib/ffread/test/Imakefile.test	1996-10-02 17:36:27.000000000 +0200
+++ cernlib-2006/2006/src/packlib/ffread/test/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -2,7 +2,7 @@
 
 DefinePackageLibrary(NullParameter)
 
-CernlibFortranProgramTarget(ffread,$(OBJS),$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
+CernlibFortranProgramTarget(ffread,$(OBJS),NullParameter,NullParameter,kernlib packlib)
 
 TestTarget(ffread,NullParameter,test.input)
 
--- cernlib-2006/2006/src/packlib/zebra/test/Imakefile.test	1997-08-29 15:33:57.000000000 +0200
+++ cernlib-2006/2006/src/packlib/zebra/test/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -41,27 +41,27 @@
 
 testrz: zebrz1 zebrz2 zebrz3
 
-CernlibFortranProgramTarget(zebmz1,zebmz1.o,$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
+CernlibFortranProgramTarget(zebmz1,zebmz1.o,libzebtlib.a,libzebtlib.a,kernlib packlib)
 
-CernlibFortranProgramTarget(zebfz1,zebfz1.o,$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
-CernlibFortranProgramTarget(zebfz2,zebfz2.o,$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
-CernlibFortranProgramTarget(zebfz3,zebfz3.o,$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
-CernlibFortranProgramTarget(zebfz4,zebfz4.o,$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
-CernlibFortranProgramTarget(zebfz5,zebfz5.o,$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
-CernlibFortranProgramTarget(zebfz6,zebfz6.o,$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
-CernlibFortranProgramTarget(zebfz7,zebfz7.o,$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
-CernlibFortranProgramTarget(zebfz8,zebfz8.o,$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
-CernlibFortranProgramTarget(zebfz9,zebfz9.o,$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
-
-CernlibFortranProgramTarget(zebfc1,zebfc1.o,$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
-CernlibFortranProgramTarget(zebfc2,zebfc2.o,$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
-CernlibFortranProgramTarget(zebfc3,zebfc3.o,$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
-
-CernlibFortranProgramTarget(zebjz1,zebjz1.o,$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
-
-CernlibFortranProgramTarget(zebrz1,zebrz1.o,$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
-CernlibFortranProgramTarget(zebrz2,zebrz2.o,$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
-CernlibFortranProgramTarget(zebrz3,zebrz3.o,$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
+CernlibFortranProgramTarget(zebfz1,zebfz1.o,libzebtlib.a,libzebtlib.a,kernlib packlib)
+CernlibFortranProgramTarget(zebfz2,zebfz2.o,libzebtlib.a,libzebtlib.a,kernlib packlib)
+CernlibFortranProgramTarget(zebfz3,zebfz3.o,libzebtlib.a,libzebtlib.a,kernlib packlib)
+CernlibFortranProgramTarget(zebfz4,zebfz4.o,libzebtlib.a,libzebtlib.a,kernlib packlib)
+CernlibFortranProgramTarget(zebfz5,zebfz5.o,libzebtlib.a,libzebtlib.a,kernlib packlib)
+CernlibFortranProgramTarget(zebfz6,zebfz6.o,libzebtlib.a,libzebtlib.a,kernlib packlib)
+CernlibFortranProgramTarget(zebfz7,zebfz7.o,libzebtlib.a,libzebtlib.a,kernlib packlib)
+CernlibFortranProgramTarget(zebfz8,zebfz8.o,libzebtlib.a,libzebtlib.a,kernlib packlib)
+CernlibFortranProgramTarget(zebfz9,zebfz9.o,libzebtlib.a,libzebtlib.a,kernlib packlib)
+
+CernlibFortranProgramTarget(zebfc1,zebfc1.o,libzebtlib.a,libzebtlib.a,kernlib packlib)
+CernlibFortranProgramTarget(zebfc2,zebfc2.o,libzebtlib.a,libzebtlib.a,kernlib packlib)
+CernlibFortranProgramTarget(zebfc3,zebfc3.o,libzebtlib.a,libzebtlib.a,kernlib packlib)
+
+CernlibFortranProgramTarget(zebjz1,zebjz1.o,libzebtlib.a,libzebtlib.a,kernlib packlib)
+
+CernlibFortranProgramTarget(zebrz1,zebrz1.o,libzebtlib.a,libzebtlib.a,kernlib packlib)
+CernlibFortranProgramTarget(zebrz2,zebrz2.o,libzebtlib.a,libzebtlib.a,kernlib packlib)
+CernlibFortranProgramTarget(zebrz3,zebrz3.o,libzebtlib.a,libzebtlib.a,kernlib packlib)
 
 TestTarget(zebmz1,zxtest.dat,NullParameter)
 
--- cernlib-2006/2006/src/phtools/wicoexam/Imakefile.test	1996-03-22 17:42:50.000000000 +0100
+++ cernlib-2006/2006/src/phtools/wicoexam/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -1,5 +1,5 @@
 DefinePackageLibrary(NullParameter)
 
-CernlibFortranProgramTarget(wicot,wicoex.o,$(PACKAGE_LIB),$(PACKAGE_LIB),NullParameter)
+CernlibFortranProgramTarget(wicot,wicoex.o,NullParameter,NullParameter,packlib phtools)
 
 TestTarget(wicot,NullParameter,NullParameter)
--- cernlib-2006/2006/src/mathlib/bvsl/test/Imakefile.test	1996-03-21 18:19:55.000000000 +0100
+++ cernlib-2006/2006/src/mathlib/bvsl/test/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -6,7 +6,7 @@
 
 DefinePackageLibrary(bvsltst)
 
-CernlibFortranProgramTarget(bvslt,tsbvsl.o,$(PACKAGE_LIB),$(PACKAGE_LIB),mathlib kernlib)
+CernlibFortranProgramTarget(bvslt,tsbvsl.o,libbvsltst.a,libbvsltst.a,mathlib kernlib)
 
 TestTarget(bvslt,NullParameter,NullParameter)
 
--- cernlib-2006/2006/src/mathlib/gen/tests/Imakefile.test	2005-03-24 17:40:10.000000000 +0100
+++ cernlib-2006/2006/src/mathlib/gen/tests/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -63,7 +63,7 @@
 
 DefinePackageLibrary(gentest)
 
-CernlibFortranProgramTarget(gent,main.o,$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
+CernlibFortranProgramTarget(gent,main.o,libgentest.a,libgentest.a,packlib mathlib)
 
 
 TestTarget(gent,NullParameter,NullParameter)
--- cernlib-2006/2006/src/mclibs/eurodec/eudtest/Imakefile.test	1997-03-14 18:32:14.000000000 +0100
+++ cernlib-2006/2006/src/mclibs/eurodec/eudtest/Imakefile	2007-04-21 11:15:36.000000000 +0200
@@ -4,11 +4,10 @@
 
 FORTRANSAVEOPTION = FortranSaveFlags
 
-CernlibFortranProgramTarget(eudtest,$(OBJS),$(PACKAGE_LIB),$(PACKAGE_LIB),packlib)
+CernlibFortranProgramTarget(eudtest,$(OBJS),NullParameter,NullParameter,packlib eurodec)
 
 TestTarget(eudtest,eurodec.dat,eutitle.dat)
 
 CopyFile(eutitle.data,eutitle.dat)
 
 LinkFileFromDir($(TOP)$(PACKAGETOP),eurodec.dat)
-
--- cernlib-2006/2006/src/mclibs/herwig/test/Imakefile.test	1997-01-06 18:06:42.000000000 +0100
+++ cernlib-2006/2006/src/mclibs/herwig/test/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -4,6 +4,6 @@
 DefinePackageLibrary(NullParameter)
 
 
-CernlibFortranProgramTarget(herwigt,test.o,$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
+CernlibFortranProgramTarget(herwigt,test.o,NullParameter,NullParameter,kernlib herwig)
 
 TestTarget(herwigt,NullParameter,NullParameter)
--- cernlib-2006/2006/src/mclibs/cojets/test/Imakefile.test	1996-03-27 10:32:16.000000000 +0100
+++ cernlib-2006/2006/src/mclibs/cojets/test/Imakefile	2007-04-21 09:30:47.000000000 +0200
@@ -3,7 +3,7 @@
 
 DefinePackageLibrary(NullParameter)
 
-CernlibFortranProgramTarget(cojetst,test.o,$(PACKAGE_LIB),$(PACKAGE_LIB),mathlib kernlib)
+CernlibFortranProgramTarget(cojetst,test.o,NullParameter,NullParameter,mathlib kernlib cojets)
 
 CopyFile(test.input,test.in)
 
--- cernlib-2006/2006/src/mclibs/photos/test/Imakefile.test	1999-03-26 11:53:26.000000000 +0100
+++ cernlib-2006/2006/src/mclibs/photos/test/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -2,6 +2,6 @@
 
 DefinePackageLibrary(NullParameter)
 
-CernlibFortranProgramTarget(photost,phodem.o pseudo_jetset.o,$(PACKAGE_LIB),$(PACKAGE_LIB),kernlib)
+CernlibFortranProgramTarget(photost,phodem.o pseudo_jetset.o,NullParameter,NullParameter,kernlib photos)
 
 TestTarget(photost,NullParameter,NullParameter)
--- cernlib-2006/2006/src/mclibs/isajet/test/Imakefile.test	2007-04-21 09:29:29.000000000 +0200
+++ cernlib-2006/2006/src/mclibs/isajet/test/Imakefile	2007-04-21 09:30:54.000000000 +0200
@@ -6,9 +6,12 @@
 
 LinkFileFromDir($(TOP)$(PACKAGETOP),isajet.dat)
 
-CernlibFortranProgramTarget(isajett,isajett.o,$(PACKAGE_LIB),$(PACKAGE_LIB),pdflib804 mathlib kernlib)
+CernlibFortranProgramTarget(isajett,isajett.o,NullParameter,NullParameter,pdflib804 mathlib kernlib isajet)
 
 #if !defined(CERNLIB_GFORTRAN)
 /* breaks on 'STOP 99' if compiled with gfortran */
 TestTarget(isajett,isajet.dat,test.input)
 #endif
+#if defined(CERNLIB_GFORTRAN)
+test::
+#endif
--- cernlib-2006/2006/src/mclibs/pdf/tpdf/Imakefile.test	2000-04-19 15:52:13.000000000 +0200
+++ cernlib-2006/2006/src/mclibs/pdf/tpdf/Imakefile	2007-04-21 09:29:30.000000000 +0200
@@ -13,13 +13,13 @@
 DefinePackageLibrary(NullParameter)
 
 
-CernlibFortranProgramTarget(testpdf,testpdf.o,$(PACKAGE_LIB),$(PACKAGE_LIB),mathlib)
+CernlibFortranProgramTarget(testpdf,testpdf.o,NullParameter,NullParameter,mathlib pdflib)
 
-CernlibFortranProgramTarget(testpdg,testpdg.o,$(PACKAGE_LIB),$(PACKAGE_LIB),mathlib)
+CernlibFortranProgramTarget(testpdg,testpdg.o,NullParameter,NullParameter,mathlib pdflib)
 
-CernlibFortranProgramTarget(testgam,testgam.o,$(PACKAGE_LIB),$(PACKAGE_LIB),mathlib)
+CernlibFortranProgramTarget(testgam,testgam.o,NullParameter,NullParameter,mathlib pdflib)
 
-CernlibFortranProgramTarget(test_npdf,test_npdf.o,$(PACKAGE_LIB),$(PACKAGE_LIB),mathlib)
+CernlibFortranProgramTarget(test_npdf,test_npdf.o,NullParameter,NullParameter,mathlib pdflib)
 
 TestTarget(testpdf,NullParameter,NullParameter)
 TestTarget(testpdg,NullParameter,NullParameter)


--- NEW FILE cernlib.README ---
The change done with regard with the CERN library are as follow:

1) Package organization

The main package is cernlib-devel which includes the cernlib static 
libraries, include files and data files. Different versions (corresponding 
with years) of the cernlib can be installed along.

The other packages can't have different versions installed in parallel.

The package cernlib-utils contains the cernlib script which can be used
to compile the cernlib library, and /etc/profile.d/cernlib-<version>.sh
which sets the environment variables usefull for the cernlib.

The package kuipc contains the kuipc interpreter, paw contains the paw
binary, and cernlib-packlib contains the other binaries from the 
cernlib.

2) Filesystem Hierarchy Standard conformance

The upstream Cernlib installs in the subdirectories (bin, lib, include...) 
of the $CERN_ROOT directory which is usually $CERN/$CERN_LEVEL. A mix of
this approach and a standard FHS conformant approach has been followed here. 

For the libraries, the Cernlib upstream scheme has been retained, with 
CERN=/usr/lib/cernlib
CERN_LEVEL=2005
and therefore the libraries are in /usr/lib/cernlib/2005/lib. The 
environment variables are set in /etc/profile.d/cernlib-<version>.sh.

For the include files and the data files the subdirectory cernlib/2005
appears in the FHS location, without subdirectories, therefore we have the
equivalences:
$CERN_ROOT/include     ->     /usr/include/cernlib/$CERN_LEVEL/
$CERN_ROOT/share       ->     /usr/share/cernlib/$CERN_LEVEL/

The binary files go into /usr/bin.

3) Removal of non-free code

Debian patches and files from the debian Cernlib package where used to remove
files licensed under non-GPL compatible licences. The script 
cernlib-remove-deadpool and the file cernlib-deadpool.txt which lists 
problematic files can be used in the SOURCES directory with the 
upstream sources to remove the problematic files.

4) Use of external lapack

The cernlib script has been modified to use an external lapack and not
the one provided with the cernlib.

5) kernlib out of packlib

kernlib has been moved outside of packlib. If you use the cernlib script
for linking it should be taken into account, however if you link directly
with packlib you could need to add the kernlib on your link command line.

6) split of motif dependent libs from packlib and pawlib

The motif dependent libs are in libpacklib-lesstif and libpawlib-lesstif.


--- NEW FILE cernlib.csh.in ---
setenv CERN "==CERN=="
setenv CERN_LEVEL "==CERN_LEVEL=="
setenv CERN_VER "$CERN_LEVEL"
setenv CERN_ROOT "$CERN/$CERN_LEVEL"


--- NEW FILE cernlib.m4 ---
dnl                                                      -*- Autoconf -*- 
dnl  autoconf macros for the cernlib libraries
dnl  Copyright (C) 2004, 2005 Patrice Dumas
dnl
dnl  This program is free software; you can redistribute it and/or modify
dnl  it under the terms of the GNU General Public License as published by
dnl  the Free Software Foundation; either version 2 of the License, or
dnl  (at your option) any later version.
dnl
dnl  This program is distributed in the hope that it will be useful,
dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dnl  GNU General Public License for more details.
dnl
dnl  You should have received a copy of the GNU General Public License
dnl  along with this program; if not, write to the Free Software
dnl  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

dnl A basic example of the macro usage:
dnl 
dnl AC_LIB_CERNLIB(kernlib,CLTOU,
dnl [
dnl    AC_LIB_CERNLIB(mathlib,GAUSS,[LIBS="$CERNLIB_LIBS $LIBS"])
dnl ])

dnl
dnl --with-static-cernlib forces the static or dynamic linking.
dnl --with-cernlib gives the location of cernlib.
dnl
dnl If the type of linking isn't specified it is assumed to be static.
dnl
dnl For static linking:
dnl - if the binary program 'cernlib-static' or 'cernlib' is in the path it is 
dnl   assumed that a static linking using the information reported by that 
dnl   script is wanted.
dnl - otherwise if the environment variable CERNLIB exists it is assumed to 
dnl   be the location of the static library.
dnl - otherwise if the environment variable CERN_ROOT exists it is assumed 
dnl   that CERN_ROOT/lib is the location of the static library.
dnl - otherwise a simple linking is performed.
dnl 
dnl If a dynamic linking is selected:
dnl - if the binary program 'cernlib' is in the path it is assumed that it 
dnl   is the debian script and it is called with -dy.
dnl - otherwise a simple linking is performed.
dnl
dnl AC_LIB_CERNLIB ([LIBRARY = kernlib], [FUNCTION = CLTOU], [ACTION-IF-FOUND],
dnl          [ACTION-IF-NOT-FOUND]) 
dnl should be called afterwards for each of the cernlib library needed. 
dnl Based on the information collected by AC_CERNLIB the needed flags are 
dnl added to the linking flags or the files and flags are added to the 
dnl $CERNLIB_LIBS shell variable and a test of linking is performed.
dnl
dnl The static library linking flags and files are in $CERNLIB_LIBS.


# AC_CERNLIB check for cernlib location and whether it should be 
# statically linked or not.
AC_DEFUN([AC_CERNLIB], [
CERNLIB_PATH=
CERNLIB_LIB_PATH=
CERNLIB_BIN_PATH=
CERNLIB_STATIC=yes
AC_ARG_WITH(static_cernlib,
[  --with-static-cernlib             link statically with the cernlib],
[  CERNLIB_STATIC=$withval      ])

AC_ARG_WITH(cernlib,
[  --with-cernlib           cernlib location],
[  CERNLIB_PATH=$withval    
   CERNLIB_LIB_PATH=$CERNLIB_PATH/lib
   CERNLIB_BIN_PATH=$CERNLIB_PATH/bin
])

CERNLIB_BIN=

if test "z$CERNLIB_STATIC" != "zno"; then    
    CERNLIB_STATIC=yes
    if test "z$CERNLIB_PATH" = z; then
        AC_PATH_PROG(CERNLIB_BIN, cernlib-static, no)
        if test $CERNLIB_BIN = no; then
            AC_PATH_PROG(CERNLIB_BIN, cernlib, no)
        fi
    else
        AC_PATH_PROG(CERNLIB_BIN, cernlib-static, no, [$CERNLIB_BIN_PATH:$PATH])
        if test $CERNLIB_BIN = no; then
            AC_PATH_PROG(CERNLIB_BIN, cernlib, no, [$CERNLIB_BIN_PATH:$PATH])
        fi
        if test $CERNLIB_BIN = no; then
            if test "z$CERNLIB" != z -a -d "$CERNLIB"; then
               CERNLIB_LIB_PATH=$CERNLIB
               AC_MSG_NOTICE([using the CERNLIB environment variable for cernlib location])
            elif test "z$CERN_ROOT" != z -a -d "$CERN_ROOT/lib"; then
                CERNLIB_LIB_PATH=$CERN_ROOT/lib
                AC_MSG_NOTICE([using the CERN_ROOT environment variable for cernlib location])
            fi
        fi
    fi
else
    if test "z$CERNLIB_PATH" = z; then
         AC_PATH_PROG(CERNLIB_BIN, cernlib, no)
    else
         AC_PATH_PROG(CERNLIB_BIN, cernlib, no, [$CERNLIB_BIN_PATH:$PATH])
         LDFLAGS="$LDFLAGS -L$CERNLIB_LIB_PATH"
    fi
fi
])

# AC_LIB_CERNLIB ([LIBRARY = kernlib], [FUNCTION = CLTOU], [ACTION-IF-FOUND],
#          [ACTION-IF-NOT-FOUND]) 
# check for a function in a library of the cernlib
AC_DEFUN([AC_LIB_CERNLIB], [
AC_REQUIRE([AC_CERNLIB])

cernlib_lib_ok="no"

if test "z$1" = z; then
    cern_library=kernlib
else
    cern_library=$1
fi

if test "z$2" = z; then
    cern_func=CLTOU
else
    cern_func=$2
fi

save_CERNLIB_LIBS=$CERNLIB_LIBS
save_LIBS=$LIBS

if test "z$CERNLIB_STATIC" = "zyes"; then
    cernlib_lib_static_found=no
    AC_MSG_NOTICE([cernlib: linking with a static $cern_library])
    if test "z$CERNLIB_BIN" != "zno"; then
        cernlib_bin_out=`$CERNLIB_BIN $cern_library`
        CERNLIB_LIBS="$cernlib_bin_out $CERNLIB_LIBS"
        cernlib_lib_static_found=yes
    elif test "z$CERNLIB_LIB_PATH" != z; then
dnl .a for UNIX libraries only ?
        if test -f "$CERNLIB_LIB_PATH/lib${cern_library}.a"; then 
            CERNLIB_LIBS="$CERNLIB_LIB_PATH/lib${cern_library}.a $CERNLIB_LIBS"
            cernlib_lib_static_found=yes
        fi
    fi
    if test "z$cernlib_lib_static_found" = zno; then
        AC_MSG_WARN([cannot determine the cernlib location for static linking])
    fi
else
    AC_MSG_NOTICE([trying a dynamical link with $cern_library])
    if test "z$CERNLIB_BIN" != "zno"; then
        # try link with debian cernlib script with -dy
        cernlib_bin_out=`$CERNLIB_BIN -dy $cern_library`
        CERNLIB_LIBS="$cernlib_bin_out $CERNLIB_LIBS"
    else
        CERNLIB_LIBS="-l$cern_library $CERNLIB_LIBS"
    fi
fi

dnl now try the link
LIBS="$CERNLIB_LIBS $LIBS"
AC_LANG_PUSH(Fortran 77)
AC_LINK_IFELSE([      program main
      call $cern_func
      end
], 
[ 
    cernlib_lib_ok=yes
],
[
    CERNLIB_LIBS=$save_CERNLIB_LIBS
])
AC_LANG_POP(Fortran 77)
LIBS=$save_LIBS
AC_SUBST([CERNLIB_LIBS])

AS_IF([test x"$cernlib_lib_ok" = xyes],
      [m4_default([$3], [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_CERNLIB_${cern_library}_${cern_func}))
      ])],
      [
       AC_MSG_WARN([cannot link $cern_func in lib$cern_library ])
       $4
      ])

])


--- NEW FILE cernlib.sh.in ---
export CERN===CERN==
export CERN_LEVEL===CERN_LEVEL==
export CERN_VER=$CERN_LEVEL
export CERN_ROOT=$CERN/$CERN_LEVEL


--- NEW FILE geant321-001-fix-missing-fluka.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 001-fix-missing-fluka.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Deal with FLUKA code having been purged from Debian's Cernlib source.

@DPATCH@
diff -urNad geant321-3.21.14~/src/geant321/Imakefile geant321-3.21.14/src/geant321/Imakefile
--- geant321-3.21.14~/src/geant321/Imakefile	1998-03-05 06:20:07.000000000 -0500
+++ geant321-3.21.14/src/geant321/Imakefile	2007-01-30 17:37:26.209615233 -0500
@@ -4,10 +4,11 @@
 
 AllTarget(geant321)
 
-LIBDIRS= block cdf cgpack fiface fluka gbase gcons gdraw \ @@\
+/* Fluka removed from Debian source package for copyright reasons. */
+LIBDIRS=       cdf cgpack              gbase gcons gdraw \ @@\
          geocad ggeom gheisha ghits ghrout ghutils giface \ @@\
 	 giopa gkine gphys gscan gstrag gtrak guser gxint \ @@\
-	 miface miguti neutron peanut
+	 miface miguti neutron
 
 
 SUBDIRS= $(LIBDIRS) data examples gxuser geant321
@@ -25,9 +26,12 @@
 InstallLibrary(geant321,$(CERN_LIBDIR))
 InstallLibraryAlias(geant321,geant,$(CERN_LIBDIR))
 
+/* Fluka removed from Debian source package for copyright reasons. */
+/*
 SubdirDataFile($(LIBRARY),flukaaf.dat,data)
 
 InstallNonExecFileTarget(install.lib,flukaaf.dat,$(CERN_LIBDIR))
+*/
 
 /* This will install the correct link for xsneut95.dat at CERN;
  * If you want a local copy of the file, just copy it there
diff -urNad geant321-3.21.14~/src/geant321/geant321/gcnmec.inc geant321-3.21.14/src/geant321/geant321/gcnmec.inc
--- geant321-3.21.14~/src/geant321/geant321/gcnmec.inc	1995-10-24 06:20:31.000000000 -0400
+++ geant321-3.21.14/src/geant321/geant321/gcnmec.inc	2007-01-30 17:39:15.301513801 -0500
@@ -16,13 +16,14 @@
       PARAMETER(NMECA=45,IBLOWN=23)
       CHARACTER*4 CHNMEC(NMECA)
 *
-* *** Two blank spaces for FISF and CAPF which do not exist
+* *** Null out all FLUKA mechanisms since we've removed FLUKA code
+* *** for DFSG reasons.  -- Kevin McCarty, for Debian
 *
 * *** The low-neutron cross-sections have to be at the end for the
 * *** logics of the routine to work, and they have to start at
 * *** IBLOWN
       DATA CHNMEC /
-     +     'HADF',  'INEF',  'ELAF',  'NULL',  'NULL',
+     +     'NULL',  'NULL',  'NULL',  'NULL',  'NULL',
      +     'HADG',  'INEG',  'ELAG',  'FISG',  'CAPG',
      +     'LOSS',  'PHOT',  'ANNI',  'COMP',  'BREM',
      +     'PAIR',  'DRAY',  'PFIS',  'RAYL',  'MUNU',
diff -urNad geant321-3.21.14~/src/geant321/miface/Imakefile geant321-3.21.14/src/geant321/miface/Imakefile
--- geant321-3.21.14~/src/geant321/miface/Imakefile	1995-10-24 06:21:53.000000000 -0400
+++ geant321-3.21.14/src/geant321/miface/Imakefile	2007-01-30 17:37:26.319591944 -0500
@@ -1,5 +1,5 @@
 SRCS_F= \ @@\
-	 gfmdis.F gfmfin.F gmicap.F gmiset.F gmorin.F gmplxs.F gmxsec.F
+	                   gmicap.F gmiset.F gmorin.F gmplxs.F gmxsec.F
 
 #ifdef CERNLIB_QMVAOS
  FORTRANSAVEOPTION=FortranSaveFlags


--- NEW FILE geant321-003-geant-dummy-functions.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 003-geant-dummy-functions.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Add stub Geant functions to avoid missing symbols due to Fluka removal.

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/geant321/gkine/Imakefile cernlib-2005.05.09.dfsg/src/geant321/gkine/Imakefile
--- cernlib-2005.05.09.dfsg~/src/geant321/gkine/Imakefile	1996-03-28 16:21:20.000000000 +0000
+++ cernlib-2005.05.09.dfsg/src/geant321/gkine/Imakefile	2005-11-29 15:59:27.035065621 +0000
@@ -1,6 +1,9 @@
 SRCS_F= gfkine.F gfvert.F gludky.F glund.F glundi.F gpkine.F \ @@\
 	gpkinx.F gpvert.F gskine.F gskinu.F gsvert.F gsveru.F gtau.F
 
+/* Dummy file containing stubs for deleted Fluka and mclibs functions: */
+SRCS_C= dummy.c
+
 #ifdef CERNLIB_QMVAOS
  FORTRANSAVEOPTION=FortranSaveFlags
  FORTRANOPTIONS = -math_library accurate $(FORTRANSAVEOPTION)
diff -urNad cernlib-2005.05.09.dfsg~/src/geant321/gkine/dummy.c cernlib-2005.05.09.dfsg/src/geant321/gkine/dummy.c
--- cernlib-2005.05.09.dfsg~/src/geant321/gkine/dummy.c	1970-01-01 00:00:00.000000000 +0000
+++ cernlib-2005.05.09.dfsg/src/geant321/gkine/dummy.c	2005-11-29 16:55:14.274440352 +0000
@@ -0,0 +1,205 @@
+/* Dummy file to avoid undefined symbols in the library */
+/* Kevin McCarty, 14 Jan 2003 */
+/* Last revised 22 November 2005 */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* Want the dummy functions to be weakly defined so they may be overridden
+ * without error. */
+
+#define kludge(x)    #x
+#define stringify(x) kludge(x)
+#define underline(x) __ ## x
+
+#define DUMMY(domain, UPPERNAME, fortranname_, returntype) \
+returntype fortranname_() {print_dummy(#domain,#UPPERNAME);}
+
+#define WEAKDUMMY(domain, UPPERNAME, fortranname_, returntype) \
+static returntype underline(fortranname_)() {print_dummy(#domain,#UPPERNAME);} \
+void fortranname_() \
+	__attribute__ ((weak, alias (stringify(underline(fortranname_))) ))
+
+static void print_dummy(const char *domain, const char *function)
+{
+  fprintf(stderr, "Geant321: Now in dummy %s routine.\n", function);
+  fprintf(stderr,
+"If you see this message, you are presumably trying to call (possibly\n"
+"indirectly) the %s routine");
+
+  if (strcmp(domain, "Jetset") == 0)
+    fprintf(stderr,
+" in the Jetset library.\n"
+#if defined (CERNLIB_DEBIAN)
+"To obtain the Jetset library, please see the file\n"
+"/usr/share/doc/geant321/README.Debian\n"
+#endif
+    );
+
+  else if (strcmp(domain, "Fluka") == 0)
+    fprintf(stderr,
+" in the FLUKA library.\n"
+"FLUKA is unfortunately not available in this distribution of Cernlib for\n"
+"licensing reasons"
+#if defined (CERNLIB_DEBIAN)
+"; please see the file /usr/share/doc/geant321/README.Debian\n"
+"for details.\n"
+#else
+".\n"
+#endif
+    );
+  
+  else if (strcmp(domain, "User") == 0)
+    fprintf(stderr, ".  This routine is not built into Geant;\n"
+"you must write code for it yourself.  Please see the documentation"
+#if defined (CERNLIB_DEBIAN)
+"\n(for instance in the geant321-doc package)"
+#endif
+".\n");
+  
+  exit(EXIT_FAILURE);
+}
+
+/* Functions that the user is supposed to set up */
+WEAKDUMMY(User, UGINIT, uginit_, void);
+WEAKDUMMY(User, UGLAST, uglast_, void);
+
+/* Functions in the non-free Jetset library, which can be used
+ * if it's installed */
+WEAKDUMMY(Jetset, LU1ENT, lu1ent_, void);
+WEAKDUMMY(Jetset, LUCOMP, lucomp_, int);
+WEAKDUMMY(Jetset, LUEEVT, lueevt_, void);
+WEAKDUMMY(Jetset, LUEXEC, luexec_, void);
+
+/* N.B.  When the libgeant321 dynamic soversion is bumped, at the same time
+ * everything below this point except the dummy FLDIST and FLINIT subroutines
+ * may be deleted; those should be turned into weak aliases in case anyone
+ * wants to create a separate GEANT-FLUKA library. */
+
+/* From src/geant321/fluka (not the complete set of functions, just
+ * those referenced from external files) */
+WEAKDUMMY(Fluka, DOST,   dost_,   double);
+WEAKDUMMY(Fluka, EEXLVL, eexlvl_, void);
+WEAKDUMMY(Fluka, EVENTV, eventv_, void);
+WEAKDUMMY(Fluka, EVEVAP, evevap_, void);
+WEAKDUMMY(Fluka, EVVINI, evvini_, void);
+WEAKDUMMY(Fluka, FKENER, fkener_, double);
+WEAKDUMMY(Fluka, FKZERO, fkzero_, void);
+WEAKDUMMY(Fluka, NIZLNW, nizlnw_, void);
+WEAKDUMMY(Fluka, NUCREL, nucrel_, void);
+WEAKDUMMY(Fluka, RACO,   raco_,   void);
+WEAKDUMMY(Fluka, SAMCST, samcst_, void);
+WEAKDUMMY(Fluka, SIGEL,  sigel_,  void);
+WEAKDUMMY(Fluka, SITSAO, sitsao_, double);
+
+/* The following dummy functions are added due to the removal
+ * of the corresponding code from Geant (it is also part of FLUKA).
+ * We are constrained to keep the ABI for the dynamic library, so
+ * these dummy functions must be kept until next time the libgeant321
+ * soversion is changed. */
+
+/* From src/geant321/fiface */
+DUMMY(Fluka, FLDIST, fldist_, void);
+DUMMY(Fluka, FLINIT, flinit_, void);
+DUMMY(Fluka, FLUFIN, flufin_, void);
+
+/* From src/geant321/miface */
+DUMMY(Fluka, GFMFIN, gfmfin_, void);
+DUMMY(Fluka, GFMDIS, gfmdis_, void);
+
+/* From src/geant321/block */
+DUMMY(Fluka, FDEVAP, fdevap_, void);
+DUMMY(Fluka, FDNOPT, fdnopt_, void);
+DUMMY(Fluka, FDPREE, fdpree_, void);
+DUMMY(Fluka, FLKDT1, flkdt1_, void);
+DUMMY(Fluka, FLKDT2, flkdt2_, void);
+DUMMY(Fluka, FLKDT3, flkdt3_, void);
+DUMMY(Fluka, FLKDT4, flkdt4_, void);
+DUMMY(Fluka, FLKDT5, flkdt5_, void);
+DUMMY(Fluka, FLKDT6, flkdt6_, void);
+DUMMY(Fluka, FLKDT7, flkdt7_, void);
+
+/* From src/geant321/peanut */
+DUMMY(Fluka, BIMNXT, bimnxt_, void);   /* alternate entry to BIMSEL */
+DUMMY(Fluka, BIMSEL, bimsel_, void);
+DUMMY(Fluka, COSLEG, cosleg_, double);
+DUMMY(Fluka, FEKFNC, fekfnc_, double);
+DUMMY(Fluka, FPFRNC, fpfrnc_, double);
+DUMMY(Fluka, FRADNC, fradnc_, double);
+DUMMY(Fluka, FRHINC, frhinc_, double);
+DUMMY(Fluka, FRHONC, frhonc_, double);
+DUMMY(Fluka, NCLVFX, nclvfx_, double); /* alternate entry to PFNCLV */
+DUMMY(Fluka, NCLVIN, nclvin_, void);
+DUMMY(Fluka, NCLVST, nclvst_, void);
+DUMMY(Fluka, NUCNUC, nucnuc_, void);
+DUMMY(Fluka, NWINXT, nwinxt_, void);   /* alternate entry to NWISEL */
+DUMMY(Fluka, NWISEL, nwisel_, void);
+DUMMY(Fluka, PEANUT, peanut_, void);
+DUMMY(Fluka, PFNCLV, pfnclv_, double);
+DUMMY(Fluka, PHDSET, phdset_, void);
+DUMMY(Fluka, PHDWLL, phdwll_, void);
+DUMMY(Fluka, PIOABS, pioabs_, void);
+DUMMY(Fluka, PREPRE, prepre_, void);
+DUMMY(Fluka, RSCOMP, rscomp_, void);   /* alternate entry to SBCOMP */
+DUMMY(Fluka, RSTNXT, rstnxt_, void);   /* alternate entry to RSTSEL */
+DUMMY(Fluka, RSTSEL, rstsel_, void);
+DUMMY(Fluka, SBCOMP, sbcomp_, void);
+DUMMY(Fluka, SIGFER, sigfer_, void);
+DUMMY(Fluka, UMOFIN, umofin_, void);
+DUMMY(Fluka, XINNEU, xinneu_, double);
+DUMMY(Fluka, XINPRO, xinpro_, double);
+
+/* The following dummy common blocks are added for the same reason.
+ * The number of bytes required was determined by inspecting the existing
+ * shared libraries in the 12 official Debian architectures and determining
+ * the maximum size of each common block there. */
+
+#define COMMON(fortranname_, size) \
+        struct { char c[size]; } fortranname_ = { { 0, } }
+
+COMMON(fkadhn_, 1376);
+COMMON(fkadhp_, 3712);
+COMMON(fkbala_,  288);
+COMMON(fkcd97_, 1152);
+COMMON(fkchpa_, 1472);
+COMMON(fkchpr_,  576);
+COMMON(fkcmcy_,  176);
+COMMON(fkcomc_, 7424);
+COMMON(fkcosp_,   64);
+COMMON(fkdecc_,10816);
+COMMON(fkdech_, 4328);
+COMMON(fkenco_,   16);
+COMMON(fkeva0_,60960);
+COMMON(fkfinu_,52000);
+COMMON(fkhadf_,  352);
+COMMON(fkheac_,   96);
+COMMON(fkheav_, 5408);
+COMMON(fkhet7_,   64);
+COMMON(fkhetp_,   32);
+COMMON(fkhigf_, 1632);
+COMMON(fkidgb_,   16);
+COMMON(fkinpf_,   32);
+COMMON(fkisot_,10208);
+COMMON(fkmapa_, 5824);
+COMMON(fknegx_,  128);
+COMMON(fknuct_,   16);
+COMMON(fknuda_, 1248);
+COMMON(fknuge_, 1120);
+COMMON(fknugi_,26944);
+COMMON(fknuii_, 1888);
+COMMON(fknule_,18048);
+COMMON(fknupw_,   32);
+COMMON(fkpapr_, 2400);
+COMMON(fkpare_,  256);
+COMMON(fkparn_, 7296);
+COMMON(fkpart_, 9696);
+COMMON(fkploc_, 2864);
+COMMON(fkquar_,  832);
+COMMON(fkreac_,50976);
+COMMON(fkredv_, 2368);
+COMMON(fkresn_,  256);
+COMMON(fkrun_,    32);
+COMMON(fkslop_,  608);
+COMMON(fkxsep_,13600);
+


--- NEW FILE geant321-109-fix-broken-xsneut95.dat-link.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 109-fix-broken-xsneut95.dat-link.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Link to xsneut95.dat in the correct place.

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/geant321/Imakefile cernlib-2005.05.09.dfsg/src/geant321/Imakefile
--- cernlib-2005.05.09.dfsg~/src/geant321/Imakefile	2005-11-23 15:38:52.663383751 +0000
+++ cernlib-2005.05.09.dfsg/src/geant321/Imakefile	2005-11-23 15:39:00.618680825 +0000
@@ -41,7 +41,7 @@
 install.lib:: $(CERN_LIBDIR)/xsneut95.dat
 
 $(CERN_LIBDIR)/xsneut95.dat:
-	cd $(@D);$(LN) ../share/lib/$(@F) $(@F)
+	cd $(@D) && $(LN) ../src/geant321/data/$(@F) $(@F)
 
 #endif
 #if defined(CERNLIB_VAXVMS)


--- NEW FILE geant321-117-fix-optimizer-bug-in-gphot.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 117-fix-optimizer-bug-in-gphot.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Patch by Harald Vogt <hvogt at ifh.de> to work around compiler
## DP: optimization problems in src/geant321/gphys/gphot.F.

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/geant321/gphys/gphot.F cernlib-2005.05.09.dfsg/src/geant321/gphys/gphot.F
--- cernlib-2005.05.09.dfsg~/src/geant321/gphys/gphot.F	1995-10-24 06:21:29.000000000 -0400
+++ cernlib-2005.05.09.dfsg/src/geant321/gphys/gphot.F	2005-12-07 15:01:52.558184613 -0500
@@ -240,7 +240,7 @@
                   ELSE
 C Radiative shell decay
                      JS = JFN+1+2*NSHELL+ISHELL
-                     JS = JPHFN+Q(JS)
+                     JS = JPHFN + INT (Q(JS))    ! compiler optimiztion problem H. Vogt 2004/04/29
                      NPOINT = Q(JS)
                      DO 40 I = 1,NPOINT
                         IF(RN05.LT.Q(JS+I)) THEN
@@ -296,7 +296,7 @@
                   ELSE
 c Nonradiative decay
                      JS = JFN+1+3*NSHELL+ISHELL
-                     JS = JPHFN+Q(JS)
+                     JS = JPHFN + INT (Q(JS))    ! compiler optimiztion problem H. Vogt 2004/04/29
                      NPOINT = Q(JS)
                      DO 60 I = 1,NPOINT
                         IF(RN05.LT.Q(JS+I)) THEN


--- NEW FILE geant321-203-compile-geant-with-ertrak.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 203-compile-geant-with-ertrak.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Ertrak code added to library in Debian since I saw no reason to exclude.

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/geant321/Imakefile cernlib-2005.05.09.dfsg/src/geant321/Imakefile
--- cernlib-2005.05.09.dfsg~/src/geant321/Imakefile	2005-11-23 15:41:44.798536817 +0000
+++ cernlib-2005.05.09.dfsg/src/geant321/Imakefile	2005-11-23 15:43:39.618959247 +0000
@@ -5,11 +5,12 @@
 AllTarget(geant321)
 
 /* Fluka removed from Debian source package for copyright reasons. */
+/* Ertrak added to Debian since I saw no reason to leave it out. */
 LIBDIRS=       cdf cgpack              gbase gcons gdraw \ @@\
          geocad ggeom gheisha ghits ghrout ghutils giface \ @@\
 	 giopa gkine gphys gscan gstrag gtrak guser gxint \ @@\
-	 miface miguti neutron
-
+	 miface miguti neutron        \ @@\
+	 erdecks erpremc matx55
 
 SUBDIRS= $(LIBDIRS) data examples gxuser geant321
 


--- NEW FILE geant321-806-bump-mathlib-and-dependents-sonames.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 806-bump-mathlib-and-dependents-sonames.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Bump so versions of mathlib and dependents since it is now compiled
## DP: against liblapack3 instead of liblapack2.

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/geant321/Imakefile cernlib-2005.05.09.dfsg/src/geant321/Imakefile
--- cernlib-2005.05.09.dfsg~/src/geant321/Imakefile	2005-11-23 15:49:19.722162373 +0000
+++ cernlib-2005.05.09.dfsg/src/geant321/Imakefile	2005-11-23 15:49:27.431512287 +0000
@@ -2,6 +2,8 @@
 #define IHaveSubdirs
 #define PassCDebugFlags
 
+export LIB_SONAME := 2
+
 AllTarget(geant321)
 
 /* Fluka removed from Debian source package for copyright reasons. */


--- NEW FILE mclibs-100-fix-isajet-manual-corruption.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 100-fix-isajet-manual-corruption.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fix corruption in LaTeX source to the Isajet manual.
## DP: (Replacement text obtained from a PS version of the manual on the web.)

@DPATCH@
diff -urNad cernlib-2005.05.09/src/mclibs/isajet/doc/physics.doc /tmp/dpep.tlmeFD/cernlib-2005.05.09/src/mclibs/isajet/doc/physics.doc
--- cernlib-2005.05.09/src/mclibs/isajet/doc/physics.doc	2001-10-08 10:03:08.000000000 -0400
+++ /tmp/dpep.tlmeFD/cernlib-2005.05.09/src/mclibs/isajet/doc/physics.doc	2005-06-08 16:12:37.814042242 -0400
@@ -122,7 +122,7 @@
 $W/Z$ decay. These were calculated using FORM 1.1 by J.~Vermaseren. The
 process $g + t \to W + b$ is {\it not} included. Both $g + b \to W^- +
 t$ and $g + \bar t \to W^- + \bar b$ of course give the same $W^- + t
-+\BARB_FINALSTATEAFTERQCDEVOLUTION
++\bar b$ final state after QCD evolution.  While the latter process is
 needed to describe the $m_t = 0$(!) mass singularity for $q_t \gg
 m_t$, it has a pole in the physical region at low $q_t$ from on-shell
 $t \to W + b$ decays. There is no obvious way to avoid this without


--- NEW FILE mclibs-101-undefine-PPC.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 101-undefine-PPC.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: If "PPC" is defined by compiler, undefine where it clashes with a
## DP: local variable.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/mclibs/cojets/code/bradlp.F /tmp/dpep.aeMGeJ/cernlib-2005.05.09/src/mclibs/cojets/code/bradlp.F
--- cernlib-2005.05.09/src/mclibs/cojets/code/bradlp.F	1996-01-11 09:14:33.000000000 -0500
+++ /tmp/dpep.aeMGeJ/cernlib-2005.05.09/src/mclibs/cojets/code/bradlp.F	2005-06-08 17:00:48.403200778 -0400
@@ -37,6 +37,15 @@
 #include "cojets/zpar2.inc"
 #include "cojets/zwpar.inc"
 #include "cojets/weakon.inc"
+
+C     The following is necessary since PPC is defined in g77 on
+C     the powerpc architecture, but it's also a variable in this
+C     file.
+C       -- Kevin McCarty
+#ifdef PPC
+#undef PPC
+#endif
+
       DIMENSION QP(4),QM(4),QK(4),QE(4),QN(4)
       DIMENSION COEF(2,2),QQV(2)
 C


--- NEW FILE mclibs-102-dont-optimize-some-code.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 102-dont-optimize-some-code.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Don't allow the compiler to optimize several files that cause trouble
## DP: (either compiler crash or broken code generation).

@DPATCH@
diff -urNad mclibs-2006.dfsg~/src/mclibs/isajet/isatape/Imakefile mclibs-2006.dfsg/src/mclibs/isajet/isatape/Imakefile
--- mclibs-2006.dfsg~/src/mclibs/isajet/isatape/Imakefile	1996-05-06 11:19:44.000000000 -0400
+++ mclibs-2006.dfsg/src/mclibs/isajet/isatape/Imakefile	2007-01-19 17:35:47.210374125 -0500
@@ -4,4 +4,8 @@
 
 FORTRANSAVEOPTION = FortranSaveFlags
 
+#if defined(CERNLIB_LINUX)
+SpecialFortranLibObjectRule(isawev,isawev,-O0,NullParameter)
+#endif
+
 SubdirLibraryTarget(NullParameter,NullParameter)
diff -urNad mclibs-2006.dfsg~/src/mclibs/pdf/spdf/Imakefile mclibs-2006.dfsg/src/mclibs/pdf/spdf/Imakefile
--- mclibs-2006.dfsg~/src/mclibs/pdf/spdf/Imakefile	2006-09-04 08:32:57.000000000 -0400
+++ mclibs-2006.dfsg/src/mclibs/pdf/spdf/Imakefile	2007-01-19 17:35:47.211373912 -0500
@@ -101,4 +101,10 @@
 #ifdef CERNLIB_HPUX
 FORTRANOPTIONS += '-WF,-P'
 #endif
+
+#if defined(CERNLIB_LINUX)
+/* -O2 optimization on ARM breaks in g77 3.3.3 */
+SpecialFortranLibObjectRule(structm,structm,-O0,NullParameter)
+#endif
+
 SubdirLibraryTarget(NullParameter,NullParameter)


--- NEW FILE mclibs-204-compile-isajet-with-isasrt.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 204-compile-isajet-with-isasrt.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Include isasrt in the Isajet library, by request (cf.
## DP: http://bugs.debian.org/260469 )

@DPATCH@
diff -urNad cernlib-2005.05.09/src/mclibs/isajet/code/Imakefile /tmp/dpep.PM12lm/cernlib-2005.05.09/src/mclibs/isajet/code/Imakefile
--- cernlib-2005.05.09/src/mclibs/isajet/code/Imakefile	2001-10-08 09:06:49.000000000 -0400
+++ /tmp/dpep.PM12lm/cernlib-2005.05.09/src/mclibs/isajet/code/Imakefile	2005-06-09 14:25:29.621215677 -0400
@@ -9,7 +9,7 @@
 	 fortop.F frgjet.F frgmnt.F gamma.F getpt.F gettot.F heavyx.F \ @@\
 	 hevolv.F higgs.F idanti.F idgen.F iframs.F inisap.F ipartns.F \ @@\
 	 ipjset.F iprtns.F irmov0.F isabeg.F isaend.F isaevt.F isaini.F \ @@\
-	 isajet.F ispjet.F istrad.F iswdky.F jetgen.F \ @@\
+	 isajet.F isasrt.F ispjet.F istrad.F iswdky.F jetgen.F \ @@\
 	 label.F lboost.F logerr.F \ @@\
 	 logic.F logp.F logphi.F logphw.F logpt.F logqm.F logqt.F logthw.F \ @@\
 	 logx.F logxw.F logyth.F logyw.F lstsq.F mbias.F mbset.F nogood.F \ @@\


--- NEW FILE mclibs-206-herwig-uses-DBLE-not-REAL.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 206-herwig-uses-DBLE-not-REAL.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Have libherwig use double precision consistently

@DPATCH@
diff -urNad mclibs-2006.dfsg~/src/mclibs/herwig/code/hwhiga.F mclibs-2006.dfsg/src/mclibs/herwig/code/hwhiga.F
--- mclibs-2006.dfsg~/src/mclibs/herwig/code/hwhiga.F	2006-09-04 08:32:57.000000000 -0400
+++ mclibs-2006.dfsg/src/mclibs/herwig/code/hwhiga.F	2007-01-19 17:39:10.154251922 -0500
@@ -72,7 +72,7 @@
       TAMP(6)=HWHIG5(T,S,U,EMH2,EMQ2,2,0,5,0,0,0)
       TAMP(7)=HWHIG5(U,T,S,EMH2,EMQ2,3,0,6,0,0,0)
       DO 20 I=1,7
-      TAMPI(I)= REAL(TAMP(I))
+      TAMPI(I)= DBLE(TAMP(I))
 #if !defined(CERNLIB_GFORTRAN)
   20  TAMPR(I)=-IMAG(TAMP(I))
 #else
diff -urNad mclibs-2006.dfsg~/src/mclibs/herwig/code/hwuli2.F mclibs-2006.dfsg/src/mclibs/herwig/code/hwuli2.F
--- mclibs-2006.dfsg~/src/mclibs/herwig/code/hwuli2.F	2006-09-04 08:32:57.000000000 -0400
+++ mclibs-2006.dfsg/src/mclibs/herwig/code/hwuli2.F	2007-01-19 17:39:27.722516271 -0500
@@ -18,7 +18,7 @@
      &  1.644934066848226D0/
       PROD(Y,Y2)=Y*(ONE+A1*Y*(ONE+A2*Y*(ONE+A3*Y2*(ONE+A4*Y2*(ONE+A5*Y2*
      & (ONE+A6*Y2*(ONE+A7*Y2*(ONE+A8*Y2*(ONE+A9*Y2*(ONE+A10*Y2))))))))))
-      XR=REAL(X)
+      XR=DBLE(X)
 #if !defined(CERNLIB_GFORTRAN)
       XI=IMAG(X)
 #else


--- NEW FILE mclibs-305-use-POWERPC-not-PPC-as-test.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 305-use-POWERPC-not-PPC-as-test.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Since patch 304 changed the meaning of CERNLIB_PPC to a mere endianness
## DP: test, we now use CERNLIB_POWERPC to mean actually checking for a PowerPC
## DP: processor; fix the three occurences of this in Imakefiles.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/mclibs/herwig/code/Imakefile /tmp/dpep.fQy2EP/cernlib-2005.05.09/src/mclibs/herwig/code/Imakefile
--- cernlib-2005.05.09/src/mclibs/herwig/code/Imakefile	1998-09-25 11:34:28.000000000 -0400
+++ /tmp/dpep.fQy2EP/cernlib-2005.05.09/src/mclibs/herwig/code/Imakefile	2005-06-09 10:51:45.913019086 -0400
@@ -43,7 +43,7 @@
 
 SubdirLibraryTarget(NullParameter,NullParameter)
 
-#if defined(CERNLIB_LINUX) && defined(CERNLIB_PPC)
+#if defined(CERNLIB_LINUX) && defined(CERNLIB_POWERPC)
 SpecialFortranLibObjectRule(hwuci2,hwuci2,-O0,NullParameter)
 #endif
 


--- NEW FILE mclibs-309-define-dummy-herwig-routines.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 309-define-dummy-herwig-routines.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Define stub functions for herwig routines that are supposed to be
## DP: provided by the user.  Also, comment out the dummy functions pdfset
## DP: and structm; real versions are provided in pdflib.

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/mclibs/herwig/code/Imakefile cernlib-2005.05.09.dfsg/src/mclibs/herwig/code/Imakefile
--- cernlib-2005.05.09.dfsg~/src/mclibs/herwig/code/Imakefile	2005-11-28 19:46:53.619963660 +0000
+++ cernlib-2005.05.09.dfsg/src/mclibs/herwig/code/Imakefile	2005-11-28 19:46:58.890844233 +0000
@@ -24,8 +24,13 @@
 	hwulob.F hwulof.F hwulor.F hwumas.F hwupcm.F hwurap.F hwures.F \ @@\
 	hwurob.F hwurof.F hwurot.F hwusor.F hwusqr.F hwusta.F hwutab.F \ @@\
 	hwutim.F hwvdif.F hwvdot.F hwvequ.F hwvsca.F hwvsum.F hwvzro.F \ @@\
-	hwwarn.F ieupdg.F ipdgeu.F pdfset.F qqinit.F qqlmat.F sasano.F \ @@\
-	sasbeh.F sasdir.F sasgam.F sasvmd.F structm.F
+	hwwarn.F ieupdg.F ipdgeu.F /*pdfset.F*/ qqinit.F qqlmat.F sasano.F \ @@\
+	sasbeh.F sasdir.F sasgam.F sasvmd.F /*structm.F*/
+	/* comment out pdfset.F, structm.F; real versions are in pdflib */
+
+/* add the following file to define dummy routines as weak symbols */
+/* --Kevin McCarty, for Debian */
+SRCS_C= dummy.c
 
 FORTRANSAVEOPTION = FortranSaveFlags
 
diff -urNad cernlib-2005.05.09.dfsg~/src/mclibs/herwig/code/dummy.c cernlib-2005.05.09.dfsg/src/mclibs/herwig/code/dummy.c
--- cernlib-2005.05.09.dfsg~/src/mclibs/herwig/code/dummy.c	1970-01-01 00:00:00.000000000 +0000
+++ cernlib-2005.05.09.dfsg/src/mclibs/herwig/code/dummy.c	2005-11-28 19:49:17.897320746 +0000
@@ -0,0 +1,34 @@
+/* Dummy file to avoid undefined symbols in the library */
+/* Kevin McCarty, 14 Jan 2003 */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/* Want the dummy functions to be weakly defined so they may be overridden
+ * without error. */
+
+#define kludge(x)    #x
+#define stringify(x) kludge(x)
+#define underline(x) dummy_ ## x
+
+#define DUMMY(UPPERNAME, fortranname_, returntype) \
+static returntype underline(fortranname_)() { print_dummy(#UPPERNAME); } \
+void fortranname_() \
+	__attribute__ ((weak, alias (stringify(underline(fortranname_))) ))
+
+static void print_dummy(const char *function)
+{
+  fprintf(stderr, "herwig59: Now in dummy %s routine.\n", function);
+  fprintf(stderr,
+          "If you see this message, you should define your own such routine.\n"
+#if defined (CERNLIB_DEBIAN)
+	  "For details, see the file /usr/share/doc/libherwig59-2-dev/herwig59.txt.gz\n"
+#endif
+  );
+  exit(EXIT_FAILURE);
+}
+
+DUMMY(HWABEG, hwabeg_, void);
+DUMMY(HWANAL, hwanal_, void);
+DUMMY(HWAEND, hwaend_, void);
+


--- NEW FILE mclibs-310-define-dummy-fowl-routines.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 310-define-dummy-fowl-routines.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Define stub functions for routines in fowl that are supposed to be
## DP: user-defined.  Also, rename START to FSTART to avoid name clash
## DP: with mathlib.

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/phtools/fowl/Imakefile cernlib-2005.05.09.dfsg/src/phtools/fowl/Imakefile
--- cernlib-2005.05.09.dfsg~/src/phtools/fowl/Imakefile	1996-04-26 07:13:52.000000000 +0000
+++ cernlib-2005.05.09.dfsg/src/phtools/fowl/Imakefile	2005-11-28 19:49:52.412989577 +0000
@@ -1,10 +1,12 @@
-SRCS_F=	 beamin.F breitw.F chmove.F delsq.F dumpme.F finish.F \ @@\
+SRCS_F=	 beamin.F breitw.F chmove.F delsq.F dumpme.F /* finish.F */ \ @@\
 	fmass.F fmassq.F fowl.F fowlmp.F fowlpr.F genev.F histey.F \ @@\
 	labsys.F pdk.F qqstrt.F rangnr.F redat2.F redata.F rotes2.F \ @@\
 	scout.F teedia.F tranch.F xplsdx.F
 
+SRCS_C= dummy.c /*"fake" defn of start, user, finish to avoid undefined syms*/
+
 #if !defined(CERNLIB_UNIX)
-SRCS_F := $(SRCS_F) start.F
+SRCS_F := $(SRCS_F) /* start.F */
 #endif
 
 SubdirLibraryTarget(fowl,NullParameter)
diff -urNad cernlib-2005.05.09.dfsg~/src/phtools/fowl/dummy.c cernlib-2005.05.09.dfsg/src/phtools/fowl/dummy.c
--- cernlib-2005.05.09.dfsg~/src/phtools/fowl/dummy.c	1970-01-01 00:00:00.000000000 +0000
+++ cernlib-2005.05.09.dfsg/src/phtools/fowl/dummy.c	2005-11-28 19:53:31.287496776 +0000
@@ -0,0 +1,39 @@
+/* Dummy file to avoid undefined symbols in the library */
+/* Kevin McCarty, 26 Apr 2004 */
+/* Last revised 13 Aug 2004 */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/* Want the dummy functions to be weakly defined so they may be overridden
+ * without error. */
+
+#define kludge(x)    #x
+#define stringify(x) kludge(x)
+#define underline(x) dummy_ ## x
+
+#define DUMMY(UPPERNAME, fortranname_, returntype) \
+static returntype underline(fortranname_)() { print_dummy(#UPPERNAME); } \
+void fortranname_() \
+	__attribute__ ((weak, alias (stringify(underline(fortranname_))) ))
+
+static void print_dummy(const char *function)
+{
+  fprintf(stderr, "phtools: Now in dummy %s routine.\n", function);
+  fprintf(stderr,
+          "If you see this message, you should define your own such routine.\n"
+	  "For details, see "
+#if defined (CERNLIB_DEBIAN)
+	                   "/usr/share/doc/libphtools2-dev/README.Debian\n"
+	  "and "
+#endif
+	      "the CERN writeup for FOWL (available at the URL\n"
+	  "http://wwwasdoc.web.cern.ch/wwwasdoc/Welcome.html ; scroll down\n"
+	  "to the link for W505 - FOWL.)\n");
+  exit(EXIT_FAILURE);
+}
+
+DUMMY(FSTART, fstart_, void);
+DUMMY(USER,   user_,   void);
+DUMMY(FINISH, finish_, void);
+
diff -urNad cernlib-2005.05.09.dfsg~/src/phtools/fowl/fowlmp.F cernlib-2005.05.09.dfsg/src/phtools/fowl/fowlmp.F
--- cernlib-2005.05.09.dfsg~/src/phtools/fowl/fowlmp.F	1996-03-22 16:42:46.000000000 +0000
+++ cernlib-2005.05.09.dfsg/src/phtools/fowl/fowlmp.F	2005-11-28 19:49:52.412989577 +0000
@@ -30,7 +30,7 @@
       CALL REDATA
       IF(NEVTOT.LT.NGRP) NGRP = NEVTOT
       N2 = MIN (NEVTOT/NGRP, 30000)
-      CALL START
+      CALL FSTART
       DO  500 I2= 1, N2
       DO  400  I= 1, NGRP
       IEVENT = IEVENT + 1
diff -urNad cernlib-2005.05.09.dfsg~/src/phtools/fowl/qqstrt.F cernlib-2005.05.09.dfsg/src/phtools/fowl/qqstrt.F
--- cernlib-2005.05.09.dfsg~/src/phtools/fowl/qqstrt.F	1996-03-22 16:42:47.000000000 +0000
+++ cernlib-2005.05.09.dfsg/src/phtools/fowl/qqstrt.F	2005-11-28 19:49:52.412989577 +0000
@@ -38,6 +38,9 @@
       COMMON
      +/TAPES / NTPIN     ,NTPOUT   ,NTPNCH   ,NTPBIN   ,KONSOL
       IF(JEVT.LE.0) RETURN
+#if 0
+C     Comment this section out; "which" is obsolete
+C     -- Kevin McCarty, for Debian, 26 April 2004
       CALL WHICH(ISIT,VAL)
       WRITE(6,700)JEVT,VAL
   700 FORMAT('0RANDOM NUMBER GENERATOR INITIATED TO',I12,
@@ -46,6 +49,7 @@
 C--     CDC   60-BIT WORD
 CDC                             )B10000000000000007171 .RO.  TVEJ( = POL
       GOTO 200
+#endif
   100 CONTINUE
 C         FOR -CDC JUST MAKE SURE IT IS ODD
       IGLOP = JEVT


--- NEW FILE mclibs-312-skip-duplicate-gamma.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 312-skip-duplicate-gamma.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Don't compile in redundant gamma function in isajet; use the mathlib one

@DPATCH@
diff -urNad cernlib-2005.05.09/src/mclibs/isajet/code/Imakefile /tmp/dpep.IX54UM/cernlib-2005.05.09/src/mclibs/isajet/code/Imakefile
--- cernlib-2005.05.09/src/mclibs/isajet/code/Imakefile	2005-06-09 14:29:18.976494518 -0400
+++ /tmp/dpep.IX54UM/cernlib-2005.05.09/src/mclibs/isajet/code/Imakefile	2005-06-09 14:30:21.913126207 -0400
@@ -1,12 +1,13 @@
 DoIncludePackage(isajet)
 #include "pilot.h"
 
+/* gamma.F removed; use the one defined in mathlib/gen/c/gamma.F */
 SRCS_F= \ @@\
 	 amass.F charge.F cteq5l.F ctxc2i.F ctxi2c.F ctxin.F ctxout.F \ @@\
 	 dblpcm.F dblvec.F dboost.F decay.F decjet.F \ @@\
 	 domssm.F drllyn.F eebeg.F eemax.F elctrn.F epf.F evol01.F evol02.F \ @@\
 	 evol03.F evol05.F evol06.F evol07.F evolms.F evolve.F flavor.F \ @@\
-	 fortop.F frgjet.F frgmnt.F gamma.F getpt.F gettot.F heavyx.F \ @@\
+	 fortop.F frgjet.F frgmnt.F         getpt.F gettot.F heavyx.F \ @@\
 	 hevolv.F higgs.F idanti.F idgen.F iframs.F inisap.F ipartns.F \ @@\
 	 ipjset.F iprtns.F irmov0.F isabeg.F isaend.F isaevt.F isaini.F \ @@\
 	 isajet.F isasrt.F ispjet.F istrad.F iswdky.F jetgen.F \ @@\


--- NEW FILE mclibs-321-support-gfortran.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 321-support-gfortran.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Minor changes to support use of gfortran.  From Harald Vogt.

@DPATCH@
diff -urNad mclibs-2005.dfsg~/src/mclibs/herwig/code/hwhew2.F mclibs-2005.dfsg/src/mclibs/herwig/code/hwhew2.F
--- mclibs-2005.dfsg~/src/mclibs/herwig/code/hwhew2.F	1996-12-03 09:16:55.000000000 -0500
+++ mclibs-2005.dfsg/src/mclibs/herwig/code/hwhew2.F	2006-09-27 13:47:59.876963852 -0400
@@ -75,8 +75,7 @@
       H(J,I)=(ZDMP*ZP-ZDPM*ZQ)*ZT
       CH(J,I)=(ZDMP*ZPS-ZDPM*ZQS)*ZT
       ZD=H(J,I)*CH(J,I)
-      PT5=CMPLX(.5,0.)
-      D(J,I)=PT5*ZD
+      D(J,I)=CMPLX(.5,0.)*ZD
    11 CONTINUE
       DO 60 I=1,NPART-1
       IPP1=I+1
diff -urNad mclibs-2005.dfsg~/src/mclibs/isajet/test/Imakefile mclibs-2005.dfsg/src/mclibs/isajet/test/Imakefile
--- mclibs-2005.dfsg~/src/mclibs/isajet/test/Imakefile	2000-07-25 12:21:34.000000000 -0400
+++ mclibs-2005.dfsg/src/mclibs/isajet/test/Imakefile	2006-09-27 13:49:49.783806148 -0400
@@ -8,4 +8,7 @@
 
 CernlibFortranProgramTarget(isajett,isajett.o,$(PACKAGE_LIB),$(PACKAGE_LIB),pdflib804 mathlib kernlib)
 
+#if !defined(CERNLIB_GFORTRAN)
+/* breaks on 'STOP 99' if compiled with gfortran */
 TestTarget(isajett,isajet.dat,test.input)
+#endif


--- NEW FILE mclibs-806-bump-mathlib-and-dependents-sonames.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 806-bump-mathlib-and-dependents-sonames.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Bump so versions of mathlib and dependents since it is now compiled
## DP: against liblapack3 instead of liblapack2.

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/mclibs/cojets/Imakefile cernlib-2005.05.09.dfsg/src/mclibs/cojets/Imakefile
--- cernlib-2005.05.09.dfsg~/src/mclibs/cojets/Imakefile	2005-11-23 15:49:19.723162159 +0000
+++ cernlib-2005.05.09.dfsg/src/mclibs/cojets/Imakefile	2005-11-23 15:49:27.431512287 +0000
@@ -2,6 +2,8 @@
 #define IHaveSubdirs
 #define PassCDebugFlags
 
+export LIB_SONAME := 2
+
 AllTarget(cojets)
 
 LIBDIRS= code cojdata cojtapew
diff -urNad cernlib-2005.05.09.dfsg~/src/mclibs/herwig/Imakefile cernlib-2005.05.09.dfsg/src/mclibs/herwig/Imakefile
--- cernlib-2005.05.09.dfsg~/src/mclibs/herwig/Imakefile	2005-11-23 15:49:19.724161945 +0000
+++ cernlib-2005.05.09.dfsg/src/mclibs/herwig/Imakefile	2005-11-23 15:49:27.432512073 +0000
@@ -2,6 +2,8 @@
 #define IHaveSubdirs
 #define PassCDebugFlags
 
+export LIB_SONAME := 2
+
 SUBDIRS= code doc test herwig59
 
 TopOfPackage(herwig59)
diff -urNad cernlib-2005.05.09.dfsg~/src/mclibs/isajet/Imakefile cernlib-2005.05.09.dfsg/src/mclibs/isajet/Imakefile
--- cernlib-2005.05.09.dfsg~/src/mclibs/isajet/Imakefile	2005-11-23 15:49:19.724161945 +0000
+++ cernlib-2005.05.09.dfsg/src/mclibs/isajet/Imakefile	2005-11-23 15:49:27.432512073 +0000
@@ -3,6 +3,8 @@
 #define IHaveSubdirs
 #define PassCDebugFlags
 
+export LIB_SONAME := 2
+
 LIBDIRS= code isadata isasusy isarun isatape
 
 SUBDIRS= $(LIBDIRS) test data isajet
diff -urNad cernlib-2005.05.09.dfsg~/src/mclibs/pdf/Imakefile cernlib-2005.05.09.dfsg/src/mclibs/pdf/Imakefile
--- cernlib-2005.05.09.dfsg~/src/mclibs/pdf/Imakefile	2005-11-23 15:49:19.724161945 +0000
+++ cernlib-2005.05.09.dfsg/src/mclibs/pdf/Imakefile	2005-11-23 15:49:27.432512073 +0000
@@ -6,6 +6,8 @@
 IMAKE_DEFINES=-DFortranDoesCpp=NO
 #endif
 
+export LIB_SONAME := 2
+
 AllTarget(pdflib804)
 
 SUBDIRS= spdf npdf tpdf pdf
diff -urNad cernlib-2005.05.09.dfsg~/src/phtools/Imakefile cernlib-2005.05.09.dfsg/src/phtools/Imakefile
--- cernlib-2005.05.09.dfsg~/src/phtools/Imakefile	2005-11-23 15:49:19.725161731 +0000
+++ cernlib-2005.05.09.dfsg/src/phtools/Imakefile	2005-11-23 15:49:27.432512073 +0000
@@ -2,6 +2,8 @@
 #define IHaveSubdirs
 #define PassCDebugFlags
 
+export LIB_SONAME := 2
+
 LIBDIRS= genbod fowl wico
 
 SUBDIRS= $(LIBDIRS) wicoexam


--- NEW FILE mkdirhier ---
#!/bin/sh
# $Xorg: mkdirhier.sh,v 1.3 2000/08/17 19:41:53 cpqbld Exp $
# Courtesy of Paul Eggert

newline='
'
IFS=$newline

case ${1--} in
-*) echo >&2 "mkdirhier: usage: mkdirhier directory ..."; exit 1
esac

status=

for directory
do
	case $directory in
	'')
		echo >&2 "mkdirhier: empty directory name"
		status=1
		continue;;
	*"$newline"*)
		echo >&2 "mkdirhier: directory name contains a newline: \`\`$directory''"
		status=1
		continue;;
	///*) prefix=/;; # See Posix 2.3 "path".
	//*) prefix=//;;
	/*) prefix=/;;
	-*) prefix=./;;
	*) prefix=
	esac

	IFS=/
	set x $directory
	case $2 in
	    */*)	# IFS parsing is broken
		IFS=' '
		set x `echo $directory | tr / ' '`
		;;
	esac
	IFS=$newline
	shift

	for filename
	do
		path=$prefix$filename
		prefix=$path/
		shift

		test -d "$path" || {
			paths=$path
			for filename
			do
				if [ -n "$filename" -a "$filename" != "." ]; then
					path=$path/$filename
					paths=$paths$newline$path
				fi
			done

			mkdir $paths || status=$?

			break
		}
	done
  done

exit $status

npatchy-curdir.patch:

--- NEW FILE npatchy-curdir.patch ---
--- cernlib-2006/2006/src/patchy/yexpand.script.curdir	2005-04-18 17:41:03.000000000 +0200
+++ cernlib-2006/2006/src/patchy/yexpand.script	2007-04-20 23:31:00.000000000 +0200
@@ -26,8 +26,8 @@
 # CERN_ROOT=":$CERN_ROOT" ; export CERN_ROOT 
   CERN_ROOT=":$CERN/$CERN_LEVEL" ; export CERN_ROOT 
 
-  tfile="$HOME/$tfile.yexp"
-  echo "#!/bin/sh"    >$tfile
+  tfile="./$tfile.yexp"
+  echo "#! /bin/sh"    >$tfile
   echo "  cat <<EOI" >>$tfile
   cat <$ifile        >>$tfile
   cc=$?

npatchy-np_flags.patch:

--- NEW FILE npatchy-np_flags.patch ---
--- cernlib-2006/2006/src/patchy/fcasplit.F.np_flags	1999-11-30 18:37:25.000000000 +0100
+++ cernlib-2006/2006/src/patchy/fcasplit.F	2007-04-20 23:39:34.000000000 +0200
@@ -343,8 +343,8 @@
       PARAMETER   (CHIDA = ';DECK  I' )
       PARAMETER   (CHOVER= 'UNKNOWN')
 
-      PARAMETER   (CHPOF = '-c -O -fno-automatic')
-      PARAMETER   (CHPOC = '-c -O2 -m486')
+      PARAMETER   (CHPOF = '-c -g -O2 -fno-automatic')
+      PARAMETER   (CHPOC = '-c -g -O2')
       PARAMETER   (CHPOA = ' ')
 
       PARAMETER   (CHEXFOR = '.f')
@@ -507,7 +507,7 @@
 #endif
 
       PARAMETER   (MLMKLN=100)
-      PARAMETER   (MXLENG=128, MXMKLN=64)
+      PARAMETER   (MXLENG=1024, MXMKLN=128)
       CHARACTER    CHHOLD*(MXLENG)
       CHARACTER    CHOPT(7)*(MXLENG)
       DIMENSION    NCHOPT(7)
@@ -532,7 +532,7 @@
       DIMENSION    LXCBUF(MXCBUF)
       CHARACTER*80 CHCBUF(MXCBUF)
 
-      CHARACTER    CHLINE*80, CHNAME*80, CHTEXT*511
+      CHARACTER    CHLINE*80, CHNAME*80, CHTEXT*3000
       CHARACTER    CHUSE*1
 
       PARAMETER   (NKEYS=11)
--- cernlib-2006/2006/src/patchy/Imakefile.np_flags	2006-09-06 16:36:54.000000000 +0200
+++ cernlib-2006/2006/src/patchy/Imakefile	2007-04-20 23:39:34.000000000 +0200
@@ -54,19 +54,9 @@
 
 $(P5LIB): $(LDIR)patchy.car $(LDIR)p5lib.cra p5lib.libmake fcasplit Makefile
 	ypatchy - p5lib p5lib TTY .go
-	fcasplit p5lib.f
-	RemoveFile(p5lib.f)
+	./fcasplit p5lib.f "-c $(FORTRANOPTIONS) $(FDEBUGFLAGS)" "-c $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)" "" "$(FC)" "$(CC)"
 	cat p5lib.libmake >> p5lib.mkfca
-#if defined(CERNLIB_GFORTRAN)	
-	sed -e 's;f77;gfortran;' -e 's;g77;gfortran;' -e 's;-Nx800;;' \
-	    -e 's;-Nc200;;' -e 's;+ppu;;' p5lib.mkfca > p5lib.mkfca.mod
-	sed -e 's;f77;gfortran;' -e 's;g77;gfortran;' -e 's;-Nx800;;' \
-	    -e 's;-Nc200;;' -e 's;+ppu;;' p5lib.shfca > p5lib.shfca.mod
-	mv p5lib.mkfca.mod p5lib.mkfca
-	mv p5lib.shfca.mod p5lib.shfca
-#endif	
 	$(MAKE) -f p5lib.mkfca $@
-	RemoveFile(p5lib.mkfca)
 	RemoveFile(p5lib.shfca)
 
 p5lib.libmake: Makefile
@@ -78,7 +68,7 @@
 	echo "	rm -f \$$(subst .o,.f,\$$(ROUTINES))" >> $@ 
 
 fcasplit: fcasplit.o
-	$(F77) $< -o $@
+	$(FCLINK) $< -o $@ $(FCLDOPTIONS)
 
 $(LDIR)%.cra: %.cra $(LDIR)yexpand
 	PLINAME=$(PLINAME);export PLINAME;$(LDIR)yexpand $< $@
@@ -87,22 +77,22 @@
 	@ ln -s $< $@
 
 %.f:  $(LDIR)%.cra $(LDIR)patchy.car
-	ypatchy - $@ $< TTY .go
-	
+	ypatchy - :$@ :$< TTY .go
+
 .f.o:
 	$(FC) -c $(FORTRANOPTIONS) $(FDEBUGFLAGS) $<
 
 $(LDIR)yexpand:	yexpand.script
-	@cp $< $@
-	@chmod +x $@
+	cp $< $@
+	chmod +x $@
 
 /*  Links to patchy 4.15 */
 YMODULES=ycompar yedit yfrceta yindex yindexb ylist ypatchy \
 	 ysearch yshift ytobcd ytobin ytoceta
 
-P4LINKS: $(foreach yp,$(YMODULES),$(CERN_BINDIR)$(yp))
+P4LINKS: $(foreach yp,$(YMODULES),$(CERN_BINDIR)/$(yp))
 
-$(foreach yp,$(YMODULES),$(CERN_BINDIR)$(yp)):
+$(foreach yp,$(YMODULES),$(CERN_BINDIR)/$(yp)):
 	cd $(dir $@);	\ @@\
 	if [ -f ../../patchy/4.15/bin/$(notdir $@) ] ; then \ @@\
 		ln -s ../../patchy/4.15/bin/$(notdir $@) $(notdir $@); \ @@\

patchy-insecure_tmp_use.diff:

--- NEW FILE patchy-insecure_tmp_use.diff ---
diff -u patchy-orig/yindex patchy/yindex
--- patchy-orig/yindex	2006-04-11 10:33:39.000000000 +0200
+++ patchy/yindex	2006-04-11 10:44:10.000000000 +0200
@@ -11,7 +11,7 @@
    [ -z "$PATCHY_VERSION" ] && PATCHY_VERSION="4.15"
    PATCHY=$CERN/patchy/$PATCHY_VERSION/bin
  
-ftmp=/tmp/`echo $0 | awk -F/ '{ print $NF }'`$$
+#ftmp=/tmp/`echo $0 | awk -F/ '{ print $NF }'`$$
  
 if [ $# -eq 0 ] ; then
    cat << EoI
@@ -45,6 +45,8 @@
       exit 1
 fi
  
+exttmp=`echo $0 | awk -F/ '{ print $NF }'`$$
+ftmp="$file-$exttmp"
 if [ "$ext" != "pam" ] ; then
    echo " Preparing temporary binary PAM file, ...wait"
    ${PATCHY}/ytobin $pam $ftmp.pam - - ${ftmp}.lis .GO  > /dev/null
Seulement dans patchy: yindex-orig
diff -u patchy-orig/ylist patchy/ylist
--- patchy-orig/ylist	2006-04-11 10:33:48.000000000 +0200
+++ patchy/ylist	2006-04-11 10:40:17.000000000 +0200
@@ -11,7 +11,7 @@
    [ -z "$PATCHY_VERSION" ] && PATCHY_VERSION="4.15"
    PATCHY=$CERN/patchy/$PATCHY_VERSION/bin
  
-ftmp=/tmp/`echo $0 | awk -F/ '{ print $NF }'`$$
+#ftmp=/tmp/`echo $0 | awk -F/ '{ print $NF }'`$$
  
 if [ $# -eq 0 ] ; then
    cat << EoI
@@ -45,6 +45,8 @@
       exit 1
 fi
  
+exttmp=`echo $0 | awk -F/ '{ print $NF }'`$$
+ftmp="$file-$exttmp"
 if [ "$ext" != "pam" ] ; then
    echo " Preparing temporary binary PAM file, ...wait"
    ${PATCHY}/ytobin $pam $ftmp.pam - - ${ftmp}.lis .GO  > /dev/null
Seulement dans patchy: ylist-orig

patchy-p4comp.patch:

--- NEW FILE patchy-p4comp.patch ---
--- patchy/p4comp.fca.orig	2006-04-08 12:46:17.000000000 +0200
+++ patchy/p4comp.fca	2006-04-08 12:47:34.000000000 +0200
@@ -11458,7 +11458,7 @@
       IF (JCARD.GE.NTOTCC)   RETURN
       LE = LTK + KDNWT1 - 1
       DO 12 L=LTK,LE
-      IF (AND(IQ(L),'FF000000'X).EQ.0)    GO TO 14
+      IF (AND(IQ(L),X'FF000000').EQ.0)    GO TO 14
    12 CONTINUE
       NWTK = KDNWT
       NCH  = 80
@@ -12383,7 +12383,7 @@
       IF (JCARD.GE.NTOTCC)   RETURN
       LE = LTK + KDNWT1 - 1
       DO 13 L=LTK,LE
-      IF (AND(IQ(L),'FF000000'X).EQ.0)    GO TO 14
+      IF (AND(IQ(L),X'FF000000').EQ.0)    GO TO 14
    13 CONTINUE
       NWTK   = KDNWT
       NCHCCT = 80
@@ -14260,7 +14260,7 @@
 C--------------    END CDE                             --------------
 C     DIMENSION    MM(10), ITP(9)                                        A8M
       DIMENSION    MM(6),  ITP(9)                                       -A8M
-      PARAMETER   ( NBLANK = '20202000'X )
+      PARAMETER   ( NBLANK = X'20202000' )
  
       IT     = ITP(1)
       JARTPX = 0
@@ -14430,7 +14430,7 @@
  
    24 JLOW = JCH
  
-      MV(JCH) = AND (MV(JCH), 'FFFFFFDF'X)
+      MV(JCH) = AND (MV(JCH), X'FFFFFFDF')
  
    49 CONTINUE
       JCCLOW = MAX  (JCCLOW,JLOW)
@@ -14465,8 +14465,8 @@
  
  
  
-      DATA ACTION/'HOLD  ','RESUME','EOF   ','REWIND','ATTACH','DETACH'
-     +,           'EOFREW','CLOSE ' /
+      DATA ACTION/6HHOLD  ,6HRESUME,6HEOF   ,6HREWIND,6HATTACH,6HDETACH
+     +,           6HEOFREW,6HCLOSE  /
  
 C------    CODE BITS IN  IOTALL, IOTOFF, IOTON, IOTYP
  
@@ -14801,7 +14801,7 @@
       DO 31 JC=1,NCD
       J = J+1
       DO 19 JJ=1,KDNWT1
-      IF (AND(MV(J),'FF000000'X).EQ.0)   GO TO 31
+      IF (AND(MV(J),X'FF000000').EQ.0)   GO TO 31
    19 J = J+1
    31 CONTINUE
  
@@ -14825,7 +14825,7 @@
  
       DO 16 J=1,KDNWT1
       KIMA(J)= MV(J)
-      IF (AND(KIMA(J),'FF000000'X).EQ.0)    GO TO 31
+      IF (AND(KIMA(J),X'FF000000').EQ.0)    GO TO 31
    16 CONTINUE
       J = KDNWT
       KIMA(J)= MV(J)
@@ -14855,7 +14855,7 @@
  
       DO 16 J=1,KDNWT1
       KIMA(J)= MV(J)
-      IF (AND(KIMA(J),'FF000000'X).EQ.0)    GO TO 31
+      IF (AND(KIMA(J),X'FF000000').EQ.0)    GO TO 31
    16 CONTINUE
       J = KDNWT
       KIMA(J)= MV(J)
@@ -17316,6 +17316,8 @@
 /*>    ROUTINE ABEND
   CERN PROGLIB# Z035    ABEND           .VERSION KERNFOR  4.31  911111
 */
+#include <stdlib.h>
+
 void abend_()
 {
     exit(7);
@@ -17430,7 +17432,7 @@
       char *fname;
       int  *lgname;
 {
-      char *malloc();
+      void *malloc();
       char *ptalc, *pttext;
       int  fchput();
       int  nalc;
@@ -17664,7 +17666,7 @@
       char *ftext;
       int  lgtext;
 {
-      char *malloc();
+      void *malloc();
       char *ptalc, *ptuse;
       char *utext;
       int  nalc;

patchy-perror.patch:

--- NEW FILE patchy-perror.patch ---
--- 2005/src/patchy/patchy.car.orig	1996-07-15 13:46:22.000000000 +0200
+++ 2005/src/patchy/patchy.car	2006-04-09 02:18:17.000000000 +0200
@@ -3708,7 +3708,7 @@
 
    38 WRITE (IQTYPE,9038) CHLIFI(1:NN)
 +SELF, IF=QS_UNIX.
-      IF (LUNOLD.NE.0)  CALL PERRORF (' System msg')
+      IF (LUNOLD.NE.0)  CALL PERROR (' System msg')
 +SELF.
       IF (NQINIT.EQ.0)  THEN
           IF (IQPRNT.NE.IQTYPE)  WRITE (IQPRNT,9038) CHLIFI(1:NN)
@@ -4399,7 +4399,7 @@
       CHARACTER    MSG*(*)
 
 +SELF, IF=QS_UNIX.
-      CALL PERRORF (' Perror has')
+      CALL PERROR (' Perror has')
 +SELF.
       CALL P_KILL (MSG)
       END
@@ -4446,7 +4446,7 @@
       CHARACTER    MSG*(*)
 
 +SELF, IF=QS_UNIX.
-      CALL PERRORF ('Perror has')
+      CALL PERROR ('Perror has')
 +SELF.
       CALL P_FATAL (MSG)
       END
@@ -15112,7 +15112,7 @@
 +DECK, SEGVIOL, T=JOIN, IF=QDIAG, IF=QS_UNIX.
       SUBROUTINE SEGVIOL
 
-      CALL PERRORF ('perrorf has')
+      CALL PERROR ('perror has')
       CALL P_KILL ('SEGVIOL reached')
 
       END

patchy-rceta.patch:

--- NEW FILE patchy-rceta.patch ---
--- patchy/rceta.sh.orig	1995-05-04 21:23:45.000000000 +0200
+++ patchy/rceta.sh	2006-04-08 12:20:26.000000000 +0200
@@ -225,8 +225,8 @@
       RETURN
       END
 \\
- fort77 -o rceta rceta.f
- rceta    <<\\
+ f77 -g -O2 -o rceta rceta.f
+ ./rceta    <<\\
 CODE  INTERNAL A1 REPRESENTATION OF THE CETA SET / LNX
 CODE  CARD    1  IN HOLLERITH FOR CETA VALUES  1 - 47
 CODE  CARD    2  IN HOLLERITH FOR CETA VALUES 65 - 90


--- NEW FILE patchy-unpack-rceta ---
#! /bin/bash

set -e
cd .

file=patchy
script=rceta.sh
archive=$file.tar.gz
echo "Unpacking from $archive"
tar xzf $archive
echo "patching script"
sed -i -e 's/fort77/f77/' -e 's:^ rceta : ./rceta :' $file/$script
pushd $file
./$script
popd
echo "Repacking $archive"
tar czf $archive $file

exit 0


patchy-use_OPT.patch:

--- NEW FILE patchy-use_OPT.patch ---
--- cernlib-2006/patchy/fcasplit.f.use_OPT	2006-04-12 19:30:57.000000000 +0200
+++ cernlib-2006/patchy/fcasplit.f	2007-04-20 23:30:53.000000000 +0200
@@ -23,7 +23,7 @@
       PARAMETER   (CHIDA = ';DECK  I' )
       PARAMETER   (CHOVER= 'UNKNOWN')
  
-      PARAMETER   (CHPOF = '-c -O2 -Nx800 -Nc200')
+      PARAMETER   (CHPOF = '-c -O2')
       PARAMETER   (CHPOC = '-c -O2 -posix')
       PARAMETER   (CHPOA = ' ')
  
@@ -37,7 +37,7 @@
       PARAMETER   (CHWHA = 'as  ')
  
       PARAMETER   (MLMKLN=100)
-      PARAMETER   (MXLENG=128, MXMKLN=64)
+      PARAMETER   (MXLENG=256, MXMKLN=128)
       CHARACTER    CHHOLD*(MXLENG)
       CHARACTER    CHOPT(7)*(MXLENG)
       DIMENSION    NCHOPT(7)
--- cernlib-2006/patchy/p4boot.sh.use_OPT	2006-04-12 19:30:57.000000000 +0200
+++ cernlib-2006/patchy/p4boot.sh	2007-04-20 23:30:53.000000000 +0200
@@ -5,6 +5,8 @@
  set  TARG =   /usr/local/bin      # target directory
  set  FOPT  = "-O2"                # Fortran compiler options
  set  FOPTC = "-c $FOPT -posix"
+ set  COPT  = "-O2"                # C compiler options
+ set  COPTC =  "-c $COPT -posix"
  
 # *******************************************************************
 # *                                                                 *
@@ -151,7 +153,7 @@
  mkdir p4sub
  cd p4sub                    # operate in the sub-directory p4sub
  
- fcasplit  ../p4comp.fca  "$FOPTC"
+ fcasplit  ../p4comp.fca  "$FOPTC" "$COPTC"
  
  csh  -v p4comp.shfca
  
@@ -177,17 +179,17 @@
  echo ' -----------   ---->  Make the new Patchy executable files'
  set  CLD  = "f77"
  
- $CLD   -o ypatchy  ypatch.o   libp4lib.a
- $CLD   -o ytobcd   ytobcd.o   libp4lib.a
- $CLD   -o ytobin   ytobin.o   libp4lib.a
- $CLD   -o ytoceta  ytocet.o   libp4lib.a
- $CLD   -o yfrceta  yfrcet.o   libp4lib.a
- $CLD   -o ycompar  ycompa.o   libp4lib.a
- $CLD   -o yedit    yedit.o    libp4lib.a
- $CLD   -o yindexb  yindex.o   libp4lib.a
- $CLD   -o ylistb   ylist.o    libp4lib.a
- $CLD   -o ysearch  ysearc.o   libp4lib.a
- $CLD   -o yshift   yshift.o   libp4lib.a
+ $CLD $FOPT  -o ypatchy  ypatch.o   libp4lib.a
+ $CLD $FOPT  -o ytobcd   ytobcd.o   libp4lib.a
+ $CLD $FOPT  -o ytobin   ytobin.o   libp4lib.a
+ $CLD $FOPT  -o ytoceta  ytocet.o   libp4lib.a
+ $CLD $FOPT  -o yfrceta  yfrcet.o   libp4lib.a
+ $CLD $FOPT  -o ycompar  ycompa.o   libp4lib.a
+ $CLD $FOPT  -o yedit    yedit.o    libp4lib.a
+ $CLD $FOPT  -o yindexb  yindex.o   libp4lib.a
+ $CLD $FOPT  -o ylistb   ylist.o    libp4lib.a
+ $CLD $FOPT  -o ysearch  ysearc.o   libp4lib.a
+ $CLD $FOPT  -o yshift   yshift.o   libp4lib.a
  
  chmod a+x  ypatchy
  chmod a+x  ytobcd


--- NEW FILE paw-102-dont-optimize-some-code.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 102-dont-optimize-some-code.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Don't allow the compiler to optimize several files that cause trouble
## DP: (either compiler crash or broken code generation).

@DPATCH@
diff -urNad cernlib-2005.05.09/src/pawlib/comis/code/Imakefile /tmp/dpep.hNz5sX/cernlib-2005.05.09/src/pawlib/comis/code/Imakefile
--- cernlib-2005.05.09/src/pawlib/comis/code/Imakefile	2001-09-14 09:08:51.000000000 -0400
+++ /tmp/dpep.hNz5sX/cernlib-2005.05.09/src/pawlib/comis/code/Imakefile	2005-06-09 11:19:57.756983183 -0400
@@ -101,4 +101,10 @@
 SpecialFortranLibObjectRule(cskide,cskide,-O0,NullParameter)
 #endif
 
+#if defined(CERNLIB_LINUX)
+/* optimizing this file, even at -O1, causes runtime breakage with g77 3.3
+   cf. http://bugs.debian.org/233689 */
+SpecialFortranLibObjectRule(csrfun,csrfun,-O0,NullParameter)
+#endif
+
 SubdirLibraryTarget(NullParameter,NullParameter)


--- NEW FILE paw-105-fix-obsolete-xmfontlistcreate-warning.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 105-fix-obsolete-xmfontlistcreate-warning.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fix Lesstif warning about use of obsolete XmFontListCreate() function

@DPATCH@
diff -urNad cernlib-2005.05.09/src/pawlib/paw/cmotif/att_font.c /tmp/dpep.kv7bf1/cernlib-2005.05.09/src/pawlib/paw/cmotif/att_font.c
--- cernlib-2005.05.09/src/pawlib/paw/cmotif/att_font.c	2000-10-03 10:11:22.000000000 -0400
+++ /tmp/dpep.kv7bf1/cernlib-2005.05.09/src/pawlib/paw/cmotif/att_font.c	2005-06-09 14:39:00.803818666 -0400
@@ -215,18 +215,22 @@
  *****************************************************************************/
 static void MajButton(Widget w, Widget font,Widget pre,int postab)
 {
+   /* this function edited not to use obsolete function XmFontListCreate() */
    XmFontList police;
+   XmFontListEntry entry;
    XFontStruct *info_police;
    char strlabel[20];
    int prenum,policenum;
-
+   
    XtVaGetValues(pre,XmNuserData,&prenum,NULL);
    prenum--;
    XtVaGetValues(font,XmNuserData,&policenum,NULL);
    policenum--;
    if (( info_police=XLoadQueryFont(UxDisplay,StrFontTab[policenum]))== NULL)
       fprintf(stderr,"Unable to load font %s \n ",StrFontTab[policenum]);
-   police=XmFontListCreate(info_police,XmSTRING_DEFAULT_CHARSET);
+   entry = XmFontListEntryCreate(XmSTRING_DEFAULT_CHARSET,XmFONT_IS_FONT,
+				 (XtPointer)info_police);
+   police=XmFontListAppendEntry(NULL,entry);
    XtVaSetValues(w,XmNfontList,police,NULL);
    /* XFreeFont(UxDisplay,info_police);*/
 


--- NEW FILE paw-108-quote-protect-comis-script.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 108-quote-protect-comis-script.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/pawlib/comis/code/cscrexec.F /tmp/dpep.tIRzzG/cernlib-2005.05.09/src/pawlib/comis/code/cscrexec.F
--- cernlib-2005.05.09/src/pawlib/comis/code/cscrexec.F	2000-09-25 10:16:36.000000000 -0400
+++ /tmp/dpep.tIRzzG/cernlib-2005.05.09/src/pawlib/comis/code/cscrexec.F	2005-06-09 15:41:16.757077306 -0400
@@ -70,7 +70,7 @@
       LEXEC=LENOCC(FEXEC)
       OPEN(LUNOUT,FILE=FEXEC(:LEXEC), STATUS='UNKNOWN',ERR=99)
       WRITE(LUNOUT,'(A)')         '#!/bin/sh'
-      WRITE(LUNOUT,'(A)')         'olddir=`pwd`'
+      WRITE(LUNOUT,'(A)')         'olddir="`pwd`"'
 *      WRITE(LUNOUT,'(A)')         'cd '//CHPATH(:LPATH)
       CHLINE=                     'cd '//CHPATH(:LPATH)
       L=LENOCC(CHLINE)
@@ -206,7 +206,7 @@
       CHLINE=                     '/bin/rm -f '//NAME(:LN)//'.o'
       L=LENOCC(CHLINE)
       WRITE(LUNOUT,'(A)')CHLINE(:L)
-      WRITE(LUNOUT,'(A)')         'cd $olddir'
+      WRITE(LUNOUT,'(A)')         'cd "$olddir"'
       WRITE(LUNOUT,'(A)')         'exit 0'
       CALL CSCLOS(LUNOUT)
       CLOSE(LUNOUT)


--- NEW FILE paw-119-fix-compiler-warnings.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 119-fix-compiler-warnings.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fix a number of compiler warnings.  Courtesy of Harald Vogt.

@DPATCH@
diff -urNad paw-2.14.04~/src/pawlib/paw/ntuple/cern_types.h paw-2.14.04/src/pawlib/paw/ntuple/cern_types.h
--- paw-2.14.04~/src/pawlib/paw/ntuple/cern_types.h	1996-04-23 14:37:54.000000000 -0400
+++ paw-2.14.04/src/pawlib/paw/ntuple/cern_types.h	2006-09-08 14:58:22.811814451 -0400
@@ -36,26 +36,38 @@
 
 typedef unsigned int		UInt32;
 
+#ifndef UINT32_MAX
 #define	UINT32_MAX	UINT_MAX
+#endif
 
 
 /* typedef unsigned long long	UInt64; */
 typedef unsigned long 		UInt64;
 
+#ifndef UINT64_MAX
 #define	UINT64_MAX	ULONG_MAX
+#endif
 
 
 typedef int			Int32;
 
+#ifndef INT32_MAX
 #define	INT32_MAX	INT_MAX
+#endif
+#ifndef INT32_MIN
 #define	INT32_MIN	INT_MIN
+#endif
 
 
 /* typedef long long		Int64; */
 typedef long			Int64;
 
+#ifndef INT64_MAX
 #define	INT64_MAX	LONG_MAX
+#endif
+#ifndef INT64_MIN
 #define	INT64_MIN	LONG_MIN
+#endif
 
 
 typedef float			Float32;
diff -urNad paw-2.14.04~/src/pawlib/paw/ntuple/qp_vvec.c paw-2.14.04/src/pawlib/paw/ntuple/qp_vvec.c
--- paw-2.14.04~/src/pawlib/paw/ntuple/qp_vvec.c	1996-05-12 11:13:56.000000000 -0400
+++ paw-2.14.04/src/pawlib/paw/ntuple/qp_vvec.c	2006-09-08 14:49:56.490766940 -0400
@@ -19,6 +19,7 @@
  */
 
 #include	<stdlib.h>
+#include	<string.h>
 
 #include	"qp_report.h"
 #include	"qp_vvec.h"
diff -urNad paw-2.14.04~/src/pawlib/paw/xbae/caption.c paw-2.14.04/src/pawlib/paw/xbae/caption.c
--- paw-2.14.04~/src/pawlib/paw/xbae/caption.c	1996-03-01 06:39:36.000000000 -0500
+++ paw-2.14.04/src/pawlib/paw/xbae/caption.c	2006-09-08 15:05:15.658762762 -0400
@@ -244,7 +244,7 @@
      * it will use our name as it's label.
      */
     (void)
-        XtVaCreateManagedWidget(XtName(new),
+        XtVaCreateManagedWidget(XtName((Widget)new),
                                 xmLabelWidgetClass, (Widget)new,
                                 XmNbackground,  new->core.background_pixel,
                                 XmNforeground,  new->manager.foreground,
@@ -613,7 +613,7 @@
          * to handle gadgets (the Motif function always calls the gadgets
          * resize method)
          */
-#if XmREVISION == 1
+#if (XmREVISION == 1) && (! defined(LESSTIF_VERSION))
         _XmConfigureObject((RectObj)UserChild(cw),
 #else
         _XmConfigureObject((Widget)UserChild(cw),
diff -urNad paw-2.14.04~/src/pawlib/paw/xbae/clip.c paw-2.14.04/src/pawlib/paw/xbae/clip.c
--- paw-2.14.04~/src/pawlib/paw/xbae/clip.c	1996-03-01 06:39:36.000000000 -0500
+++ paw-2.14.04/src/pawlib/paw/xbae/clip.c	2006-09-08 14:49:56.491766727 -0400
@@ -190,8 +190,8 @@
      * XXX It might be more efficient to fake up an Expose event
      * and call Redisplay directly
      */
-    if (XtIsRealized(cw))
-        XClearArea(XtDisplay(cw), XtWindow(cw),
+    if (XtIsRealized((Widget)cw))
+        XClearArea(XtDisplay((Widget)cw), XtWindow((Widget)cw),
                    0, 0,
                    0 /*Full Width*/, 0 /*Full Height*/,
                    True);
diff -urNad paw-2.14.04~/src/pawlib/paw/xbae/matrix.c paw-2.14.04/src/pawlib/paw/xbae/matrix.c
--- paw-2.14.04~/src/pawlib/paw/xbae/matrix.c	1998-09-02 11:23:57.000000000 -0400
+++ paw-2.14.04/src/pawlib/paw/xbae/matrix.c	2006-09-08 14:49:56.494766087 -0400
@@ -67,7 +67,10 @@
 #endif
 
 /* this BSDism is used to often to replace it in the code */
+/* but avoid warning of redefinition for linux OS         */
+#ifndef linux
 #define bcopy(src,dst,n) memmove(dst,src,n)
+#endif
 
 /*
  * Translations for Matrix (these will also be used by the Clip child).
@@ -3467,7 +3470,7 @@
      */
     VERT_ORIGIN(mw) = call_data->value;
 
-    if (!XtIsRealized(mw))
+    if (!XtIsRealized((Widget)mw))
         return;
 
     /*
@@ -3646,7 +3649,7 @@
      */
     HORIZ_ORIGIN(mw) = call_data->value;
 
-    if (!XtIsRealized(mw))
+    if (!XtIsRealized((Widget)mw))
         return;
 
     /*
@@ -6162,7 +6165,7 @@
     (*((XbaeMatrixWidgetClass) XtClass(mw))->matrix_class.cancel_edit)
         (mw, True);
 
-    if (XtIsRealized(mw)) {
+    if (XtIsRealized((Widget)mw)) {
         /*
          * Generate expose events on Matrix and Clip to force the
          * new rows to be drawn.
@@ -6254,7 +6257,7 @@
     (*((XbaeMatrixWidgetClass) XtClass(mw))->matrix_class.cancel_edit)
         (mw, True);
 
-    if (XtIsRealized(mw)) {
+    if (XtIsRealized((Widget)mw)) {
         /*
          * Generate expose events on Matrix and Clip to force the
          * rows to be redrawn.
@@ -6349,7 +6352,7 @@
     (*((XbaeMatrixWidgetClass) XtClass(mw))->matrix_class.cancel_edit)
         (mw, True);
 
-    if (XtIsRealized(mw)) {
+    if (XtIsRealized((Widget)mw)) {
         /*
          * Generate expose events on Matrix and Clip to force the
          * new columns to be drawn.
@@ -6446,7 +6449,7 @@
     (*((XbaeMatrixWidgetClass) XtClass(mw))->matrix_class.cancel_edit)
         (mw, True);
 
-    if (XtIsRealized(mw)) {
+    if (XtIsRealized((Widget)mw)) {
         /*
          * Generate expose events on Matrix and Clip to force the
          * columns to be redrawn.
@@ -6528,7 +6531,7 @@
         for (j = 0; j < mw->matrix.columns; j++)
             mw->matrix.cell_background[i + position][j] = colors[i];
 
-    if (XtIsRealized(mw)) {
+    if (XtIsRealized((Widget)mw)) {
         /*
          * Redraw all the visible non-fixed cells. We don't need to clear first
          * since only the color changed.
@@ -6626,7 +6629,7 @@
         for (j = 0; j < num_colors; j++)
             mw->matrix.cell_background[i][j + position] = colors[j];
 
-    if (XtIsRealized(mw)) {
+    if (XtIsRealized((Widget)mw)) {
         /*
          * Redraw all the visible non-fixed cells. We don't need to clear first
          * since only the color changed.
@@ -6716,7 +6719,7 @@
      */
     mw->matrix.cell_background[row][column] = color;
 
-    if (XtIsRealized(mw)) {
+    if (XtIsRealized((Widget)mw)) {
         /*
          * Redraw the cell if it is visible
          */


--- NEW FILE paw-120-fix-mlp-cdf-file.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 120-fix-mlp-cdf-file.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: add missing >Guidance keyword in CDF file before help text.

@DPATCH@
diff -urNad paw-2.14.04.dfsg~/src/pawlib/paw/cdf/mlpdef.cdf paw-2.14.04.dfsg/src/pawlib/paw/cdf/mlpdef.cdf
--- paw-2.14.04.dfsg~/src/pawlib/paw/cdf/mlpdef.cdf	2001-05-21 05:12:35.000000000 -0400
+++ paw-2.14.04.dfsg/src/pawlib/paw/cdf/mlpdef.cdf	2007-01-17 14:26:43.199756845 -0500
@@ -260,6 +260,7 @@
 >Action mlppawc%c
 
 >Menu ../TPAT
+>Guidance
 Operations on the test patterns
 .
 Whereas it is obviously necessary to define learning


--- NEW FILE paw-121-call-gfortran-in-cscrexec.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 121-call-gfortran-in-cscrexec.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Build temporary shared libs with gfortran when it is the default
## DP: Fortran compiler on Linux and OS X.

@DPATCH@
diff -urNad paw-2.14.04.dfsg~/src/pawlib/comis/code/cscrexec.F paw-2.14.04.dfsg/src/pawlib/comis/code/cscrexec.F
--- paw-2.14.04.dfsg~/src/pawlib/comis/code/cscrexec.F	2007-03-06 15:05:30.173089849 -0500
+++ paw-2.14.04.dfsg/src/pawlib/comis/code/cscrexec.F	2007-03-06 15:08:05.919014086 -0500
@@ -179,14 +179,25 @@
       ENDIF
 #endif
 #if defined(CERNLIB_LINUX) && !defined(CERNLIB_MACOSX)
-      CHLINE=                   'ld -shared -o '
+#if defined (CERNLIB_GFORTRAN)
+      CHLINE=                   'gfortran -shared -o '
      +                    // NAME(:LN) //'.sl '// NAME(:LN) //'.o'
+#else
+      CHLINE=                   'g77 -shared -o '
+     +                    // NAME(:LN) //'.sl '// NAME(:LN) //'.o'
+#endif
 #endif
 #if defined(CERNLIB_MACOSX)
+#if defined (CERNLIB_GFORTRAN)
+      CHLINE= 'gfortran -bundle -bundle_loader `/usr/bin/which pawX11`'
+     +                    // ' -bind_at_load -o '
+     +                    // NAME(:LN) //'.sl '// NAME(:LN) //'.o'
+#else
       CHLINE= 'g77 -bundle -bundle_loader `/usr/bin/which pawX11` '
      +                    // ' -bind_at_load -o '
      +                    // NAME(:LN) //'.sl '// NAME(:LN) //'.o'
 #endif
+#endif
 #if defined(CERNLIB_ALPHA_OSF)
         CHLINE=                   'ld -shared -o '
      +                    // NAME(:LN) //'.sl '// NAME(:LN) //'.o \\'


--- NEW FILE paw-200-comis-allow-special-chars-in-path.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 200-comis-allow-special-chars-in-path.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/pawlib/paw/code/pawfca.F /tmp/dpep.gkT1Y2/cernlib-2005.05.09/src/pawlib/paw/code/pawfca.F
--- cernlib-2005.05.09/src/pawlib/paw/code/pawfca.F	1997-05-20 05:37:58.000000000 -0400
+++ /tmp/dpep.gkT1Y2/cernlib-2005.05.09/src/pawlib/paw/code/pawfca.F	2005-06-08 19:34:43.101436210 -0400
@@ -29,6 +29,7 @@
 C.    *        CHFUNC may be the name of a COMIS function              *
 C.    *        or a file name. A file cannot contain one of            *
 C.    *        the following characters: +*=-()<>                      *
+C.    *        [n.b. patched to work around this. --Kevin McCarty]     *
 C.    *                                                                *
 C.    ******************************************************************
 #include "paw/pawcfu.inc"
@@ -60,7 +61,11 @@
       IF(NCH.LE.0)GO TO 99
       IFILE=0
       TFILE=' '
-      IF(INDEX(CHFUNC,']').EQ.0.AND.INDEX(CHFUNC,':').EQ.0)THEN
+* Added '/' as a character symbolizing a filename; otherwise Unix paths
+* containing +, *, =, -, etc. return a bogus "Unknown routine" error
+* (Fix by Kevin McCarty)
+      IF(INDEX(CHFUNC,']').EQ.0.AND.INDEX(CHFUNC,':').EQ.0.AND.
+     +   INDEX(CHFUNC,'/').EQ.0)THEN
          IF(INDEX(CHFUNC,'+').NE.0.OR.
      +      INDEX(CHFUNC,'*').NE.0.OR.
      +      INDEX(CHFUNC,'=').NE.0.OR.


--- NEW FILE paw-207-compile-temp-libs-with-fPIC.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 207-compile-temp-libs-with-fPIC.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Compile temporary COMIS libraries with -fPIC for non-x86 arches.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/pawlib/comis/code/cscrexec.F /tmp/dpep.srSRmd/cernlib-2005.05.09/src/pawlib/comis/code/cscrexec.F
--- cernlib-2005.05.09/src/pawlib/comis/code/cscrexec.F	2000-09-25 10:16:36.000000000 -0400
+++ /tmp/dpep.srSRmd/cernlib-2005.05.09/src/pawlib/comis/code/cscrexec.F	2005-06-09 15:47:44.859676286 -0400
@@ -81,12 +81,12 @@
       WRITE(LUNOUT,'(A)')CHLINE(:L)
       IF(FEXT.EQ.'.c')THEN
         L=LENOCC(CHCC)
-*                                 'cc -c .... name.c'
-        CHLINE=CHCC(:L)//' '//NAME(:LN)// '.c'
+*                                 'cc -c .... -fPIC name.c'
+        CHLINE=CHCC(:L)//' -fPIC '//NAME(:LN)// '.c'
       ELSE
         L=LENOCC(CHF77)
-*                                 'f77 -c .... name.f'
-        CHLINE=CHF77(:L)//' '//NAME(:LN)// '.f'
+*                                 'f77 -c .... -fPIC name.f'
+        CHLINE=CHF77(:L)//' -fPIC '//NAME(:LN)// '.f'
       ENDIF
       L=LENOCC(CHLINE)
       WRITE(LUNOUT,'(A)')CHLINE(:L)


--- NEW FILE paw-211-support-amd64-and-itanium.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 211-support-amd64-and-itanium.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Large patch from Harald Vogt <hvogt at ifh.de> to make PAW and Paw++ work
## DP: (at least when statically linked) on 64-bit architectures.
## DP: Slightly modified in an attempt to keep ABI compatibility of the
## DP: dynamic libraries; not that it matters much as they don't work well
## DP: when dynamically linked on 64-bit anyway.  Last revision 2006-07-20.

@DPATCH@
diff -urNad paw-2.14.04~/src/pawlib/comis/code/Imakefile paw-2.14.04/src/pawlib/comis/code/Imakefile
--- paw-2.14.04~/src/pawlib/comis/code/Imakefile	2006-09-08 14:44:11.387353882 -0400
+++ paw-2.14.04/src/pawlib/comis/code/Imakefile	2006-09-08 14:44:11.806264586 -0400
@@ -50,6 +50,10 @@
 SRCS_F := $(SRCS_F) cscrexec.F
 #endif
 
+#if defined(CERNLIB_QMLXIA64)
+SRCS_F := $(SRCS_F) csrtgpl.F csitgpl.F
+#endif
+
 #if defined(CERNLIB_OLD)
 SRCS_F := $(SRCS_F) cspdir.F csrmbk.F
 #endif
diff -urNad paw-2.14.04~/src/pawlib/comis/code/csaddr.F paw-2.14.04/src/pawlib/comis/code/csaddr.F
--- paw-2.14.04~/src/pawlib/comis/code/csaddr.F	1996-02-26 12:16:25.000000000 -0500
+++ paw-2.14.04/src/pawlib/comis/code/csaddr.F	2006-09-08 14:44:11.806264586 -0400
@@ -17,8 +17,15 @@
       INTEGER CSLTGP,CSITGP
       CHARACTER*32 NAME
 #include "comis/cstab.inc"
-#if defined(CERNLIB_SHL)
+#if defined(CERNLIB_SHL)&&(!defined(CERNLIB_QMLXIA64))
       INTEGER CS_GET_FUNC
+#endif
+#if defined(CERNLIB_SHL)&&(defined(CERNLIB_QMLXIA64))
+#include "comis/cstab64.inc"
+      INTEGER CSITGPL
+      INTEGER*8 CS_GET_FUNC
+#endif
+#if defined(CERNLIB_SHL)
       NAME=CHNAME
       NC=LENOCC(NAME)
       CALL CSCHID(NAME(:NC))
@@ -26,21 +33,39 @@
       I=CSLTGP(IPVS)
       IF(I.GT.0)THEN
         IF(IFCS.EQ.0)THEN
+#if defined (CERNLIB_QMLXIA64)
+          IADGPL=CS_GET_FUNC(NAME(1:NC)//'_')
+          IF(IADGPL.NE.0)THEN
+            IFCS=-2
+            CALL CSRTGPL(I)
+#else
           IADGP=CS_GET_FUNC(NAME(1:NC)//'_')
           IF(IADGP.NE.0)THEN
             IFCS=-2
             CALL CSRTGP(I)
+#endif
+#endif
+#if defined(CERNLIB_SHL)
           ELSE
             I=0
           ENDIF
         ENDIF
       ELSE
+#if defined (CERNLIB_QMLXIA64)
+          IADGPL=CS_GET_FUNC(NAME(1:NC)//'_')
+        IF(IADGPL.NE.0)THEN
+          IFCS=-2
+          ITYPGP=-2
+          I=CSITGPL(IPVS)
+        ENDIF
+#else
         IADGP=CS_GET_FUNC(NAME(1:NC)//'_')
         IF(IADGP.NE.0)THEN
           IFCS=-2
           ITYPGP=-2
           I=CSITGP(IPVS)
         ENDIF
+#endif
       END IF
       CSADDR=I
 #endif
diff -urNad paw-2.14.04~/src/pawlib/comis/code/csinit.F paw-2.14.04/src/pawlib/comis/code/csinit.F
--- paw-2.14.04~/src/pawlib/comis/code/csinit.F	2005-04-18 11:41:04.000000000 -0400
+++ paw-2.14.04/src/pawlib/comis/code/csinit.F	2006-09-08 14:44:11.807264373 -0400
@@ -64,6 +64,9 @@
 #if defined(CERNLIB_SHL)
 #include "comis/cshlnm.inc"
 #endif
+#if defined(CERNLIB_SHL)&&(defined(CERNLIB_QMLXIA64))
+#include "comis/cstab64.inc"
+#endif
 #if defined(CERNLIB_PAW)
 #include "paw/pcmode.inc"
 #include "comis/cshfill.inc"
@@ -159,6 +162,9 @@
       ICHMINU=ICHAR('-')
       ICHPLUS=ICHAR('+')
       ICHCOMM=ICHAR(',')
+#if defined(CERNLIB_SHL)&&(defined(CERNLIB_QMLXIA64))
+      IPIADGV=0
+#endif
 #if defined(CERNLIB_PAW)
       CALL CSPAWI
       MODHFI=0
@@ -211,8 +217,8 @@
 #endif
 #if (defined(CERNLIB_LINUX))
       ITMPLEN=CSTMPD(CHPATH, 256)
-      CHF77 ='g77 -c'
-      CHCC  ='cc -c'
+      CHF77 ='g77 -g -c -fPIC'
+      CHCC  ='cc -g -c -fPIC'
 #endif
 #if (defined(CERNLIB_SGI))&&(defined(CERNLIB_SHL))
       ITMPLEN=CSTMPD(CHPATH, 256)
diff -urNad paw-2.14.04~/src/pawlib/comis/code/csintx.F paw-2.14.04/src/pawlib/comis/code/csintx.F
--- paw-2.14.04~/src/pawlib/comis/code/csintx.F	1996-12-05 04:50:37.000000000 -0500
+++ paw-2.14.04/src/pawlib/comis/code/csintx.F	2006-09-08 14:44:11.807264373 -0400
@@ -38,6 +38,9 @@
 #if defined(CERNLIB_PAW)
 #include "comis/cskucs.inc"
 #endif
+#if defined(CERNLIB_QMLXIA64)
+#include "comis/cstab64.inc"
+#endif
 #if (defined(CERNLIB_UNIX))&&(!defined(CERNLIB_ALPHA_OSF))
       INTEGER CSTRCMP
 #endif
@@ -1105,6 +1108,23 @@
       ENDIF
 #endif
 #if (!defined(CERNLIB_VAX))&&(!defined(CERNLIB_APOLLO))
+#if defined(CERNLIB_QMLXIA64)
+      IF(IQ(IP+KSIFCS).EQ.-2)THEN
+*Dynamic linker may give long addresses
+        IADGPL = IADGPLV(IADGP)
+      ELSE
+        IADGPL = IADGP
+      ENDIF
+      IF(ITP.EQ.1.OR.ITP.EQ.4.OR.ITP.EQ.6)THEN
+        ICSRES=CSCALI(IADGPL,NPAR,IDA(IOFSPL))
+      ELSEIF(ITP.EQ.2)THEN
+        RCSRES=CSCALR(IADGPL,NPAR,IDA(IOFSPL))
+      ELSEIF(ITP.EQ.5)THEN
+        DCSRES=CSCALD(IADGPL,NPAR,IDA(IOFSPL))
+      ELSEIF(ITP.EQ.7)THEN
+        DCSRES=CSCALD(IADGPL,NPAR,IDA(IOFSPL))
+      ENDIF
+#else
       IF(ITP.EQ.1.OR.ITP.EQ.4.OR.ITP.EQ.6)THEN
         ICSRES=CSCALI(IADGP,NPAR,IDA(IOFSPL))
       ELSEIF(ITP.EQ.2)THEN
@@ -1115,6 +1135,7 @@
         DCSRES=CSCALD(IADGP,NPAR,IDA(IOFSPL))
       ENDIF
 #endif
+#endif
       IPC=IPC+4
       GO TO 999
 *NUM I
diff -urNad paw-2.14.04~/src/pawlib/comis/code/csitgpl.F paw-2.14.04/src/pawlib/comis/code/csitgpl.F
--- paw-2.14.04~/src/pawlib/comis/code/csitgpl.F	1969-12-31 19:00:00.000000000 -0500
+++ paw-2.14.04/src/pawlib/comis/code/csitgpl.F	2006-09-08 14:44:11.808264160 -0400
@@ -0,0 +1,32 @@
+* Comis
+*
+*
+#if (defined(CERNLIB_QMLXIA64))
+#include "comis/pilot.h"
+*CMZU:  1.16/16 04/10/93  12.14.52  by  Vladimir Berezhnoi
+*-- Author : V.Berezhnoi
+* special for 64 bit addresses for dynamic linking (H. Vogt)
+      INTEGER FUNCTION CSITGPL(IP)
+***------------------------------
+*   it is last routine from the tables-set.
+***-----------------------------
+#include "comis/cspar.inc"
+#include "comis/mdpool.inc"
+#include "comis/cspnts.inc"
+#include "comis/cstabps.inc"
+#include "comis/cstab64.inc"
+      I=MHLOC(KSIDP+NWIDEN)
+      IQ(I)=0
+      IQ(I+1)=NCIDEN
+      DO 1 K=1,NWIDEN
+        IQ(I+KSIDP-1+K)=IDEN(K)
+   1  CONTINUE
+      CALL CSRTGPL(I)
+      IF(IP.EQ.0)THEN
+        IPGP=I
+      ELSE
+        IQ(IP)=I
+      ENDIF
+      CSITGPL=I
+      END
+#endif
diff -urNad paw-2.14.04~/src/pawlib/comis/code/cskcal.F paw-2.14.04/src/pawlib/comis/code/cskcal.F
--- paw-2.14.04~/src/pawlib/comis/code/cskcal.F	1996-12-05 04:50:39.000000000 -0500
+++ paw-2.14.04/src/pawlib/comis/code/cskcal.F	2006-09-08 14:44:11.808264160 -0400
@@ -31,6 +31,9 @@
 #include "comis/cstab.inc"
 #include "comis/csfres.inc"
 #include "comis/cssysd.inc"
+#if defined(CERNLIB_QMLXIA64)
+#include "comis/cstab64.inc"
+#endif
       CHARACTER PRONAME*32
       INTEGER CSCALI
       DOUBLE PRECISION CSCALD
@@ -232,6 +235,24 @@
         I2=I2+KS
         I=I+1
  9203 CONTINUE
+#if defined(CERNLIB_QMLXIA64)
+*  Dynamic linker may give long addresses
+      IF (IFCS.EQ.-2)THEN
+        IADGPL = IADGPLV(IADGP)
+      ELSE
+        IADGPL = IADGP
+      ENDIF
+      IF(ITP.EQ.1.OR.ITP.EQ.4.OR.ITP.EQ.6)THEN
+        ICSRES=CSCALI(IADGPL,NOPAR,IF77PL(1))
+      ELSEIF(ITP.EQ.2)THEN
+        RCSRES=CSCALR(IADGPL,NOPAR,IF77PL(1))
+      ELSEIF(ITP.EQ.5)THEN
+        DCSRES=CSCALD(IADGPL,NOPAR,IF77PL(1))
+      ELSEIF(ITP.EQ.7)THEN
+*  I think it will works correctly
+        DCSRES=CSCALD(IADGPL,NOPAR,IF77PL(1))
+      ENDIF
+#else
 *      IT=IABS(ITYPGP)
       IF(ITP.EQ.1.OR.ITP.EQ.4.OR.ITP.EQ.6)THEN
         ICSRES=CSCALI(IADGP,NOPAR,IF77PL(1))
@@ -245,6 +266,7 @@
       ENDIF
 *+SELF,IF=UNIX,IF=-SGI,IF=-IBMRT,IF=-DECS,IF=-HPUX,IF=-SUN,IF=-MSDOS.
 #endif
+#endif
 #if (defined(CERNLIB_UNIX))&&(!defined(CERNLIB_STDUNIX))
       I=1
       DO 9203 K=ITA-NPAR+1,ITA
diff -urNad paw-2.14.04~/src/pawlib/comis/code/cslink.F paw-2.14.04/src/pawlib/comis/code/cslink.F
--- paw-2.14.04~/src/pawlib/comis/code/cslink.F	1996-02-26 12:16:17.000000000 -0500
+++ paw-2.14.04/src/pawlib/comis/code/cslink.F	2006-09-08 14:44:11.808264160 -0400
@@ -21,10 +21,15 @@
 #include "comis/cstab.inc"
 #include "comis/cspnts.inc"
 #include "comis/cslun.inc"
-#if defined(CERNLIB_SHL)
+#if defined(CERNLIB_SHL)&&(!defined(CERNLIB_QMLXIA64))
       CHARACTER*(KLENID) FNNAME
       INTEGER CS_GET_FUNC
 #endif
+#if defined(CERNLIB_SHL)&&(defined(CERNLIB_QMLXIA64))
+#include "comis/cstab64.inc"
+      CHARACTER*(KLENID) FNNAME
+      INTEGER*8 CS_GET_FUNC
+#endif
          COMMON/CSGSCM/IGS,JGS,NGS,CSJUNK(3)
       IF(ISTLIB.EQ.0 .AND. ITBS.EQ.0)RETURN
    2  I=IPGP
@@ -60,12 +65,20 @@
 #if defined(CERNLIB_SHL)
           CALL CSGTIDP(I,FNNAME,NC)
           CALL CUTOL(FNNAME(1:NC))
+#if defined (CERNLIB_QMLXIA64)
+          IADGPL=CS_GET_FUNC(FNNAME(1:NC)//'_')
+          IF(IADGPL.NE.0)THEN
+            IFCS=-2
+            CALL CSRTGPL(I)
+          ENDIF
+#else
           IADGP=CS_GET_FUNC(FNNAME(1:NC)//'_')
           IF(IADGP.NE.0)THEN
             IFCS=-2
             CALL CSRTGP(I)
           ENDIF
 #endif
+#endif
           IP=0
         ENDIF
       ENDIF
diff -urNad paw-2.14.04~/src/pawlib/comis/code/cspawi.F paw-2.14.04/src/pawlib/comis/code/cspawi.F
--- paw-2.14.04~/src/pawlib/comis/code/cspawi.F	1996-02-26 12:16:22.000000000 -0500
+++ paw-2.14.04/src/pawlib/comis/code/cspawi.F	2006-09-08 14:44:11.808264160 -0400
@@ -23,10 +23,12 @@
       COMMON/PAWC/NWPAW,IXPAWC,IHDIV,IXHIGZ,IXKU,FENC(5),LMAIN,HCV(9989)
       DIMENSION IQ(2),Q(2),LQ(8000)
       EQUIVALENCE (LQ(1),LMAIN),(IQ(1),LQ(9)),(Q(1),IQ(1))
+      CHARACTER*8 MYCSPAWC
+      MYCSPAWC = 'CSPAWC  '
 ****      JKUVBS=LOCF(IQ(1))-1
       JKUVBS=LOCF(IQ(1))+KUVOFS-1
       KUVCUR=0
-      CALL CCOPYS(MJSCHA('CSPAWC  '),JID,8)
+      CALL CCOPYS(MJSCHA(MYCSPAWC),JID,8)
       NCIDEN=6
       NWIDEN=2
       I=CSLTGB(IPVS)
diff -urNad paw-2.14.04~/src/pawlib/comis/code/csrtgpl.F paw-2.14.04/src/pawlib/comis/code/csrtgpl.F
--- paw-2.14.04~/src/pawlib/comis/code/csrtgpl.F	1969-12-31 19:00:00.000000000 -0500
+++ paw-2.14.04/src/pawlib/comis/code/csrtgpl.F	2006-09-08 14:44:11.808264160 -0400
@@ -0,0 +1,31 @@
+* Comis
+*
+*
+#if (defined(CERNLIB_QMLXIA64))
+#include "comis/pilot.h"
+*CMZ :  1.18/14 10/01/95  15.41.06  by  Vladimir Berezhnoi
+*-- Author : V.Berezhnoi
+* special for 64 bit addresses for dynamic linking (H. Vogt)
+
+      SUBROUTINE CSRTGPL(I)
+***--------------------------
+#include "comis/cspar.inc"
+#include "comis/mdpool.inc"
+#include "comis/cstabps.inc"
+#include "comis/cstab.inc"
+#include "comis/cstab64.inc"
+
+      IPIADGV = IPIADGV + 1
+      IF (IPIADGV .GT. MAXIAD64)  THEN
+        WRITE (*,'(2a,I4)') 'to much addresses for dynamik linking, ',
+     &                      'limit is ', MAXIAD64
+        WRITE (*,'(2a)') 'increase MAXIAD64 in cstab64.inc and ',
+     &                    'recompile COMIS'
+
+        STOP
+      END IF
+      IADGPLV(IPIADGV) = IADGPL
+      IADGP            = IPIADGV
+      CALL CCOPYA(IADGP,IQ(I+2),KSIDP-2)
+      END
+#endif
diff -urNad paw-2.14.04~/src/pawlib/comis/code/cstran.F paw-2.14.04/src/pawlib/comis/code/cstran.F
--- paw-2.14.04~/src/pawlib/comis/code/cstran.F	2001-02-07 04:27:01.000000000 -0500
+++ paw-2.14.04/src/pawlib/comis/code/cstran.F	2006-09-08 14:44:11.810263734 -0400
@@ -521,6 +521,7 @@
 *                 '#'             DRSJNT
 *            'OD'/'FI'/'ENDDO'/'ENDIF'/'END' DELIM DRSJNT
 ****
+      CHARACTER*8 MYCSPAWC
       INTEGER GSCMST(3046),GSSTRC(135),GSSTRP(255)
       INTEGER GSCMS1(361),GSCMS2(361),GSCMS3(361),GSCMS4(361),
      *GSCMS5(361),GSCMS6(361),GSCMS7(361),GSCMS8(361),GSCMS9(158)
@@ -719,6 +720,7 @@
       DATA IOST/0/
 **      DATA NHSSC/4H;   /, NHSEQ/4H=   /, NHSBR/4H)   /
       DATA NMPAWC/4HPAWC/
+      MYCSPAWC = 'CSPAWC  '
       CALL CCOPYA(IDEN,IDENPR,NWIDEN)
       NCIDPR=NCIDEN
       NWIDPR=NWIDEN
@@ -903,7 +905,7 @@
   211 CONTINUE
 #if defined(CERNLIB_PAW)
       KEYWD=22
-      CALL CCOPYS(MJSCHA('CSPAWC  '),JID,8)
+      CALL CCOPYS(MJSCHA(MYCSPAWC),JID,8)
       NCIDEN=6
       NWIDEN=2
       IGB=CSLTGB(IPVSB)
diff -urNad paw-2.14.04~/src/pawlib/comis/comis/cstab64.inc paw-2.14.04/src/pawlib/comis/comis/cstab64.inc
--- paw-2.14.04~/src/pawlib/comis/comis/cstab64.inc	1969-12-31 19:00:00.000000000 -0500
+++ paw-2.14.04/src/pawlib/comis/comis/cstab64.inc	2006-09-08 14:44:11.810263734 -0400
@@ -0,0 +1,10 @@
+*
+*
+* cstab64.inc
+*
+      PARAMETER (MAXIAD64=100) !maximum number of shared objects
+      INTEGER*8 IADGPL,IADGPLV(MAXIAD64)
+      INTEGER   IADGPL1, IADGPL2
+      COMMON /CSTB64/ IADGPL,IADGPLV
+      COMMON /CSTB64I/ IPIADGV
+      EQUIVALENCE (IADGPL, IADGPL1)
diff -urNad paw-2.14.04~/src/pawlib/comis/deccc/ccopys.c paw-2.14.04/src/pawlib/comis/deccc/ccopys.c
--- paw-2.14.04~/src/pawlib/comis/deccc/ccopys.c	1997-09-02 11:50:38.000000000 -0400
+++ paw-2.14.04/src/pawlib/comis/deccc/ccopys.c	2006-09-08 14:44:11.810263734 -0400
@@ -33,11 +33,42 @@
 #else
 void ccopys_(ja,jb,nn)
 #endif
+
+/*
+ * 64-bit pointer systems require a special treatment of addresses - see below -
+ * using the CERNLIB_QMLXIA64 cpp flag (H. Vogt - Sep 2005)
+ */
+
+/* For Itanium, the situation is even worse.  Itanium architecture is such
+ * that the data section starts at 0x6000000000000000.  The stack is
+ * supposed to be between 0x80...0 and 0xa0...0 starting at the high end
+ * and growing downwards, although on a test machine (merulo.debian.org)
+ * it seemed instead to start at 0x6000100000000000 and grow downwards.
+ * The addresses we actually get are truncated to the lowest 32 bits,
+ * so we assume that those greater than 0x80000000 are in the stack.
+ *
+ * Constant strings are in the text section starting at 0x40...0; we hope
+ * this function doesn't receive any.
+ * -- Kevin McCarty
+ */
+
+#if defined(CERNLIB_QMLXIA64)
+# include "cscal_lp64.h"
+     int *ja, *jb;
+     int *nn;
+{
+  int i,n; char *a,*b;
+  n=*nn; 
+  setaddr_lp64(*ja,*jb)
+
+#else
      char **ja, **jb;
      int *nn;
 {
   int i,n; char *a,*b;
-  n=*nn; a=*ja; b=*jb;
+  n=*nn; 
+  a=*ja; b=*jb;
+#endif
   if ( a >= b )
      for ( i=0; i<n; i++ )
           b[i]=a[i];
diff -urNad paw-2.14.04~/src/pawlib/comis/deccc/cs_hlshl.c paw-2.14.04/src/pawlib/comis/deccc/cs_hlshl.c
--- paw-2.14.04~/src/pawlib/comis/deccc/cs_hlshl.c	1998-01-12 04:56:07.000000000 -0500
+++ paw-2.14.04/src/pawlib/comis/deccc/cs_hlshl.c	2006-09-08 14:48:50.060932620 -0400
@@ -25,9 +25,24 @@
 #if (defined(CERNLIB_SUN)||defined(CERNLIB_SGI)||defined(CERNLIB_IBMRT)||defined(CERNLIB_ALPHA_OSF)||defined(CERNLIB_LINUX))&&(defined(CERNLIB_SHL))
 /*CMZ :          22/05/95  18.40.45  by  Julian Bunn*/
 /*-- Author :*/
-#if defined(CERNLIB_SUN)||defined(CERNLIB_LINUX)
+#if defined(CERNLIB_SUN)||defined(CERNLIB_LINUX)&&(!defined(CERNLIB_QMLXIA64))
 #define SUN
 #endif
+
+/*
+ * 64-bit pointer systems require a special treatment of addresses  
+ * using the CERNLIB_QMLXIA64 cpp flag (H. Vogt - Sep 2005)
+ * This code will be consistent with that of jumptn.c and jumpxn.c
+ * in packlib/kernlib/kerngen/ccgen (usage of jumpad_)
+ */
+
+#if defined(CERNLIB_LINUX)
+#include <stdio.h>
+#if defined(CERNLIB_QMLXIA64)
+#define ALPHA_OSF
+#endif
+#endif
+
 #if defined(CERNLIB_SGI)
 #define SGI
 #endif
diff -urNad paw-2.14.04~/src/pawlib/comis/deccc/cscal_lp64.h paw-2.14.04/src/pawlib/comis/deccc/cscal_lp64.h
--- paw-2.14.04~/src/pawlib/comis/deccc/cscal_lp64.h	1969-12-31 19:00:00.000000000 -0500
+++ paw-2.14.04/src/pawlib/comis/deccc/cscal_lp64.h	2006-09-08 14:44:11.811263521 -0400
@@ -0,0 +1,74 @@
+#if defined(CERNLIB_QMLXIA64)
+/* Hideous hack macros that attempt to deal with 64-bit pointers using
+ * knowledge about only 32 bits of them. */
+
+/* Test whether a variable is automatic or static based on the lowest 32 bits
+ * of its address.
+ *
+ * Itanium architecture is such that the data section starts at
+ * 0x6000000000000000.  The stack is supposed to be between 0x80...0 and
+ * 0xa0...0 starting at the high end and growing downwards, although on a test
+ * machine (merulo.debian.org) it seemed instead to start at 0x6000100000000000
+ * and grow downwards.  The addresses we actually get are truncated to the
+ * lowest 32 bits, so we assume that those greater than 0x80000000 are in the
+ * stack.  Constant strings are in the text section starting at 0x40...0; we
+ * hope that functions using these macros don't receive any.
+ *
+ * On AMD64, the data section and constant strings are all within 32 bits
+ * of NULL, starting at 0x400000 and growing upward.  The stack starts
+ * at 0x80000000000 and grows downward.  However, tests I've run on an AMD64
+ * indicate that the low-order 32 bits of the address for variables on the
+ * stack may be indistinguishable from data segments; therefore we simply
+ * hope (pray) that all variables used are in the data segments.
+ *
+ * On Alpha, on the other hand, I couldn't find any docs for the Linux
+ * segmentation for virtual memory.  Judging by a test machine
+ * (escher.debian.org), the data section starts slightly above 0x120010000.
+ * On the other hand the stack grows downward from 0x120000000.  Here it
+ * seems safe to suppose that the variable is in the stack if the uint32
+ * truncated address received is less than 0x20000000.
+ *
+ * -- Kevin McCarty
+ */
+
+#if defined (__ia64__)
+# define autotest(_var) ((unsigned long)(_var) > 0x80000000UL)
+#elif defined (__alpha__)
+# define autotest(_var) ((unsigned long)(_var) < 0x20000000UL)
+#else /* amd64 */
+# define autotest(_var) 0 /* can't test for it */
+#endif
+
+
+#define restore_pointer(_var, _ptr, _cast) do {			      	    \
+   static int sdummy = 0; int adummy = 0;                                   \
+   unsigned long sbase = ((unsigned long)&sdummy) & 0xffffffff00000000UL;   \
+   unsigned long abase = ((unsigned long)&adummy) & 0xffffffff00000000UL;   \
+   _ptr = (_cast)((unsigned long)(_var) + (autotest(_var) ? abase : sbase));\
+ } while (0)
+
+
+#define setcall_lp64(type)                                                  \
+ long *fptr;                                                                \
+ int *n;                                                                    \
+ unsigned pin[16];                                                          \
+{                                                                           \
+   int jumpad_();                                                           \
+   type (*name)();                                                          \
+   unsigned long ptr = (unsigned long)jumpad_;                              \
+   unsigned long p[16];                                                     \
+   int  count;                                                              \
+   ptr += *fptr;                                                            \
+   name = (type (*)())ptr;                                                  \
+   for ( count=0; count<16; count++ )                                       \
+     restore_pointer(pin[count], p[count], unsigned long);                  \
+   /* end of macro */
+
+
+#define setaddr_lp64(__ja, __jb)                                            \
+  restore_pointer(__ja, a, char*);                                          \
+  restore_pointer(__jb, b, char*);                                          \
+   /* end of macro */
+
+#endif
+
diff -urNad paw-2.14.04~/src/pawlib/comis/deccc/cscald.c paw-2.14.04/src/pawlib/comis/deccc/cscald.c
--- paw-2.14.04~/src/pawlib/comis/deccc/cscald.c	2004-10-27 05:01:54.000000000 -0400
+++ paw-2.14.04/src/pawlib/comis/deccc/cscald.c	2006-09-08 14:45:54.322410202 -0400
@@ -29,11 +29,10 @@
 #define cscald   
 #undef  cscald
 
-#ifdef CERNLIB_WINNT
+#if defined(CERNLIB_WINNT) || defined(CERNLIB_LINUX)
 # include <stdio.h>
 #endif
-
-#if (defined(CERNLIB_QX_SC))&&(!defined(CERNLIB_WINNT))
+#if (defined(CERNLIB_QX_SC))&&(!defined(CERNLIB_WINNT))&&(!defined(CERNLIB_QMLXIA64))
 double cscald_ (name,n,p)
 #endif
 #if defined(CERNLIB_QXNO_SC)
@@ -46,10 +45,30 @@
     int CSCALD (name,n,p)
 #  endif
 #endif
+
+/*
+ * 64-bit pointer systems require a special treatment of addresses - see below 
+ * using the CERNLIB_QMLXIA64 macro definition (H. Vogt - Sep 2005)
+ * This code will be consistent with that of jumptn.c and jumpxn.c
+ * in packlib/kernlib/kerngen/ccgen (usage of jumpad_)
+ *
+ * for shared objects loaded by the dynamic linker content of the 1st arg
+ * in cscald_ is a pointer which may be above the 32 bit address space
+ * therefore *fptr has been changed to type long
+ * see changes in csintx.F, cskcal.F, ... (introduction of INTEGER*8 array for
+ * those pointers)
+ */
+
+#if defined(CERNLIB_QMLXIA64)
+# include "cscal_lp64.h"
+double cscald_ (fptr,n,pin)
+ setcall_lp64(double)
+#else
  double (type_of_call *(*name)) ();
  int *n;
- int *p[15];
+ int *p[16];
 {
+#endif
    double d;
    switch (*n)
    {
diff -urNad paw-2.14.04~/src/pawlib/comis/deccc/cscali.c paw-2.14.04/src/pawlib/comis/deccc/cscali.c
--- paw-2.14.04~/src/pawlib/comis/deccc/cscali.c	2004-10-22 08:42:40.000000000 -0400
+++ paw-2.14.04/src/pawlib/comis/deccc/cscali.c	2006-09-08 14:46:14.981004397 -0400
@@ -26,11 +26,10 @@
 #define cscali
 #undef  cscali
 
-#ifdef CERNLIB_WINNT
+#if defined(CERNLIB_WINNT) || defined(CERNLIB_LINUX)
 # include <stdio.h>
 #endif
-
-#if (defined(CERNLIB_QX_SC))&&(!defined(CERNLIB_WINNT))
+#if (defined(CERNLIB_QX_SC))&&(!defined(CERNLIB_WINNT))&&(!defined(CERNLIB_QMLXIA64))
 int cscali_ (name,n,p)
 #endif
 #if defined(CERNLIB_QXNO_SC)
@@ -39,10 +38,30 @@
 #if defined(CERNLIB_QXCAPT)
 int type_of_call CSCALI (name,n,p)
 #endif
+
+/*
+ * 64-bit pointer systems require a special treatment of addresses - see below 
+ * using the CERNLIB_QMLXIA64 macro definition (H. Vogt - Sep 2005)
+ * This code will be consistent with that of jumptn.c and jumpxn.c
+ * in packlib/kernlib/kerngen/ccgen (usage of jumpad_)
+ *
+ * for shared objects loaded by the dynamic linker content of the 1st arg
+ * in cscali_ is a pointer which may be above the 32 bit address space
+ * therefore *fptr has been changed to type long
+ * see changes in csintx.F, cskcal.F, ... (introduction of INTEGER*8 array for
+ * those pointers)
+ */
+
+#if defined(CERNLIB_QMLXIA64)
+# include "cscal_lp64.h"
+int cscali_ (fptr,n,pin)
+ setcall_lp64(int)
+#else
  int (type_of_call *(*name)) ();
  int *n;
- int *p[15];
+ int *p[16];
 {
+#endif
    int i;
    switch (*n)
    {
diff -urNad paw-2.14.04~/src/pawlib/comis/deccc/cscalr.c paw-2.14.04/src/pawlib/comis/deccc/cscalr.c
--- paw-2.14.04~/src/pawlib/comis/deccc/cscalr.c	2004-10-22 08:03:16.000000000 -0400
+++ paw-2.14.04/src/pawlib/comis/deccc/cscalr.c	2006-09-08 14:47:10.662129691 -0400
@@ -30,19 +30,15 @@
 #define cscalr
 #undef  cscalr
 
-#ifdef CERNLIB_WINNT
+#if defined(CERNLIB_WINNT) || defined(CERNLIB_LINUX)
 # include <stdio.h>
 #endif
-
-
-#if (defined(CERNLIB_QX_SC))&&(!defined(CERNLIB_WINNT))
+#if (defined(CERNLIB_QX_SC))&&(!defined(CERNLIB_WINNT))&&(!defined(CERNLIB_QMLXIA64))
 float cscalr_ (name,n,p)
 #endif
-
 #if defined(CERNLIB_QXNO_SC)
 float cscalr (name,n,p)
 #endif
-
 #if defined(CERNLIB_QXCAPT)
 # if defined(CERNLIB_MSSTDCALL)
    float type_of_call CSCALR(name,n,p)
@@ -51,10 +47,42 @@
 # endif
 #endif
 
+/*
+ * 64-bit pointer systems require a special treatment of addresses - see below 
+ * using the CERNLIB_QMLXIA64 macro definition (H. Vogt - Sep 2005)
+ * This code will be consistent with that of jumptn.c and jumpxn.c
+ * in packlib/kernlib/kerngen/ccgen (usage of jumpad_)
+ *
+ * for shared objects loaded by the dynamic linker content of the 1st arg
+ * in cscalr_ is a pointer which may be above the 32 bit address space
+ * therefore *fptr has been changed to type long
+ * see changes in csintx.F, cskcal.F, ... (introduction of INTEGER*8 array for
+ * those pointers)
+ */
+
+#if defined(CERNLIB_QMLXIA64)
+
+/* Additional note: g77 generates code such that it expects REAL functions
+ * to return "double".  Hence C functions to be used in FORTRAN as REAL
+ * must return "double", and declarations of REAL FORTRAN functions in C files
+ * must also return "double".  On most architectures one can get away with
+ * using "float" instead, but not on amd64 ... see
+ * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15397
+ *
+ * -- Kevin McCarty */
+# if !(defined(CERNLIB_GFORTRAN)||defined(CERNLIB_INTELIFC))  /* i.e. g77 */
+#  define float double
+# endif
+
+# include "cscal_lp64.h"
+float cscalr_ (fptr,n,pin)
+ setcall_lp64(float)
+#else
  float (type_of_call *(*name)) ();
  int *n;
- int *p[15];
+ int *p[16];
 {
+#endif
    float r;
    switch (*n)
    {
diff -urNad paw-2.14.04~/src/pawlib/comis/deccc/cstrcmp.c paw-2.14.04/src/pawlib/comis/deccc/cstrcmp.c
--- paw-2.14.04~/src/pawlib/comis/deccc/cstrcmp.c	1997-09-02 11:50:44.000000000 -0400
+++ paw-2.14.04/src/pawlib/comis/deccc/cstrcmp.c	2006-09-08 14:44:11.812263308 -0400
@@ -36,6 +36,43 @@
 #else
 int cstrcmp_(ja,na,jb,nb)
 #endif
+
+/*
+ * 64-bit pointer systems require a special treatment of addresses - see below -
+ * using the CERNLIB_QMLXIA64 cpp flag (H. Vogt - Sep 2005)
+ */
+ 
+/* For Itanium, the situation is even worse.  Itanium architecture is such
+ * that the data section starts at 0x6000000000000000.  The stack is
+ * supposed to be between 0x80...0 and 0xa0...0 starting at the high end
+ * and growing downwards, although on a test machine (merulo.debian.org)
+ * it seemed instead to start at 0x6000100000000000 and grow downwards.
+ * The addresses we actually get are truncated to the lowest 32 bits,
+ * so we assume that those greater than 0x80000000 are in the stack.
+ *
+ * Constant strings are in the text section starting at 0x40...0; we hope
+ * this function doesn't receive any.
+ * -- Kevin McCarty
+ */
+
+#if defined(CERNLIB_QMLXIA64)
+# include "cscal_lp64.h"
+     int *ja, *jb;
+     int *na, *nb;
+{
+
+  static int i,la,lb,k; static char *a,*b;
+  if ( *na >= *nb )
+     {
+       setaddr_lp64(*ja,*jb)
+       la=*na; lb=*nb; k=1;
+     }
+  else
+     {
+       setaddr_lp64(*jb,*ja)
+       la=*nb; lb=*na; k=-1;
+     }
+#else
      char **ja, **jb;
      int *na, *nb;
 {
@@ -48,6 +85,7 @@
     {
       a=*jb; b=*ja; la=*nb; lb=*na; k=-1;
      }
+#endif
   for ( i=0; i<lb; i++ )
     { if(a[i] != b[i])
       { return ( (a[i] > b[i]) ? k : -k ); }
diff -urNad paw-2.14.04~/src/pawlib/paw/cmotif/att_color.c paw-2.14.04/src/pawlib/paw/cmotif/att_color.c
--- paw-2.14.04~/src/pawlib/paw/cmotif/att_color.c	1996-03-01 06:38:53.000000000 -0500
+++ paw-2.14.04/src/pawlib/paw/cmotif/att_color.c	2006-09-08 14:44:11.812263308 -0400
@@ -114,7 +114,7 @@
 
    XtVaGetValues(ObjectRow,XmNmenuHistory,&CurrentObject,NULL);
    XtVaGetValues(CurrentObject,XmNuserData,&data,NULL);
-   switch ((int ) client_data) {
+   switch ((long) client_data) {
       case 1: /* Surface */
          sprintf(Svalue,"%d",data->SurfaceColor);
          break;
@@ -164,7 +164,7 @@
       Ncol=atoi((char *)XmTextGetString(NcolText));
    } else Ncol=8;
    ColorNum=atoi((char *)XmTextGetString(AttColorText));
-   switch((int) client_data) {
+   switch((long) client_data) {
       case 1: /* UpArrow */
          ColorNum++;
          break;
diff -urNad paw-2.14.04~/src/pawlib/paw/cmotif/att_define_color.c paw-2.14.04/src/pawlib/paw/cmotif/att_define_color.c
--- paw-2.14.04~/src/pawlib/paw/cmotif/att_define_color.c	1999-03-01 04:07:01.000000000 -0500
+++ paw-2.14.04/src/pawlib/paw/cmotif/att_define_color.c	2006-09-08 14:44:11.812263308 -0400
@@ -338,7 +338,7 @@
 static void MoveScale_cb(Widget w,caddr_t client_data,
                          XmAnyCallbackStruct *call_data)
 {
-   switch ((int ) client_data) {
+   switch ((long) client_data) {
       case 1 : /* RED */
          EditColor.red=((XmScaleCallbackStruct *) call_data)->value;
          break;
@@ -369,7 +369,7 @@
       default :
          fprintf(stderr,"Error in function MoveScale_cb");
    } /*end of switch */
-   apply_color((int) client_data);
+   apply_color((long) client_data);
 }
 
 /*****************************************************************************
@@ -452,7 +452,7 @@
    char *ComStr;
 
    ColorNum=atoi((char *)XmTextGetString(ColorIndex));
-   switch((int) client_data) {
+   switch((long) client_data) {
       case 1: /* UpArrow */
          ColorNum++;
          break;
@@ -494,7 +494,7 @@
    XmAnyCallbackStruct cb;
 
    Ncol=atoi((char *)XmTextGetString(NcolText));
-   switch((int) client_data) {
+   switch((long) client_data) {
       case 1: /* UpArrow*/
          Ncol++;
          break;
diff -urNad paw-2.14.04~/src/pawlib/paw/cmotif/att_general.c paw-2.14.04/src/pawlib/paw/cmotif/att_general.c
--- paw-2.14.04~/src/pawlib/paw/cmotif/att_general.c	1996-03-01 06:38:53.000000000 -0500
+++ paw-2.14.04/src/pawlib/paw/cmotif/att_general.c	2006-09-08 14:44:11.813263095 -0400
@@ -454,7 +454,7 @@
 {
    char ComStr[15];
 
-   sprintf(ComStr,"IGSET MTYP %d",(int) client_data);
+   sprintf(ComStr,"IGSET MTYP %ld",(long) client_data);
    execute_kuip_cmd(ComStr);
    if (appres.auto_refresh) {
       plot_current_histo();
@@ -471,8 +471,8 @@
 {
    char ComStr[15];
 
-   sprintf(ComStr,"IGSET LTYP %d",(int) client_data);
-   sprintf(ComStr,"SET DMOD %d",(int) client_data);
+   sprintf(ComStr,"IGSET LTYP %ld",(long) client_data);
+   sprintf(ComStr,"SET DMOD %ld",(long) client_data);
 
    execute_kuip_cmd(ComStr);
    if (appres.auto_refresh) {
diff -urNad paw-2.14.04~/src/pawlib/paw/cmotif/att_geometry.c paw-2.14.04/src/pawlib/paw/cmotif/att_geometry.c
--- paw-2.14.04~/src/pawlib/paw/cmotif/att_geometry.c	1999-02-01 12:56:11.000000000 -0500
+++ paw-2.14.04/src/pawlib/paw/cmotif/att_geometry.c	2006-09-08 14:44:11.815262668 -0400
@@ -2582,7 +2582,7 @@
    char *ComStr;
 
    XtVaGetValues(CButton,XmNuserData,&data,NULL);
-   switch ((int) client_data ) {
+   switch ((long) client_data ) {
       case 1 : /**** value change in text */
          Fvalue= (float)atof((char *)XmTextGetString(Text));
 
diff -urNad paw-2.14.04~/src/pawlib/paw/cmotif/att_main.c paw-2.14.04/src/pawlib/paw/cmotif/att_main.c
--- paw-2.14.04~/src/pawlib/paw/cmotif/att_main.c	1996-03-01 06:38:54.000000000 -0500
+++ paw-2.14.04/src/pawlib/paw/cmotif/att_main.c	2006-09-08 14:44:11.816262455 -0400
@@ -139,7 +139,7 @@
 {
    int i;
    XmAnyCallbackStruct cb;
-   int pos;
+   long pos;
    char tempstr[6];
    int tempint;
 
@@ -147,7 +147,7 @@
 
    switch (*label) {
       case 'B' :
-         pos=(int) strchr(value,'.')-(int) value;
+         pos=strchr(value,'.')-value;
          strncpy(tempstr,value,pos);
          tempint=atoi(tempstr);
          if (tempint>=1000) {
@@ -157,7 +157,7 @@
             StateObject[i].ContourColor=tempint;
             StateObject[i].SurfaceColor=0;
          }
-         value=(char *)((int) value+pos+1);
+         value=(char *)(value+pos+1);
          strncpy(tempstr,value,2);
          StateObject[i].StatColor=tempstr[1]-'0';
          StateObject[i].ZoneColor=tempstr[0]-'0';
@@ -324,12 +324,12 @@
 static char *Clean(char *string)
 {
    char *Apos;
-   int pos;
+   long pos;
    char end[MAX_TITLE_SIZE];
 
    Apos=strrchr(string,39); /* #27 == ' */
    if (Apos) {
-      pos=((int)Apos  - (int)string  );
+      pos=Apos  - string;
       strcpy(end,++Apos);
       string[pos]='\0';
       strcat(Clean(string),"@'");
@@ -692,7 +692,7 @@
    XtVaGetValues(ObjectRow,XmNmenuHistory,&CurrentToggle,NULL);
    XtVaGetValues(CurrentToggle,XmNuserData,&CurrentState,NULL);
    LineWidth=CurrentState->LineWidth;
-   switch((int) client_data) {
+   switch((long) client_data) {
       case 1: /* UpArrow */
          LineWidth++;
          break;
diff -urNad paw-2.14.04~/src/pawlib/paw/cmotif/attatch.c paw-2.14.04/src/pawlib/paw/cmotif/attatch.c
--- paw-2.14.04~/src/pawlib/paw/cmotif/attatch.c	1996-03-01 06:38:54.000000000 -0500
+++ paw-2.14.04/src/pawlib/paw/cmotif/attatch.c	2006-09-08 14:44:11.816262455 -0400
@@ -88,7 +88,7 @@
 
    XtVaGetValues(ObjectRow,XmNmenuHistory,&CurrentObject,NULL);
    XtVaGetValues(CurrentObject,XmNuserData,&data,NULL);
-   switch ((int) client_data ) {
+   switch ((long) client_data ) {
       case 1 : /**** value change in text */
          Svalue=(char *)XmTextGetString(IndexText);
 
@@ -124,7 +124,7 @@
        /* value change in scale */
          XmScaleGetValue(w,&Ivalue);
          Svalue=(char *)XmTextGetString(IndexText);
-         Svalue[((int) client_data )-2]='0' + Ivalue;
+         Svalue[((long) client_data )-2]='0' + Ivalue;
          XmTextSetString(IndexText,Svalue);
          if (data->IndexHatch!=atoi(Svalue)) {
             data->IndexHatch=atoi(Svalue);
diff -urNad paw-2.14.04~/src/pawlib/paw/cmotif/axis.c paw-2.14.04/src/pawlib/paw/cmotif/axis.c
--- paw-2.14.04~/src/pawlib/paw/cmotif/axis.c	1996-03-01 06:38:54.000000000 -0500
+++ paw-2.14.04/src/pawlib/paw/cmotif/axis.c	2006-09-08 14:44:11.817262242 -0400
@@ -1336,7 +1336,7 @@
 {
    XmAnyCallbackStruct cbs1;
 
-   switch ((int)type) {
+   switch ((long)type) {
       case 1:
        axis.xo = 1;
        break;
@@ -1432,7 +1432,7 @@
    unselect_list();
    comstr = XtCalloc(MAX_CMD_LENGTH, 1);
 
-   switch ((int)type) {
+   switch ((long)type) {
       case 0:
 
        XmToggleButtonGadgetSetState(labeltoggleButtonGadget0,True,False);
@@ -1680,7 +1680,7 @@
    cbs1.reason = 0;
    cbs1.event = (XEvent *) NULL;
 
-   switch ((int) num) {
+   switch ((long) num) {
       case 1:
        if (XmToggleButtonGadgetGetState(labeltoggleButtonGadget1))
           XtCallCallbacks(labeltoggleButtonGadget1,XmNvalueChangedCallback,
diff -urNad paw-2.14.04~/src/pawlib/paw/cmotif/histo.c paw-2.14.04/src/pawlib/paw/cmotif/histo.c
--- paw-2.14.04~/src/pawlib/paw/cmotif/histo.c	1996-03-01 06:38:56.000000000 -0500
+++ paw-2.14.04/src/pawlib/paw/cmotif/histo.c	2006-09-08 14:44:11.818262029 -0400
@@ -529,7 +529,7 @@
 static void show_option(Widget w, int *type, XmToggleButtonCallbackStruct *cbs)
 {
    if (cbs->set) {
-      switch( (int)type ) {
+      switch( (long)type ) {
          case 1:
             if ( !widget_stat ) {
                widget_stat = create_statFormDialog();
@@ -651,7 +651,7 @@
             return;
       }
    } else {
-      switch( (int)type ) {
+      switch( (long)type ) {
          case 1:
           if (widget_stat) {
              XtUnmanageChild(widget_stat);
@@ -758,7 +758,7 @@
    int            x,y;
 
 
-   switch( (int)type ) {
+   switch( (long)type ) {
       case 1:
          sprintf (comstr,"Set STAT %d%d%d%d%d%d%d"
                   ,XmToggleButtonGadgetGetState(AllchanToggleButtonGadget)
@@ -996,7 +996,7 @@
 static void coordinate_set(Widget w, int *type, XmAnyCallbackStruct *cbs)
 {
 
-   switch( (int)type ) {
+   switch( (long)type ) {
       case 1:
          sprintf (histogram.coordinate,"   ");
          break;
@@ -1034,7 +1034,7 @@
    int      ilen1, ilen2;
    XmString xmstr;
 
-   switch( (int)type ) {
+   switch( (long)type ) {
       case 1:
          histogram.x1 = cbs->value;
          if( x_range_lock != 0 ) {
@@ -1131,7 +1131,7 @@
       if( histogram.y1 <= 0 ) histogram.y1 = 1;
       if( histogram.y2 <= 0 ) histogram.y2 = 1;
 
-   if ( (int)type < 3 ) {
+   if ( (long)type < 3 ) {
       XmScaleSetValue(X2Scale,histogram.x2);
       XmScaleSetValue(X1Scale,histogram.x1);
       if( x_range_lock == 0 || upd_nbin) {
diff -urNad paw-2.14.04~/src/pawlib/paw/cmotif/init.c paw-2.14.04/src/pawlib/paw/cmotif/init.c
--- paw-2.14.04~/src/pawlib/paw/cmotif/init.c	1996-03-12 11:58:51.000000000 -0500
+++ paw-2.14.04/src/pawlib/paw/cmotif/init.c	2006-09-08 14:44:11.818262029 -0400
@@ -286,7 +286,7 @@
 static void destroy_browser(Widget w, int *which, XmAnyCallbackStruct *cbs)
 {
    MenuCbStruct    *menu_item;
-   int              i = (int) which;
+   long             i = (long) which;
 
    browser[i].widget = NULL;
    if (browser[i].open_dialog) {
@@ -308,7 +308,7 @@
  ***********************************************************************/
 static void destroy_graphics(Widget w, int *which, XmAnyCallbackStruct *cbs)
 {
-   int    i = (int) which;
+   long   i = (long) which;
 
    graphics[i].widget = NULL;
 }
diff -urNad paw-2.14.04~/src/pawlib/paw/ntuple/c_hcntpar.h paw-2.14.04/src/pawlib/paw/ntuple/c_hcntpar.h
--- paw-2.14.04~/src/pawlib/paw/ntuple/c_hcntpar.h	1996-04-23 14:37:45.000000000 -0400
+++ paw-2.14.04/src/pawlib/paw/ntuple/c_hcntpar.h	2006-09-08 14:44:11.818262029 -0400
@@ -47,7 +47,7 @@
 #define ZID	12
 #define ZITMP	10
 #define ZNTMP	6
-#define ZNTMP1	3
+#define ZNTMP1	4
 #define ZLINK	6
 
 #endif	/*	CERN_C_HCNTPAR	*/
diff -urNad paw-2.14.04~/src/pawlib/paw/ntuple/qp_execute.c paw-2.14.04/src/pawlib/paw/ntuple/qp_execute.c
--- paw-2.14.04~/src/pawlib/paw/ntuple/qp_execute.c	2001-09-18 09:41:35.000000000 -0400
+++ paw-2.14.04/src/pawlib/paw/ntuple/qp_execute.c	2006-09-08 14:44:11.819261816 -0400
@@ -184,12 +184,19 @@
 					/* all definitions for the stack */
 #undef INIT_STACK_TO_NULL		/* are kept together in this file */
 
+#if defined(CERNLIB_QMLXIA64)
+# undef HBALLOC
+# undef HGNTBF
+# define HBALLOC HBALLOC64
+# define HGNTBF HGNTBF64
+#endif
+
 /* extern functions */
 extern void qp_exec_evt( QueryExe *, long, long, QPCmd *, int *);
 
 typedef		char	tName[MAX_NAME_LEN+1];
 tName		*namelist;
-int		*offsetlist;
+long		*offsetlist;
 int		*indexlist;
 
 
@@ -245,7 +252,23 @@
 	char		ntname[MAX_NAME_LEN+6];
 	int		i, ierr, indx, itype, isize, ielem;
 	Int32 *		addr;
-	int		ibase[1], ioff, nuse;
+
+	/* LP64 compatibility:
+	   - use static for ibase (at least) because its address is stored
+	     as Int32 in structure CWNBlock
+	     static takes ibase from the stack and puts it the code area.
+	   - use type long for ioff and offsetlist[i]
+	     (for 32 bit architectures type long is 4 Bytes as it is used
+	      also in packlib/hbook/chbook/halloc.c in hballo1 !)
+	   The x86-64 ABI has the code area in the 32 bit address space
+	   but addresses to the stack and to dynamically allocated areas
+	   may and will be above the 32 bit address space (below 0x80000000000).
+	   See also: http://www.x86-64.org/documentation/abi-0.96.pdf
+	   (H. Vogt, Oct. 2005) */
+
+	static int	ibase[1];
+	long		ioff;
+	int		nuse;
 	int		id = qe->id;
 	char *		path = qe->path;
 	char *		title;
@@ -286,7 +309,11 @@
 	CWNBlock = (RefCWN *) calloc( CWNCount + 1, sizeof( RefCWN ) );
 	qp_assert( MAX_NAME_LEN == 32 ); /* see hbook.h (HGNTBF) */
 	namelist = (tName *) calloc( CWNCount + 1, sizeof(tName) );
-	offsetlist = (int *) calloc( CWNCount + 1, sizeof(int) );
+
+	/* offsetlist should be of type long (see above) (H. Vogt, Oct. 2005) */
+
+	offsetlist = (long *) calloc( CWNCount + 1, sizeof(long) );
+
 	indexlist = (int *) calloc( CWNCount + 1, sizeof(int) );
 	qp_assert(
 		CWNBlock != 0 &&
@@ -381,6 +408,7 @@
 						offsetlist[nt_load_cnt]=
 						CWNBlock[index].p -
 						PAWC.iq_eqv;
+
 						strncpy(
 						namelist[nt_load_cnt],
 						vi->name,
@@ -871,8 +899,21 @@
 			if ( cmd->u.scan.pawpp ) {
 				char	buf[33];
 
+				/* for LP64 ABI matlab and matrow are 64 bit pointer, type is void*  
+				   but PCADDR.jmlab and PCADDR.jmrow are of type int
+				   see: c_pcaddr.h and qp_command.h
+				   it is related to CWNBlock -> see above (H. Vogt)*/
+
+#if defined(CERNLIB_QMLXIA64)
+				unsigned long long int	 myjmlab, myjmrow;
+				myjmlab = PCADDR.jmlab;
+				myjmrow = PCADDR.jmrow;
+				c->matlab = (TableCallBack) myjmlab;
+				c->matrow = (TableCallBack) myjmrow;
+#else
 				c->matlab = (TableCallBack) PCADDR.jmlab;
 				c->matrow = (TableCallBack) PCADDR.jmrow;
+#endif
 
 				qp_assert( qe->nexpr <= MAX_OUTSTR );
 
@@ -1791,6 +1832,31 @@
 	PAWIDN.idnevt = ievt;
         PAWCHN.ichevt = ievt_chain;
 
+#if defined(CERNLIB_QMLXIA64)
+/* avoid addresses from calloc which are above 32 bits here */
+	static Int32 helpp[8];
+	int i;
+	if ( npar < 9 ) {
+		for ( i=0; i<npar; i++ ) helpp[i] = stack[frame[framep-i]];
+	}
+	switch ( npar ) {
+	case 8: p8 = &helpp[7];
+	case 7: p7 = &helpp[6];
+	case 6: p6 = &helpp[5];
+	case 5: p5 = &helpp[4];
+	case 4: p4 = &helpp[3];
+	case 3: p3 = &helpp[2];
+	case 2: p2 = &helpp[1];
+	case 1: p1 = &helpp[0];
+	case 0: 
+		break;
+	default:
+		sf_report( "exec_comis: To many arguments (%d)\n", npar );
+		*errp = R_INTERNAL_ERROR;
+		return FALSE;
+		break;
+	}
+#else
 	switch ( npar ) {
 	case 8: p8 = &stack[frame[framep-7]];
 	case 7: p7 = &stack[frame[framep-6]];
@@ -1808,6 +1874,7 @@
 		return FALSE;
 		break;
 	}
+#endif
 
 	switch ( fc ) {
 
diff -urNad paw-2.14.04~/src/pawlib/paw/ntuple/qp_hbook_if.c paw-2.14.04/src/pawlib/paw/ntuple/qp_hbook_if.c
--- paw-2.14.04~/src/pawlib/paw/ntuple/qp_hbook_if.c	1999-07-05 11:43:35.000000000 -0400
+++ paw-2.14.04/src/pawlib/paw/ntuple/qp_hbook_if.c	2006-09-08 14:44:11.820261603 -0400
@@ -149,7 +149,15 @@
 	int	idn, idtmp;
 	int	icycle;
 	int	ierr;
-	int     izero = 0;
+
+	/* LP64 compatibility:
+	   use static for izero because its address is fetched by hbname_
+	   using locb and locb expects 32 bit addresses only.
+	   static takes izero from the stack and puts it the code area
+	   and the LP64 ABI has the code area in the 32 bit address space
+	   but the stack starts downward from 0x80000000000 (H. Vogt) */
+
+	static int     izero = 0;
 
 	/* split string into  path, id and cycle */
 


--- NEW FILE paw-305-use-POWERPC-not-PPC-as-test.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 305-use-POWERPC-not-PPC-as-test.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Since patch 304 changed the meaning of CERNLIB_PPC to a mere endianness
## DP: test, we now use CERNLIB_POWERPC to mean actually checking for a PowerPC
## DP: processor; fix the three occurences of this in Imakefiles.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/pawlib/paw/code/Imakefile /tmp/dpep.fQy2EP/cernlib-2005.05.09/src/pawlib/paw/code/Imakefile
--- cernlib-2005.05.09/src/pawlib/paw/code/Imakefile	1998-09-25 05:33:51.000000000 -0400
+++ /tmp/dpep.fQy2EP/cernlib-2005.05.09/src/pawlib/paw/code/Imakefile	2005-06-09 10:50:47.068482917 -0400
@@ -56,7 +56,7 @@
 
 SubdirLibraryTarget(NullParameter,NullParameter)
 
-#if defined(CERNLIB_LINUX) && defined(CERNLIB_PPC)
+#if defined(CERNLIB_LINUX) && defined(CERNLIB_POWERPC)
 SpecialFortranLibObjectRule(pawins,pawins,-O0,NullParameter)
 #endif
 
diff -urNad cernlib-2005.05.09/src/pawlib/paw/ntuple/Imakefile /tmp/dpep.fQy2EP/cernlib-2005.05.09/src/pawlib/paw/ntuple/Imakefile
--- cernlib-2005.05.09/src/pawlib/paw/ntuple/Imakefile	1999-09-14 05:20:08.000000000 -0400
+++ /tmp/dpep.fQy2EP/cernlib-2005.05.09/src/pawlib/paw/ntuple/Imakefile	2005-06-09 10:51:15.807396176 -0400
@@ -46,7 +46,7 @@
 
 SubdirLibraryTarget(NullParameter,NullParameter)
 
-#if defined(CERNLIB_LINUX) && defined(CERNLIB_PPC)
+#if defined(CERNLIB_LINUX) && defined(CERNLIB_POWERPC)
 SpecialObjectRule(archive/qp_execute.o,qp_execute.c archive/qp_execute.d,-O0 -o $@)
 SpecialObjectRule(debug/qp_execute.o,qp_execute.c debug/qp_execute.d,-O0 -o $@)
 SpecialObjectRule(shared/qp_execute.o,qp_execute.c shared/qp_execute.d,-O0 -o $@)


--- NEW FILE paw-308-use-canonical-cfortran-location.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 308-use-canonical-cfortran-location.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: All code compiled at Cernlib build-time should look for cfortran.h
## DP: at <cfortran/cfortran.h>.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/pawlib/paw/testsuite/tuple/tuple.c /tmp/dpep.d3syqe/cernlib-2005.05.09/src/pawlib/paw/testsuite/tuple/tuple.c
--- cernlib-2005.05.09/src/pawlib/paw/testsuite/tuple/tuple.c	1996-04-17 10:46:29.000000000 -0400
+++ /tmp/dpep.d3syqe/cernlib-2005.05.09/src/pawlib/paw/testsuite/tuple/tuple.c	2005-06-09 13:14:58.654908060 -0400
@@ -16,7 +16,7 @@
 #include	<float.h>
 
 
-#include	"cfortran.h"
+#include	<cfortran/cfortran.h>
 
 /* #include	"packlib.h" */
 #include	"hbook_interface.h"


--- NEW FILE paw-313-comis-preserves-filename-case.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 313-comis-preserves-filename-case.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Have COMIS preserve filename case when interpreting FORTRAN code.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/pawlib/paw/code/pawint3.F /tmp/dpep.GROFhd/cernlib-2005.05.09/src/pawlib/paw/code/pawint3.F
--- cernlib-2005.05.09/src/pawlib/paw/code/pawint3.F	1999-05-20 03:37:18.000000000 -0400
+++ /tmp/dpep.GROFhd/cernlib-2005.05.09/src/pawlib/paw/code/pawint3.F	2005-06-09 15:23:49.276738602 -0400
@@ -140,7 +140,7 @@
       CHUTIT = ' '
 *
       IF (IPIAF.EQ.0) THEN
-         CALL KUOPEN(10,'PAW.METAFILE','UNKNOWN',ISTAT)
+         CALL KUOPEN(10,'paw.metafile','UNKNOWN',ISTAT)
 #if (defined(CERNLIB_IBM))&&(!defined(CERNLIB_IBMMVS))
          CALL HERMES(19)
          CALL VMCMS('FILEDEF 19 DISK GKSERROR OUTPUT A',IRET)


--- NEW FILE paw-320-support-ifort-and-gfortran.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 320-support-ifort-and-gfortran.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Support use of ifort, icc and/or gfortran as default compilers.

@DPATCH@
diff -urNad paw-2.14.04~/src/pawlib/comis/code/csinit.F paw-2.14.04/src/pawlib/comis/code/csinit.F
--- paw-2.14.04~/src/pawlib/comis/code/csinit.F	2006-09-07 17:57:19.881356063 -0400
+++ paw-2.14.04/src/pawlib/comis/code/csinit.F	2006-09-07 18:04:23.085153626 -0400
@@ -217,8 +217,18 @@
 #endif
 #if (defined(CERNLIB_LINUX))
       ITMPLEN=CSTMPD(CHPATH, 256)
+# if (defined(CERNLIB_GFORTRAN))
+      CHF77 ='gfortran -g -c -fPIC'
+# elif (defined(CERNLIB_INTELIFC))
+      CHF77 ='ifort -g -c -fPIC'
+# else
       CHF77 ='g77 -g -c -fPIC'
+# endif
+# if (defined(CERNLIB_INTELIFC))
+      CHCC  ='icc -g -c -fPIC'
+# else
       CHCC  ='cc -g -c -fPIC'
+# endif
 #endif
 #if (defined(CERNLIB_SGI))&&(defined(CERNLIB_SHL))
       ITMPLEN=CSTMPD(CHPATH, 256)
diff -urNad paw-2.14.04~/src/pawlib/paw/ntuple/Imakefile paw-2.14.04/src/pawlib/paw/ntuple/Imakefile
--- paw-2.14.04~/src/pawlib/paw/ntuple/Imakefile	2006-09-07 17:57:19.916348611 -0400
+++ paw-2.14.04/src/pawlib/paw/ntuple/Imakefile	2006-09-07 17:57:35.628002463 -0400
@@ -16,9 +16,17 @@
 EXTRA_DEFINES := $(EXTRA_DEFINES) -Dextname
 #endif
 
-#if defined(CERNLIB_LINUX)
+#if defined(CERNLIB_LINUX) && !defined(CERNLIB_QMLXIA64)
+EXTRA_DEFINES := $(EXTRA_DEFINES) -Df2cFortran
+#endif
+
+#if defined(CERNLIB_QMLXIA64) 
+#if defined(CERNLIB_GFORTRAN)
+EXTRA_DEFINES := $(EXTRA_DEFINES) -DgFortran
+#else
 EXTRA_DEFINES := $(EXTRA_DEFINES) -Df2cFortran
 #endif
+#endif
 
 #if defined(CERNLIB_HPUX)
 CCOPTIONS += -Wp,-H10000


--- NEW FILE paw-701-patch-hbook-comis-Imakefiles.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 701-patch-hbook-comis-Imakefiles.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fix up makefiles after moving hkfill.F and hkf1q.F in the other
## DP: 701 dpatch (a shell script).

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/pawlib/comis/code/Imakefile cernlib-2005.05.09.dfsg/src/pawlib/comis/code/Imakefile
--- cernlib-2005.05.09.dfsg~/src/pawlib/comis/code/Imakefile	2005-12-07 14:59:22.782783593 -0500
+++ cernlib-2005.05.09.dfsg/src/pawlib/comis/code/Imakefile	2005-12-07 14:59:31.519940694 -0500
@@ -37,7 +37,8 @@
 	csspar.F cssubr.F cssvpt.F cstadv.F cstarr.F csterr.F cstext.F \ @@\
 	cstfrf.F cstinf.F cstlgb.F cstlog.F cstpar.F cstran.F cstrer.F \ @@\
 	cstypar.F cstype.F csubad.F csunam.F csundf.F csxpar.F \ @@\
-	mcline.F mcsident.F
+	mcline.F mcsident.F \ @@\
+	hkfill.F hkf1q.F /* moved here from src/packlib/hbook/code */
 
 #if defined(CERNLIB_PAW)
 SRCS_F := $(SRCS_F) cspawi.F cskuix.F cktoiv.F cspawv.F csmkvd.F \ @@\


--- NEW FILE paw-706-use-external-xbae-and-xaw.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 706-use-external-xbae-and-xaw.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Do not compile embedded old Xbae and Xaw code.

@DPATCH@
diff -urNad paw-2.14.04.dfsg~/src/paw_motif/Imakefile paw-2.14.04.dfsg/src/paw_motif/Imakefile
--- paw-2.14.04.dfsg~/src/paw_motif/Imakefile	2007-01-11 16:35:03.203039255 -0500
+++ paw-2.14.04.dfsg/src/paw_motif/Imakefile	2007-01-11 16:35:55.436956428 -0500
@@ -5,7 +5,7 @@
 #define PassCDebugFlags
 
 MotifDependantMakeVar(MOTIF_DIRS,cmotif fmotif fpanelsc)
-MotifDependantMakeVar(PAWPP_DIRS,fpanelsf tree uimx)
+MotifDependantMakeVar(PAWPP_DIRS,fpanelsf      uimx)
 
 LIBDIRS= code cdf
 
@@ -13,6 +13,7 @@
 LIBDIRS :=$(LIBDIRS) $(MOTIF_DIRS) $(PAWPP_DIRS)
 #endif
 
+#if 0 /* we want to use external libXbae */
 #if defined(CERNLIB_UNIX) && !defined(CERNLIB_WINNT)
 MotifDependantMakeVar(PAWPP_DIRS,xbae)
 LIBDIRS := $(LIBDIRS) $(PAWPP_DIRS)
@@ -22,6 +23,7 @@
 MotifDependantMakeVar(PAWPP_DIRS,xbaevms)
 LIBDIRS := $(LIBDIRS) $(PAWPP_DIRS)
 #endif
+#endif
 
 SUBDIRS= $(LIBDIRS)
 
diff -urNad paw-2.14.04.dfsg~/src/paw_motif/cmotif/chain_tree.c paw-2.14.04.dfsg/src/paw_motif/cmotif/chain_tree.c
--- paw-2.14.04.dfsg~/src/paw_motif/cmotif/chain_tree.c	1996-03-01 06:38:54.000000000 -0500
+++ paw-2.14.04.dfsg/src/paw_motif/cmotif/chain_tree.c	2007-01-11 16:37:01.447950095 -0500
@@ -19,7 +19,7 @@
 
 #include "hmotif/pawm.h"
 #include "hpaw/chain.h"
-#include "paw/tree.h"
+#include <X11/Xaw/Tree.h>
 
 #if defined(CERNLIB_QX_SC)
 #define  show_chain_tree     show_chain_tree_
diff -urNad paw-2.14.04.dfsg~/src/paw_motif/hmotif/scan.h paw-2.14.04.dfsg/src/paw_motif/hmotif/scan.h
--- paw-2.14.04.dfsg~/src/paw_motif/hmotif/scan.h	1996-09-09 11:21:28.000000000 -0400
+++ paw-2.14.04.dfsg/src/paw_motif/hmotif/scan.h	2007-01-11 16:36:26.990261436 -0500
@@ -20,10 +20,10 @@
 #define _scan_h
 
 #include "ntuplescan.h"
-#ifdef CERNLIB_VAXVMS
+#if 0
 #include "xbaevms/matrix.h"
 #else
-#include "xbae/matrix.h"
+#include <Xbae/Matrix.h>
 #endif
 
 


--- NEW FILE paw-801-non-optimized-rule-uses-fPIC-g.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 801-non-optimized-rule-uses-fPIC-g.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Ensure that special rules for creating non-optimized object files
## DP: use -fPIC for files that go into shared libs, and -g for all files.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/paw_motif/fmotif/Imakefile /tmp/dpep.gResDB/cernlib-2005.05.09/src/paw_motif/fmotif/Imakefile
--- cernlib-2005.05.09/src/paw_motif/fmotif/Imakefile	1996-09-23 10:20:46.000000000 -0400
+++ /tmp/dpep.gResDB/cernlib-2005.05.09/src/paw_motif/fmotif/Imakefile	2005-06-09 10:37:55.631538119 -0400
@@ -3,7 +3,7 @@
 	plotisto.F pmhist.F pminit.F show_chain.F
 
 #if defined(CERNLIB_LINUX) && !defined(CERNLIB_GFORTRAN)
-FORTRANOPTIONS = -fno-backslash  $(FORTRANSAVEOPTION) -fno-second-underscore
+FORTRANOPTIONS = -g -fno-backslash  $(FORTRANSAVEOPTION) -fno-second-underscore
 #endif
 
 SubdirLibraryTarget(NullParameter,NullParameter)
diff -urNad cernlib-2005.05.09/src/pawlib/paw/ntuple/Imakefile /tmp/dpep.gResDB/cernlib-2005.05.09/src/pawlib/paw/ntuple/Imakefile
--- cernlib-2005.05.09/src/pawlib/paw/ntuple/Imakefile	1999-09-14 05:20:08.000000000 -0400
+++ /tmp/dpep.gResDB/cernlib-2005.05.09/src/pawlib/paw/ntuple/Imakefile	2005-06-09 10:40:47.421285771 -0400
@@ -46,8 +46,8 @@
 
 SubdirLibraryTarget(NullParameter,NullParameter)
 
-#if defined(CERNLIB_LINUX) && defined(CERNLIB_POWERPC)
-SpecialObjectRule(archive/qp_execute.o,qp_execute.c archive/qp_execute.d,-O0 -o $@)
-SpecialObjectRule(debug/qp_execute.o,qp_execute.c debug/qp_execute.d,-O0 -o $@)
-SpecialObjectRule(shared/qp_execute.o,qp_execute.c shared/qp_execute.d,-O0 -o $@)
+#if defined(CERNLIB_LINUX)
+SpecialObjectRule(archive/qp_execute.o,qp_execute.c archive/qp_execute.d,-O0 -g -o $@)
+SpecialObjectRule(debug/qp_execute.o,qp_execute.c debug/qp_execute.d,-O0 -g -o $@)
+SpecialObjectRule(shared/qp_execute.o,qp_execute.c shared/qp_execute.d,-O0 -g -fPIC -o $@)
 #endif


--- NEW FILE paw-803-link-binaries-dynamically.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 803-link-binaries-dynamically.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Link binaries dynamically against Cern libraries.

@DPATCH@
diff -urNad cernlib-2005.05.09/src/pawlib/paw/programs/Imakefile /tmp/dpep.E9pQlc/cernlib-2005.05.09/src/pawlib/paw/programs/Imakefile
--- cernlib-2005.05.09/src/pawlib/paw/programs/Imakefile	2005-06-13 15:26:19.418526524 -0400
+++ /tmp/dpep.E9pQlc/cernlib-2005.05.09/src/pawlib/paw/programs/Imakefile	2005-06-13 15:27:38.102678258 -0400
@@ -20,7 +20,7 @@
 InstallScript(paw,$(CERN_BINDIR))
 
 #if defined (CERNLIB_UNIX) && !defined(CERNLIB_WINNT)
-CernlibFortranProgramTarget(pawX11,0pamain.o,NullParameter,NullParameter,pawlib graflib/X11 packlib mathlib kernlib)
+CernlibFortranProgramTarget(pawX11,0pamain.o,NullParameter,NullParameter,-G X11 pawlib)
 
 InstallProgram(pawX11,$(CERN_BINDIR))
 
@@ -34,7 +34,7 @@
 /* This is a gmake ifeq, not a Imake/cpp #if... ! */
 ifeq ($(DO_PAW_PP),YES)
 
-CernlibFortranProgramTarget(paw++,0pamainm.o,NullParameter,NullParameter,pawlib graflib/Motif packlib mathlib kernlib)
+CernlibFortranProgramTarget(paw++,0pamainm.o,NullParameter,NullParameter,-G Motif pawlib)
 
 InstallProgram(paw++,$(CERN_BINDIR))
 


--- NEW FILE paw-804-workaround-for-comis-mdpool-struct-location.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 804-workaround-for-comis-mdpool-struct-location.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Hack to workaround Comis not liking it when code has a negative
## DP: offset from the mdpool struct (as is the case when using shared
## DP: libraries on some arches).

@DPATCH@
diff -urNad cernlib-2005.05.09/src/cfortran/Examples/pamain.c /tmp/dpep.nHIc6F/cernlib-2005.05.09/src/cfortran/Examples/pamain.c
--- cernlib-2005.05.09/src/cfortran/Examples/pamain.c	2002-09-12 12:05:18.000000000 -0400
+++ /tmp/dpep.nHIc6F/cernlib-2005.05.09/src/cfortran/Examples/pamain.c	2005-06-11 09:59:51.875449396 -0400
@@ -2,6 +2,7 @@
 #include <cfortran.h>
 #include <paw.h>
 #include <kuip.h>
+#include <comis/mdpool.h>
 
 #define PAWC_SIZE 9000000
 
diff -urNad cernlib-2005.05.09/src/pawlib/comis/comis/cspar.inc /tmp/dpep.nHIc6F/cernlib-2005.05.09/src/pawlib/comis/comis/cspar.inc
--- cernlib-2005.05.09/src/pawlib/comis/comis/cspar.inc	2000-05-30 09:53:58.000000000 -0400
+++ /tmp/dpep.nHIc6F/cernlib-2005.05.09/src/pawlib/comis/comis/cspar.inc	2005-06-11 09:59:51.876449180 -0400
@@ -15,7 +15,9 @@
 *
 * cspar.inc
 *
-        PARAMETER (LHP=50006, KON1=17694720, KON2=KON1
+#include "comis/mdsize.h"
+
+        PARAMETER (LHP=MDSIZE, KON1=17694720, KON2=KON1
      +, KON3=2**16, LRECU=8,NRECU=5,MLRECU=NRECU*LRECU
      +, MXRECU=MLRECU-LRECU
      1,      LASTK=2000,LSSTK=50,KLENID=32
diff -urNad cernlib-2005.05.09/src/pawlib/comis/comis/mdpool.h /tmp/dpep.nHIc6F/cernlib-2005.05.09/src/pawlib/comis/comis/mdpool.h
--- cernlib-2005.05.09/src/pawlib/comis/comis/mdpool.h	1969-12-31 19:00:00.000000000 -0500
+++ /tmp/dpep.nHIc6F/cernlib-2005.05.09/src/pawlib/comis/comis/mdpool.h	2004-06-30 21:54:11.000000000 -0400
@@ -0,0 +1,33 @@
+#ifndef _MDPOOL_H
+#define _MDPOOL_H
+
+/* mdpool.h */
+
+/* #include <comis/mdpool.h> or <comis/mdpool.inc> in one source code file of
+ * your executable program dynamically linked against libpaw
+ * so that MDPOOL is defined in your executable.  This is
+ * necessary for proper functioning of the COMIS interpreter when
+ * dynamically linked.
+ */
+
+/* define MDSIZE: */
+#include <comis/mdsize.h>
+
+#include <cfortran.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+  int iq[MDSIZE];
+} mdpool_def;
+
+#define MDPOOL COMMON_BLOCK(MDPOOL, mdpool)
+COMMON_BLOCK_DEF(mdpool_def, MDPOOL);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* _MDPOOL_H */
diff -urNad cernlib-2005.05.09/src/pawlib/comis/comis/mdpool.inc /tmp/dpep.nHIc6F/cernlib-2005.05.09/src/pawlib/comis/comis/mdpool.inc
--- cernlib-2005.05.09/src/pawlib/comis/comis/mdpool.inc	1996-02-26 12:16:34.000000000 -0500
+++ /tmp/dpep.nHIc6F/cernlib-2005.05.09/src/pawlib/comis/comis/mdpool.inc	2005-06-11 09:59:51.876449180 -0400
@@ -12,6 +12,8 @@
 *
 * mdpool.inc
 *
+#include "comis/cspar.inc"
+
       COMMON/MDPOOL/IQ(LHP)
       INTEGER ISEM(LHP),KD(LHP),IDA(LHP),KD1(99),KD2(99),KD3(99)
       EQUIVALENCE (IQ,ISEM),(IQ,KD),(IQ,IDA)
diff -urNad cernlib-2005.05.09/src/pawlib/comis/comis/mdsize.h /tmp/dpep.nHIc6F/cernlib-2005.05.09/src/pawlib/comis/comis/mdsize.h
--- cernlib-2005.05.09/src/pawlib/comis/comis/mdsize.h	1969-12-31 19:00:00.000000000 -0500
+++ /tmp/dpep.nHIc6F/cernlib-2005.05.09/src/pawlib/comis/comis/mdsize.h	2004-06-30 21:54:11.000000000 -0400
@@ -0,0 +1,6 @@
+#ifndef _MDSIZE_H
+#define _MDSIZE_H
+
+#define MDSIZE 50006
+
+#endif
diff -urNad cernlib-2005.05.09/src/pawlib/comis/deccc/csallo.c /tmp/dpep.nHIc6F/cernlib-2005.05.09/src/pawlib/comis/deccc/csallo.c
--- cernlib-2005.05.09/src/pawlib/comis/deccc/csallo.c	1999-11-15 08:36:24.000000000 -0500
+++ /tmp/dpep.nHIc6F/cernlib-2005.05.09/src/pawlib/comis/deccc/csallo.c	2005-06-11 09:59:51.875449396 -0400
@@ -39,21 +39,20 @@
 /*-- Author :*/
 
 #include <cfortran/cfortran.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "comis/mdsize.h"
 
 typedef struct {
-    int iq[6];
+    int iq[MDSIZE]; /* instead of int iq[6] */
 } mdpool_def;
 
 #define MDPOOL COMMON_BLOCK(MDPOOL,mdpool)
-COMMON_BLOCK_DEF(mdpool_def,MDPOOL);
+extern COMMON_BLOCK_DEF(mdpool_def,MDPOOL);
 
-unsigned long iqpntr = (unsigned long)MDPOOL.iq;
+unsigned long iqpntr = 0;
 
 
-#ifdef CERNLIB_WINNT
-# include <stdlib.h>
-#endif
-
 #if defined(CERNLIB_QX_SC)
 int type_of_call csallo_(lenb)
 #endif
@@ -65,11 +64,31 @@
 #endif
  int *lenb;
 {
-  long lpntr;
+  unsigned long lpntr;
   int pntr; 
 
+  if (! iqpntr)
+    iqpntr = (unsigned long)MDPOOL.iq;
   lpntr= (long)( malloc(*lenb) );
-  pntr=lpntr - iqpntr;
+  if (! lpntr) {
+    fprintf(stderr,
+	    "CSALLO: not enough dynamic memory to allocate %d bytes\n", *lenb);
+    exit(EXIT_FAILURE);
+  }
+
+  pntr = (long)lpntr - (long)iqpntr;
+  if (pntr < 0) {
+    fprintf(stderr, "CSALLO: heap below bss?!");
+#if defined (CERNLIB_DEBIAN)
+    fprintf(stderr, "\n"
+"See the file /usr/share/doc/libpawlib2-dev/README.Debian for more information.\n"
+"If it does not help to solve this problem, please file a bug report against\n"
+"the libpawlib2 package, including the source code of your executable.\n");
+#else
+    fprintf(stderr, "  Try linking against pawlib statically.\n");
+#endif
+    exit(EXIT_FAILURE);
+  }
   return pntr;
 }
 
diff -urNad cernlib-2005.05.09/src/pawlib/paw/paw/pawsiz.inc /tmp/dpep.nHIc6F/cernlib-2005.05.09/src/pawlib/paw/paw/pawsiz.inc
--- cernlib-2005.05.09/src/pawlib/paw/paw/pawsiz.inc	1996-03-01 11:50:06.000000000 -0500
+++ /tmp/dpep.nHIc6F/cernlib-2005.05.09/src/pawlib/paw/paw/pawsiz.inc	2005-06-11 09:59:51.875449396 -0400
@@ -28,5 +28,9 @@
 #include "paw/pawsmall.inc"
 #endif
 
+C      Include this file so that MDPOOL/IQ is present in pawX11 and
+C      paw++ dynamically linked executables.
+C      -- Kevin McCarty, for Debian, 1 Nov 2003
+#include "comis/mdpool.inc"
 
 #endif
diff -urNad cernlib-2005.05.09/src/paw_motif/paw/pawsiz.inc /tmp/dpep.nHIc6F/cernlib-2005.05.09/src/paw_motif/paw/pawsiz.inc
--- cernlib-2005.05.09/src/paw_motif/paw/pawsiz.inc	1996-03-01 11:50:06.000000000 -0500
+++ /tmp/dpep.nHIc6F/cernlib-2005.05.09/src/paw_motif/paw/pawsiz.inc	2005-06-11 09:59:51.875449396 -0400
@@ -28,5 +28,9 @@
 #include "paw/pawsmall.inc"
 #endif
 
+C      Include this file so that MDPOOL/IQ is present in pawX11 and
+C      paw++ dynamically linked executables.
+C      -- Kevin McCarty, for Debian, 1 Nov 2003
+#include "comis/mdpool.inc"
 
 #endif


--- NEW FILE paw-806-bump-mathlib-and-dependents-sonames.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 806-bump-mathlib-and-dependents-sonames.dpatch by  <kmccarty at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Bump so versions of mathlib and dependents since it is now compiled
## DP: against liblapack3 instead of liblapack2.

@DPATCH@
diff -urNad cernlib-2005.05.09.dfsg~/src/paw_motif/Imakefile cernlib-2005.05.09.dfsg/src/paw_motif/Imakefile
--- cernlib-2005.05.09.dfsg~/src/paw_motif/Imakefile	2005-11-23 15:49:19.724161945 +0000
+++ cernlib-2005.05.09.dfsg/src/paw_motif/Imakefile	2005-11-23 15:49:27.432512073 +0000
@@ -1,6 +1,8 @@
 DoIncludePackage(paw)
 #include "paw/pilot.h"
 
+export LIB_SONAME := 3
+
 #define IHaveSubdirs
 #define PassCDebugFlags
 
diff -urNad cernlib-2005.05.09.dfsg~/src/pawlib/Imakefile cernlib-2005.05.09.dfsg/src/pawlib/Imakefile
--- cernlib-2005.05.09.dfsg~/src/pawlib/Imakefile	2005-11-23 15:49:19.724161945 +0000
+++ cernlib-2005.05.09.dfsg/src/pawlib/Imakefile	2005-11-23 15:49:27.432512073 +0000
@@ -2,6 +2,7 @@
 #define IHaveSubdirs
 #define PassCDebugFlags
 
+export LIB_SONAME := 2
 
 LIBDIRS= comis paw sigma
 SUBDIRS= $(LIBDIRS)


--- NEW FILE paw.README ---
Notes on paw
------------

1) Graphics window corruption

If you experience corruption of the graphics window when other windows are
moved over top of it, turn on the BackingStore option of the X server.
In the "Screen" section of your /etc/X11/XF86Config-4 or /etc/X11/xorg.conf
file (whichever one exists), you should have something like:

Section "Screen"
	.
	.
	.
    Option "BackingStore"
	.
	.
	.
EndSection

2) Remote data files

PAW can read files remotely from computers running the distributed PAW
(pawserv) server, which is included in the cernlib-packlib package.  This is
done from within PAW using 'rlogin' and 'rshell' commands; see the PAW
User's Guide for details.  Please note that these commands transmit passwords
in clear text and should be used only within a secured LAN.

3) Path issues

If you compile a FORTRAN script within PAW, the path to the file cannot
be excessively long (more than 256 characters).

4) Filename case issues

The default behavior has been set so that PAW is case-sensitive in its 
treatment of filenames.  If you have any old Paw scripts that do not
treat filenames in a case-sensitive way, you may need to add the line

        filecase convert

to the beginning of them.

5) Shared and static libs

There are 2 sets of binaries installed. In one set the binaries are 
statically linked with the cernlib (but still dynamically linked with 
the other libraries), these are the binaries used in the default case 
(pawX11 and paw++). 

The other binaries are compiled dynamically (pawX11.dynamic and
paw++.dynamic), therefore the pawlib used is selected by the 
/etc/ld.so.conf or $LD_LIBRARY_PATH settings.

The statically compiled one are used in the default case because 
dynamically linked one fail on some 64 bit architectures.

-- Kevin McCarty <kmccarty at debian.org>, Tue, 22 Nov 2005

Adapted to the rpm package by 
-- Dumas Patrice <dumas at centre-cired.fr>


Index: .cvsignore
===================================================================
RCS file: /cvs/extras/rpms/cernlib-g77/devel/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- .cvsignore	2 Aug 2007 22:50:56 -0000	1.1
+++ .cvsignore	5 Aug 2007 09:41:49 -0000	1.2
@@ -0,0 +1,6 @@
+2006_src-free.tar.gz
+patchy.tar.gz
+cernlib_2006.dfsg.2-1.diff.gz
+geant321_3.21.14.dfsg-5.diff.gz
+mclibs_2006.dfsg.2-1.diff.gz
+paw_2.14.04.dfsg.2-1.diff.gz


Index: sources
===================================================================
RCS file: /cvs/extras/rpms/cernlib-g77/devel/sources,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sources	2 Aug 2007 22:50:56 -0000	1.1
+++ sources	5 Aug 2007 09:41:49 -0000	1.2
@@ -0,0 +1,6 @@
+fe71a3f6b95ff2151c5a4690116a0358  2006_src-free.tar.gz
+b1f550eedc545a02f0ab58eb7d550480  patchy.tar.gz
+c68f372589cb39f734cad81a2a52c895  cernlib_2006.dfsg.2-1.diff.gz
+c3133b7a5885bd1ee7e47d4f4e76beca  geant321_3.21.14.dfsg-5.diff.gz
+3978b81499f205062b540aa58bb79193  mclibs_2006.dfsg.2-1.diff.gz
+90982e80623338cf2d4b4a9efb445f8c  paw_2.14.04.dfsg.2-1.diff.gz




More information about the fedora-extras-commits mailing list