[3f9500]: configure.ac Maximize Restore History

Download this file

configure.ac    1822 lines (1578 with data), 47.4 kB

dnl $Id: configure.ac,v 1.44 2010/07/12 03:25:55 jarodwilson Exp $

dnl Process this file with autoconf to produce a configure script.
dnl configure.ac, (c)1999 Tom Wheeley <tw104@york.ac.uk>

AC_INIT
AC_CONFIG_SRCDIR([daemons/lircd.c])
AC_CONFIG_MACRO_DIR([m4])

AM_INIT_AUTOMAKE(lirc, 0.9.0)
AM_CONFIG_HEADER(config.h)

CFLAGS="${CFLAGS--O2 -g -Wall}"

dnl Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PATH_PROG(mknod, mknod, /bin/mknod)
AC_PATH_PROG(mkfifo, mkfifo, /usr/bin/mkfifo)
AC_PATH_PROG(depmod, depmod, /sbin/depmod, $PATH:/sbin)
AC_PATH_PROG(LIBUSB_CONFIG, libusb-config)
AC_PROG_LN_S
AC_PROG_LIBTOOL
AM_PATH_PYTHON(,, [:])
AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != ""])

dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_TIME
AC_CHECK_HEADERS(fcntl.h limits.h sys/ioctl.h sys/time.h syslog.h unistd.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_STRUCT_TM

dnl Checks for library functions.
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(gethostname gettimeofday mkfifo select socket strdup \
	strerror strtoul snprintf strsep vsyslog)

forkpty=""
AC_CHECK_FUNCS(forkpty)
if test "$ac_cv_func_forkpty" != yes; then
  AC_CHECK_LIB(util,forkpty,[
    forkpty="-lutil"
    AC_DEFINE(HAVE_FORKPTY)])
fi

vga_progs=
AC_CHECK_HEADER(vga.h,
  [AC_CHECK_HEADER(vgagl.h,
    [AC_CHECK_LIB(vga, vga_init,
      [AC_CHECK_LIB(vgagl, gl_setcontextvga,
        [AC_DEFINE(HAVE_LIBVGA)]
        vga_progs=smode2,,
        -lvga
      )]
    )]
  )]
)
x_progs="irxevent xmode2"
AC_PATH_XTRA
if test "$no_x" = "yes"; then
  x_progs=
fi

dnl getopt_long support
AC_CHECK_FUNCS(getopt_long,,
  [AC_CHECK_LIB(gnugetopt,getopt_long,LDFLAGS="${LDFLAGS} -lgnugetopt",
    [AC_MSG_ERROR([*** your libc doesn't provide the getopt_long function.
Therfore you need to have \"libgnugetopt\" installed to compile LIRC.
You can get a version from:
  http://www.inf.ethz.ch/~mringwal/downloads/libgnugetopt-1.2.tar.gz
Extract the package and do a \"./configure  && make && sudo make install\"
in its directory.
])]
  )]
)
	

dnl Determine default configuration based on OS
case "${host_os}" in
  darwin*)
    dnl Mac OS X configuration

    dnl PortAudio for mac os x
    portaudio_lib_other="-framework CoreAudio -framework AudioToolbox"

    dnl default devdir, on mac os x/darwin, /dev/ can not be used without kernel programming, so use a fifo somewhere else
    devdir_default="/usr/lirc/dev/"
    use_fifos="yes"
    ;;
  *)
    dnl Unix OSS configuration

    dnl PortAudio for UNIX OSS
    portaudio_lib_other="-lm -lpthread ${forkpty}"

    dnl default devdir
    devdir_default="/dev"
    use_fifos="no"
    ;;
esac

# use fifo instead of devnode (required on mac os x)
AM_CONDITIONAL(USE_FIFOS, test "$use_fifos" = "yes")


dnl look for Linux kernel source

AC_PATH_KERNEL_SOURCE

dnl here we see what drivers we could possibly even hope to run.
dnl this could be _much_ more sophisticated!  especially the lirc ones.

AC_MSG_CHECKING([for which drivers can be installed on this system])
AC_MSG_RESULT()

# this list must only contain userspace drivers without external
# (header/library) dependencies!
possible_drivers="(none) \
	(userspace) \
	(accent) \
	(atwf83) \
	(bte) \
	(creative) \
	(ea65) \
	(exaudio) \
	(irlink) \
	(irreal) \
	(livedrive_midi) \
	(livedrive_seq) \
	(logitech) \
	(mediafocusI) \
	(mouseremote) \
	(mouseremote_ps2) \
	(mp3anywhere) \
	(mplay) \
	(pcmak) \
	(pcmak_usb) \
	(pctv) \
	(remotemaster) \
	(silitek) \
	(slinke) \
	(tira) \
	(tira_raw) \
	(uirt2) \
	(uirt2_raw) \
	(usb_uirt_raw) \
	(usbx) \
	(udp)"

if test x${no_kernel} != xyes; then
  possible_drivers="${possible_drivers} \
	(all) \
	(lirc_dev) \
	(lirc_dev lirc_atiusb) \
	(lirc_dev lirc_bt829) \
	(lirc_dev lirc_gpio) \
	(lirc_dev lirc_i2c) \
	(lirc_dev lirc_igorplugusb) \
	(lirc_dev lirc_ttusbir) \
	(lirc_dev lirc_imon) \
	(lirc_dev lirc_parallel) \
	(lirc_dev lirc_sasem) \
	(lirc_dev lirc_serial) \
	(lirc_dev lirc_sir) \
	(lirc_dev lirc_wpc8769l)"
fi

AH_TEMPLATE([DAEMONIZE],
	[Define to run daemons as daemons])

AH_TEMPLATE([DEBUG],
	[Define to enable debugging output])

AH_TEMPLATE([DEVDIR],
	[device files directory])

AH_TEMPLATE([DYNCODES],
	[Define to use dynamic IR codes])

AH_TEMPLATE([HAVE_ALSA_SB_RC],	
	[Define if the ALSA library with SB RC support is installed])

AH_TEMPLATE([HAVE_FORKPTY],
	[Define if forkpty is available])

AH_TEMPLATE([HAVE_IGUANAIR],
	[Define if the iguanaIR library is installed])

AH_TEMPLATE([HAVE_FTDI],
	[Define if the libftdi library is installed])
	
AH_TEMPLATE([HAVE_LIBALSA],
	[Define if the ALSA library is installed])

AH_TEMPLATE([HAVE_LIBCARACA],
	[Define if the caraca library is installed])

AH_TEMPLATE([HAVE_LIBIRMAN],
	[Define if the libirman library is installed])

AH_TEMPLATE([HAVE_LIBIRMAN_SW],
	[Define if the software only test version of libirman is installed])

AH_TEMPLATE([HAVE_LIBPORTAUDIO],
	[Define if the portaudio library is installed])

AH_TEMPLATE([HAVE_LIBUSB],
	[Define if libusb is installed])

AH_TEMPLATE([HAVE_LIBVGA],
	[Define if the complete vga libraries (vga, vgagl) are installed])

AH_TEMPLATE([HAVE_LINUX_DEVINPUT],
	[defined if Linux input interface is available])

AH_TEMPLATE([HAVE_LINUX_HIDDEV_FLAG_UREF],
	[defined if Linux hiddev HIDDEV_FLAG_UREF flag is available])

AH_TEMPLATE([HAVE_SCSI],
	[defined if SCSI API is available])

AH_TEMPLATE([HAVE_SOUNDCARD],
	[defined if soundcard API is available])

AH_TEMPLATE([HAVE_VSYSLOG],
	[define if you have vsyslog( prio, fmt, va_arg )])

AH_TEMPLATE([HW_DEFAULT],
	[The name of the hw_* structure to use by default])

AH_TEMPLATE([LIRC_DRIVER],
	[Text string signifying which driver is configured])

AH_TEMPLATE([LIRC_DRIVER_ANY],
	[Define to include most drivers])

AH_TEMPLATE([LIRC_HAVE_DEVFS],
	[Define if devfs support is present in current kernel])

AH_TEMPLATE([LIRC_IRQ],
	[Set the IRQ for the lirc driver])

