File: porting

package info (click to toggle)
apcupsd 3.10.17-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 16,616 kB
  • ctags: 6,941
  • sloc: ansic: 42,075; sh: 7,896; cpp: 3,561; makefile: 2,001; perl: 1,469; tcl: 368; sed: 93
file content (29 lines) | stat: -rw-r--r-- 984 bytes parent folder | download | duplicates (2)
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
Porting apcupsd seem to be quite easy at least at first glance.

OS detection:
it is done configure.in with the macro AM_CONDITIONAL and AC_DEFINE.
The AM_CONDITIONAL is for Makefile generating HAVE_SUN_OS_TRUE=' ' or
HAVE_SUN_OS_TRUE='#' for example if you have or not SUNOS. It expand these
variables and they become comments or spaces. Now it is used for selecting the
compiler switches.
The AC_DEFINE define HAVE_SUN_OS in the config.h file so that the C
preprocessor can know which OS we are compiling for.
For adding a new OS:
In configure.in add:

if test $HAVE_UNAME=yes -a x`uname -s` = xSunOS
then
        AM_CONDITIONAL(HAVE_NEW_OS, /bin/true)
        AC_DEFINE(HAVE_NEW_OS)
else
        AM_CONDITIONAL(HAVE_NEW_OS, /bin/false)
fi

In acconfig.h add:

#undef HAVE_NEW_OS

then regenerate the configure script and config.h.in files with autoregen.sh.

This thing is useful for compilers too. I have added checks for GCC so that
the Makefile know if we are using GCC or not.