]> git.proxmox.com Git - mirror_smartmontools-debian.git/blob - Makefile.am
7f79e9dfbeee58811effb1fadd5da8e5294e3cf7
[mirror_smartmontools-debian.git] / Makefile.am
1 ## Process this file with automake to produce Makefile.in
2 #
3 # $Id: Makefile.am,v 1.79 2006/08/09 20:40:19 chrfranke Exp $
4 #
5
6 @SET_MAKE@
7
8 # Make sure .cpp takes precedence to avoid compiling old .c file
9 SUFFIXES = .cpp .c .s .o
10
11
12 AM_CPPFLAGS = -DSMARTMONTOOLS_SYSCONFDIR=\"$(sysconfdir)\"
13
14 sbin_PROGRAMS = smartd \
15 smartctl
16
17 smartd_SOURCES = smartd.cpp \
18 smartd.h \
19 atacmdnames.cpp \
20 atacmdnames.h \
21 atacmds.cpp \
22 atacmds.h \
23 ataprint.cpp \
24 ataprint.h \
25 extern.h \
26 int64.h \
27 knowndrives.cpp \
28 knowndrives.h \
29 scsicmds.cpp \
30 scsicmds.h \
31 scsiata.cpp \
32 scsiata.h \
33 scsiprint.cpp \
34 scsiprint.h \
35 utility.cpp \
36 utility.h
37
38 smartd_LDADD = @os_deps@ @os_libs@
39 smartd_DEPENDENCIES = @os_deps@
40
41 EXTRA_smartd_SOURCES = os_darwin.cpp \
42 os_darwin.h \
43 os_linux.cpp \
44 os_linux.h \
45 os_freebsd.cpp \
46 os_freebsd.h \
47 os_netbsd.cpp \
48 os_netbsd.h \
49 os_openbsd.cpp \
50 os_openbsd.h \
51 os_solaris.cpp \
52 os_solaris.h \
53 os_solaris_ata.s \
54 os_win32.cpp \
55 os_generic.cpp \
56 os_generic.h
57
58
59 if OS_WIN32_MINGW
60
61 smartd_SOURCES += \
62 posix/regex.h \
63 posix/regex.c \
64 os_win32/daemon_win32.h \
65 os_win32/daemon_win32.cpp \
66 os_win32/hostname_win32.h \
67 os_win32/hostname_win32.cpp \
68 os_win32/syslog.h \
69 os_win32/syslog_win32.cpp
70
71 # Included by regex.c:
72 EXTRA_smartd_SOURCES += \
73 posix/regcomp.c \
74 posix/regexec.c \
75 posix/regex_internal.c \
76 posix/regex_internal.h
77
78 endif
79
80 smartctl_SOURCES= smartctl.cpp \
81 smartctl.h \
82 atacmdnames.cpp \
83 atacmdnames.h \
84 atacmds.cpp \
85 atacmds.h \
86 ataprint.cpp \
87 ataprint.h \
88 extern.h \
89 int64.h \
90 knowndrives.cpp \
91 knowndrives.h \
92 scsicmds.cpp \
93 scsicmds.h \
94 scsiata.cpp \
95 scsiata.h \
96 scsiprint.cpp \
97 scsiprint.h \
98 utility.cpp \
99 utility.h
100
101 smartctl_LDADD = @os_deps@ @os_libs@
102 smartctl_DEPENDENCIES = @os_deps@
103
104 EXTRA_smartctl_SOURCES = os_linux.cpp \
105 os_linux.h \
106 os_freebsd.cpp \
107 os_freebsd.h \
108 os_netbsd.cpp \
109 os_netbsd.h \
110 os_openbsd.cpp \
111 os_openbsd.h \
112 os_solaris.cpp \
113 os_solaris.h \
114 os_win32.cpp \
115 os_generic.cpp \
116 os_generic.h
117
118 if OS_WIN32_MINGW
119
120 smartctl_SOURCES += \
121 posix/regex.h \
122 posix/regex.c \
123 os_win32/syslog.h
124
125 # Included by regex.c:
126 EXTRA_smartctl_SOURCES += \
127 posix/regcomp.c \
128 posix/regexec.c \
129 posix/regex_internal.c \
130 posix/regex_internal.h
131
132 endif
133
134 if OS_SOLARIS
135 # This block is required because Solaris uses manual page section 1m
136 # for administrative command (linux/freebsd use section 8) and Solaris
137 # uses manual page section 4 for file formats (linux/freebsd use
138 # section 5). Automake can deal cleanly with man page sections 1-8
139 # and n, but NOT with sections of the form 1m.
140 extra_MANS = smartd.conf.4 \
141 smartctl.1m \
142 smartd.1m
143 install-man: $(extra_MANS)
144 @$(NORMAL_INSTALL)
145 $(mkinstalldirs) $(DESTDIR)$(mandir)/man4
146 $(mkinstalldirs) $(DESTDIR)$(mandir)/man1m
147 for i in $(extra_MANS); do \
148 if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
149 else file=$$i; fi; \
150 ext=`echo $$i | sed -e 's/^.*\\.//'`; \
151 inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
152 inst=`echo $$inst | sed -e 's/^.*\///'`; \
153 inst=`echo $$inst | sed '$(transform)'`.$$ext; \
154 echo " $(INSTALL_DATA) $$file $(DESTDIR)$(mandir)/man$$ext/$$inst"; \
155 $(INSTALL_DATA) $$file $(DESTDIR)$(mandir)/man$$ext/$$inst; \
156 done
157 uninstall-man:
158 @$(NORMAL_UNINSTALL)
159 for i in $(extra_MANS); do \
160 if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
161 else file=$$i; fi; \
162 ext=`echo $$i | sed -e 's/^.*\\.//'`; \
163 inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
164 inst=`echo $$inst | sed -e 's/^.*\///'`; \
165 inst=`echo $$inst | sed '$(transform)'`.$$ext; \
166 echo " rm -f $(DESTDIR)$(mandir)/man$$ext/$$inst"; \
167 rm -f $(DESTDIR)$(mandir)/man$$ext/$$inst; \
168 done
169 %.1m: %.8
170 awk '/^.TH/ {$$3="1m"} {print}' < $< | \
171 sed -e 's/smartd\.conf\(.*\)(5)/smartd.conf\1(4)/g' \
172 -e 's/syslog\.conf\(.*\)(5)/syslog.conf\1(4)/g' \
173 -e 's/smartctl\(.*\)(8)/smartctl\1(1m)/g' \
174 -e 's/syslogd\(.*\)(8)/syslogd\1(1m)/g' \
175 -e 's|/var/log/messages|/var/adm/messages|g' \
176 -e 's/smartd\(.*\)(8)/smartd\1(1m)/g' > $@
177 %.4: %.5
178 awk '/^.TH/ {$$3="4"} {print}' < $< | \
179 sed -e 's/smartd\.conf\(.*\)(5)/smartd.conf\1(4)/g' \
180 -e 's/syslog\.conf\(.*\)(5)/syslog.conf\1(4)/g' \
181 -e 's/smartctl\(.*\)(8)/smartdctl\1(1m)/g' \
182 -e 's/syslogd\(.*\)(8)/syslogd\1(1m)/g' \
183 -e 's|/var/log/messages|/var/adm/messages|g' \
184 -e 's/smartd\(.*\)(8)/smartd\1(1m)/g' > $@
185 else
186 # For systems that adopts traditional manner
187 man_MANS = smartd.conf.5 \
188 smartctl.8 \
189 smartd.8
190 endif
191
192 docsdir=$(docdir)
193 docs_DATA = AUTHORS \
194 CHANGELOG \
195 COPYING \
196 INSTALL \
197 NEWS \
198 README \
199 TODO \
200 WARNINGS \
201 smartd.conf
202
203 sysconf_DATA = smartd.conf$(smartd_suffix)
204
205 if SMARTD_SUFFIX
206 smartd.conf$(smartd_suffix): smartd.conf
207 cp ${srcdir}/smartd.conf smartd.conf$(smartd_suffix)
208 endif
209
210 EXTRA_DIST = smartmontools.spec \
211 smartd.initd.in \
212 smartd.8.in \
213 smartctl.8.in \
214 smartd.conf.5.in \
215 smartd.conf \
216 autogen.sh \
217 os_darwin/SMART.in \
218 os_darwin/StartupParameters.plist \
219 os_darwin/English_Localizable.strings \
220 os_win32/installer.nsi \
221 $(docs_DATA)
222
223 CLEANFILES = smartd.conf.5 \
224 smartd.conf.4 \
225 smartd.8 \
226 smartd.1m \
227 smartd.8.html \
228 smartd.8.txt \
229 smartctl.8 \
230 smartctl.1m \
231 smartctl.8.html \
232 smartctl.8.txt \
233 smartd.conf.5.html \
234 smartd.conf.5.txt \
235 smartd.initd \
236 SMART
237
238 if SMARTD_SUFFIX
239 CLEANFILES += smartd.conf$(smartd_suffix)
240 endif
241
242
243 smartd.conf.5.in: smartd.8.in
244 sed '1,/STARTINCLUDE/ D;/ENDINCLUDE/,$$D' < $(srcdir)/smartd.8.in > $(top_builddir)/tmp.directives
245 sed '/STARTINCLUDE/,$$D' < $(srcdir)/smartd.conf.5.in > $(top_builddir)/tmp.head
246 sed '1,/ENDINCLUDE/D' < $(srcdir)/smartd.conf.5.in > $(top_builddir)/tmp.tail
247 cat $(top_builddir)/tmp.head > $(srcdir)/smartd.conf.5.in
248 echo '.\" STARTINCLUDE' >> $(srcdir)/smartd.conf.5.in
249 cat $(top_builddir)/tmp.directives >> $(srcdir)/smartd.conf.5.in
250 echo '.\" ENDINCLUDE' >> $(srcdir)/smartd.conf.5.in
251 cat $(top_builddir)/tmp.tail >> $(srcdir)/smartd.conf.5.in
252 rm -f $(top_builddir)/tmp.head $(top_builddir)/tmp.tail $(top_builddir)/tmp.directives
253
254 if OS_DARWIN
255 initd_DATA = SMART \
256 os_darwin/StartupParameters.plist \
257 os_darwin/English_Localizable.strings
258
259 initd_install_name = SMART
260
261 initd_DATA_install = install-initdDATA-darwin
262
263 SMART : os_darwin/SMART.in
264 sed "s|/usr/sbin/|$(sbindir)/|" $< > $@
265
266 install-initdDATA-darwin: $(initd_DATA)
267 $(mkinstalldirs) $(DESTDIR)$(initddir)
268 $(mkinstalldirs) $(DESTDIR)$(initddir)/SMART
269 $(mkinstalldirs) $(DESTDIR)$(initddir)/SMART/Resources
270 $(INSTALL_SCRIPT) $(top_builddir)/SMART $(DESTDIR)$(initddir)/SMART
271 $(INSTALL_DATA) $(srcdir)/os_darwin/StartupParameters.plist \
272 $(DESTDIR)$(initddir)/SMART/StartupParameters.plist
273 for i in English ; do \
274 RDIR=$(DESTDIR)$(initddir)/SMART/Resources/$${i}.lproj ; \
275 $(mkinstalldirs) $$RDIR ;\
276 $(INSTALL_DATA) $(srcdir)/os_darwin/$${i}_Localizable.strings \
277 $$RDIR/Localizable.strings ; \
278 done
279 @echo -e "\n\n####################################################################\n#"
280 @echo -e "# PLEASE READ THIS BOX!\n#"
281 @echo -e "# To manually start the smartd daemon, run:\n# ${initddir}/SMART/SMART start\n#"
282 @echo -e "# To automatically start smartd on bootup, add the line:\n# SMARTd=-YES-\n# to /etc/hostconfig\n#"
283 @echo -e "# smartd can now use a configuration file ${sysconfdir}/smartd.conf. Do:\n# man smartd"
284 @echo -e "# to learn about it. A sample configuration file can be found in:\n# ${docdir}\n#"
285 @echo -e "####################################################################\n\n"
286
287 else
288
289 initd_DATA = smartd.initd
290
291 smartd.initd: $(srcdir)/smartd.initd.in Makefile
292 sed "s|/usr/local/sbin/|$(sbindir)/|g" $(srcdir)/smartd.initd.in > $@
293
294 initd_install_name = smartd$(smartd_suffix)
295
296 initd_DATA_install = install-initdDATA-generic
297
298 install-initdDATA-generic: $(initd_DATA)
299 $(mkinstalldirs) $(DESTDIR)$(initddir)
300 $(INSTALL_SCRIPT) $(top_builddir)/smartd.initd $(DESTDIR)$(initddir)/smartd$(smartd_suffix)
301 @echo -e "\n\n####################################################################\n#"
302 @echo -e "# PLEASE READ THIS BOX!\n#"
303 @echo -e "# To manually start the smartd daemon, run:\n# ${initddir}/smartd start\n#"
304 @echo -e "# To automatically start smartd on bootup, run:\n# /sbin/chkconfig --add smartd\n#"
305 @echo -e "# smartd can now use a configuration file ${sysconfdir}/smartd.conf. Do:\n# man smartd"
306 @echo -e "# to learn about it. A sample configuration file can be found in:\n# ${docdir}\n#"
307 @echo -e "####################################################################\n\n"
308
309 endif
310
311 install-initdDATA : $(initd_DATA_install)
312
313 uninstall-initdDATA:
314 rm -rf $(DESTDIR)$(initddir)/$(initd_install_name)
315
316 uninstall-docsDATA:
317 rm -rf $(DESTDIR)$(docsdir)
318
319 smart%: $(srcdir)/smart%.in Makefile
320 sed "s|CURRENT_CVS_VERSION|$(releaseversion)|g" $< | \
321 sed "s|CURRENT_CVS_DATE|$(smartmontools_release_date)|g" | \
322 sed "s|CURRENT_CVS_TIME|$(smartmontools_release_time)|g" | \
323 sed "s|/usr/local/share/man/|$(mandir)/|g" | \
324 sed "s|/usr/local/sbin/|$(sbindir)/|g" | \
325 sed "s|/usr/local/etc/rc\\.d/init.d/|$(initddir)/|g" | \
326 sed "s|/usr/local/share/doc/smartmontools-5.1/|$(docsdir)/|g" | \
327 sed "s|/usr/local/etc/smartd\\.conf|$(sysconfdir)/smartd.conf|g" > $@
328
329
330 # Commands to convert man pages into .html and .txt
331 # TODO: configure
332 MAN2HTML = man2html
333 #MAN2HTML = groff -man -Thtml
334 MAN2TXT = groff -man -Tascii -P'-bcou'
335
336 # Remove HTTP header and fix links in man2html output
337 FIXHTML = sed '1s,^Content-type.*,,' \
338 | sed 's,<A HREF="http://[-a-z/]*/man2html?\([1-8]\)+\(smart[cd][.a-z]*\)">,<A HREF="\2.\1.html">,g' \
339 | sed 's,<A HREF="http://[-a-z/]*/man2html">,<A HREF=".">,g' \
340 | sed 's,<A HREF="http://[-a-z/]*/man2html?[^"]*">\([^<]*\)</A>,\1,g' \
341 | sed 's,<A HREF="mailto:[^s][^m][^a][^"]*">\([^<]*\)</A>,\1,g'
342
343 # Convert man pages into .html and .txt
344
345 htmlman: smartctl.8.html smartd.8.html smartd.conf.5.html
346
347 txtman: smartctl.8.txt smartd.8.txt smartd.conf.5.txt
348
349 if OS_WIN32_MINGW
350
351 %.5.html: %.5
352 $(DOS2UNIX) < $< | $(MAN2HTML) | $(FIXHTML) > $@
353
354 %.8.html: %.8
355 $(DOS2UNIX) < $< | $(MAN2HTML) | $(FIXHTML) > $@
356 else
357
358 %.5.html: %.5
359 $(MAN2HTML) $< | $(FIXHTML) > $@
360
361 %.8.html: %.8
362 $(MAN2HTML) $< | $(FIXHTML) > $@
363 endif
364
365 %.5.txt: %.5
366 $(MAN2TXT) $< > $@
367
368 %.8.txt: %.8
369 $(MAN2TXT) $< > $@
370
371
372
373 if OS_WIN32_MINGW
374 # Definitions for Windows distribution
375
376 distdir_win32 = $(PACKAGE)-$(VERSION).win32
377 distzip_win32 = $(PACKAGE)-$(VERSION).win32.zip
378 distinst_win32= $(PACKAGE)-$(VERSION).win32-setup.exe
379
380 exedir_win32 = $(distdir_win32)/bin
381 docdir_win32 = $(distdir_win32)/doc
382
383 FILES_WIN32 = $(exedir_win32)/smartctl.exe \
384 $(exedir_win32)/smartd.exe \
385 $(docdir_win32)/AUTHORS.txt \
386 $(docdir_win32)/CHANGELOG.txt \
387 $(docdir_win32)/COPYING.txt \
388 $(docdir_win32)/INSTALL.txt \
389 $(docdir_win32)/NEWS.txt \
390 $(docdir_win32)/README.txt \
391 $(docdir_win32)/TODO.txt \
392 $(docdir_win32)/WARNINGS.txt \
393 $(docdir_win32)/smartd.conf \
394 $(docdir_win32)/smartctl.8.html \
395 $(docdir_win32)/smartctl.8.txt \
396 $(docdir_win32)/smartd.8.html \
397 $(docdir_win32)/smartd.8.txt \
398 $(docdir_win32)/smartd.conf.5.html \
399 $(docdir_win32)/smartd.conf.5.txt
400
401 CLEANFILES += $(FILES_WIN32) $(exedir_win32)/syslogevt.exe distdir.mkdir syslogevt.check
402
403 # Textfile converter from cygutils
404 UNIX2DOS = unix2dos -D
405 DOS2UNIX = dos2unix -U
406
407 # Build Windows distribution
408
409 dist-win32: $(distzip_win32)
410
411 install-win32: $(distinst_win32)
412 ./$(distinst_win32)
413
414 installer-win32: $(distinst_win32)
415
416 distdir-win32: distdir.mkdir $(FILES_WIN32) syslogevt.check
417
418 $(distzip_win32): distdir.mkdir $(FILES_WIN32) syslogevt.check
419 @rm -fv $(distzip_win32)
420 cd $(distdir_win32) && zip -9Dr ../$(distzip_win32) .
421
422 # Build NSIS installer, try to locate makensis in default location first
423 $(distinst_win32): $(srcdir)/os_win32/installer.nsi distdir.mkdir $(FILES_WIN32) syslogevt.check
424 @makensis="$(MAKENSIS)"; if [ -z "$$makensis" ]; then \
425 if [ ! -z "$$PROGRAMFILES" ] && "$$PROGRAMFILES/NSIS/makensis" /VERSION >/dev/null 2>&1; then \
426 makensis="$$PROGRAMFILES/NSIS/makensis"; \
427 elif makensis /VERSION >/dev/null 2>&1; then \
428 makensis=makensis; \
429 else \
430 echo 'makensis: command not found. Please download and install NSIS' 1>&2; \
431 echo 'from http://nsis.sourceforge.net/Download' 1>&2; exit 1; \
432 fi; \
433 fi; \
434 echo "$$makensis /V2 /NOCD /DINPDIR=$(distdir_win32) /DOUTFILE=$(distinst_win32) $(srcdir)/os_win32/installer.nsi"; \
435 "$$makensis" /V2 /NOCD /DINPDIR="$(distdir_win32)" /DOUTFILE="$(distinst_win32)" "$(srcdir)/os_win32/installer.nsi"
436
437 cleandist-win32:
438 rm -rf $(distdir_win32) distdir.mkdir syslogevt.check
439
440 distdir.mkdir:
441 @test -d $(exedir_win32) || mkdir -pv $(exedir_win32)
442 @test -d $(docdir_win32) || mkdir -pv $(docdir_win32)
443 touch $@
444
445 syslogevt.check:
446 @if [ -f $(srcdir)/os_win32/syslogevt.exe ]; then \
447 cp -pv $(srcdir)/os_win32/syslogevt.exe $(exedir_win32)/syslogevt.exe; \
448 else echo "Warning: $(srcdir)/os_win32/syslogevt.exe missing."; fi
449 touch $@
450
451 $(exedir_win32)/%.exe: %.exe
452 cp -p $< $@
453 strip -s $@
454 touch -r $< $@
455
456 $(docdir_win32)/%: %
457 $(UNIX2DOS) < $< > $@
458 touch -r $< $@
459
460 $(docdir_win32)/%.txt: $(srcdir)/%
461 $(UNIX2DOS) < $< > $@
462 touch -r $< $@
463
464 $(docdir_win32)/%.conf: $(srcdir)/%.conf
465 $(UNIX2DOS) < $< > $@
466 touch -r $< $@
467
468
469 # Build config_vc6.h for MSVC 6 from MinGW config.h
470
471 config-vc6: $(srcdir)/os_win32/config_vc6.h
472
473 $(srcdir)/os_win32/config_vc6.h: config.h
474 sed '1i/* config_vc6.h. Generated by Makefile. */' $< | \
475 sed 's,^#define HAVE_\(ATTR_PACKED\|INTTYPES_H\|STDINT_H\|STRINGS_H\|STRTOULL\|U*INT64_T\|UNISTD_H\) 1$$,/* #undef HAVE_\1 */,' | \
476 sed 's,i.86-pc-mingw32,i686-pc-win32vc6,' > $@
477
478 endif
479
480 SUBDIRS= . examplescripts