On 10/20/2009 06:55 AM, CB wrote:
> I have been able to cross compile NSS/NSPR and ecrypt-utils, but the
> cross build system does not recognize NSS/NSPR as providing any
> binaries.  This might be due to them using a funky nsinstall program
> instead of the linux install program - I don't know.  Bottom line, it
> won't install ecrypt-utils due to missing dependencies.
>   
I think it's looking for the package config files. These are part of
linux packaging. You can find those in the NSS srpm, certainly from
Fedora. I don't know if debian includes it in their apt files.

The raw NSS build puts things in a private 'dist' file, which is where
most traditional NSS apps picked it up from. We probably should have an
install target for NSS and NSPR for linux, Right now the .spec files do
this 'by hand'.



Here's the essetial build script for the package file from the NSS spec.
I've removed the RPM variables and changed them to shell variables.

You'll have to set _libdir, _prefix, _includedir, version, and nspr_version

-------------------------------------------------------------------------------------------------------------------------------------------

# Set up our package file
mkdir -p ./mozilla/dist/pkgconfig
cat nss.pc.in | sed -e "s,%%libdir%%,${_libdir},g" \
                          -e "s,%%prefix%%,${_prefix},g" \
                          -e "s,%%exec_prefix%%,${_prefix},g" \
                          -e "s,%%includedir%%,${_includedir}/nss3,g" \
                          -e "s,%%NSPR_VERSION%%,${nspr_version},g" \
                          -e "s,%%NSS_VERSION%%,${version},g" > \
                          ./mozilla/dist/pkgconfig/nss.pc

NSS_VMAJOR=`cat mozilla/security/nss/lib/nss/nss.h | grep
"#define.*NSS_VMAJOR" | awk '{print $3}'`
NSS_VMINOR=`cat mozilla/security/nss/lib/nss/nss.h | grep
"#define.*NSS_VMINOR" | awk '{print $3}'`
NSS_VPATCH=`cat mozilla/security/nss/lib/nss/nss.h | grep
"#define.*NSS_VPATCH" | awk '{print $3}'`

export NSS_VMAJOR
export NSS_VMINOR
export NSS_VPATCH

cat nss-config.in | sed -e "s,@libdir@,${_libdir},g" \
                          -e "s,@prefix@,${_prefix},g" \
                          -e "s,@exec_prefix@,${_prefix},g" \
                          -e "s,@includedir@,${_includedir}/nss3,g" \
                          -e "s,@MOD_MAJOR_VERSION@,$NSS_VMAJOR,g" \
                          -e "s,@MOD_MINOR_VERSION@,$NSS_VMINOR,g" \
                          -e "s,@MOD_PATCH_VERSION@,$NSS_VPATCH,g" \
                          > ./mozilla/dist/pkgconfig/nss-config

chmod 755 ./mozilla/dist/pkgconfig/nss-config

------------------------------------------------------------------------------------------------

Install target for NSS. spec modified the same way described above, but
you also need to define _bindir. (Also $RPM_BUILD_ROOT)
# There is no make install target so we'll do it ourselves.

mkdir -p $RPM_BUILD_ROOT/${_includedir}/nss3
mkdir -p $RPM_BUILD_ROOT/${_bindir}
mkdir -p $RPM_BUILD_ROOT/${_lib}
mkdir -p $RPM_BUILD_ROOT/${_libdir}/nss/unsupported-tools
mkdir -p $RPM_BUILD_ROOT/${_libdir}/pkgconfig

# Copy the binary libraries we want
for file in libsoftokn3.so libfreebl3.so libnss3.so libnssutil3.so \
            libssl3.so libsmime3.so libnssckbi.so libnsspem.so libnssdbm3.so