AH_TEMPLATE([LIRC_IRTTY],
	[Set the default tty used by the drivers accessing /dev/ttyX])

AH_TEMPLATE([LIRC_ON_SA1100],
	[Define if you want to cross-compile for the SA1100])

AH_TEMPLATE([LIRC_PORT],
	[Set the port address for the lirc driver])

AH_TEMPLATE([LIRC_SERIAL_ANIMAX],
	[Define if you have an animax serial port receiver])

AH_TEMPLATE([LIRC_SERIAL_IGOR],
	[Define if you have an Igor Cesko receiver])

AH_TEMPLATE([LIRC_SERIAL_IRDEO],
	[Define if you have an IRdeo serial port receiver])

AH_TEMPLATE([LIRC_SERIAL_IRDEO_REMOTE],
	[Define if you have an IRdeo remote transmitter])

AH_TEMPLATE([LIRC_SERIAL_NSLU2],
	[Define if you have a Linksys NSLU2 and use CTS2+GreenLED])

AH_TEMPLATE([LIRC_SERIAL_SOFTCARRIER],
	[Define if the software needs to generate the carrier frequency])

AH_TEMPLATE([LIRC_SERIAL_TRANSMITTER],
	[Define if you have a IR diode connected to the serial port])

AH_TEMPLATE([LIRC_SIR_ACTISYS_ACT200L],
	[Define if you want to use a Actisys Act200L])

AH_TEMPLATE([LIRC_SIR_ACTISYS_ACT220L],
	[Define if you want to use a Actisys Act220L])

AH_TEMPLATE([LIRC_SIR_TEKRAM],
	[Define if you want to use a Tekram Irmate 210])

AH_TEMPLATE([LIRC_SYSLOG],
	[syslog facility to use])

AH_TEMPLATE([LIRC_IMON_LCD],
	[Define if your iMON is an LCD and not a VFD.])

AH_TEMPLATE([LIRC_TIMER],
	[Set the timer for the parallel port driver])

AH_TEMPLATE([LOCALSTATEDIR],
	[modifiable single-machine data])

AH_TEMPLATE([MAINTAINER_MODE],
	[define in maintainer mode])

AH_TEMPLATE([SYSCONFDIR],
	[system configuration directory])

AH_TEMPLATE([USE_SYSLOG],
	[define if you want to log to syslog instead of logfile])

if test -n "${LIBUSB_CONFIG}"; then
  AC_DEFINE(HAVE_LIBUSB)
  possible_drivers="${possible_drivers} (atilibusb) (awlibusb) (dfclibusb) (commandir) (srm7500libusb)" 
fi

AC_CHECK_LIB(caraca_client, caraca_init,
  AC_DEFINE(HAVE_LIBCARACA)
  possible_drivers="${possible_drivers} (caraca)"
)
AC_CHECK_HEADER(ftdi.h,
  AC_DEFINE(HAVE_FTDI)
  possible_drivers="${possible_drivers} (ftdi)"
)
AC_CHECK_HEADER(iguanaIR.h,
  AC_DEFINE(HAVE_IGUANAIR)
  possible_drivers="${possible_drivers} (iguanaIR)"
)
AC_CHECK_LIB(irman, ir_strerror,
  AC_DEFINE(HAVE_LIBIRMAN)
  possible_drivers="${possible_drivers} (irman)"
)
AC_CHECK_LIB(irman_sw, ir_strerror,
  AC_DEFINE(HAVE_LIBIRMAN_SW)
  possible_drivers="${possible_drivers} (irman_sw)"
)
dnl audio driver requires PortAudio library installed and some linker flags
AC_CHECK_HEADERS(portaudio.h,[
  AC_CHECK_LIB(portaudio, Pa_Initialize,[
    AC_DEFINE(HAVE_LIBPORTAUDIO)
    possible_drivers="${possible_drivers} (audio)"
    ],,${portaudio_lib_other}
  )]
)
dnl audio_alsa driver requires ALSA library installed and some linker flags
have_alsa=no
AC_CHECK_HEADERS(alsa/asoundlib.h,[
  AC_CHECK_LIB(asound, snd_pcm_open,[
    AC_DEFINE(HAVE_LIBALSA)
    have_alsa=yes
    possible_drivers="${possible_drivers} (audio_alsa)"
    ],,
  )]
)
dnl alsa_usb driver requires an ALSA that knows about our hwdep device
if test "$have_alsa" = "yes"; then
  AC_MSG_CHECKING(for ALSA SB RC hwdep support)
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <alsa/asoundlib.h>
]], [[
  if (snd_hwdep_info_get_iface(NULL) == SND_HWDEP_IFACE_SB_RC) {}
]])],[
    AC_MSG_RESULT(yes)
    AC_DEFINE(HAVE_ALSA_SB_RC)
    possible_drivers="${possible_drivers} (alsa_usb)"
    ],[
    AC_MSG_RESULT(no)
  ])
fi
dnl creative_infracd driver requires linux scsi api
AC_CHECK_HEADERS(scsi/sg.h,[
  AC_DEFINE(HAVE_SCSI)
  possible_drivers="${possible_drivers} (creative_infracd)"
  ]
)
dnl dev_input driver requires linux input device api
AC_CHECK_HEADERS(linux/input.h,[
  AC_DEFINE(HAVE_LINUX_DEVINPUT)
  possible_drivers="${possible_drivers} (devinput)"
  ]
)
dnl check if hiddev is available
AC_CHECK_HEADERS([linux/types.h])
AC_CHECK_HEADERS([linux/hiddev.h],[
  possible_drivers="${possible_drivers} (asusdh) (bw6130) (dvico) (macmini)"
  AC_MSG_CHECKING(for HIDDEV_FLAG_UREF support)
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <linux/types.h>
#include <linux/hiddev.h>
    ]], [[
      int flag = HIDDEV_FLAG_UREF;
    ]])],[
    AC_MSG_RESULT(yes)
    AC_DEFINE(HAVE_LINUX_HIDDEV_FLAG_UREF)
    possible_drivers="${possible_drivers} (samsung) (sb0540)"
    ],[
    AC_MSG_RESULT(no)
    ])
  ], [],
[#ifdef HAVE_LINUX_TYPES_H
#include <linux/types.h>
#endif
]
)
dnl dsp driver requires linux soundcard api
AC_CHECK_HEADERS(sys/soundcard.h,[
  AC_DEFINE(HAVE_SOUNDCARD)
  possible_drivers="${possible_drivers} (dsp)"
  ]
)
dnl i2cuser driver requires the Linux I2C API
AC_CHECK_HEADERS(linux/i2c-dev.h,[
  possible_drivers="${possible_drivers} (i2cuser)"
  ]
)

dnl here we see what driver the user wants.

AC_ARG_WITH(driver,
[  --with-driver=X         specify the driver to use, where X is one of:
                          all, none, userspace, accent, act200l,
                          act220l, adaptec, alsa_usb, animax, asusdh,
                          atilibusb, atiusb, atwf83, audio, audio_alsa
                          avermedia, avermedia_vdomate, avermedia98,
                          awlibusb, bestbuy, bestbuy2, breakoutbox,
                          bte, bw6130, caraca, chronos, commandir,
                          comX, cph06x, creative, creative_infracd,
                          devinput, dfclibusb, digimatrix, dsp, dvico, ea65,
                          exaudio, flyvideo, ftdi, gvbctv5pci,
                          hauppauge, hauppauge_dvb,
                          hercules_smarttv_stereo, i2cuser,
                          igorplugusb, iguanaIR, imon, imon_24g,
                          imon_knob, imon_lcd, imon_pad, imon_rsc,
                          irdeo, irdeo_remote, irlink, irman, irreal,
                          knc_one, kworld,
                          leadtek_0007, leadtek_0010, leadtek_pvr2000,
                          livedrive_midi, livedrive_seq, logitech,
                          lptX, macmini, mediafocusI,
                          mouseremote, mouseremote_ps2, mp3anywhere,
                          mplay, nslu2,packard_bell, parallel, pcmak,
                          pcmak_usb, pctv, pixelview_bt878,
                          pixelview_pak, pixelview_pro, provideo,
                          realmagic, remotemaster, sa1100, samsung,
                          sasem, sb0540, serial, silitek, sir, slinke,
                          srm7500libusb, tekram,
                          tekram_bt829, tira, tira_raw, ttusbir,
                          tuxbox, tvbox, udp, uirt2, uirt2_raw,
                          usb_uirt_raw, usbx, wpc8769l],
driver=${withval},
driver="unset"
)

