1 #!/usr/bin/bash
   2 #
   3 # CDDL HEADER START
   4 #
   5 # The contents of this file are subject to the terms of the
   6 # Common Development and Distribution License, Version 1.0 only
   7 # (the "License").  You may not use this file except in compliance
   8 # with the License.
   9 #
  10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  11 # or http://www.opensolaris.org/os/licensing.
  12 # See the License for the specific language governing permissions
  13 # and limitations under the License.
  14 #
  15 # When distributing Covered Code, include this CDDL HEADER in each
  16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  17 # If applicable, add the following below this CDDL HEADER, with the
  18 # fields enclosed by brackets "[]" replaced with your own identifying
  19 # information: Portions Copyright [yyyy] [name of copyright owner]
  20 #
  21 # CDDL HEADER END
  22 #
  23 #
  24 # Copyright 2011-2012 OmniTI Computer Consulting, Inc.  All rights reserved.
  25 # Use is subject to license terms.
  26 #
  27 # Load support functions
  28 . ../../lib/functions.sh
  29 
  30 PROG=trousers   # App name
  31 VER=0.3.8       # App version
  32 VERHUMAN=$VER   # Human-readable version
  33 PKG=library/security/trousers  # Package name (without prefix)
  34 SUMMARY="trousers - TCG Software Stack - software for accessing a TPM device"
  35 DESC="$SUMMARY ($VER)"
  36 
  37 BUILD_DEPENDS_IPS="developer/build/libtool developer/build/automake developer/build/autoconf developer/sunstudio12.1"
  38 DEPENDS_IPS="system/library/gcc-5-runtime library/security/openssl@1.0.2"
  39 
  40 LIBS="-lbsm -lnsl -lsocket -lgen -lscf -lresolv"
  41 
  42 preprep_build() {
  43   pushd $TMPDIR/$BUILDDIR > /dev/null || logerr "Cannot change to build directory"
  44   for f in `ls src/include/tss/*.h` ; do
  45     /usr/bin/dos2unix $f $f
  46   done
  47   for f in `ls src/include/trousers/*.h` ; do
  48     /usr/bin/dos2unix $f $f
  49   done
  50   for f in `ls src/include/*.h` ; do
  51     /usr/bin/dos2unix $f $f
  52   done
  53   logcmd libtoolize -f || logerr "libtoolize failed"
  54   logcmd aclocal || logerr "aclocal failed"
  55   logcmd automake --add-missing || logerr "automake --add-missing failed"
  56   logcmd automake src/tspi/Makefile || logerr "automake failed"
  57   logcmd autoreconf -vi 2>&1 > /dev/null
  58   logcmd autoreconf -vi || logerr "autoreconf failed"
  59   popd > /dev/null
  60 }
  61 
  62 cleanup_configure() {
  63     for makefile in src/trspi/Makefile src/tspi/Makefile; do
  64         mv $makefile $makefile.unneeded
  65         cat $makefile.unneeded | sed -e 's/LIBS = .*/LIBS = -lnsl -lsocket -lgen/;' > $makefile
  66     done
  67 }
  68 
  69 configure32() {
  70     logmsg "--- configure (32-bit)"
  71     CFLAGS="$CFLAGS $CFLAGS32" \
  72     CXXFLAGS="$CXXFLAGS $CXXFLAGS32" \
  73     CPPFLAGS="$CPPFLAGS $CPPFLAGS32" \
  74     LDFLAGS="$LDFLAGS $LDFLAGS32" \
  75     CC=$CC CXX=$CXX \
  76     LIBS="$LIBS" \
  77     logcmd $CONFIGURE_CMD $CONFIGURE_OPTS_32 \
  78     $CONFIGURE_OPTS || \
  79         logerr "--- Configure failed"
  80     cleanup_configure
  81 }
  82 
  83 configure64() {
  84     logmsg "--- configure (64-bit)"
  85     CFLAGS="$CFLAGS $CFLAGS64" \
  86     CXXFLAGS="$CXXFLAGS $CXXFLAGS64" \
  87     CPPFLAGS="$CPPFLAGS $CPPFLAGS64" \
  88     LDFLAGS="$LDFLAGS $LDFLAGS64" \
  89     CC=$CC CXX=$CXX \
  90     LIBS="$LIBS" \
  91     logcmd $CONFIGURE_CMD $CONFIGURE_OPTS_64 \
  92     $CONFIGURE_OPTS || \
  93         logerr "--- Configure failed"
  94     cleanup_configure
  95 }
  96 
  97 install_license() {
  98     cp $TMPDIR/$BUILDDIR/LICENSE $DESTDIR/license
  99 }
 100 
 101 init
 102 download_source $PROG $PROG $VER
 103 patch_source
 104 preprep_build
 105 prep_build
 106 build
 107 make_lintlibs tspi /usr/lib /usr/include "{tss,trousers}/*.h"
 108 make_isa_stub
 109 install_license
 110 make_package
 111 clean_up