File: configure.in

package info (click to toggle)
ledcontrol 0.5.2-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 792 kB
  • ctags: 259
  • sloc: ansic: 3,264; sh: 848; makefile: 176; perl: 49
file content (406 lines) | stat: -rw-r--r-- 9,918 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
dnl Process this file with autoconf to produce a configure script.
AC_INIT(ledd/ledd.c)

AM_INIT_AUTOMAKE(ledcontrol, 0.5.2)
# Release date:
DATE="08-Feb-2001"
AC_SUBST(DATE)

AM_CONFIG_HEADER(config.h)

dnl Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_AWK

dnl Checks for libraries.
### GTK will be checked for later...
AM_PATH_GLIB(1.2.0,,AC_MSG_ERROR(You should get glib 1.2.0 or better, for your own sake.))


### Configurable pieces
# Defaults:

function absdir {
    if test "`echo "$1" | colrm 2`" = "/"; then
	echo $1
    else
	echo `pwd`/$1
    fi
}

##### Get the package dirs:
## PREFIX
if test "x${prefix}" = 'xNONE'; then
    prefix_int=${ac_default_prefix}
else
    prefix_int=`absdir ${prefix}`
fi

## EXEC-PREFIX
if test "x${exec_prefix}" = 'xNONE' ; then
    exec_prefix_int=${prefix_int}
else
    exec_prefix_int=`absdir ${exec_prefix}`
fi

## SBINDIR
if test "x${sbindir}" = 'x${exec_prefix}/sbin' ; then
    sbindir_int=${exec_prefix_int}/sbin
else
    sbindir_int=`absdir ${sbindir}`
fi
AC_SUBST(sbindir_int)

## SYSCONFDIR
if test "x${sysconfdir}" = 'x${prefix}/etc' ; then
    sysconfdir_int=${prefix_int}/etc
else
    sysconfdir_int=`absdir ${sysconfdir}`
fi

## DATADIR
if test "x${datadir}" = 'x${prefix}/share' ; then
    datadir_int=${prefix_int}/share/${PACKAGE}
else
    datadir_int=`absdir ${datadir}`/${PACKAGE}
fi


# Now we have set:
#   sysconfdir_int (/usr/local/etc)
#   sbindir_int    (/usr/local/sbin)
#   datadir_int    (/usr/local/share/ledcontrol)

AC_SUBST(sysconfdir_int)    # for ledd.conf and ledcontrol.conf
AC_SUBST(sbindir_int)       # for the sysv-scripts
AC_SUBST(datadir_int)       # for startup.sh and installation

# Define the location of ledd.conf
AC_DEFINE_UNQUOTED(DEFAULTCONFIG_LEDD,"${sysconfdir_int}/ledd.conf",Default configuration file location (ledd))











##### COMMAND-LINE OPTIONS FOR CONFIGURE


### Disable the optimization
AC_ARG_ENABLE(optimization,
[  --disable-optimization   Disable optimization, for debugging purposes only.],
if test "$enable_optimization" == "no"; then
    CFLAGS="-g"
fi)


### gled installation
do_gled=default
AC_ARG_ENABLE(gled,
[  --disable-gled           Do not compile/install gled [yes if GTK+ found].],
do_gled=$enable_gled)


### User requested sysv
sysv_install=CHECK
sysv_type=CHECK
sysv_base=CHECK
sysv_runlevel_on=DEFAULT
sysv_runlevel_off=DEFAULT

sysv_types="debian redhat generic"

AC_ARG_ENABLE(sysv-init,
[  --enable-sysv-init [type] Install sysvinit-script for implementation type
                            (debian,redhat,generic,none) [guess]],
if test "$enable_sysv_init" = "yes"; then
    sysv_install=YES
elif test "$enable_sysv_init" = "no" -o "$enable_sysv_init" = "none"; then
    sysv_install=NO
else
    for i in $sysv_types NONE; do
	if echo "$enable_sysv_init" | grep -qi "^$i$" ; then
	    break;
	fi
    done
    if test "$i" = NONE; then
	AC_MSG_ERROR([Bad argument: --enable-sysv-init=${enable_sysv_init}
 Available types include: ${sysv_types}])
    fi
    sysv_install=YES
    sysv_type=$i
fi)

# WHY THE FSCK MUST THIS BE SO DIFFICULT?!?
changequote(,)
reg="^[1-5]*$"
changequote([,])