#START HARDWARE HEURISTIC
lirc_driver="$driver"
lircd_conf=""
lircmd_conf=""
iguanaIR_lib=""
irman_lib=""
ftdi_lib=""
caraca_lib=""
commandir_lib=""
portaudio_lib=""
alsa_lib=""
atilibusb_lib=""
atwf83_lib=""
awlibusb_lib=""
dfclibusb_lib=""
srm7500libusb_lib=""
hw_module="hw_default.o receive.o transmit.o"
HW_DEFAULT="hw_default"
kernel_module=""

if test "$driver" = "none"; then
  lirc_driver=none
  hw_module=""
  HW_DEFAULT="hw_null"
fi

if test "$driver" = "userspace" -o "$driver" = "all"; then
  AC_DEFINE(LIRC_DRIVER_ANY)
  lirc_driver=$driver
  
  any_possible_drivers=`echo ${possible_drivers} | sed -e's/ /-/g' \
			  -e's/)-(/ /g'  -e's/(//g' -e's/)//g' \
			  -e's/-$//g'`
  for any_driver in ${any_possible_drivers}; do
  case ${any_driver} in
	accent)
		hw_module="${hw_module} hw_accent.o serial.o"
		;;
	alsa_usb)
		hw_module="${hw_module} hw_alsa_usb.o"
		alsa_lib=-lasound
		;;
	asusdh)
		hw_module="${hw_module} hw_hiddev.o"
		;;
	atilibusb)
		hw_module="${hw_module} hw_atilibusb.o receive.o"
		atilibusb_lib=`${LIBUSB_CONFIG} --libs`
		CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
		;;
	atwf83)
		hw_module="${hw_module} hw_atwf83.o"
		atwf83_lib=-lpthread
		;;
	audio)
		hw_module="${hw_module} hw_audio.o transmit.o receive.o"
		portaudio_lib="-lportaudio ${portaudio_lib_other}"
		;;
	audio_alsa)
		hw_module="${hw_module} hw_audio_alsa.o receive.o"
		alsa_lib=-lasound
		;;
	awlibusb)
		hw_module="${hw_module} hw_awlibusb.o receive.o"
		awlibusb_lib=`${LIBUSB_CONFIG} --libs`
		CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
		;;
	bte)
		hw_module="${hw_module} hw_bte.o serial.o"
		;;
	bw6130)
		hw_module="${hw_module} hw_hiddev.o"
		;;
	caraca)
		hw_module="${hw_module} hw_caraca.o"
		caraca_lib=-lcaraca_client
		;;
	creative)
		hw_module="${hw_module} hw_creative.o serial.o"
		;;
	creative_infracd)
		hw_module="${hw_module} hw_creative_infracd.o"
		;;
	commandir)
		hw_module="${hw_module} hw_commandir.o receive.o"
		commandir_lib=`${LIBUSB_CONFIG} --libs`
		CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
		;;
	devinput)
		hw_module="${hw_module} hw_devinput.o"
		;;
	dfclibusb)
		hw_module="${hw_module} hw_dfclibusb.o receive.o"
		dfclibusb_lib=`${LIBUSB_CONFIG} --libs`
		CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
		;;
	dsp)
		hw_module="${hw_module} hw_dsp.o receive.o"
		;;
	dvico)
		hw_module="${hw_module} hw_hiddev.o"
		;;
	ea65)
		hw_module="${hw_module} hw_ea65.o serial.o"
		;;
	exaudio)
		;;
	ftdi)
		hw_module="${hw_module} hw_ftdi.o receive.o transmit.o"
		ftdi_lib="-lftdi"
		;;
	i2cuser)
		hw_module="${hw_module} hw_i2cuser.o receive.o"
		;;
	iguanaIR)
		hw_module="${hw_module} hw_iguanaIR.o transmit.o receive.o"
		iguanaIR_lib=-liguanaIR
		;;
	irlink)
		hw_module="${hw_module} hw_irlink.o serial.o receive.o"
		;;
	irman)
		hw_module="${hw_module} hw_irman.o serial.o"
		irman_lib=-lirman
		;;
	# There is not much sense in using 'irman_sw' with driver
	# 'any' and that would conflict with 'irman' which will
	# probably also be available.
	#
	#irman_sw)
		#hw_module="${hw_module} hw_irman.o serial.o"
		#irman_lib=-lirman_sw
		#;;
	irreal)
		#hw_module="${hw_module} hw_irreal.o serial.o receive.o transmit.o"
		;;
	lirc_dev-lirc_atiusb)
		;;
	lirc_dev-lirc_gpio)
		#lirc_driver="${lirc_driver} lirc_dev lirc_gpio"
		;;
	lirc_dev-lirc_i2c)
		#lirc_driver="${lirc_driver} lirc_dev lirc_i2c"
		;;
	lirc_dev-lirc_igorplugusb)
		;;
	lirc_dev-lirc_ttusbir)
		;;
	lirc_dev-lirc_imon)
		;;
	lirc_dev-lirc_parallel)
		;;
	lirc_dev-lirc_sasem)
		;;
	lirc_dev-lirc_serial)
		;;
	lirc_dev-lirc_sir)
		;;
	lirc_dev-lirc_wpc8769l)
		;;
	lirc_flyvideo)
		;;
	livedrive_midi)
		hw_module="${hw_module} hw_livedrive_common.o hw_livedrive_midi.o"
		;;
	livedrive_seq)
		hw_module="${hw_module} hw_livedrive_common.o hw_livedrive_seq.o"
		;;
	logitech)
		hw_module="${hw_module} hw_logitech.o serial.o"
		;;
	macmini)
		hw_module="${hw_module} hw_hiddev.o"
		;;
	mediafocusI)
		;;
	mouseremote)
		hw_module="${hw_module} hw_mouseremote.o serial.o"
		;;
	mouseremote_ps2)
		hw_module="${hw_module} hw_mouseremote.o serial.o"
		;;
	mp3anywhere)
		hw_module="${hw_module} hw_mp3anywhere.o serial.o"
		;;
	mplay)
		hw_module="${hw_module} hw_mplay.o serial.o"
		;;
	mplay2)
		hw_module="${hw_module} hw_mplay.o serial.o"
		;;
	pcmak*)
		hw_module="${hw_module} hw_pcmak.o serial.o"
		;;
	pctv)
		hw_module="${hw_module} hw_pinsys.o serial.o"
		;;
	remotemaster)
		hw_module="${hw_module} hw_pixelview.o serial.o"
		;;
	samsung)
		hw_module="${hw_module} hw_hiddev.o"
		;;
	sb0540)
		hw_module="${hw_module} hw_hiddev.o"
		;;
	silitek)
		hw_module="${hw_module} hw_silitek.o serial.o"
		;;
	#slinke)
		#hw_module="${hw_module} hw_slinke.o serial.o receive.o"
		#;;
	srm7500libusb)
		hw_module="${hw_module} hw_srm7500libusb.o receive.o"
		srm7500libusb_lib=`${LIBUSB_CONFIG} --libs`
		CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
		;;
	tira|tira_raw)
		hw_module="${hw_module} hw_tira.o receive.o transmit.o"
		;;
	udp)
		hw_module="${hw_module} hw_udp.o receive.o"
		;;
	uirt2)
		hw_module="${hw_module} hw_uirt2.o serial.o"
		;;
	uirt2_raw|usb_uirt_raw)
		hw_module="${hw_module} hw_uirt2_raw.o hw_uirt2_common.o serial.o receive.o transmit.o"
		;;
	usbx)
		hw_module="${hw_module} hw_usbx.o serial.o"
		;;
  esac
  done
  #remove duplicates

  #sed segfaults when $hw_module is too long :(
  #hw_module=`echo ${hw_module}| sed \
  #			-e':again' \
  #			-e's/\(.*\)\(\<.*\) \(.*\) \2\(.*\)$/\1\2 \3\4/' \
  #			-e'tagain'`

  space_to_newline()
  { for token in $*; do echo $token; done; }
  newline_to_space()
  { echo $*; }
  
  hw_module=$(newline_to_space $(space_to_newline ${hw_module}| sort -u))

