Added README.
[irreco.git] / lirc-0.8.4a / setup.sh
blob5e6efc59cb771032c29254f07c0783005a11f820
1 #! /bin/sh
3 LIRC_VERSION="0.8.4a"
5 #############################################################################
6 ## Default Values
7 COM1_PORT=0x3f8
8 COM2_PORT=0x2f8
9 COM3_PORT=0x3e8
10 COM4_PORT=0x2e8
11 COM1_IRQ=4
12 COM2_IRQ=3
13 COM3_IRQ=4
14 COM4_IRQ=3
15 LPT1_PORT=0x378
16 LPT2_PORT=0x278
17 LPT3_PORT=0x3bc
18 LPT1_IRQ=7
19 LPT2_IRQ=5
20 LPT3_IRQ=none
22 LIRC_DRIVER="serial"
23 LIRC_MAJOR=61
24 SELECTED_DRIVER=""
25 DRIVER_PARAMETER="com1"
26 DRIVER_PARAM_TYPE=""
27 SOFT_CARRIER="on"
28 TRANSMITTER="on"
29 IGOR="off"
30 TIMER=65536
31 X11_WINDOWS="on"
32 DEBUG="off"
33 NO_DAEMONIZE="off"
34 NO_LONG_CODES="off"
35 DYNCODES="off"
36 USE_SYSLOG="off"
38 #############################################################################
39 ## Variables
40 BACKTITLE="LIRC $LIRC_VERSION Configuration"
41 TEMP=".setup.tmp"
42 CONFIG=".setup.config"
43 START="configure.sh"
44 CONFIGURE=no
46 MAIN_MENU_TEXT="Welcome to the LIRC Configuration Menu. Here you"
47 MAIN_MENU_TEXT="$MAIN_MENU_TEXT can configure the driver and some compile-time"
48 MAIN_MENU_TEXT="$MAIN_MENU_TEXT settings for LIRC applications."
49 CONFIG_DRIVER_TEXT="Please select a driver, that supports your hardware."
50 CONFIG_SOFTWARE_TEXT="Here you can change some compile-time settings for LIRC applications"
51 SET_PORT_TEXT="Either choose a predefined I/O base address/IRQ combination, or enter costum values"
52 SET_PORT_TEXT="$SET_PORT_TEXT Hint: use <Space> to choose and <Enter> to proceed"
53 SET_TTY_TEXT="Choose the tty where your hardware is available."
54 GET_PORT_TEXT="Enter the I/O base address followed with a space and the IRQ (none for no IRQ)"
56 #############################################################################
57 ## Functions
58 GetSelectedDriver ()
60 COM1="off"; COM2="off"; COM3="off"; COM4="off"
61 LPT1="off"; LPT2="off"; LPT3="off"; USER="off"
62 IRTTY="none"
64 if test "$DRIVER_PARAMETER" = "btty"; then IRTTY="/dev/rfcomm0"; LIRC_PORT="none"; LIRC_IRQ="none"
65 elif test "$DRIVER_PARAMETER" = "ttyUSB1"; then COM1="on"; IRTTY="/dev/ttyUSB0"; LIRC_PORT="none"; LIRC_IRQ="none"
66 elif test "$DRIVER_PARAMETER" = "ttyUSB2"; then COM2="on"; IRTTY="/dev/ttyUSB1"; LIRC_PORT="none"; LIRC_IRQ="none"
67 elif test "$DRIVER_PARAMETER" = "ttyUSB3"; then COM3="on"; IRTTY="/dev/ttyUSB2"; LIRC_PORT="none"; LIRC_IRQ="none"
68 elif test "$DRIVER_PARAMETER" = "ttyUSB4"; then COM4="on"; IRTTY="/dev/ttyUSB3"; LIRC_PORT="none"; LIRC_IRQ="none"
69 elif test "$DRIVER_PARAMETER" = "com1"; then COM1="on"; LIRC_PORT=$COM1_PORT; LIRC_IRQ=$COM1_IRQ
70 elif test "$DRIVER_PARAMETER" = "com2"; then COM2="on"; LIRC_PORT=$COM2_PORT; LIRC_IRQ=$COM2_IRQ
71 elif test "$DRIVER_PARAMETER" = "com3"; then COM3="on"; LIRC_PORT=$COM3_PORT; LIRC_IRQ=$COM3_IRQ
72 elif test "$DRIVER_PARAMETER" = "com4"; then COM4="on"; LIRC_PORT=$COM4_PORT; LIRC_IRQ=$COM4_IRQ
73 elif test "$DRIVER_PARAMETER" = "tty1"; then COM1="on"; IRTTY="/dev/ttyS0"; LIRC_PORT="none"; LIRC_IRQ="none"
74 elif test "$DRIVER_PARAMETER" = "tty2"; then COM2="on"; IRTTY="/dev/ttyS1"; LIRC_PORT="none"; LIRC_IRQ="none"
75 elif test "$DRIVER_PARAMETER" = "tty3"; then COM3="on"; IRTTY="/dev/ttyS2"; LIRC_PORT="none"; LIRC_IRQ="none"
76 elif test "$DRIVER_PARAMETER" = "tty4"; then COM4="on"; IRTTY="/dev/ttyS3"; LIRC_PORT="none"; LIRC_IRQ="none"
77 elif test "$DRIVER_PARAMETER" = "lpt1"; then LPT1="on"; LIRC_PORT=$LPT1_PORT; LIRC_IRQ=$LPT1_IRQ
78 elif test "$DRIVER_PARAMETER" = "lpt2"; then LPT2="on"; LIRC_PORT=$LPT2_PORT; LIRC_IRQ=$LPT2_IRQ
79 elif test "$DRIVER_PARAMETER" = "lpt3"; then LPT3="on"; LIRC_PORT=$LPT3_PORT; LIRC_IRQ=$LPT3_IRQ
80 elif test "$DRIVER_PARAMETER" = "none"; then LIRC_PORT="none"; LIRC_IRQ="none"
81 elif test "$DRIVER_PARAMETER" = "void"; then LIRC_PORT="";LIRC_IRQ=""
82 elif test "$DRIVER_PARAMETER" = "user"; then USER="on"
85 SELECTED_DRIVER="driver:$LIRC_DRIVER"
86 if test "$LIRC_PORT" != "none" -a "$LIRC_PORT" != ""; then SELECTED_DRIVER="$SELECTED_DRIVER io:$LIRC_PORT"; fi
87 if test "$LIRC_IRQ" != "none" -a "$LIRC_IRQ" != ""; then SELECTED_DRIVER="$SELECTED_DRIVER irq:$LIRC_IRQ"; fi
88 if test "$IRTTY" != "none" -a "$IRTTY" != ""; then SELECTED_DRIVER="$SELECTED_DRIVER tty:$IRTTY"; fi
93 GetPortAndIrq ()
95 dialog --clear --backtitle "$BACKTITLE" \
96 --title "Enter I/O base address and IRQ" \
97 --inputbox "$GET_PORT_TEXT" 9 74 "$LIRC_PORT $LIRC_IRQ" \
98 2> $TEMP
99 if test "$?" = "0"; then
101 set `cat $TEMP`
102 LIRC_PORT=$1
103 LIRC_IRQ=$2
105 else
106 return 1;
111 SetPortAndIrq ()
113 if test "$DRIVER_PARAM_TYPE" = "com"; then
115 dialog --clear --backtitle "$BACKTITLE" \
116 --title "Specify I/O base address and IRQ of your hardware" \
117 --radiolist "$SET_PORT_TEXT" 14 74 5 \
118 1 "COM1 ($COM1_PORT, $COM1_IRQ)" $COM1 \
119 2 "COM2 ($COM2_PORT, $COM2_IRQ)" $COM2 \
120 3 "COM3 ($COM3_PORT, $COM3_IRQ)" $COM3 \
121 4 "COM4 ($COM4_PORT, $COM4_IRQ)" $COM4 \
122 9 "Other (custom values)" $USER \
123 2> $TEMP
124 if test "$?" = "0"; then
126 set `cat $TEMP`
127 if test "$1" = "1"; then DRIVER_PARAMETER="com1"
128 elif test "$1" = "2"; then DRIVER_PARAMETER="com2"
129 elif test "$1" = "3"; then DRIVER_PARAMETER="com3"
130 elif test "$1" = "4"; then DRIVER_PARAMETER="com4"
131 elif test "$1" = "9"; then DRIVER_PARAMETER="user"; GetPortAndIrq
133 GetSelectedDriver
135 else
136 return 1;
139 elif test "$DRIVER_PARAM_TYPE" = "lpt"; then
141 dialog --clear --backtitle "$BACKTITLE" \
142 --title "Specify I/O base address and IRQ of your hardware" \
143 --radiolist "$SET_PORT_TEXT" 13 74 4 \
144 1 "LPT1 ($LPT1_PORT, $LPT1_IRQ)" $LPT1 \
145 2 "LPT2 ($LPT2_PORT, $LPT2_IRQ)" $LPT2 \
146 3 "LPT3 ($LPT3_PORT, $LPT3_IRQ)" $LPT3 \
147 9 "Other (custom values)" $USER \
148 2> $TEMP
149 if test "$?" = "0"; then
151 set `cat $TEMP`
152 if test "$1" = "1"; then DRIVER_PARAMETER="lpt1"
153 elif test "$1" = "2"; then DRIVER_PARAMETER="lpt2"
154 elif test "$1" = "3"; then DRIVER_PARAMETER="lpt3"
155 elif test "$1" = "9"; then DRIVER_PARAMETER="user"; GetPortAndIrq
157 GetSelectedDriver
159 else
160 return 1;
163 elif test "$DRIVER_PARAM_TYPE" = "tty"; then
165 dialog --clear --backtitle "$BACKTITLE" \
166 --title "Select tty to use" \
167 --radiolist "$SET_TTY_TEXT" 13 74 6 \
168 1 "COM1 (/dev/ttyS0)" $COM1 \
169 2 "COM2 (/dev/ttyS1)" $COM2 \
170 3 "COM3 (/dev/ttyS2)" $COM3 \
171 4 "COM4 (/dev/ttyS3)" $COM4 \
172 2> $TEMP
174 if test "$?" = "0"; then
176 set `cat $TEMP`
177 if test "$1" = "1"; then DRIVER_PARAMETER="tty1"
178 elif test "$1" = "2"; then DRIVER_PARAMETER="tty2"
179 elif test "$1" = "3"; then DRIVER_PARAMETER="tty3"
180 elif test "$1" = "4"; then DRIVER_PARAMETER="tty4"
182 GetSelectedDriver
184 else
185 return 1;
187 elif test "$DRIVER_PARAM_TYPE" = "ttyUSB"; then
189 dialog --clear --backtitle "$BACKTITLE" \
190 --title "Select tty to use" \
191 --radiolist "$SET_TTY_TEXT" 13 74 6 \
192 1 "/dev/ttyUSB0" $COM1 \
193 2 "/dev/ttyUSB1" $COM2 \
194 3 "/dev/ttyUSB2" $COM3 \
195 4 "/dev/ttyUSB3" $COM4 \
196 2> $TEMP
198 if test "$?" = "0"; then
200 set `cat $TEMP`
201 if test "$1" = "1"; then DRIVER_PARAMETER="ttyUSB1"
202 elif test "$1" = "2"; then DRIVER_PARAMETER="ttyUSB2"
203 elif test "$1" = "3"; then DRIVER_PARAMETER="ttyUSB3"
204 elif test "$1" = "4"; then DRIVER_PARAMETER="ttyUSB4"
206 GetSelectedDriver
208 else
209 return 1;
212 return 0;
217 DriverOptions ()
219 if test "$LIRC_DRIVER" = "serial"; then
221 dialog --clear --backtitle "$BACKTITLE" \
222 --title "Driver specific Options" \
223 --checklist "" 10 74 3 \
224 1 "With transmitter diode" $TRANSMITTER \
225 2 "Software generated carrier" $SOFT_CARRIER \
226 3 "Igor Cesko's variation" $IGOR \
227 2> $TEMP
228 if test "$?" = "0"; then
230 set -- `cat $TEMP`
231 SOFT_CARRIER="off"
232 TRANSMITTER="off"
233 IGOR="off"
234 for ITEM in $@; do
236 if test $ITEM = "1" || test $ITEM = "\"1\""; then TRANSMITTER="on";
237 elif test $ITEM = "2" || test $ITEM = "\"2\""; then SOFT_CARRIER="on";
238 elif test $ITEM = "3" || test $ITEM = "\"3\""; then IGOR="on";
241 done
242 # if test "$TRANSMITTER" = "off"; then SOFT_CARRIER="off"; fi
244 else
245 return 1;
248 elif test "$LIRC_DRIVER" = "parallel"; then
250 dialog --clear --backtitle "$BACKTITLE" \
251 --title "Driver specific Options" \
252 --inputbox "Timer value for parallel port driver" 9 74 "$TIMER" \
253 2> $TEMP
254 if test "$?" = "0"; then
256 set `cat $TEMP`
257 TIMER=$1
259 else
260 return 1;
264 return 0;
267 ConfigDriver ()
269 . ./setup-driver.sh
270 if test "$?" = "0"; then
271 GetSelectedDriver
272 SetPortAndIrq
273 if test "$?" = "0"; then
274 DriverOptions
281 ConfigSoftware ()
283 dialog --clear --backtitle "$BACKTITLE" \
284 --title "Software Configuration" \
285 --checklist "$CONFIG_SOFTWARE_TEXT" 14 74 6 \
286 1 "Compile tools for X-Windows" $X11_WINDOWS \
287 2 "Compile with DEBUG code" $DEBUG \
288 3 "Disable daemonize" $NO_DAEMONIZE \
289 4 "Disable long codes" $NO_LONG_CODES \
290 5 "Use syslogd instead of own log-file" $USE_SYSLOG \
291 6 "Enable dynamic codes" $DYNCODES 2>$TEMP
293 if test "$?" = "0"; then
295 set -- `cat $TEMP`
296 X11_WINDOWS="off"; DEBUG="off"; NO_DAEMONIZE="off"; NO_LONG_CODES="off"
297 USE_SYSLOG="off"; DYNCODES="off"
298 for ITEM in $@; do
300 if test $ITEM = "1" || test $ITEM = "\"1\""; then X11_WINDOWS="on"
301 elif test $ITEM = "2" || test $ITEM = "\"2\""; then DEBUG="on"
302 elif test $ITEM = "3" || test $ITEM = "\"3\""; then NO_DAEMONIZE="on"
303 elif test $ITEM = "4" || test $ITEM = "\"4\""; then NO_LONG_CODES="on"
304 elif test $ITEM = "5" || test $ITEM = "\"5\""; then USE_SYSLOG="on"
305 elif test $ITEM = "6" || test $ITEM = "\"6\""; then DYNCODES="on"
308 done
315 SaveConfig ()
317 echo "LIRC_DRIVER=$LIRC_DRIVER" >$CONFIG
318 echo "LIRC_PORT=$LIRC_PORT" >>$CONFIG
319 echo "LIRC_IRQ=$LIRC_IRQ" >>$CONFIG
320 echo "LIRC_MAJOR=$LIRC_MAJOR" >>$CONFIG
321 echo "IRTTY=$IRTTY" >>$CONFIG
322 echo "DRIVER_PARAM_TYPE=$DRIVER_PARAM_TYPE" >>$CONFIG
323 echo "DRIVER_PARAMETER=$DRIVER_PARAMETER" >>$CONFIG
324 echo "SOFT_CARRIER=$SOFT_CARRIER" >>$CONFIG
325 echo "TRANSMITTER=$TRANSMITTER" >>$CONFIG
326 echo "IGOR=$IGOR" >>$CONFIG
327 echo "TIMER=$TIMER" >>$CONFIG
328 echo "X11_WINDOWS=$X11_WINDOWS" >>$CONFIG
329 echo "DEBUG=$DEBUG" >>$CONFIG
330 echo "NO_DAEMONIZE=$NO_DAEMONIZE" >>$CONFIG
331 echo "NO_LONG_CODES=$NO_LONG_CODES" >>$CONFIG
332 echo "USE_SYSLOG=$USE_SYSLOG" >>$CONFIG
333 echo "DYNCODES=$DYNCODES" >>$CONFIG
334 chmod 666 $CONFIG
336 echo '#! /bin/sh' >$START
337 echo >>$START
338 echo "./configure \\" >>$START
339 echo "--with-moduledir=/lib/modules/`uname -r`/misc \\" >>$START
340 if test "$LIRC_DRIVER" = "serial"; then
342 if test "$SOFT_CARRIER" = "off"; then echo "--without-soft-carrier \\" >>$START; fi
343 if test "$TRANSMITTER" = "on"; then echo "--with-transmitter \\" >>$START; fi
344 if test "$IGOR" = "on"; then echo "--with-igor \\" >>$START; fi
346 elif test "$LIRC_DRIVER" = "parallel"; then
348 if test "$TIMER" != "0"; then echo "--with-timer=$TIMER \\" >>$START;
349 else echo "--without-timer \\" >>$START;
352 elif test "$DRIVER_PARAM_TYPE" = "tty" -o "$DRIVER_PARAM_TYPE" = "ttyUSB" -o "$LIRC_DRIVER" = "bte"; then
354 echo "--with-tty=$IRTTY \\" >>$START
357 if test "$X11_WINDOWS" = "on"; then echo "--with-x \\" >>$START; else echo "--without-x \\" >>$START; fi
358 if test "$DEBUG" = "on"; then echo "--enable-debug \\" >>$START; fi
359 if test "$NO_DAEMONIZE" = "on"; then echo "--disable-daemonize \\" >>$START; fi
360 if test "$NO_LONG_CODES" = "on"; then echo "--disable-long-codes \\" >>$START; fi
361 if test "$USE_SYSLOG" = "on"; then echo "--with-syslog \\" >>$START; fi
362 if test "$DYNCODES" = "on"; then echo "--enable-dyncodes \\" >>$START; fi
363 echo "--with-driver=$LIRC_DRIVER \\" >>$START
364 echo "--with-major=$LIRC_MAJOR \\" >>$START
365 echo "--with-port=$LIRC_PORT \\" >>$START
366 echo "--with-irq=$LIRC_IRQ \\" >>$START
367 echo "\"\$@\"" >>$START
368 chmod 755 $START
370 MESSAGE="Configuration: $CONFIG, executable shell script: $START"
371 EXIT="yes"
374 #############################################################################
375 ## Main Program
376 if ! which dialog >/dev/null; then
377 echo "dialog not found!"
378 exit 1
381 if test -f $CONFIG; then
383 echo "Loading saved configuration from $CONFIG"
384 case $CONFIG in
385 */*) . $CONFIG ;;
386 *) . ./$CONFIG ;;
387 esac
388 sleep 1
391 EXIT="no"
392 MESSAGE="Abnormal Termination"
393 GetSelectedDriver
394 while test "$EXIT" != "yes"; do
396 dialog --clear --backtitle "$BACKTITLE" \
397 --title "Mainmenu" \
398 --menu "$MAIN_MENU_TEXT" 13 74 5 \
399 1 "Driver configuration ($SELECTED_DRIVER)" \
400 2 "Software configuration" \
401 3 "Save configuration & run configure" \
402 4 "Save configuration & exit" \
403 5 "Exit WITHOUT doing anything" 2>$TEMP
405 if test "$?" != "0"; then
407 MESSAGE="Configuration cancelled!"
408 EXIT="yes"
410 else
412 set `cat $TEMP`
413 if test "$1" = "1"; then ConfigDriver
414 elif test "$1" = "2"; then ConfigSoftware
415 elif test "$1" = "3"; then
417 SaveConfig
418 CONFIGURE="yes"
420 elif test "$1" = "4"; then SaveConfig
421 elif test "$1" = "5"; then
423 MESSAGE="Configuration NOT saved!"
424 EXIT=yes
430 done
431 #clear
432 rm -f $TEMP
433 echo "setup.sh written by Karsten Scheibler, 1999-JUN-28"
434 echo
435 echo "If you have problems or questions please consult the mailing list"
436 echo "<http://lists.sourceforge.net/mailman/listinfo/lirc-list>"
437 echo
438 echo $MESSAGE
439 if test "$CONFIGURE" = "yes"; then
441 echo "Starting the generated shell script which will call configure with the right"
442 echo "parameters..."
443 ./$START
446 ## EOF ######################################################################