AC_ARG_ENABLE(sysv-levels,
[  --enable-sysv-levels lvls Enable sysvinit-script on given runlevels []
  --disable-sysv-levels     Don't create any symlinks (for packaging)],
if test "$enable_sysv_levels" = "yes"; then
    sysv_install=YES
elif test "$enable_sysv_levels" = "no"; then
    # Previously this disabled the sysv script, now as it has its own option
    # this disables all symlink creation.
    sysv_runlevel_off=
    sysv_runlevel_on=
elif echo "$enable_sysv_levels" | grep -q "$reg"; then
    sysv_install=YES
    sysv_runlevel_on=$enable_sysv_levels
    # Sort it...
    sysv_runlevel_off=`echo 0123456 | tr -d "$sysv_runlevel_on"`
    sysv_runlevel_on=`echo 0123456 | tr -d "$sysv_runlevel_off"`
else
    AC_MSG_ERROR([Bad argument: --enable-sysv-levels=${enable_sysv_init}
 Use ./configure --enable-sysv-levels=345   (available: 12345)])
fi)

AC_ARG_ENABLE(sysv-dir,
[  --enable-sysv-dir DIR     Set DIR as base dir for sysv scripts [search]],
if test "$enable_sysv_dir" != "yes" -a "$enable_sysv_dir" != "no"; then
    sysv_base=$enable_sysv_dir
fi)


### Shell
STARTUPSHELL=CHECK
AC_ARG_ENABLE(shell,
[  --enable-shell SHELL      Use SHELL as default shell for startup.sh [search]],
if test "$enable_shell" != "yes" -a "$enable_shell" != "no"; then
    STARTUPSHELL=$enable_shell
fi)


###### OPTIONS END HERE











dnl Checks for header files.
AC_STDC_HEADERS
AC_HAVE_HEADERS(fcntl.h sys/ioctl.h unistd.h sys/kd.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_PID_T


dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_TYPE_SIGNAL

dnl Check for syslog - copied from an autoconf manual
AC_CHECK_FUNCS(syslog)
if test "$ac_cv_func_syslog" = no; then
    # syslog is not in the default libraries.  See if it's in some other.
    for lib in bsd socket inet; do
        AC_CHECK_LIB($lib, syslog, [AC_DEFINE(HAVE_SYSLOG)
                     LIBS="$LIBS $lib"; break])
    done
fi


### gled checking and conditional...
if test "$do_gled" = yes -o "$do_gled" = default ; then
    AM_PATH_GTK(1.2.0,do_gled=yes,havegtk=no)
    if test "$havegtk" = "no"; then
	if test "$dogled" = default; then
	    AC_MSG_WARN(GTK+ 1.2.0 not found, disabling gled.)
	    do_gled=no
	else
	    AC_MSG_ERROR(gled requires GTK+ 1.2.0 or higher.)
	fi
    fi
fi
AM_CONDITIONAL(DO_GLED, test "x$do_gled" = "xyes")


### Check for sysv
# Check the base dir for the scripts (which holds rc?.d)
#    Checks /etc (Debian) and /etc/rc.d (RH)
#    Default is the last one:

#sysv_base_check="/home/sampo/c/ledcontrol/dist/sysv-test /etc /etc/rc.d"
sysv_base_check="/etc /etc/rc.d"


##### Check sysv base, if neccessary.
changequote(,)
if test "$sysv_base" = CHECK; then
    for sysv_base in $sysv_base_check; do
	if ls -d $sysv_base/rc[0-6].d/ 1>/dev/null 2>/dev/null ; then
	    break;
	fi
    done
fi
changequote([,])


##### Check for sysv existance, if neccessary.
changequote(,)
if test "$sysv_install" = CHECK; then
    AC_MSG_CHECKING(for sysvinit)
    if ls -d $sysv_base/rc[0-6].d/ 1>/dev/null 2>/dev/null; then
	sysv_install=YES
	AC_MSG_RESULT(found under ${sysv_base}/rc?.d)
    else
	sysv_install=NO
	AC_MSG_RESULT(not found)
    fi
fi
changequote([,])


##### Check sysv type, if neccessary.
if test "$sysv_install" = YES -a "$sysv_type" = CHECK; then
    AC_MSG_CHECKING(sysvinit flavor)
    if test -e /sbin/start-stop-daemon ; then         # Debian
	sysv_type=debian
	AC_MSG_RESULT(Debian)
    elif test -e /etc/rc.d/init.d/functions ; then    # RedHat
	sysv_type=redhat
	AC_MSG_RESULT(RedHat)
    else                                              # generic
	sysv_type=generic
	AC_MSG_RESULT(generic)
    fi
fi


##### Check what runlevels to be set on/off...
if test "$sysv_install" = YES -a "$sysv_runlevel_on" = DEFAULT; then
    if ls $sysv_base/rc?.d/???ledd 1>/dev/null 2>/dev/null ; then
	# There are previous scripts, let them be...
	sysv_runlevel_on=
	sysv_runlevel_off=
    else
	# There are no previous scripts, disable all...
	sysv_runlevel_on=
	sysv_runlevel_off=0123456
    fi
fi

##### sysv-installaion message to give.
if test "$sysv_install" = YES -a -n "$sysv_runlevel_on"; then
    # The damn plural mode...
    if test $sysv_runlevel_on -gt 9; then
	sysv_message="default on for runlevels $sysv_runlevel_on"
    else
	sysv_message="default on for runlevel $sysv_runlevel_on"
    fi
else
    if test -n "$sysv_runlevel_off" ; then
	sysv_message="default off for all runlevels"
    else
	sysv_message="leaving settings alone"
    fi
fi

##### Report status.
if test "$sysv_install" = YES; then
    AC_MSG_RESULT(Installing ${sysv_type} sysv-initscript for ledd (${sysv_message}).)
else
    AC_MSG_RESULT(Disabling sysv-initscript installation.)
    sysv_message=""
fi

AC_SUBST(sysv_install)
AC_SUBST(sysv_runlevel_on)
AC_SUBST(sysv_runlevel_off)
AC_SUBST(sysv_message)
AC_SUBST(sysv_base)
AC_SUBST(sysv_type)



### Check for BSD-like tr
# For Makefile.am... ;)
AC_MSG_CHECKING(whether tr is BSD-like)
if echo "abc de,.?" | tr "[:print:]" "=" | grep -qv "[^=]"; then
    bsd_tr=YES
    AC_MSG_RESULT(yes)
else
    bsd_tr=NO
    AC_MSG_RESULT(no)
fi
AC_SUBST(bsd_tr)


### Find best shell to use...
# This test should work with almost any shell...
# I've tested it to work with the following:
# bash 1.14.7(1), 2.04.0(1), 2.03.0(1)
# ash (version 5.1 ?)
# tcsh 6.08
# zsh 3.0.6

# Return true if shell is OK - ie. is executable and NOT bash 2.xx.x
shellok () {
    if ! test -x "$1"; then
	return 1
    fi
    # Test the BASH_VERSION environment variable...
    VER=`"$1" -c 'echo $BASH_VERSION' 2>/dev/null`
    if echo $VER | grep -q "^2\." ; then
	# It's bash 2.xx.x
	return 1
    else
	# It's not bash 2.xx.x
	return 0
    fi
}

TESTSHELL="/bin/sh /bin/bash*"

if test "$STARTUPSHELL" = "CHECK"; then
    AC_MSG_CHECKING(for best shell)
    STARTUPSHELL="/bin/sh"
    for sh in $TESTSHELL; do
	if shellok $sh; then
	    STARTUPSHELL=$sh
	    break;
	fi
    done
    shellok $STARTUPSHELL
    if test -n "$VER"; then
	AC_MSG_RESULT($STARTUPSHELL (bash $VER))
    else
	AC_MSG_RESULT($STARTUPSHELL (non-bash))
    fi
fi
if ! shellok $STARTUPSHELL && test -x $STARTUPSHELL ; then
    AC_MSG_WARN(Backgrounding will be disabled due to bug in bash)
fi

AC_SUBST(STARTUPSHELL)




AC_OUTPUT([Makefile ledd/Makefile scripts/Makefile
           gled/Makefile ledcontrol ledd.conf.sample
           ledd-sysv-debian ledd-sysv-redhat ledd-sysv-generic
           configtext scripts/startup.sh gled.1 ledcontrol.1
           ledcontrol.conf.5 ledd.8 ledd.conf.5 startup.sh.8],
          [chmod 755 ledcontrol scripts/startup.sh ledd-sysv-debian ledd-sysv-redhat ledd-sysv-generic])

# Why is there no command for common notices???
AC_MSG_RESULT([
Configuration files will be placed under ${sysconfdir_int}
])