fi

if test "$driver" = "accent"; then
  lirc_driver="none"
  hw_module="hw_accent.o serial.o"
  HW_DEFAULT="hw_accent"
  lircd_conf="kanam_accent/lircd.conf.IR-100"
fi

if test "$driver" = "act200l"; then
  lirc_driver="lirc_dev lirc_sir"
  AC_DEFINE(LIRC_SIR_ACTISYS_ACT200L)
fi

if test "$driver" = "act220l"; then
  lirc_driver="lirc_dev lirc_sir"
  AC_DEFINE(LIRC_SIR_ACTISYS_ACT220L)
fi
    
if test "$driver" = "adaptec"; then
  lirc_driver="lirc_dev lirc_i2c"
  lircd_conf="adaptec/lircd.conf.AVC-2410"
#  lircmd_conf="adaptec/lircmd.conf.AVC-2410"
fi

if test "$driver" = "alsa_usb"; then
  lirc_driver="alsa_usb"
  hw_module="hw_alsa_usb.o"
  HW_DEFAULT="hw_alsa_usb"
  alsa_lib=-lasound
  lircd_conf="creative/lircd.conf.alsa_usb"
fi

if test "$driver" = "animax"; then
  lirc_driver="lirc_dev lirc_serial"
  lircd_conf="animax/lircd.conf.animax"
  lircmd_conf="animax/lircmd.conf.animax"
  AC_DEFINE(LIRC_SERIAL_ANIMAX)
fi

if test "$driver" = "asusdh"; then
  lirc_driver="$driver"
  hw_module="hw_hiddev.o"
  HW_DEFAULT="hw_asusdh"
  lircd_conf="asus/lircd.conf.asusdh"
fi

if test "$driver" = "atiusb"; then
  lirc_driver="lirc_dev lirc_atiusb"
  lircd_conf="atiusb/lircd.conf.atiusb"
fi

if test "$driver" = "atilibusb"; then
  lirc_driver="$driver"
  hw_module="hw_atilibusb.o receive.o"
  HW_DEFAULT="hw_atilibusb"
  lircd_conf="atiusb/lircd.conf.atilibusb"
  if test -n "${LIBUSB_CONFIG}"; then
    atilibusb_lib=`${LIBUSB_CONFIG} --libs`
    CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
  fi
fi

if test "$driver" = "atwf83"; then
  lirc_driver="$driver"
  hw_module="hw_atwf83.o"
  HW_DEFAULT="hw_atwf83"
  lircd_conf="aureal/lircd.conf.atwf83"
  atwf83_lib=-lpthread
fi

if test "$driver" = "awlibusb"; then
  lirc_driver="$driver"
  hw_module="hw_awlibusb.o receive.o"
  HW_DEFAULT="hw_awlibusb"
  lircd_conf="awlibusb/lircd.conf.awlibusb"
  if test -n "${LIBUSB_CONFIG}"; then
    awlibusb_lib=`${LIBUSB_CONFIG} --libs`
    CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
  fi
fi

if test "$driver" = "audio"; then
  lirc_driver="audio"
  hw_module="hw_audio.o transmit.o receive.o"
  HW_DEFAULT="hw_audio"
  portaudio_lib="-lportaudio ${portaudio_lib_other}"
fi

if test "$driver" = "audio_alsa"; then
  lirc_driver="audio_alsa"
  hw_module="hw_audio_alsa.o receive.o"
  HW_DEFAULT="hw_audio_alsa"
  alsa_lib=-lasound
fi

if test "$driver" = "avermedia"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="avermedia/lircd.conf.avermedia"
  lircmd_conf="avermedia/lircmd.conf.avermedia"
fi

if test "$driver" = "avermedia98"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="avermedia/lircd.conf.avermedia98"
  lircmd_conf="avermedia/lircmd.conf.avermedia98"
fi

if test "$driver" = "avermedia_vdomate"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="avermedia/lircd.conf.vdomate"
#  lircmd_conf="avermedia/lircmd.conf.vdomate"
fi

if test "$driver" = "bestbuy"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="bestbuy/lircd.conf.bestbuy"
  lircmd_conf="bestbuy/lircmd.conf.bestbuy"
fi

if test "$driver" = "bestbuy2"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="bestbuy/lircd.conf.bestbuy2"
  lircmd_conf="bestbuy/lircmd.conf.bestbuy2"
fi

if test "$driver" = "breakoutbox"; then
  lirc_driver="lirc_dev lirc_i2c"
  lircd_conf="creative/lircd.conf.breakoutbox"
fi

if test "$driver" = "bte"; then
  lirc_driver="none"
  hw_module="hw_bte.o  serial.o"
  HW_DEFAULT="hw_bte"
  lircd_conf="ericsson/lircd.conf.bte"
#  lircmd_conf="ericsson/lircmd.conf.bte"
fi

if test "$driver" = "bw6130"; then
  lirc_driver="$driver"
  hw_module="hw_hiddev.o"
  HW_DEFAULT="hw_bw6130"
  lircd_conf="remotec/lircd.conf.BW6130"
  lircmd_conf="remotec/lircmd.conf.BW6130"
fi

if test "$driver" = "caraca"; then
  lirc_driver="caraca"
  hw_module="hw_caraca.o"
  HW_DEFAULT="hw_caraca"
  caraca_lib=-lcaraca_client
  lircd_conf="caraca/lircd.conf.caraca"
#  lircmd_conf="caraca/lircmd.conf.caraca"
fi

if test "$driver" = "chronos"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="chronos/lircd.conf.chronos"
#  lircmd_conf="chronos/lircmd.conf.chronos"
fi

if test "$driver" = "com1"; then
  lirc_driver="lirc_dev lirc_serial"
  port=0x3f8
  irq=4
fi

if test "$driver" = "com2"; then
  lirc_driver="lirc_dev lirc_serial"
  port=0x2f8
  irq=3
fi

if test "$driver" = "com3"; then
  lirc_driver="lirc_dev lirc_serial"
  port=0x3e8
  irq=4
fi

if test "$driver" = "com4"; then
  lirc_driver="lirc_dev lirc_serial"
  port=0x2e8
  irq=3
fi

if test "$driver" = "commandir"; then
  lirc_driver="$driver"
  hw_module="hw_commandir.o receive.o transmit.o"
  HW_DEFAULT="hw_commandir"
  lircd_conf="hauppauge/lircd.conf.hauppauge"
  lircmd_conf="hauppauge/lircmd.conf.hauppauge"
  if test -n "${LIBUSB_CONFIG}"; then
    commandir_lib=`${LIBUSB_CONFIG} --libs`
    CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
  fi
fi

if test "$driver" = "cph03x" -o "$driver" = "cph06x"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="cph03x/lircd.conf.cph03x"
#  lircmd_conf="cph03x/lircmd.conf.cph03x"
fi

if test "$driver" = "creative"; then
  lirc_driver="none"
  hw_module="hw_creative.o serial.o"
  HW_DEFAULT="hw_creative"
  lircd_conf="creative/lircd.conf.creative"
#  lircmd_conf="creative/lircmd.conf.creative"
fi

if test "$driver" = "creative_infracd"; then
  lirc_driver="none"
  hw_module="hw_creative_infracd.o"
  HW_DEFAULT="hw_creative_infracd"
  lircd_conf="creative/lircd.conf.infracd"
fi

if test "$driver" = "devinput"; then
  lirc_driver="none"
  hw_module="hw_devinput.o"
  HW_DEFAULT="hw_devinput"
  lircd_conf="devinput/lircd.conf.devinput"
fi

