summaryrefslogtreecommitdiffstats
path: root/macros/README.md
blob: 608b2ecd9075f73d81008eac99abf7e34281e263 (plain)
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
autoconf-macros
===============

The purpose of Nagios autoconf-macros is to have a central place for
autoconf macros that can be maintained in one place, but be used by any
of the Nagios software. It is intended to be used as a git subtree.
See the [Usage](#usage) and [References](#references) sections below.

Since this project will be included in several parent projects, any
changes must be as project-neutral as possible.

Make sure to check out the [CHANGELOG](CHANGELOG.md) for relevant 
information, as well.


Contents
--------

The collection consists of the following macros:

### AX_NAGIOS_GET_OS alias AC_NAGIOS_GET_OS

> Output Variable : `opsys`

This macro detects the operating system, and transforms it into a generic
label. The most common OS's that use Nagios software are recognized and
used in subsequent macros.

### AX_NAGIOS_GET_DISTRIB_TYPE alias AC_NAGIOS_GET_DISTRIB_TYPE

> Output Variables : `dist_type`, `dist_ver`

This macro detects the distribution type. For Linux, this would be rh
(for Red Hat and derivitives), suse (OpenSUSE, SLES, derivitives), gentoo
(Gentoo and derivitives), debian (Debian and derivitives), and so on.
For BSD, this would be openbsd, netbsd, freebsd, dragonfly, etc. It can
also be aix, solaris, osx, and so on for Unix operating systems.

### AX_NAGIOS_GET_INIT alias AC_NAGIOS_GET_INIT

> Output Variable : `init_type`

This macro detects what software is used to start daemons on bootup
or on request, generally knows as the "init system". The init_type
will generally be one of sysv (many), bsd (Slackware), newbsd (*BSD),
launchd (OS X), smf10 or smf11 (Solaris), systemd (newer Linux),
gentoo (older Gentoo), upstart (several), or unknown.

### AX_NAGIOS_GET_INETD alias AC_NAGIOS_GET_INETD

> Output Variable : `inetd_type`

This macro detects what software is used to start daemons or services
on demand, which historically has been "inetd". The inetd_type
will generally be one of inetd, xinetd, launchd (OS X), smf10 or smf11
(Solaris), systemd (newer Linux), upstart (several), or unknown.

### AX_NAGIOS_GET_PATHS alias AC_NAGIOS_GET_PATHS

> Output Variables : **many!**

This macro determines the installation paths for binaries, config files,
PID files, and so on. For a "standard" install of Nagios, NRPE, NDO Utils,
etc., most will be in the /usr/local/nagios hierarchy with startup files
located in /etc. For distributions or software repositories, the
"--enable-install-method=os" option can be used. This will determine the
O/S dependant directories, such as /usr/bin, /usr/sbin, /var/lib/nagios,
/usr/lib/nagios, etc. or for OS X, /Library/LaunchDaemons.

### AX_NAGIOS_GET_FILES alias AC_NAGIOS_GET_FILES

> Output Variables : `src_init`, `src_inetd`, `src_tmpfile`

Each Nagios project will have a top-level directory named "/startup/".
In that directory will be "*.in" files for the various "init_type" and
"inetd_type" systems. This macro will determine which file(s) from
that directory will be needed.

### AX_NAGIOS_GET_SSL alias AC_NAGIOS_GET_SSL

> Output Variables : `HAVE_KRB5_H`, `HAVE_SSL`, `SSL_INC_DIR`, `SSL_LIB_DIR`, `CFLAGS`, `LDFLAGS`, `LIBS`

This macro checks various directories for SSL libraries and header files.
The searches are based on known install locations on various operating
systems and distributions, for openssl, gnutls-openssl, and nss_compat_ossl.
If it finds the headers and libraries, it will then do an `AC_LINK_IFELSE`
on a simple program to make sure a compile and link will work correctly.


Usage
-----

This repo is intended to be used as a git subtree, so changes will
automatically propogate, and still be reasonably easy to use.

* First, Create, checkout, clone, or branch your project. If you do an
`ls -AF` it might look something like this:

           .git/      .gitignore    ChangeLog   LICENSE   Makefile.in
           README     configure.ac  include/    src/

* Then make a reference to _this_ project inside your project.

           git remote add autoconf-macros git@github.com:NagiosEnterprises/autoconf-macros
           git subtree add --prefix=macros/ autoconf-macros master

* After executing the above two commands, if you do an `ls -AF` now,
it should look like this:

           .git/      .gitignore    ChangeLog   LICENSE   Makefile.in
           README     configure.ac  include/    macros/   src/

* The `macros/` directory has been added.

* Now do a `git push` to save everything.

* If you make any changes to autoconf-macros, commit them separately
from any parent-project changes to keep from polluting the commit
history with unrelated comments.

* To submit your changes to autoconf-macros:

           git subtree push --prefix=macros autoconf-macros peters-updates
This will create a new branch called `peters-updates`. You then need to
create a _pull request_ to get your changes merged into autoconf-macros
master.

* To get the latest version of `autoconf-macros` into your parent project:

           git subtgree pull --squash --prefix=macros autoconf-macros master


References
----------

Now that autoconf-macros is available to your project, you will need to
reference it.

* Create (or add these lines to) file `YourProject/aclocal.m4`

           m4_include([macros/ax_nagios_get_os])
           m4_include([macros/ax_nagios_get_distrib])
           m4_include([macros/ax_nagios_get_init])
           m4_include([macros/ax_nagios_get_inetd])
           m4_include([macros/ax_nagios_get_paths])
           m4_include([macros/ax_nagios_get_files])
           m4_include([macros/ax_nagios_get_ssl])

* In your `YourProject/configure.ac` add the following lines. A good place
to put them would be right after any `AC_PROG_*` entries:

           AC_NAGIOS_GET_OS
           AC_NAGIOS_GET_DISTRIB_TYPE
           AC_NAGIOS_GET_INIT
           AC_NAGIOS_GET_INETD
           AC_NAGIOS_GET_PATHS
           AC_NAGIOS_GET_FILES

* If you need SSL functionality, add the following to `YourProject/configure.ac`
where you want to check for SSL:

           AC_NAGIOS_GET_SSL

* You will now be able to reference any of the variables in `config.h.in`
and any files listed in the `AC_CONFIG_FILES` macro in `configure.ac`.


License Notice
--------------

Copyright (c) 2016-2017 Nagios Enterprises, LLC

This work is made available to you under the terms of Version 2 of
the GNU General Public License. A copy of that license should have
been provided with this software, but in any event can be obtained
from http://www.fsf.org.

This work is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 or visit their web page on the internet at
http://www.fsf.org.


Questions?
----------

If you have questions about this addon, or problems getting things
working, first try searching the nagios-users mailing list archives.
Details on searching the list archives can be found at
http://www.nagios.org

If you don't find an answer there, post a message in the Nagios
Plugin Development forum at https://support.nagios.com/forum/viewforum.php?f=35