[csw-maintainers] GAR Tutorial: Building OpenSSL with multiple ISAs

Dagobert Michelsen dam at opencsw.org
Thu Nov 5 20:41:36 CET 2009


Hi Yann,

Am 05.11.2009 um 19:36 schrieb Yann Rouillard:
> I successfully used your new system to build distinct packages for  
> different architecture on multiple host and it works perfectly,  
> thanks for your work.
>
> However I would like to use it for openssl to build the 64 libs (and  
> not the whole package) on build10x, but I am not sure I understand  
> how to do it. Could you explain me how to do it ?

Sure. I take the liberty of commenting some techniques on your Makefile:

> #####################################################################
> # OpenCSW build recipe for OpenSSL
> #
> # Copyright 2009 Yann Rouillard <yann at pleiades.fr.eu.org>
> # All rights reserved.  Use is subject to license terms.
> #
> # Redistribution and/or use, with or without modification, is
> # permitted.  This software is without warranty of any kind.  The
> # author(s) shall not be liable in the event that use of the
> # software causes damage.
> #####################################################################
>
> ###### Package information #######
>
> GARNAME = openssl
> GARVERSION = 0.9.8k
> OPENSSL_VERSION := $(shell echo $(GARVERSION) | sed -e 's/[a-z]//g')
> OPENSSL_RELEASE := $(shell echo $(GARVERSION) | sed -e 's/[^a-z]//g')

Why not
   OPENSSL_VESION = 0.9.8
   OPENSSL_RELEASE = k
   GARVERSION = $(OPENSSL_VERSION)$(OPENSSL_RELEASE)
But the used version is equally good.

> CATEGORIES = lib
>
> DESCRIPTION = The Open Source toolkit for SSL and TLS
> define BLURB
>   The OpenSSL Project is a collaborative effort to develop a robust,
>   commercial-grade, fully featured, and Open Source toolkit  
> implementing the
>   Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS  
> v1) as well
>   as a full-strength general-purpose cryptography library.
> endef
>
> PACKAGES = CSWossl CSWosslrt CSWossldevel CSWosslutils
>
> SPKG_DESC_CSWossl = Openssl meta package
> CATALOGNAME_CSWossl = openssl
> REQUIRED_PKGS_CSWossl = CSWossldevel CSWosslutils CSWosslrt
>
> SPKG_DESC_CSWosslrt = Openssl runtime libraries
> CATALOGNAME_CSWosslrt = openssl_rt
> REQUIRED_PKGS_CSWosslrt = CSWcacertificates
>
> SPKG_DESC_CSWossldevel = Openssl development files
> CATALOGNAME_CSWossldevel = openssl_devel
> REQUIRED_PKGS_CSWossldevel = CSWosslrt
>
> SPKG_DESC_CSWosslutils = Openssl binaries and related tools
> CATALOGNAME_CSWosslutils = openssl_utils
> REQUIRED_PKGS_CSWosslutils = CSWosslrt
> SPKG_CLASSES_CSWosslutils = none cswpreserveconf
>
>
> ###### Upstream and opencsw files information #######
>
> MASTER_SITES = http://www.openssl.org/source/ http://openssl.org/news/
>
> # We define upstream file regex so we can be notifed of new upstream  
> software release
> UFILES_REGEX = $(GARNAME)-(\d+(?:\.\d+)*[a-z]?).tar.gz
>
> DISTNAME   = $(GARNAME)-$(GARVERSION)

This is default, no need to redefine it.

> DISTFILES  = $(GARNAME)-$(GARVERSION).tar.gz
> DISTFILES += CSWossl.prototype

For this there is a more elegant way: dynamic prototypes where
you specify the files for a package with regular expressions.
This is more robust on version updates. Details can be found at
   <http://sourceforge.net/apps/trac/gar/wiki/Prototypes>
or as practical examples at
   cd mgar/pkg
     grep PKGFILES */trunk/Makefile

