Subversion Repositories f9daq

Rev

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