Subversion Repositories f9daq

Rev

Rev 117 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
117 f9daq 1
#!/bin/bash
2
 
3
function helptext()
4
{
5
  echo "#------------------------------"
6
  echo "# Configure instructions: -----"
7
  echo "#------------------------------"
8
  echo ""
9
  echo "./configure [option] [type]"
10
  echo ""
11
  echo "[option] = Option for configure:"
12
  echo "  - help = Display configure instructions."
127 f9daq 13
  echo "  - nomake = Only prepare system dependent files (base directory and online/offline mode)."
14
  echo "  - all = Prepare system dependent files and make used libraries."
15
  echo "  - clean = Clean the installation directory. Does not clean the results directory."
117 f9daq 16
  echo "  - compress = Compress the source code in a tar-ball."
17
  echo ""
18
  echo "[type] = Configure for use in online or offline mode (only needed in nomake and all):"
19
  echo "  - I = Online mode."
20
  echo "  - O = Offline mode (no connection to CAMAC, motor, voltage supply and scope)."
127 f9daq 21
  echo "  - S = Offline mode with scope connection (no connection to CAMAC, motor and voltage supply)."
117 f9daq 22
  echo ""
23
  echo "#------------------------------"
24
}
25
 
26
# Check for arguments
27
if [ "$1" == "" ]; then
28
  echo "Error! No arguments supplied."
29
  echo ""
30
  helptext
31
  exit 1
32
else
33
  # When using help, only display help and then exit
34
  if  [ "$1" == "help" ]; then
35
    helptext
36
    exit 0
37
  fi
38
 
39
  # Print help and exit if we give a wrong first argument
40
  if  [ "$1" != "nomake" ] && [ "$1" != "all" ] && [ "$1" != "clean" ] && [ "$1" != "compress" ]; then
41
    echo "Error! Wrong configuration option selected (first argument)."
42
    echo ""
43
    helptext
44
    exit 1
45
  fi
46
 
47
  startdir=$PWD
48
 
49
  ostype=`uname -p`
50
 
51
  # Compiles the table microcontroller program
52
  if [ "$1" == "all" ]; then
53
    if [ -d $startdir/MIKRO ]; then
54
      cd $startdir/MIKRO
55
      rm -f $startdir/MIKRO/mikro_ctrl
56
      make
57
      cd $startdir
58
    fi
59
  fi
60
 
61
  # When using compress, only create a tar-ball and then exit
62
  if [ "$1" == "compress" ]; then
63
    cd $startdir
64
    if [ ! -d $startdir/camac_gui_windowed ]; then
65
      mkdir $startdir/camac_gui_windowed
66
      mkdir $startdir/camac_gui_windowed/results
67
      echo "Copying source files to temporary directory $startdir/camac_gui_windowed..."
127 f9daq 68
      cp -r configure daq.h daqscope.h GuiLinkDef.h libxxusb.cpp root_include.h start.cxx windowed_test.C windowed_test.h wusbcc.h wusbxx_dll.c wusbxx_dll.h mpod/ MIKRO/ vxi11_x86_64/ vxi11_i686/ input/ ./camac_gui_windowed/
117 f9daq 69
      cd $startdir/camac_gui_windowed
70
      echo "Cleaning the base directory in $startdir/camac_gui_windowed..."
71
      rm -f *.bak
72
      cd $startdir/camac_gui_windowed/input
73
      echo "Cleaning the input directory in $startdir/camac_gui_windowed/input..."
74
      rm -f *.bak
75
      cd $startdir/camac_gui_windowed/vxi11_x86_64
76
      echo "Cleaning the 64 bit VXI11 directory in $startdir/camac_gui_windowed/vxi11_x86_64..."
77
      rm -f *.bak
78
      make clean
79
      cd $startdir/camac_gui_windowed/vxi11_i686
80
      echo "Cleaning the 32 bit VXI11 directory in $startdir/camac_gui_windowed/vxi11_i686..."
81
      rm -f *.bak
82
      make clean
83
      cd $startdir
84
      echo "Creating a tar-ball camac_gui_windowed.tar.gz..."
85
      tar czf $startdir/camac_gui_windowed.tar.gz ./camac_gui_windowed
86
      echo "Removing the temporary directory $startdir/camac_gui_windowed..."
87
      rm -r $startdir/camac_gui_windowed
88
      exit 0
89
    else
90
      echo "Error! Directory ./camac_gui_windowed already exists."
91
      exit 1
92
    fi
93
  fi
94
 
95
  # Configure the workstation information and directory of program (0 if we find something and 1 otherwise)
96
  basedir=$(echo $startdir | sed 's/\//\\\//g')
97
 
98
  if [ "$1" == "nomake" ] || [ "$1" == "all" ]; then
127 f9daq 99
    if [ "$2" == "O" ] || [ "$2" == "I" ] || [ "$2" == "S" ]; then