if test "$driver" = "dfclibusb"; then
  lirc_driver="$driver"
  hw_module="hw_dfclibusb.o receive.o"
  HW_DEFAULT="hw_dfclibusb"
  if test -n "${LIBUSB_CONFIG}"; then
    dfclibusb_lib=`${LIBUSB_CONFIG} --libs`
    CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
  fi
fi

if test "$driver" = "dsp"; then
  lirc_driver="none"
  hw_module="hw_dsp.o receive.o"
  HW_DEFAULT="hw_dsp"
fi

if test "$driver" = "dvico"; then
  lirc_driver="$driver"
  hw_module="hw_hiddev.o"
  HW_DEFAULT="hw_dvico"
  lircd_conf="dvico/lircd.conf.fusionHDTV"
fi

if test "$driver" = "ea65"; then
  lirc_driver="none"
  hw_module="hw_ea65.o  serial.o"
  HW_DEFAULT="hw_ea65"
  lircd_conf="ea65/lircd.conf.ea65"
fi

if test "$driver" = "exaudio"; then
  lirc_driver="none"
#  lircd_conf="creative/lircd.conf.exaudio"
#  lircmd_conf="creative/lircmd.conf.exaudio"
fi

if test "$driver" = "flyvideo"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="life-view/lircd.conf.flyvideo"
  lircmd_conf="life-view/lircmd.conf.flyvideo"
fi

if test "$driver" = "ftdi"; then
  lirc_driver="none"
  hw_module="hw_ftdi.o receive.o transmit.o"
  HW_DEFAULT="hw_ftdi"
  ftdi_lib="-lftdi"
fi

if test "$driver" = "gvbctv5pci"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="iodata/lircd.conf.gvbctv5pci"
#  lircmd_conf="iodata/lircmd.conf.gvbctv5pci"
fi

if test "$driver" = "hauppauge"; then
  lirc_driver="lirc_dev lirc_i2c"
  lircd_conf="hauppauge/lircd.conf.hauppauge"
  lircmd_conf="hauppauge/lircmd.conf.hauppauge"
fi

if test "$driver" = "hauppauge_dvb"; then
  lirc_driver="lirc_dev"
  lircd_conf="hauppauge/lircd.conf.hauppauge"
  lircmd_conf="hauppauge/lircmd.conf.hauppauge"
fi

if test "$driver" = "hercules_smarttv_stereo"; then
  lirc_driver="lirc_dev lirc_i2c"
  lircd_conf="hercules/lircd.conf.smarttv_stereo"
fi

if test "$driver" = "i2cuser"; then
  lirc_driver="none"
  hw_module="hw_i2cuser.o receive.o"
  HW_DEFAULT="hw_i2cuser"
fi

if test "$driver" = "igorplugusb"; then
  lirc_driver="lirc_dev lirc_igorplugusb"
fi

if test "$driver" = "iguanaIR"; then
  lirc_driver="iguanaIR"
  hw_module="hw_iguanaIR.o transmit.o receive.o"
  HW_DEFAULT="hw_iguanaIR"
  iguanaIR_lib=-liguanaIR
fi

if test "$driver" = "imon"; then
  lirc_driver="lirc_dev lirc_imon"
  lircd_conf="imon/lircd.conf.imon"  
fi

if test "$driver" = "imon_24g"; then
  lirc_driver="lirc_dev lirc_imon"
  lircd_conf="imon/lircd.conf.imon-2.4g"
fi

if test "$driver" = "imon_knob"; then
  lirc_driver="lirc_dev lirc_imon"
  lircd_conf="imon/lircd.conf.imon-knob"
fi

if test "$driver" = "imon_lcd"; then
  lirc_driver="lirc_dev lirc_imon"
  lircd_conf="imon/lircd.conf.imon"
  AC_DEFINE(LIRC_IMON_LCD)
fi

if test "$driver" = "imon_pad"; then
  lirc_driver="lirc_dev lirc_imon"
  lircd_conf="imon/lircd.conf.imon-pad"  
fi

if test "$driver" = "imon_rsc"; then
  lirc_driver="lirc_dev lirc_imon"
  lircd_conf="imon/lircd.conf.imon-rsc"  
fi

if test "$driver" = "irdeo"; then
  lirc_driver="lirc_dev lirc_serial"
  AC_DEFINE(LIRC_SERIAL_IRDEO)
fi

if test "$driver" = "irdeo_remote"; then
  lirc_driver="lirc_dev lirc_serial"
  AC_DEFINE(LIRC_SERIAL_IRDEO_REMOTE)
fi

if test "$driver" = "irlink"; then
  lirc_driver="none"
  hw_module="hw_irlink.o serial.o receive.o"
  HW_DEFAULT="hw_irlink"
fi

if test "$driver" = "irman"; then
  lirc_driver="irman"
  hw_module="hw_irman.o serial.o"
  HW_DEFAULT="hw_irman"
  irman_lib=-lirman
fi

if test "$driver" = "irman_sw"; then
  lirc_driver="irman_sw"
  hw_module="hw_irman.o serial.o"
  HW_DEFAULT="hw_irman"
  irman_lib=-lirman_sw
fi

if test "$driver" = "irreal"; then
  lirc_driver="none"
  hw_module="hw_irreal.o serial.o receive.o transmit.o"
  HW_DEFAULT="hw_irreal"
fi

if test "$driver" = "knc_one"; then
  lirc_driver="lirc_dev lirc_i2c"
  lircd_conf="knc_one/lircd.conf.knc_one"
#  lircmd_conf="knc_one/lircmd.conf.knc_one"
fi

if test "$driver" = "kworld"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="kworld/lircd.conf.kworld"
#  lircmd_conf="kworld/lircmd.conf.kworld"
fi

if test "$driver" = "leadtek_0007"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="leadtek/lircd.conf.RM-0007"
  lircmd_conf="leadtek/lircmd.conf.RM-0007"
fi

if test "$driver" = "leadtek_0010"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="leadtek/lircd.conf.RM-0010"
  lircmd_conf="leadtek/lircmd.conf.RM-0010"
fi

if test "$driver" = "leadtek_pvr2000"; then
  lirc_driver="lirc_dev lirc_i2c"
  lircd_conf="leadtek/lircd.conf.PVR2000"
#  lircmd_conf="leadtek/lircmd.conf.PVR2000"
fi

if test "$driver" = "livedrive_midi"; then
  lirc_driver="none"
  hw_module="hw_livedrive_common.o hw_livedrive_midi.o"
  HW_DEFAULT="hw_livedrive_midi"
  lircd_conf="creative/lircd.conf.livedrive"
#  lircmd_conf="creative/lircmd.conf.livedrive"
fi

if test "$driver" = "livedrive_seq"; then
  lirc_driver="none"
  hw_module="hw_livedrive_common.o hw_livedrive_seq.o"
  HW_DEFAULT="hw_livedrive_seq"
  lircd_conf="creative/lircd.conf.livedrive"
#  lircmd_conf="creative/lircmd.conf.livedrive"
fi

if test "$driver" = "logitech"; then
  lirc_driver="none"
  hw_module="hw_logitech.o serial.o"
  HW_DEFAULT="hw_logitech"
  lircd_conf="logitech/lircd.conf.logitech"
  lircmd_conf="logitech/lircmd.conf.logitech"
fi

if test "$driver" = "lpt1"; then
  lirc_driver="lirc_dev lirc_parallel"
  port=0x378
  irq=7
fi

if test "$driver" = "lpt2"; then
  lirc_driver="lirc_dev lirc_parallel"
  port=0x278
  irq=5
fi

if test "$driver" = "macmini"; then
  lirc_driver="$driver"
  hw_module="hw_hiddev.o"
  HW_DEFAULT="hw_macmini"
  lircd_conf="apple/lircd.conf.macmini"
fi

if test "$driver" = "mediafocusI"; then
  lirc_driver="none"
  lircd_conf="technisat/lircd.conf.mediafocusI"
#  lircmd_conf="technisat/lircmd.conf.mediafocusI"
fi

if test "$driver" = "mouseremote"; then
  lirc_driver="none"
  hw_module="hw_mouseremote.o serial.o"
  HW_DEFAULT="hw_mouseremote"
  lircd_conf="x10/lircd.conf.mouseremote"
  lircmd_conf="x10/lircmd.conf.mouseremote"
