Back Midas Rome Roody Rootana
  Midas DAQ System  Not logged in ELOG logo
Message ID: 674     Entry time: 23 Nov 2009
Author: Exaos Lee 
Topic: Suggestion 
Subject: Scripts for "midas-config" 
Supposing you have installed MIDAS to some directory such as "/opt/MIDAS/r4621", you have to write some Makefile as the following while building some applications based on the version installed:

Quote:
CFLAGS += -I/opt/MIDAS/r4621/include -DOS_LINUX -g -O2 -Wall -fPIC
LIBS += -lutil -lpthread -lodbc -lz
....

Why not use a script to record your MIDAS building options? When you want to build something based on it, just type something such as

Quote:
M_CFLAGS := `midas-config --cflags`
M_LIBS := `midas-config --libs`

You needn't to check your installed options each time when you build something against it. Each time you install a new version of MIDAS, you only need to update the script called 'midas-config'. I wrote a sample script named "genconf.sh" in the first zipped attachment. The 2nd "midas-config" is a sampled generated by it. Also a diff of Makefile is included. I hope it may help. Smile
Attachment 1: genc.zip  2 kB
Attachment 2: midas-config  2 kB  | Hide | Hide all
#!/bin/sh
prefix=/usr/local
cflags="-I/usr/local/include -g -O2 -Wall -Wuninitialized -DINCLUDE_FTPLIB  -DOS_LINUX -fPIC -Wno-unused-function -DHAVE_ODBC -DHAVE_ZLIB"
st_libs="-lutil -lpthread -lodbc -lz /usr/local/lib/libmidas.a"
dyn_libs="-lutil -lpthread -lodbc -lz -L/usr/local/lib -lmidas"
incdir=/usr/local/include
libdir=/usr/local/lib
svnver=r4621
platform=linux

drvdir=/usr/local/share/drivers
camacdir=/usr/local/share/drivers/camac
vmedir=/usr/local/share/drivers/vme

srcdir=/usr/local/share/src
exampledir=/usr/local/share/examples

out=""
while test $# -gt 0; do
  case "$1" in
  -*=*) optarg=/usr/local ;;
  *)    optarg= ;;
  esac

  case $1 in
      --prefix)
	  out="$out ${prefix}"
	  ;;
      --cflags|-c)
	  out="$out ${cflags}"
	  ;;
      --incdir|-dI)
	  out="$out ${incdir}"
	  ;;
      --libdir|-dL)
	  out="$out ${libdir}"
	  ;;
      --libs|--static-libs|-l)
	  out="$out ${st_libs}"
	  ;;
      --dyn-libs)
	  out="$out ${dyn_libs}"
	  ;;
      --platform)
	  out="$out ${platform}"
	  ;;
      --drvdir|-dD)
	  out="$out ${drvdir}"
	  ;;
      --camacdir|-dC)
	  out="$out ${camacdir}"
	  ;;
      --vmedir|-dV)
	  out="$out ${vmedir}"
	  ;;
      --srcdir|-dS)
	  out="$out ${srcdir}"
	  ;;
      --exampledir|-dE)
	  out="$out ${exampledir}"
	  ;;
      --version|-v)
          out="$out ${svnver}"
          ;;
      --help|-h)
	  echo "Usage: midas-config [options]"
	  echo "Options:"
	  echo "   --prefix        Display the installation prefix"
	  echo "   --cflags,-c     Display C/C++ flags using for compilation"
	  echo "   --incdir,-dI    Display midas header directory installed"
	  echo "   --libdir,-dL    Display midas library directory installed"
          echo "   --libs, -l"
	  echo "   --static-libs   Display link flags while linking with static midas library"
	  echo "   --dyn-libs      Display link flags while linking with dynamic library"
	  echo "   --platform      Display installed platform"
	  echo "   --drvdir,-dD    Display the driver directory"
	  echo "   --camacdir,-dC    Display the directory including CAMAC APIs"
	  echo "   --vmedir,-dV      Display the directory including VME APIs"
	  echo "   --srcdir,-dS      Display the source directory"
	  echo "   --exampledir,-dE  Display the examples directory"
          echo "   --version, -v  Show the subversion number"
	  echo "   --help, -h     Display this usage"
	  echo
          exit 0
	  ;;
      *)
      ### Give an error
	  echo "Unknown argument \"/usr/local\"!" 1>&2
	  echo "${usage}" 1>&2
	  exit 1
	  ;;
  esac
  shift
done

echo $out

ELOG V3.1.4-2e1708b5