> DISTFILES += CSWosslrt.checkinstall CSWosslrt.preinstall  
> CSWosslrt.postinstall CSWosslrt.prototype-i386 CSWosslrt.prototype- 
> sparc
> DISTFILES += CSWossldevel.prototype-i386 CSWossldevel.prototype-sparc
> DISTFILES += CSWosslutils.prototype
> DISTFILES += changelog.CSW README.CSW
>
> DOCFILES = CHANGES CHANGES.SSLeay PROBLEMS README FAQ README.ASN1  
> INSTALL NEWS README.ENGINE
>
> PATCHFILES = openssl.$(OPENSSL_VERSION).patch
>
>
> ##### Build and installation information #####
>
> GARCOMPILER = SOS11
>
> # The list of instructions set for which we will
> # provide optimized libraries and binaries
> EXTRA_BUILD_ISAS_i386 = pentium_pro amd64
> EXTRA_BUILD_ISAS_sparc = sparcv8plus+vis sparcv9
>
> # we don't yet use isaexec support so we disable
> # isa relocation for default isa
> NO_ISAEXEC = 1
> # GAR wants and puts sparcv9 in lib/64 but openssl build system
> # isn't the standard autoconf/automake one so we disable this
> # relocation for now
> ISALIBDIR_sparcv9 = .
> libdir = /opt/csw/lib
>
> # we redefine the default merge exclude so *.a files are not excluded
> MERGE_EXCLUDE_DEFAULT = $(MERGE_EXCLUDE_INFODIR)

In gar.conf.mk the MERGE_EXCLUDE_DEFAULT is assembled from a list of  
items
excluded by default. If you don't want a specific thing to be excluded  
it
is easier to just clean the specific item you don't want excluded. In  
your
cases this is
   MERGE_EXCLUDE_STATICLIBS =
This way there is no need to adjust the definition when the default  
changes
to exclude other things depending on the general packaging policy.

> # The corresponding os/compiler to pass to the
> # openssl Configure script
> i386_OS_COMPILER        = solaris-386-cc
> pentium_OS_COMPILER     = solaris-pentium-cc
> pentium_pro_OS_COMPILER = solaris-pentium_pro-cc
> amd64_OS_COMPILER       = solaris64-x86_64-cc
>
> sparcv8_OS_COMPILER             = solaris-sparcv8-cc
> sparcv8plus_OS_COMPILER         = solaris-sparcv9-cc
> sparcv8plus+vis_OS_COMPILER     = solaris-sparcv9+vis-cc
> sparcv9_OS_COMPILER             = solaris64-sparcv9-cc
>
> CONFIGURE_ARGS = --prefix=$(prefix) shared $($(ISA)_OS_COMPILER) -- 
> install_prefix=$(DESTDIR)
>
> # We want the csw perl to be used
> #CONFIGURE_ENV += PERL="/opt/csw/bin/perl"
> # For now we want the sun perl to be used
> CONFIGURE_ENV += PERL="/usr/bin/perl"
>
> # Some optimization
> EXT_CFLAGS   += -mt -xstrconst
> EXT_CXXFLAGS += -noex -mt
>
> # By default, the install target put man pages under
> # /opt/csw/ssl/man, but we want them under /opt/csw/share/man
> INSTALL_ARGS += MANDIR=$(mandir)
>
> # we include previous release of libraries file for comptability  
> purpose
> OLDLIBS                 = 0.9.7m

This can be done with version modulations. You can take a look at
some package already implementing this:
   grep EXTRA_MODULATORS */trunk/Makefile | grep GARVERSION
However, you must do a couple of things in different stages right, so
I would really consider this an advanced topic. But feel free to take
a look and ask if there are any problems :-)

> SKIPTEST = 1

I would highly disregard turning tests on OpenSSL off. There were  
multiple
instances where missing Sun Studio patches and too high optimization
levels caused errors which were detected by the testsuite. If you don't
want to wait for tests please do something like
   SKIPTEST=1 gmake package
If we switch to automatic builds some time in the future running the  
testsuite
will a good thing. If there are no tests define
   TEST_SCRIPTS =
do indicate that there are no tests but the test-phase should be run.