do
  install -m 755 mozilla/dist/*.OBJ/lib/$file $RPM_BUILD_ROOT/${_lib}
  ln -sf ../../${_lib}/$file $RPM_BUILD_ROOT/${_libdir}/$file
done

# Make sure chk files can be found in both places
for file in libsoftokn3.chk libfreebl3.chk libnssdbm3.chk
do
  ln -s ../../${_lib}/$file $RPM_BUILD_ROOT/${_libdir}/$file
done

# Copy the development libraries we want
for file in libcrmf.a libnssb.a libnssckfw.a
do
  install -p -m 644 mozilla/dist/*.OBJ/lib/$file $RPM_BUILD_ROOT/${_libdir}
done

# Copy the binaries we want
for file in certutil cmsutil crlutil modutil pk12util signtool signver
ssltap
do
  install -p -m 755 mozilla/dist/*.OBJ/bin/$file $RPM_BUILD_ROOT/${_bindir}
done

# Copy the binaries we ship as unsupported
for file in atob btoa derdump ocspclnt pp selfserv shlibsign strsclnt
symkeyutil tstclnt vfyserv vfychain
do
  install -p -m 755 mozilla/dist/*.OBJ/bin/$file
$RPM_BUILD_ROOT/${_libdir}/nss/unsupported-tools
done

# Copy the include files we want
for file in mozilla/dist/public/nss/*.h
do
  install -p -m 644 $file $RPM_BUILD_ROOT/${_includedir}/nss3
done

# Copy the package configuration files
install -p -m 644 ./mozilla/dist/pkgconfig/nss.pc
$RPM_BUILD_ROOT/%{_libdir}/pkgconfig/nss.pc
install -p -m 755 ./mozilla/dist/pkgconfig/nss-config
$RPM_BUILD_ROOT/%{_bindir}/nss-config

-----------------------------------------------------------------------------------------------------
Install script for NSPR.

DESTDIR=$RPM_BUILD_ROOT \
  make install

NSPR_LIBS=`./config/nspr-config --libs`
NSPR_CFLAGS=`./config/nspr-config --cflags`
NSPR_VERSION=`./config/nspr-config --version`
mkdir -p $RPM_BUILD_ROOT/${_libdir}/pkgconfig

cat ./config/nspr-config-vars > \
                     $RPM_BUILD_ROOT/${_libdir}/pkgconfig/nspr.pc

cat nspr.pc.in | sed -e "s,%%libdir%%,${_libdir},g" \
                     -e "s,%%prefix%%,${_prefix},g" \
                     -e "s,%%exec_prefix%%,${_prefix},g" \
                     -e "s,%%includedir%%,${_includedir}/nspr4,g" \
                     -e "s,%%NSPR_VERSION%%,$NSPR_VERSION,g" \
                     -e "s,%%FULL_NSPR_LIBS%%,$NSPR_LIBS,g" \
                     -e "s,%%FULL_NSPR_CFLAGS%%,$NSPR_CFLAGS,g" >> \
                     $RPM_BUILD_ROOT/${_libdir}/pkgconfig/nspr.pc

mkdir -p $RPM_BUILD_ROOT/${_bindir}
mdkir -p $RPM_BUILD_ROOT/${_lib}
cp ./config/nspr-config-pc $RPM_BUILD_ROOT/${_bindir}/nspr-config

# Get rid of the things we don't want installed (per upstream)
rm -rf \
   $RPM_BUILD_ROOT/${_bindir}/compile-et.pl \
   $RPM_BUILD_ROOT/${_bindir}/prerr.properties \
   $RPM_BUILD_ROOT/${_libdir}/libnspr4.a \
   $RPM_BUILD_ROOT/${_libdir}/libplc4.a \
   $RPM_BUILD_ROOT/${_libdir}/libplds4.a \
   $RPM_BUILD_ROOT/${_datadir}/aclocal/nspr.m4 \
   $RPM_BUILD_ROOT/${_includedir}/nspr4/md

for file in libnspr4.so libplc4.so libplds4.so
do
  mv -f $RPM_BUILD_ROOT/${_libdir}/$file $RPM_BUILD_ROOT/%{_lib}/$file
  ln -sf ../../${_lib}/$file $RPM_BUILD_ROOT/%{_libdir}/$file
done

---------------------------------------------------------------------------------------------------------------------------------------



prefix=%prefix%
exec_prefix=%exec_prefix%
libdir=%libdir%
includedir=%includedir%

Name: NSS
Description: Network Security Services
Version: %NSS_VERSION%
Requires: nspr >= %NSPR_VERSION%
Libs: -lssl3 -lsmime3 -lnss3 -lnssutil3
Cflags: -I${includedir}
#!/bin/sh

pref...@prefix@

major_versi...@mod_major_version@
minor_versi...@mod_minor_version@
patch_versi...@mod_patch_version@

usage()
{
        cat <<EOF
Usage: nss-config [OPTIONS] [LIBRARIES]
Options:
        [--prefix[=DIR]]
        [--exec-prefix[=DIR]]
        [--includedir[=DIR]]
        [--libdir[=DIR]]
        [--version]
        [--libs]
        [--cflags]
Dynamic Libraries:
        nss
        nssutil
        ssl
        smime
EOF
        exit $1
}

if test $# -eq 0; then
        usage 1 1>&2
fi

lib_ssl=yes
lib_smime=yes
lib_nss=yes
lib_nssutil=yes

while test $# -gt 0; do
  case "$1" in
  -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
  *) optarg= ;;
  esac

  case $1 in
    --prefix=*)
      prefix=$optarg
      ;;
    --prefix)
      echo_prefix=yes
      ;;
    --exec-prefix=*)
      exec_prefix=$optarg
      ;;
    --exec-prefix)
      echo_exec_prefix=yes
      ;;
    --includedir=*)
      includedir=$optarg
      ;;
    --includedir)
      echo_includedir=yes
      ;;
    --libdir=*)
      libdir=$optarg
      ;;
    --libdir)
      echo_libdir=yes
      ;;
    --version)
      echo ${major_version}.${minor_version}.${patch_version}
      ;;
    --cflags)
      echo_cflags=yes
      ;;
    --libs)
      echo_libs=yes
      ;;
    ssl)
      lib_ssl=yes
      ;;
    smime)
      lib_smime=yes
      ;;
    nss)
      lib_nss=yes
      ;;
    nssutil)
      lib_nssutil=yes
      ;;
    *)
      usage 1 1>&2
      ;;
  esac
  shift
done

# Set variables that may be dependent upon other variables
if test -z "$exec_prefix"; then
    exec_prefix=`pkg-config --variable=exec_prefix nss`
fi
if test -z "$includedir"; then
    includedir=`pkg-config --variable=includedir nss`
fi
if test -z "$libdir"; then
    libdir=`pkg-config --variable=libdir nss`
fi

if test "$echo_prefix" = "yes"; then
    echo $prefix
fi

if test "$echo_exec_prefix" = "yes"; then
    echo $exec_prefix
fi

if test "$echo_includedir" = "yes"; then
    echo $includedir
fi

if test "$echo_libdir" = "yes"; then
    echo $libdir
fi

if test "$echo_cflags" = "yes"; then
    echo -I$includedir
fi

if test "$echo_libs" = "yes"; then
      libdirs="-Wl,-rpath-link,$libdir -L$libdir"
      if test -n "$lib_ssl"; then
        libdirs="$libdirs -lssl${major_version}"
      fi
      if test -n "$lib_smime"; then
        libdirs="$libdirs -lsmime${major_version}"
      fi
      if test -n "$lib_nss"; then
        libdirs="$libdirs -lnss${major_version}"
      fi
      if test -n "$lib_nssutil"; then
        libdirs="$libdirs -lnssutil${major_version}"
      fi
      echo $libdirs
fi      

prefix=%prefix%
exec_prefix=%exec_prefix%
libdir=%libdir%
includedir=%includedir%

Name: NSPR
Description: The Netscape Portable Runtime
Version: %NSPR_VERSION%
Libs: %FULL_NSPR_LIBS%
Cflags: %FULL_NSPR_CFLAGS%
-- 
dev-tech-crypto mailing list
dev-tech-crypto@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-crypto

Reply via email to