117 f9daq 100
      grep -q "#define WORKSTAT 'N'" $startdir/input/workstation.h.in
101
      if [ $? == 0 ]; then
102
        sed "s/define WORKSTAT 'N'/define WORKSTAT '$2'/" $startdir/input/workstation.h.in > $startdir/workstation.h.mid
103
      fi
104
      grep -q "#define rootdir \"path-to-installation\"" $startdir/input/workstation.h.in
105
      if [ $? == 0 ]; then
106
        sed "s/path-to-installation/$basedir/g" $startdir/workstation.h.mid > $startdir/workstation.h
107
        rm $startdir/workstation.h.mid
108
      fi
109
      grep -q "#include \"vxi11_user.h\"" $startdir/input/daqscope.C.in
110
      if [ $? == 0 ]; then
111
	sed "s/vxi11_user.h/.\/vxi11_$ostype\/vxi11_user.h/g" $startdir/input/daqscope.C.in > $startdir/daqscope.C
112
      fi
113
      grep -q "SHLIB = \$(LIBFILE) libvxi11.a" $startdir/input/Makefile.in
114
      if [ $? == 0 ]; then
115
	if [ "$2" == "I" ]; then
116
	  sed "s/SHLIB = \$(LIBFILE) libvxi11.a/SHLIB = \$(LIBFILE) libvxi11.a -lusb/g" $startdir/input/Makefile.in > $startdir/Makefile.mid
117
	fi
118
      fi
119
      grep -q "CAMLIB = \$(LIBFILE)" $startdir/input/Makefile.in
120
      if [ $? == 0 ]; then
121
	if [ "$2" == "I" ]; then
122
	  sed "s/CAMLIB = \$(LIBFILE)/CAMLIB = \$(LIBFILE) -lusb/g" $startdir/Makefile.mid > $startdir/Makefile
123
	  rm $startdir/Makefile.mid
127 f9daq 124
        elif [ "$2" == "O" ] || [ "$2" == "S" ]; then
117 f9daq 125
	  cp $startdir/input/Makefile.in $startdir/Makefile
126
        fi
127
      fi
128
 
127 f9daq 129
      if [ "$2" == "O" ] || [ "$2" == "S" ]; then
117 f9daq 130
        cp $startdir/input/daqusb.C.offline $startdir/daqusb.C
131
        cp $startdir/input/start.sh.offline $startdir/start.sh
127 f9daq 132
	cp $startdir/input/libxxusb.h.offline $startdir/libxxusb.h
133
	cp $startdir/input/usb.h.offline $startdir/usb.h
117 f9daq 134
      elif [ "$2" == "I" ]; then
135
        cp $startdir/input/daqusb.C.online $startdir/daqusb.C
136
        cp $startdir/input/start.sh.online $startdir/start.sh
127 f9daq 137
	cp $startdir/input/libxxusb.h.online $startdir/libxxusb.h
117 f9daq 138
      fi
139
    fi
140
  fi
141
 
142
  # In case we just want to set the workstation information, exit here
143
  if [ "$1" == "nomake" ]; then
144
    exit 0
145
  fi
146
 
147
  # 64 bit configuration rules
148
  if [ $ostype == "x86_64" ]; then
149
    vxidir=$startdir/vxi11_$ostype
150
    if [ -d $vxidir ]; then
151
      cd $vxidir
152
      if [ "$1" == "clean" ]; then
153
        make clean
154
	cd $startdir
155
	make clean
156
	rm -f Makefile
157
      else
127 f9daq 158
        if [ "$2" == "O" ] || [ "$2" == "I" ] || [ "$2" == "S" ]; then
117 f9daq 159
          make
160
	else
161
          echo "Error! No configuration type selected (second argument)."
162
	  echo ""
163
	  helptext
164
	  exit 1
165
	fi
166
      fi
167
      cd $startdir
168
    else
169
      echo "No 64 bit VXI11 source folder."
170
      exit 1
171
    fi
172
  # 32 bit configuration rules
173
  elif [ $ostype == "i686" ]; then
174
    vxidir=$startdir/vxi11_$ostype
175
    if [ -d $vxidir ]; then
176
      cd $vxidir
177
      if [ "$1" == "clean" ]; then
178
        make clean
179
	cd $startdir
180
	make clean
181
	rm -f Makefile
182
      else
127 f9daq 183
        if [ "$2" == "O" ] || [ "$2" == "I" ] || [ "$2" == "S" ]; then
117 f9daq 184
          make
185
	else
186
          echo "Error! No installation type selected (second argument)."
187
	  echo ""
188
	  helptext
189
	  exit 1
190
	fi
191
      fi
192
      cd $startdir
193
    else
194
      echo "No 32 bit VXI11 source folder."
195
      exit 1
196
    fi
197
  else
198
    echo "No OS type information found."
199
    exit 1
200
  fi
201
fi
202
 
203
exit 0