fi

if test "$driver" = "mouseremote_ps2"; then
  lirc_driver="none"
  hw_module="hw_mouseremote.o serial.o"
  HW_DEFAULT="hw_mouseremote_ps2"
  lircd_conf="x10/lircd.conf.mouseremote"
  lircmd_conf="x10/lircmd.conf.mouseremote"
fi

if test "$driver" = "mp3anywhere"; then
  lirc_driver="none"
  hw_module="hw_mp3anywhere.o serial.o"
  HW_DEFAULT="hw_mp3anywhere"
  lircd_conf="x10/lircd.conf.mp3anywhere"
fi

if test "$driver" = "mplay"; then
  lirc_driver="none"
  hw_module="hw_mplay.o serial.o"
  HW_DEFAULT="hw_mplay"
  lircd_conf="vlsystem/lircd.conf.mplay"
fi

if test "$driver" = "mplay2"; then
  lirc_driver="none"
  hw_module="hw_mplay.o serial.o"
  HW_DEFAULT="hw_mplay2"
  lircd_conf="vlsystem/lircd.conf.mplay"
fi

if test "$driver" = "nslu2"; then
  lirc_driver="lirc_dev lirc_serial"
  AC_DEFINE(LIRC_SERIAL_NSLU2)
fi

if test "$driver" = "packard_bell"; then
  lirc_driver="lirc_dev lirc_serial"
  lircd_conf="packard_bell/lircd.conf.packard_bell"
fi

if test "$driver" = "parallel"; then
  lirc_driver="lirc_dev lirc_parallel"
fi

if test "$driver" = "pcmak" -o "$driver" = "pcmak_usb"; then
  lirc_driver="none"
  hw_module="hw_pcmak.o serial.o"
  HW_DEFAULT="hw_pcmak"
  lircd_conf="pcmak/lircd.conf.pcmak"
  lircmd_conf="pcmak/lircmd.conf.pcmak"
fi

if test "$driver" = "pctv"; then
  lirc_driver="none"
  hw_module="hw_pinsys.o serial.o"
  HW_DEFAULT="hw_pinsys"
  lircd_conf="pinnacle_systems/lircd.conf.pctv"
#  lircmd_conf="pinnacle_systems/lircmd.conf.pctv"
fi

if test "$driver" = "pixelview_bt878"; then
  lirc_driver="lirc_dev lirc_i2c"
  lircd_conf="pixelview/lircd.conf.playtv_bt878"
#  lircmd_conf="pixelview/lircmd.conf.pixelview_bt878"
fi

if test "$driver" = "pixelview_pak"; then
  lirc_driver="lirc_dev lirc_gpio"
# the config files are the same as for the PlayTV pro
  lircd_conf="pixelview/lircd.conf.playtv_pro"
  lircmd_conf="pixelview/lircmd.conf.playtv_pro"
fi

if test "$driver" = "pixelview_pro"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="pixelview/lircd.conf.playtv_pro"
  lircmd_conf="pixelview/lircmd.conf.playtv_pro"
fi

if test "$driver" = "provideo"; then
  lirc_driver="lirc_dev lirc_i2c"
  lircd_conf="provideo/lircd.conf.pv951"
#  lircmd_conf="provideo/lircmd.conf.pv951"
fi

if test "$driver" = "realmagic"; then
  lirc_driver="none"
  hw_module="hw_pixelview.o serial.o"
  HW_DEFAULT="hw_pixelview"
  lircd_conf="sigma_designs/lircd.conf.realmagic"
#  lircmd_conf="sigma_designs/lircmd.conf.realmagic"
fi

if test "$driver" = "remotemaster"; then
  lirc_driver="none"
  hw_module="hw_pixelview.o serial.o"
  HW_DEFAULT="hw_pixelview"
  lircd_conf="pixelview/lircd.conf.remotemaster"
  lircmd_conf="pixelview/lircmd.conf.remotemaster"
fi

if test "$driver" = "sa1100"; then
  lirc_driver="lirc_dev lirc_sir"
  AC_DEFINE(LIRC_ON_SA1100)
fi

if test "$driver" = "sasem"; then
  lirc_driver="lirc_dev lirc_sasem"
  lircd_conf="sasem/lircd.conf.sasem"
fi

if test "$driver" = "samsung"; then
  lirc_driver="$driver"
  hw_module="hw_hiddev.o"
  HW_DEFAULT="hw_samsung"
  lircd_conf="samsung/lircd.conf.samsung"
fi

if test "$driver" = "sb0540"; then
  lirc_driver="$driver"
  hw_module="hw_hiddev.o"
  HW_DEFAULT="hw_sb0540"
# original RM-1500 is included here
  lircd_conf="creative/lircd.conf.alsa_usb"
fi

if test "$driver" = "serial"; then
  lirc_driver="lirc_dev lirc_serial"
fi

if test "$driver" = "silitek"; then
  lirc_driver="none"
  hw_module="hw_silitek.o serial.o"
  HW_DEFAULT="hw_silitek"
  lircd_conf="silitek/lircd.conf.silitek"
  lircmd_conf="silitek/lircmd.conf.silitek"
fi

if test "$driver" = "sir"; then
  lirc_driver="lirc_dev lirc_sir"
fi

if test "$driver" = "sir_com3"; then
  lirc_driver="lirc_dev lirc_sir"
  port=0x3e8
  irq=4
fi

if test "$driver" = "slinke"; then
  echo
  echo "Please use lirc-0.6.5. The Slink-e is no longer supported."
  echo
  exit 1
  lirc_driver="none"
  hw_module="hw_slinke.o serial.o receive.o"
  HW_DEFAULT="hw_slinke"
fi

if test "$driver" = "srm7500libusb"; then
  lirc_driver="$driver"
  hw_module="hw_srm7500libusb.o receive.o"
  HW_DEFAULT="hw_srm7500libusb"
  lircd_conf="philips/lircd.conf.srm7500libusb"
  if test -n "${LIBUSB_CONFIG}"; then
    srm7500libusb_lib=`${LIBUSB_CONFIG} --libs`
    CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
  fi
fi

if test "$driver" = "tekram"; then
  lirc_driver="lirc_dev lirc_sir"
  AC_DEFINE(LIRC_SIR_TEKRAM)
fi

if test "$driver" = "tekram_bt829"; then
  lirc_driver="lirc_dev lirc_bt829"
  lircd_conf="tekram/lircd.conf.m230"
  lircmd_conf="tekram/lircmd.conf.m230"
fi

if test "$driver" = "tira"; then
  lirc_driver="none"
  hw_module="hw_tira.o serial.o receive.o transmit.o"
  HW_DEFAULT="hw_tira"
fi

if test "$driver" = "tira_raw"; then
  lirc_driver="none"
  hw_module="hw_tira.o serial.o receive.o transmit.o"
  HW_DEFAULT="hw_tira_raw"
fi

if test "$driver" = "ttusbir"; then
  lirc_driver="lirc_dev lirc_ttusbir"
fi

if test "$driver" = "tuxbox"; then
  lirc_driver="none"
  hw_module="hw_default.o receive.o transmit.o"
  HW_DEFAULT="hw_default"
fi

if test "$driver" = "tvbox"; then
  lirc_driver="lirc_dev lirc_i2c"
  lircd_conf="asus/lircd.conf.asus"
fi

if test "$driver" = "udp"; then
  lirc_driver="none"
  hw_module="hw_udp.o receive.o"
  HW_DEFAULT="hw_udp"
fi

if test "$driver" = "uirt2"; then
  lirc_driver="none"
  hw_module="hw_uirt2.o serial.o"
  HW_DEFAULT="hw_uirt2"
fi
if test "$driver" = "uirt2_raw"; then
  lirc_driver="none"
  hw_module="hw_uirt2_raw.o hw_uirt2_common.o serial.o receive.o transmit.o"
  HW_DEFAULT="hw_uirt2_raw"
fi
if test "$driver" = "usb_uirt_raw"; then
  lirc_driver="none"
  hw_module="hw_uirt2_raw.o hw_uirt2_common.o serial.o receive.o transmit.o"
  HW_DEFAULT="hw_usb_uirt_raw"
