#!/bin/bash # dpkg configuration script for emc2 # Copyright (C) 2006 Jeff Epler # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # When used to produce a debian package, this file is a script "used to # control compilation and installation of the executable" usage () { P=${0##*/} cat < /dev/null | cut -d - -f 2- | head -1) if [ -z "$KERNEL" ]; then echo "no realtime kernels found!" exit 1 fi fi set -- $KERNEL fi TARGET=$1 MODULE_PATH=usr/realtime-$1/modules/emc2 MODULE_EXT=.ko KERNEL_DEPENDS=linux-image-$1,rtai-modules-$1 KERNEL_HEADERS=linux-headers-$1 EXTRA_FILES="usr/bin/emc_module_helper" KERNEL_VERSION=$1 DRIVERS=drivers.files.in PYTHON_VERSION=$(python -c 'import sys; print sys.version[:3]') PYTHON_VERSION_NEXT=$(python -c 'import sys; print sys.version[:2] + str(1+int(sys.version[2]))') # hope this works on other systems too DISTRIB_NAME= if [ "$(which lsb_release)" != "" ]; then DISTRIB_NAME="$(lsb_release -s -i)-$(lsb_release -s -r)" elif [ -f /etc/lsb-release ]; then source /etc/lsb-release DISTRIB_NAME=$DISTRIB_ID-$DISTRIB_RELEASE fi if [ -d extras-$DISTRIB_NAME/emc2.files ]; then EXTRAS=extras-$DISTRIB_NAME/emc2-files else EXTRAS=extras fi case $DISTRIB_NAME in Ubuntu-11.04) # natty EXTRA_BUILD=dvipng,texlive-extra-utils,texlive-latex-recommended,texlive-fonts-recommended,ghostscript,imagemagick,texlive-lang-french,texlive-font-utils TCLTK_VERSION=8.5 ;; Ubuntu-10.04) EXTRA_BUILD=dvipng,texlive-extra-utils,texlive-latex-recommended,texlive-fonts-recommended,ghostscript,imagemagick,texlive-lang-french,texlive-font-utils TCLTK_VERSION=8.5 ;; Ubuntu-9.10) EXTRA_BUILD=dvipng,texlive-extra-utils,texlive-latex-recommended,texlive-fonts-recommended,ghostscript,imagemagick,texlive-lang-french TCLTK_VERSION=8.5 ;; Ubuntu-8.04) EXTRA_BUILD=dvipng,texlive-extra-utils,texlive-latex-recommended,texlive-fonts-recommended,ghostscript,imagemagick,texlive-lang-french TCLTK_VERSION=8.4 ;; Debian-testing|Debian-6.0) EXTRA_BUILD=dvipng TCLTK_VERSION=8.5 ;; Debian-5.0*) EXTRA_BUILD=dvipng TCLTK_VERSION=8.4 ;; *) EXTRA_BUILD=dvipng TCLTK_VERSION=8.4 ;; esac DOC_BUILD= EMC2_PACKAGE_NAME=emc2 case $TARGET in sim) MODULE_PATH=usr/lib/emc2/modules MODULE_EXT=.so KERNEL_DEPENDS= KERNEL_HEADERS=libpth-dev DRIVERS= EXTRA_FILES="usr/bin/rtapi_app" DISTRIB_NAME=sim-$DISTRIB_NAME EMC2_PACKAGE_NAME=emc2-sim ;; 2.6.12-magma) KERNEL_HEADERS=$KERNEL_HEADERS,gcc-3.4 ;; 2.6.15-magma) KERNEL_HEADERS=$KERNEL_HEADERS,gcc-4.0 ;; 2.6.22.6-magma|2.6.24-16-rtai) KERNEL_HEADERS="$KERNEL_HEADERS" ;; 2.6.24-16-rtai) KERNEL_HEADERS=$KERNEL_HEADERS,gcc-4.2 ;; 2.6.32-122-rtai) ;; *) echo "your kernel '$TARGET' is not known. There might be needed dependencies which won't get set automatically." esac subst () { sed -e "s|@MODULE_PATH@|$MODULE_PATH|g" \ -e "s|@MODULE_EXT@|$MODULE_EXT|g" \ -e "s|@KERNEL_VERSION@|$KERNEL_VERSION|g" \ -e "s|@KERNEL_DEPENDS@|$KERNEL_DEPENDS|g" \ -e "s|@KERNEL_HEADERS@|$KERNEL_HEADERS|g" \ -e "s|@EXTRA_BUILD@|$EXTRA_BUILD|g" \ -e "s|@EMC2_PACKAGE_NAME@|$EMC2_PACKAGE_NAME|g" \ -e "s|@EXTRAS@|$EXTRAS|g" \ -e "s|@EXTRA_FILES@|$EXTRA_FILES|g" \ -e "s|@DISTRIB_NAME@|$DISTRIB_NAME|g" \ -e "s|@TARGET@|$TARGET|g" \ -e "s|@PYTHON_VERSION@|$PYTHON_VERSION|g" \ -e "s|@TCLTK_VERSION@|$TCLTK_VERSION|g" \ -e "s|@PYTHON_VERSION_NEXT@|$PYTHON_VERSION_NEXT|g" \ $* } subst control.in > control if [ "$TARGET" == "sim" ]; then cp emc2-dev.files.in emc2-sim-dev.files else cp emc2-dev.files.in emc2-dev.files echo "$MODULE_PATH/Module.symvers" >> emc2-dev.files fi subst rules.in > rules; chmod +x rules if [ -f $EXTRAS/emc2.files ]; then subst emc2.files.in $DRIVERS $EXTRAS/emc2.files > $EMC2_PACKAGE_NAME.files else subst emc2.files.in $DRIVERS > $EMC2_PACKAGE_NAME.files fi DOCS_PACKAGES=$(echo emc2-doc-{en,fr,de,es}) for P in $DOCS_PACKAGES; do if [ -f $EXTRAS/$P.files ]; then cat $P.files.in $EXTRAS/$P.files > $P.files else cat $P.files.in > $P.files fi done rm -f ../build-stamp echo "successfully configured for '$DISTRIB_NAME'-'$TARGET'.."