#!/bin/sh # -------------------------------------------------------------------- # -------------------------------------------------------------------- AWK=awk TR=tr TOUCH=touch # -------------------------------------------------------------------- if [ $# -ge 1 ] then case $1 in -drivers) shift if [ $# -ge 1 ] then echo "Usage: $0 [-help] [-drivers] [-modemlib [smsmodem|libmodem]]" 1>&2 exit 1 fi echo echo "Generating file 'Makefile.drivers' from file 'drivers'..." cp config/Makefile.drivers Makefile.drivers if [ $? -ne 0 ] then echo "ERROR: 'cp config/Makefile.drivers Makefile.drivers' failed" 1>&2 exit 1 fi drivers=`$AWK '!/^#/ && !/^$/ { print $1 }' drivers` drivers=`echo $drivers` for driver in $drivers do drv_def="-D$driver $drv_def" driver=`echo $driver | $TR '[A-Z]' '[a-z]'`.o drv_obj="$driver $drv_obj" done echo "# --------------------------------------------------------------------" >>Makefile.drivers echo >>Makefile.drivers echo "DRIVERS=$drivers" >>Makefile.drivers echo "DRV_OBJ=$drv_obj" >>Makefile.drivers echo "DRV_DEF=$drv_def" >>Makefile.drivers echo >>Makefile.drivers echo "# --------------------------------------------------------------------" >>Makefile.drivers echo "Done." exit 0 ;; -modemlib) libmodem=1 smsmodem=2 shift if [ $# -ge 1 ] then if [ $# -gt 1 ] then echo "Usage: $0 [-help] [-drivers] [-modemlib [smsmodem|libmodem]]" 1>&2 exit 1 fi modemlib=$1 else echo echo "SMS Client can optionally be compiled against:" echo echo echo " 1. Libmodem - A third party modem library" echo " 2. SMSModem - The internal modem library" echo modemlib= while [ "X-$modemlib" = "X-" ] do echo "Please make a selection [1,2]:" read selection case "$selection" in 1) modemlib=libmodem ;; 2) modemlib=smsmodem ;; *) echo "ERROR: Invalid selection" 1>&2 ;; esac done fi case $modemlib in libmodem) modemlib=$libmodem mlibs=-lmodem ;; smsmodem) modemlib=$smsmodem mlibs= ;; *) echo "Usage: $0 [-help] [-drivers] [-modemlib [smsmodem|libmodem]]" 1>&2 exit 1 esac echo echo "Generating file 'Makefile.modemlib'..." cp config/Makefile.modemlib Makefile.modemlib if [ $? -ne 0 ] then echo "ERROR: 'cp config/Makefile.modemlib Makefile.modemlib' failed" 1>&2 exit 1 fi echo "# --------------------------------------------------------------------" >>Makefile.modemlib echo >>Makefile.modemlib echo "SMSMODEM = $smsmodem" >>Makefile.modemlib echo "LIBMODEM = $libmodem" >>Makefile.modemlib echo >>Makefile.modemlib echo "# --------------------------------------------------------------------" >>Makefile.modemlib echo >>Makefile.modemlib echo "MODEMLIB = $modemlib" >>Makefile.modemlib echo "MLIBS = $mlibs" >>Makefile.modemlib echo >>Makefile.modemlib echo "# --------------------------------------------------------------------" >>Makefile.modemlib echo "Done." exit 0 ;; -h|-help) echo "Usage: $0 [-help] [-drivers] [-modemlib [smsmodem|libmodem]]" exit 0 ;; *) echo "Usage: $0 [-help] [-drivers] [-modemlib [smsmodem|libmodem]]" 1>&2 exit 1 esac fi if [ -f ".configured" ] then echo "" echo "You have already run 'configure'" echo "running it again will overwrite 'Makefile', 'Makefile.drivers'" echo "and 'Makefile.config'" echo "Are you sure you wish to continue [Y/N]?" read answer case "$answer" in Y*|y*) ;; *) exit 0 ;; esac fi # -------------------------------------------------------------------- sh $0 -drivers sh $0 -modemlib smsmodem # -------------------------------------------------------------------- UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown # -------------------------------------------------------------------- case $UNAME_SYSTEM in SunOS*) case $UNAME_RELEASE in 5.4) EXTENSION=solaris-2.4 ;; 5.5) EXTENSION=solaris-2.5 ;; 5.5.1) EXTENSION=solaris-2.5.1 ;; 5.6) EXTENSION=solaris-2.6 ;; 5.7) EXTENSION=solaris-2.7 ;; 5.8) EXTENSION=solaris-2.8 ;; *) EXTENSION= ;; esac ;; Linux*) EXTENSION=linux ;; FreeBSD*) EXTENSION=freebsd ;; UnixWare*) EXTENSION=unixware ;; SCO*) EXTENSION=sco ;; HP-UX*) EXTENSION=hp-ux ;; OSF1*) EXTENSION=osf1 ;; unknown) ( hostinfo | grep NeXT ) 2>/dev/null >/dev/null if [ $? -eq 0 ] then EXTENSION=next else EXTENSION= fi ;; *) EXTENSION= ;; esac if [ "X-${EXTENSION}" = "X-" ] then echo "" echo "I Dont know how to build for '${UNAME_SYSTEM}'" echo "Copy a 'Makefile.config.OSTYPE' from the config directory" echo "which most closely resembles your platform into this" echo "directory and rename it 'Makefile.config'" echo "" echo "You may wish to edit Makefile.config for site specific dependencies" echo "When you have finished, to build and install sms_client run:" echo "" echo " make ; make install" echo "" exit 1 fi # -------------------------------------------------------------------- cp config/Makefile.config.${EXTENSION} Makefile.config if [ $? -ne 0 ] then echo "ERROR: 'cp config/Makefile.config.${EXTENSION} Makefile.config' failed" 1>&2 exit 1 fi cp config/Makefile Makefile if [ $? -ne 0 ] then echo "ERROR: 'cp config/Makefile Makefile' failed" 1>&2 exit 1 fi $TOUCH .configured if [ $? -ne 0 ] then echo "ERROR: '$TOUCH .configured' failed" 1>&2 exit 1 fi echo "" echo "Copying 'config/Makefile.config.${EXTENSION}' to 'Makefile.config'" echo "Configuration complete" echo "You may wish to edit Makefile.config for site specific dependencies" echo "When you have finished, to build and install sms_client run:" echo "" echo " make ; make install" echo "" exit 0 # --------------------------------------------------------------------