fi
if test "$driver" = "usbx"; then
  lirc_driver="none"
  hw_module="hw_usbx.o serial.o"
  HW_DEFAULT="hw_usbx"
  lircd_conf="adstech/lircd.conf.usbx-707"
fi

if test "$driver" = "wpc8769l"; then
  lirc_driver="lirc_dev lirc_wpc8769l"
  lircd_conf="acer/lircd.conf.Aspire_6530G"
fi


#END HARDWARE HEURISTIC

AC_DEFINE_UNQUOTED(HW_DEFAULT, ${HW_DEFAULT})

dnl now check to see if the user is behaving himself

if test "$lirc_driver" = "unset"; then
  AC_MSG_ERROR([no driver specified, try ./configure --help])
fi

if echo ${possible_drivers} | grep "($lirc_driver)" >/dev/null 2>&1; then
  dummy=
else
  case $lirc_driver in
  ftdi*)
    AC_MSG_ERROR([*** you need to first install the libftdi package
	before you can use this driver])
    ;;
  irman*)
    AC_MSG_ERROR([*** you need to first install the libirman package
	(libirman-0.4.2 or better) before you can use this driver])
    ;;
  caraca*)
    AC_MSG_ERROR([*** you need to first install the caraca package
	before you can use this driver])
    ;;
  all|lirc_*)
    AC_MSG_ERROR([*** you need to have the Linux kernel source installed
	for this driver])
    ;;
  atilibusb|awlibusb|commandir|dfclibusb|srm7500libusb)
    AC_MSG_ERROR([*** you need to have libusb installed for this driver.

Get it at:

  http://libusb.sourceforge.net/
  
Or install these packages from your distro:

   libusb
   libusb-dev

])
    ;;
  audio)
    AC_MSG_ERROR([*** you need to have the PortAudio library V19 installed
to use the audio driver. You can get it at:
  http://www.portaudio.com/
])
    ;;
  audio_alsa)
    AC_MSG_ERROR([*** you need to have the ALSA headers and libraries
	for this driver])
    ;;
  alsa_usb)
    AC_MSG_ERROR([*** you need to have the ALSA libraries and drivers
	from at least version 1.0.9 for this driver])
    ;;
  iguanaIR)
    AC_MSG_ERROR([*** you need to have the iguanaIR headers and
        libraries for this driver])
    ;;
  *)
    AC_MSG_ERROR([*** it is not possible to install the specified driver
	on this system])
    ;;
  esac
fi

dnl now we've checked, we can rename things for the drivers/Makefile

if test "$lirc_driver" = "none" || \
	test "$lirc_driver" = "alsa_usb" || \
	test "$lirc_driver" = "asusdh" || \
	test "$lirc_driver" = "atilibusb" || \
	test "$lirc_driver" = "atwf83" || \
	test "$lirc_driver" = "audio" || \
	test "$lirc_driver" = "audio_alsa" || \
	test "$lirc_driver" = "awlibusb" || \
	test "$lirc_driver" = "bw6130" || \
	test "$lirc_driver" = "caraca" || \
	test "$lirc_driver" = "commandir" || \
	test "$lirc_driver" = "dfclibusb" || \
	test "$lirc_driver" = "dvico" || \
	test "$lirc_driver" = "iguanaIR" || \
	test "$lirc_driver" = "irman" || \
	test "$lirc_driver" = "irman_sw" || \
	test "$lirc_driver" = "macmini" || \
	test "$lirc_driver" = "samsung" || \
	test "$lirc_driver" = "sb0540" || \
	test "$lirc_driver" = "srm7500libusb" || \
	test "$lirc_driver" = "userspace"; then
  lirc_driver=
elif test "$lirc_driver" = "all"; then
  lirc_driver="lirc_dev \
	lirc_atiusb \
	lirc_bt829 \
	lirc_i2c \
	lirc_igorplugusb \
	lirc_imon \
	lirc_parallel \
	lirc_sasem \
	lirc_serial \
	lirc_sir \
	lirc_ttusbir \
	lirc_wpc8769l"
fi
if kernel_module=$(expr "$lirc_driver" : 'lirc_dev \(.*\)'); then
  :
elif test "$lirc_driver" != ""; then
  kernel_module=$lirc_driver
fi

dnl slightly more advanced options

dnl maintainer mode options

maintmode_daemons_extra=
AC_ARG_ENABLE(maintainer-mode,
[  --enable-maintainer-mode    enable maintainer specific things],
[
if test x${enableval} = xyes; then
AC_DEFINE(MAINTAINER_MODE)
maintmode_daemons_extra="lircd.simrec lircd.simsend slinke"
fi
])

dnl don't create nor destroy devices when installing and uninstalling