> # support for pkcs11 engine http://blogs.sun.com/chichang1/entry/how_to_integrate_pkcs11_engine
> ifdef PKCS11
>         PATCHFILES += pkcs11_engine-0.9.8h.patch.2008-07-29
>         ifeq ($(GARCH),sparc)
>                 ifeq ($(ISA),sparcv9)
>                         CONFIGURE_ARGS += --pk11-libname=/usr/lib/ 
> sparcv9/libpkcs11.so
>                 else
>                         CONFIGURE_ARGS += --pk11-libname=/usr/lib/ 
> libpkcs11.so
>                 endif
>         else
>                 ifeq ($(ISA),amd64)
>                         CONFIGURE_ARGS += --pk11-libname=/usr/lib/ 
> sparcv9/libpkcs11.so
>                 else
>                         CONFIGURE_ARGS += --pk11-libname=/usr/lib/ 
> libpkcs11.so
>                 endif
>         endif

Instead of this nested ifeqs you could simple write
   CONFIGURE_ARGS += --pk11-libname=$(abspath /usr/lib/$(MM_LIBDIR))
This expands to either '.' for 32 bit or '64' for 64 bit which is  
guaranteed to be linked
to the arch-specific 64 bit dir sparcv9/ or amd64/.

> endif
>
> include gar/category.mk
>
>
> pre-configure-modulated:
>         echo " ==> Creating configure script"
>         cd $(WORKSRC) && ln -nf Configure configure
>         @$(MAKECOOKIE)
>
> # we remove every debug information except symbol table
> # (should rather be done in the gar scripts)
> post-install-modulated:
>         echo " ==> Stripping libraries"
>         chmod -R u+w $(DESTDIR)$(libdir)
>         find $(DESTDIR)$(libdir) -name "*.so*" -exec strip -x '{}' ';'
>
> install-changelog:
>         ginstall -D $(WORKROOTDIR)/build-$(firstword $(MODULATIONS))/ 
> changelog.CSW $(SPKG_PKGBASE)/changelog.CSW
>         @$(MAKECOOKIE)
>
> install-doc:
>         cd $(WORKSRC_FIRSTMOD)/ && ginstall $(DOCFILES) $ 
> (SPKG_PKGBASE)/
>         ginstall -D $(WORKROOTDIR)/build-$(firstword $(MODULATIONS))/ 
> README.CSW $(SPKG_PKGBASE)/README.CSW
>         @$(MAKECOOKIE)
>
> install-certs:
>         [ -f $(PKGROOT)$(prefix)/ssl/openssl.cnf ] && \
>                 ginstall -D $(PKGROOT)$(prefix)/ssl/openssl.cnf $ 
> (PKGROOT)$(sysconfdir)/ssl/openssl.cnf.CSW
>
> install-oldlibs: $(addprefix install-oldlibs-,$(OLDLIBS))
> install-oldlibs-%:
>         @echo " ==> Installing old libraries $* from archive oldlibs. 
> $*-$(GARCH).tar.gz"
>         cd $(PKGROOT) && gunzip -c $(CURDIR)/$(FILEDIR)/oldlibs.$*-$ 
> (GARCH).tar.gz | tar xvf -
>         @$(MAKECOOKIE)
>
> post-merge: install-certs install-oldlibs install-changelog install- 
> doc


Now your question again:

> However I would like to use it for openssl to build the 64 libs (and  
> not the whole package) on build10x, but I am not sure I understand  
> how to do it. Could you explain me how to do it ?

The manual process is
   build8x:  gmake merge   (builds 32 bit ISAs)
   build10x: gmake merge   (builds 64 bit ISA)
   build8x:  gmake package (assembles the package)
With the new platform support you can just say
   build8x> gmake package
and GAR automatically hops over to the server capable of building the  
ISA.

All ISAs build in
   work/<platform>/build-isa-<isa>
and install to
   work/<platform>/install-isa-<isa>
These directories contain everything from 'make install' from each  
build.
Now during the merge-phase an image of all packages to be built is  
assembled in
   work/<platform>/pkgroot
This is done during the merge phase. I talked about this in Oslo,  
slides linked
from here:
   https://sourceforge.net/apps/trac/gar/wiki/Learning%20the%20details
If you only want the libs you restrict the directories to be merged to  
the libdir:
   MERGE_DIRS_isa-extra = $(libdir)
For examples see fftw or glpk or
   grep isa-extra */trunk/Makefile


Don't hesitate to ask if you have further questions :-)


Best regards

   -- Dago



More information about the maintainers mailing list