LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   SlackBuild to make both STATIC and SHARED wireless-tools package. (http://www.linuxquestions.org/questions/slackware-14/slackbuild-to-make-both-static-and-shared-wireless-tools-package-786045/)

GrapefruiTgirl 01-31-2010 03:49 PM

SlackBuild to make both STATIC and SHARED wireless-tools package.
 
I don't use wireless tools myself currently, since I'm wired to the internet; but, I found that a package I wanted to build, required at the least, a shared version of libiw, if not both the shared AND static version.

Symptoms of when you are in this boat, are error messages during compiling, similar to:

Code:

/usr/lib64/libiw.a(iwlib.so): In function `iw_mwatt2dbm':
iwlib.c:(.text+0x1a77): undefined reference to `log10'
iwlib.c:(.text+0x1a84): undefined reference to `ceil'
/usr/lib64/libiw.a(iwlib.so): In function `iw_freq2float':
iwlib.c:(.text+0x1b11): undefined reference to `pow'
/usr/lib64/libiw.a(iwlib.so): In function `iw_dbm2mwatt':
iwlib.c:(.text+0x2254): undefined reference to `pow'
iwlib.c:(.text+0x2259): undefined reference to `trunc'
/usr/lib64/libiw.a(iwlib.so): In function `iw_float2freq':
iwlib.c:(.text+0x2272): undefined reference to `log10'
iwlib.c:(.text+0x2277): undefined reference to `floor'
iwlib.c:(.text+0x229a): undefined reference to `pow'
iwlib.c:(.text+0x22ac): undefined reference to `floor'
collect2: ld returned 1 exit status
make: *** [i3status] Error 1
make: *** Waiting for unfinished jobs....

Anyhow, here is a modified SlackBuild, based on the one I have here on my Slack64 DVD (from when 13/64 first came out) which I've modified to build both a static & a shared wireless-tools package.
You'll need these new slack-desc files too, since I adjusted the package name slightly.
Enjoy, I hope someone else can use these too.

Code:

#!/bin/sh

# Copyright 2008, 2009  Patrick J. Volkerding, Sebeka, Minnesota, USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# This is the Slack13-64 SlackBuild for wireless-tools version 29.0
# Modified by GrapefruiTgirl:
# modified 2010 Jan 30 or so, to build two packages, one static, one shared.
# Installing them in either order will overwrite the first one installed
# which is OK because they both contain exactly the same stuff, only the
# shared package contains the shared lib and symlink, instead of the libiw.a
# static lib. So, installing both packages results in both a static, and a
# shared, library installed.
# Why?? Some things want to build against libiw, but can't, if there's no
# shared library. Example: i3status, a tool associated with i3 window manager.
# Is there a better way to do this? Sure! But I wanted this _now_ and it works.

VERSION=29
ARCH=${ARCH:-x86_64}
BUILD=${BUILD:-5}

if [ "$ARCH" = "x86_64" ]; then
  LIBDIRSUFFIX="64"
else
  LIBDIRSUFFIX=""
fi

CWD=$(pwd)
TMP=${TMP:-/tmp}

main () {
  PKG=$TMP/package-wireless-tools-$1
  rm -rf $PKG
  mkdir -p $TMP $PKG
  cd $TMP

  rm -rf wireless_tools.$VERSION
  tar xvf $CWD/wireless_tools.$VERSION.tar.gz || exit 1
  cd wireless_tools.$VERSION
  zcat $CWD/wireless_tools.nowhine.diff.gz | patch -p1 --verbose --suffix=.orig --backup || exit 1
  if [ "$1" = "static" ]; then
    zcat $CWD/wireless_tools.static.diff.gz | patch -p1 --verbose --suffix=.orig --backup || exit 1
  fi;
  chown -R root:root .
  find . \
    \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
    -exec chmod 755 {} \; -o \
    \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
    -exec chmod 644 {} \;

  make || exit 1

  mkdir -p $PKG/sbin
  cp -a ifrename iwconfig iwevent iwgetid iwlist iwpriv iwspy $PKG/sbin
  chmod 755 $PKG/sbin/*
  # The library seems to be used by kdenetwork, but since the .soname in the shared library
  # doesn't seem to be forward-thinking we'll leave that out still:
  mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}

  [ -e libiw.a ] && cp -a libiw.a $PKG/usr/lib${LIBDIRSUFFIX}
  if [ -e libiw.so.29 ]; then
    cp -a libiw.so.29 $PKG/usr/lib${LIBDIRSUFFIX}
    ln -sf $PKG/usr/lib${LIBDIRSUFFIX}/libiw.so.29 $PKG/usr/lib${LIBDIRSUFFIX}/libiw.so
  fi;

  find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
    | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null

  mkdir -p $PKG/usr/include
  cp -a iwlib.h wireless.h $PKG/usr/include
  chmod 644 $PKG/usr/include/*.h

  mkdir -p $PKG/usr/man/man5
  cat iftab.5 | gzip -9c > $PKG/usr/man/man5/iftab.5.gz
  mkdir -p $PKG/usr/man/man7
  cat wireless.7 | gzip -9c > $PKG/usr/man/man7/wireless.7.gz
  mkdir -p $PKG/usr/man/man8
  for file in *.8 ; do
    cat $file | gzip -9c > $PKG/usr/man/man8/$file.gz
  done

  mkdir -p $PKG/usr/doc/wireless-tools-$VERSION
  cp -a \
    COPYING INSTALL *.txt README* \
    $PKG/usr/doc/wireless-tools-$VERSION
  chmod 644 $PKG/usr/doc/wireless-tools-$VERSION/*

  # Add init scripts from Eric Hameleers:
  mkdir -p $PKG/etc/rc.d
  cat $CWD/scripts/rc.wireless > $PKG/etc/rc.d/rc.wireless.new
  chmod 755 $PKG/etc/rc.d/rc.wireless.new
  # This might contain a secret key, so we'll use chmod 600:
  cat $CWD/scripts/rc.wireless.conf > $PKG/etc/rc.d/rc.wireless.conf.new
  chmod 600 $PKG/etc/rc.d/rc.wireless.conf.new

  mkdir $PKG/install
  cat $CWD/slack-desc-$1 > $PKG/install/slack-desc
  zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
} # end of main()

# call function to build STATIC version
main static
cd $PKG
/sbin/makepkg -l y -c n $TMP/wirelesstools-static-$VERSION-$ARCH-$BUILD.txz

cd $CWD

# call function to build SHARED version
main shared
cd $PKG
/sbin/makepkg -l y -c n $TMP/wirelesstools-shared-$VERSION-$ARCH-$BUILD.txz

The slack-desc files:
Code:

root@reactor: cat slack-desc-static               
# HOW TO EDIT THIS FILE:                                                               
# The "handy ruler" below makes it easier to edit a package description.  Line         
# up the first '|' above the ':' following the base package name, and the '|'           
# on the right side marks the last column you can put a character in.  You must         
# make exactly 11 lines for the formatting to be correct.  It's also                   
# customary to leave one space after the ':'.                                           

                    |-----handy-ruler------------------------------------------------------|
wirelesstools-static: wireless-tools (utilities for wireless networking)                   
wirelesstools-static: This package contains tools and a library used for configuring       
wirelesstools-static: wireless networking interfaces:
wirelesstools-static:  iwconfig (the main wireless tool),  iwlist (display more detailed
wirelesstools-static:  information than iwconfig),  iwspy (get stats per MAC address and
wirelesstools-static:  more),  iwpriv (set driver private ioctls),  iwgetid (show the
wirelesstools-static:  ESSID or NWID of a device),  iwevent (display wireless events),
wirelesstools-static:  ifrename (rename a network interface).
wirelesstools-static: Compiled as a static library.
wirelesstools-static: Wireless tools written by Jean Tourrilhes.
wirelesstools-static:
root@reactor:
root@reactor: cat slack-desc-shared
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.  Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in.  You must
# make exactly 11 lines for the formatting to be correct.  It's also
# customary to leave one space after the ':'.

                    |-----handy-ruler------------------------------------------------------|
wirelesstools-shared: wireless-tools (utilities for wireless networking)
wirelesstools-shared: This package contains tools and a library used for configuring
wirelesstools-shared: wireless networking interfaces:
wirelesstools-shared:  iwconfig (the main wireless tool),  iwlist (display more detailed
wirelesstools-shared:  information than iwconfig),  iwspy (get stats per MAC address and
wirelesstools-shared:  more),  iwpriv (set driver private ioctls),  iwgetid (show the
wirelesstools-shared:  ESSID or NWID of a device),  iwevent (display wireless events),
wirelesstools-shared:  ifrename (rename a network interface).
wirelesstools-shared: Compiled as a shared library.
wirelesstools-shared: Wireless tools written by Jean Tourrilhes.
wirelesstools-shared:
root@reactor:


dive 01-31-2010 05:06 PM

Useful, thanks :-)


All times are GMT -5. The time now is 01:52 AM.