AC_ARG_ENABLE(sandboxed,
[  --enable-sandboxed      don't touch anything out of the install directory],
[ enable_sandboxed="${enableval}" ],
[ enable_sandboxed="no"])
AM_CONDITIONAL(SANDBOXED, test x$enable_sandboxed = xyes)

AC_ARG_WITH(devdir,
[  --with-devdir=DIR       Install device files in DIR (/dev)],
devdir=${withval},
devdir=${devdir_default})

default_moduledir=/lib/modules/`uname -r`/misc
AC_ARG_WITH(moduledir,
[  --with-moduledir=DIR    kernel modules in DIR (/lib/modules/`uname -r`/misc)], 
moduledir=${withval},
moduledir=${default_moduledir})

AC_ARG_ENABLE(dyncodes,
[  --enable-dyncodes       use dynamic codes],
test x${enableval} = xyes && AC_DEFINE(DYNCODES))

AC_ARG_WITH(major,
[  --with-major=value      specify the device major for the driver (61)],
lirc_major=${withval},
lirc_major=61)

AC_ARG_WITH(port,
[  --with-port=port        specify the port number for the lirc device.],
port=${withval}
)

AC_ARG_WITH(irq,
[  --with-irq=irq          specify the irq line for the lirc device.],
irq=${withval}
)

AC_ARG_WITH(timer,
[  --with-timer=value      specify the timer value for the parallel driver],
timer=${withval})

AC_ARG_WITH(tty,
[  --with-tty=file         specify the tty to use (Irman, RemoteMaster, etc.)],
irtty=${withval})

AC_ARG_WITH(soft-carrier,
[  --without-soft-carrier  use this if your serial hw generates carrier],
test x${withval} = xyes && AC_DEFINE(LIRC_SERIAL_SOFTCARRIER),
AC_DEFINE(LIRC_SERIAL_SOFTCARRIER))

AC_ARG_WITH(transmitter,
[  --with-transmitter      use this if you use a transmitter diode],
test x${withval} = xyes && AC_DEFINE(LIRC_SERIAL_TRANSMITTER))

AC_ARG_WITH(igor,
[  --with-igor             use this if you have an Igor Cesko receiver],
test x${withval} = xyes && AC_DEFINE(LIRC_SERIAL_IGOR))

AC_ARG_ENABLE(debug,
[  --enable-debug          enable debugging features],
test x${enableval} = xyes && AC_DEFINE(DEBUG)
)

AC_ARG_ENABLE(daemonize,
[  --disable-daemonize     disable daemons from daemonizing],
test x${enableval} = xyes && AC_DEFINE(DAEMONIZE),
[
AC_CHECK_FUNCS(daemon)
if test "$ac_cv_func_daemon" != yes; then
  daemon=""
  AC_CHECK_LIB(bsd,daemon,daemon="-lbsd")
  if test "$daemon" = ""; then
    AC_MSG_ERROR([*** daemon() function not available on this system and --disable-daemonize not specified])
  fi
fi
AC_DEFINE(DAEMONIZE)
])

AC_ARG_WITH(syslog,
[  --with-syslog=facility  use syslog instead of logfile],
if test -n "${withval}"; then
  facility="${withval}"
  if test "${withval}" = yes; then
    facility=LOG_DAEMON;
  elif test "${withval}" = LOG_AUTH; then
    true;
  elif test "${withval}" = LOG_AUTHPRIV; then
    true;
  elif test "${withval}" = LOG_DAEMON; then
    true;
  elif test "${withval}" = LOG_LOCAL0; then
    true;
  elif test "${withval}" = LOG_LOCAL1; then
    true;
  elif test "${withval}" = LOG_LOCAL2; then
    true;
  elif test "${withval}" = LOG_LOCAL3; then
    true;
  elif test "${withval}" = LOG_LOCAL4; then
    true;
  elif test "${withval}" = LOG_LOCAL5; then
    true;
  elif test "${withval}" = LOG_LOCAL6; then
    true;
  elif test "${withval}" = LOG_LOCAL7; then
    true;
  elif test "${withval}" = LOG_USER; then
    true;
  else
    AC_MSG_ERROR([*** invalid facility (see syslog(3) for possible facilities) ])
  fi
  AC_DEFINE(USE_SYSLOG)
fi
)

dnl if --prefix is not specified, then $prefix is still set to NONE by
dnl configure.  That's bad here where we want to expand it!
cur_prefix=$prefix
test "x${prefix}" = "xNONE" && prefix=$ac_default_prefix 
test "${sysconfdir}" = "\${prefix}/etc" && sysconfdir=/etc
test "${localstatedir}" = "\${prefix}/var" && localstatedir=/var
varrundir="${localstatedir}/run"
sysconfdir_exp=`eval "echo ${sysconfdir}"`
localstatedir_exp=`eval "echo ${localstatedir}"`
varrundir_exp=`eval "echo ${varrundir}"`
prefix=$cur_prefix

receive=""
if ! echo ${hw_module}|grep " receive.o" >/dev/null; then
	receive="receive.o"
fi

hw_module_libs="${alsa_lib} ${atilibusb_lib} ${awlibusb_lib} ${caraca_lib} ${commandir_lib} ${dfclibusb_lib} ${ftdi_lib} ${iguanaIR_lib} ${irman_lib} ${portaudio_lib} ${srm7500libusb_lib} ${atwf83_lib}"

dnl tell the Makefiles what we decided
AC_SUBST(daemon)
AC_SUBST(forkpty)
AC_SUBST(devdir)
AC_SUBST(sysconfdir)
AC_SUBST(varrundir)
AC_SUBST(moduledir)
AC_SUBST(lirc_major)
AC_SUBST(driver)
AC_SUBST(lirc_driver)
AC_SUBST(hw_module_libs)
AC_SUBST(vga_progs) 
AC_SUBST(x_progs)
AC_SUBST(hw_module)
AC_SUBST(receive)
AC_SUBST(lircd_conf)
AC_SUBST(lircmd_conf)
AC_SUBST(maintmode_daemons_extra)

dnl tell the C code what we decided
AC_DEFINE_UNQUOTED(DEVDIR, "$devdir")
AC_DEFINE_UNQUOTED(SYSCONFDIR, "$sysconfdir_exp")
AC_DEFINE_UNQUOTED(LOCALSTATEDIR, "$localstatedir_exp")
AC_DEFINE_UNQUOTED([VARRUNDIR], "$varrundir_exp", [/var/run])
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
AC_DEFINE_UNQUOTED(VERSION, "$VERSION")

AC_DEFINE_UNQUOTED(LIRC_DRIVER, "$driver")
if test "$port" != ""; then
  AC_DEFINE_UNQUOTED(LIRC_PORT, $port)
fi
if test "$irq" != ""; then
  AC_DEFINE_UNQUOTED(LIRC_IRQ, $irq)
fi
if test "$timer" != ""; then
  AC_DEFINE_UNQUOTED(LIRC_TIMER, $timer)
fi
if test "$irtty" != ""; then
  AC_DEFINE_UNQUOTED(LIRC_IRTTY, "$irtty")
fi
AC_DEFINE_UNQUOTED(LIRC_SYSLOG, $facility)

AH_TOP([
/* device file names - beneath DEVDIR (default /dev) */
#define DEV_LIRC	"lirc"
#define DEV_LIRCD	"lircd"
#define DEV_LIRCM	"lircm"

/* config file names - beneath SYSCONFDIR (default /etc) */
#define CFG_LIRCD	"lircd.conf"
#define CFG_LIRCM	"lircmd.conf"

/* config file names - beneath $HOME or SYSCONFDIR */
#define CFG_LIRCRC	"lircrc"

/* log files */
#define LOG_LIRCD	"lircd"
#define LOG_LIRMAND	"lirmand"

/* pid file */
#define PID_LIRCD       "lircd.pid"

/* default port number */
#define	LIRC_INET_PORT	8765
])

AH_BOTTOM([
#ifdef LIRC_HAVE_DEVFS
#define LIRC_DRIVER_DEVICE	DEVDIR "/" DEV_LIRC "/0"
#else
#define LIRC_DRIVER_DEVICE      DEVDIR "/" DEV_LIRC
#endif /* LIRC_HAVE_DEVFS */

#define LIRCD			VARRUNDIR "/" PACKAGE "/" DEV_LIRCD
#define LIRCM			VARRUNDIR "/" PACKAGE "/" DEV_LIRCM

#define LIRCDCFGFILE		SYSCONFDIR "/" PACKAGE "/" CFG_LIRCD
#define LIRCMDCFGFILE		SYSCONFDIR "/" PACKAGE "/" CFG_LIRCM

#define LIRCDOLDCFGFILE		SYSCONFDIR "/" CFG_LIRCD
#define LIRCMDOLDCFGFILE	SYSCONFDIR "/" CFG_LIRCM

#define LIRCRC_USER_FILE	"." CFG_LIRCRC
#define LIRCRC_ROOT_FILE	SYSCONFDIR "/" PACKAGE "/" CFG_LIRCRC
#define LIRCRC_OLD_ROOT_FILE	SYSCONFDIR "/" CFG_LIRCRC

#define LOGFILE			LOCALSTATEDIR "/log/" LOG_LIRCD
#define LIRMAND_LOGFILE		LOCALSTATEDIR "/log/" LOG_LIRMAND

#define PIDFILE                 VARRUNDIR "/" PACKAGE "/" PID_LIRCD

#define LIRC_RELEASE_SUFFIX     "_UP"
])

dnl bug in automake/autoconf?
dnl SHELL=/bin/sh AC_SUBST(SHELL)

dnl write these decisions out to the Makefiles
AC_CONFIG_FILES([
  Makefile
  drivers/Makefile
  drivers/lirc_atiusb/Makefile
  drivers/lirc_bt829/Makefile
  drivers/lirc_dev/Makefile
  drivers/lirc_gpio/Makefile
  drivers/lirc_i2c/Makefile
  drivers/lirc_igorplugusb/Makefile
  drivers/lirc_ttusbir/Makefile
  drivers/lirc_imon/Makefile
  drivers/lirc_parallel/Makefile
  drivers/lirc_sasem/Makefile
  drivers/lirc_serial/Makefile
  drivers/lirc_sir/Makefile
  drivers/lirc_wpc8769l/Makefile
  daemons/Makefile
  tools/Makefile
  doc/Makefile
  doc/man/Makefile
])
AC_OUTPUT

echo
if test "$driver" = "all"; then
  echo "All kernel modules will be built."
elif test "$driver" = "mediafocusI"; then
  echo "You will have to use the MediaFocus driver from:"
  echo "http://freenet-homepage.de/mediafocus/"
elif test "$driver" = "exaudio"; then
  echo "You will have to use the Exaudio driver from:"
  echo "http://exaudio.sourceforge.net/"
elif test "$driver" = "alsa_usb"; then
  echo "You will have to use the snd-usb-audio driver from:"
  echo "http://www.alsa-project.org/"
elif test "$driver" = "hauppauge_dvb"; then
  echo "You will have to use the DVB driver from:"
  echo "http://www.linuxtv.org"
elif test "$kernel_module" = ""; then
  echo "Your hardware does not require a special LIRC kernel module."
  if test "${irtty}" != ""; then
    echo
    echo "You will have to use the suitable kernel driver to access ${irtty}."
  fi
else
  echo "You will have to use the $kernel_module kernel module."
fi
echo
echo "Now enter 'make' and 'make install' to compile and install the package."
echo