[buildout]
extends =
  https://svn.erp5.org/repos/public/erp5/trunk/buildout/software-profiles/zlib.cfg
  nspr.cfg
  sed.cfg
parts =
  nss

[nss-patch]
recipe = hexagonit.recipe.download
filename = nss-3.12.9-with-nspr-4.8.7-1.patch
url = http://www.linuxfromscratch.org/patches/blfs/svn/nss-3.12.8-standalone-1.patch
md5sum = ee7b5966961bef16ca896435e78652d3
download-only = true

[nss-download]
recipe = hexagonit.recipe.download
url = ftp://ftp.mozilla.org/pub/mozilla.org/security/nss/releases/NSS_3_12_9_RTM/src/nss-3.12.9.tar.gz
md5sum = bd32f183ca28440c1744650be31a9ccc
strip-top-level-dir = true

[nss]
recipe = plone.recipe.command
source = ${nss-download:location}
destination = ${buildout:parts-directory}/${:_buildout_section_name_}
location = ${buildout:parts-directory}/${:_buildout_section_name_}
compile-location = ${buildout:parts-directory}/${:_buildout_section_name_}_compile_
stop-on-error = true
command =
  rm -rf ${:destination} &&
  mkdir -p ${:destination} &&
  rm -rf ${:compile-location} &&
  cp -R ${:source} ${:compile-location} &&
  cd ${:compile-location} &&
  patch -Np1 -i ${nss-patch:location}/${nss-patch:filename} &&
  ${sed:location}/bin/sed -i "s/ZLIB_LIBS = -lz//g" ${:compile-location}/mozilla/security/coreconf/Linux.mk &&
  ${sed:location}/bin/sed -i "s/# INCLUDES += -I\/usr\/include -Y\/usr\/include\/linux/INCLUDES += \$(ZLIB_INCLUDE_DIR)/g" ${:compile-location}/mozilla/security/coreconf/Linux.mk &&
  gmake -C mozilla/security/nss \
        USE_64=1 \
        BUILD_OPT=1 \
        ZLIB_INCLUDE_DIR=-I${zlib:location}/include \
        ZLIB_LIBS="-lz -L${zlib:location}/lib -Wl,-rpath=${zlib:location}/lib" \
        NSPR_INCLUDE_DIR=${nspr:location}/include/nspr \
        NSPR_LIB_DIR="${nspr:location}/lib -Wl,-rpath=${nspr:location}/lib" \
        NSSUTIL_LIB_DIR="${:location}/lib -Wl,-rpath=${:location}/lib" \
        nss_build_all &&
  mkdir -p ${:destination}/bin &&
  mkdir -p ${:destination}/include/nss3 &&
  mkdir -p ${:destination}/lib/pkgconfig &&
  install -v -m755 ${:compile-location}/mozilla/dist/*.OBJ/lib/*.so ${:destination}/lib &&
  install -v -m644 ${:compile-location}/mozilla/dist/*.OBJ/lib/{*.chk,libcrmf.a} ${:destination}/lib &&
  install -v -m755 -d ${:destination}/include/nss &&
  install -v -m755 ${:compile-location}/mozilla/dist/*.OBJ/bin/{certutil,nss-config,pk12util} ${:destination}/bin &&
  install -v -m644 ${:compile-location}/mozilla/dist/*.OBJ/lib/pkgconfig/nss.pc ${:destination}/lib/pkgconfig &&
  cp -v -RL ${:compile-location}/mozilla/dist/{public,private}/nss/* ${:destination}/include/nss &&
  chmod 644 ${:destination}/include/nss/* &&
  cd ${buildout:parts-directory} &&
  rm -rf ${:compile-location}

[nss-cmmi]
recipe = slapos.recipe.cmmi
path = ${nss-download:location}/mozilla/security/nss
configure-command = echo "No need to configure"
make-binary = gmake
make-options = USE_64=1
make-targets = nss_build_all

