1 ## Process this file with automake to produce Makefile.in
3 # $Id: Makefile.am 3059 2010-02-03 21:42:09Z chrfranke $
8 # Make sure .cpp takes precedence to avoid compiling old .c file
9 SUFFIXES = .cpp .c .s .o
11 # BUILD_INFO can be provided by package maintainers (see INSTALL file)
12 BUILD_INFO= "(local build)"
14 AM_CPPFLAGS = -DBUILD_INFO='$(BUILD_INFO)' -DSMARTMONTOOLS_SYSCONFDIR='"$(sysconfdir)"'
16 AM_CPPFLAGS += -DSMARTMONTOOLS_DRIVEDBDIR='"$(drivedbdir)"'
19 AM_CPPFLAGS += -DSMARTMONTOOLS_SAVESTATES='"$(savestates)"'
21 if ENABLE_ATTRIBUTELOG
22 AM_CPPFLAGS += -DSMARTMONTOOLS_ATTRIBUTELOG='"$(attributelog)"'
25 sbin_PROGRAMS = smartd \
28 smartd_SOURCES = smartd.cpp \
49 smartd_LDADD = @os_deps@ @os_libs@ @CAPNG_LDADD@
50 smartd_DEPENDENCIES = @os_deps@
52 EXTRA_smartd_SOURCES = os_darwin.cpp \
79 os_win32/daemon_win32.h \
80 os_win32/daemon_win32.cpp \
81 os_win32/hostname_win32.h \
82 os_win32/hostname_win32.cpp \
84 os_win32/syslog_win32.cpp
86 # Included by regex.c:
87 EXTRA_smartd_SOURCES += \
90 posix/regex_internal.c \
91 posix/regex_internal.h
95 smartctl_SOURCES= smartctl.cpp \
103 dev_ata_cmd_set.cpp \
122 smartctl_LDADD = @os_deps@ @os_libs@
123 smartctl_DEPENDENCIES = @os_deps@
125 EXTRA_smartctl_SOURCES = os_linux.cpp \
145 smartctl_SOURCES += \
150 # Included by regex.c:
151 EXTRA_smartctl_SOURCES += \
154 posix/regex_internal.c \
155 posix/regex_internal.h
160 # This block is required because Solaris uses manual page section 1m
161 # for administrative command (linux/freebsd use section 8) and Solaris
162 # uses manual page section 4 for file formats (linux/freebsd use
163 # section 5). Automake can deal cleanly with man page sections 1-8
164 # and n, but NOT with sections of the form 1m.
165 extra_MANS = smartd.conf.4 \
168 install-man: $(extra_MANS)
170 $(mkinstalldirs) $(DESTDIR)$(mandir)/man4
171 $(mkinstalldirs) $(DESTDIR)$(mandir)/man1m
172 for i in $(extra_MANS); do \
173 if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
175 ext=`echo $$i | sed -e 's/^.*\\.//'`; \
176 inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
177 inst=`echo $$inst | sed -e 's/^.*\///'`; \
178 inst=`echo $$inst | sed '$(transform)'`.$$ext; \
179 echo " $(INSTALL_DATA) $$file $(DESTDIR)$(mandir)/man$$ext/$$inst"; \
180 $(INSTALL_DATA) $$file $(DESTDIR)$(mandir)/man$$ext/$$inst; \
184 for i in $(extra_MANS); do \
185 if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
187 ext=`echo $$i | sed -e 's/^.*\\.//'`; \
188 inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
189 inst=`echo $$inst | sed -e 's/^.*\///'`; \
190 inst=`echo $$inst | sed '$(transform)'`.$$ext; \
191 echo " rm -f $(DESTDIR)$(mandir)/man$$ext/$$inst"; \
192 rm -f $(DESTDIR)$(mandir)/man$$ext/$$inst; \
195 awk '/^.TH/ {$$3="1m"} {print}' < $< | \
196 sed -e 's/smartd\.conf\(.*\)(5)/smartd.conf\1(4)/g' \
197 -e 's/syslog\.conf\(.*\)(5)/syslog.conf\1(4)/g' \
198 -e 's/smartctl\(.*\)(8)/smartctl\1(1m)/g' \
199 -e 's/syslogd\(.*\)(8)/syslogd\1(1m)/g' \
200 -e 's|/var/log/messages|/var/adm/messages|g' \
201 -e 's/smartd\(.*\)(8)/smartd\1(1m)/g' > $@
203 awk '/^.TH/ {$$3="4"} {print}' < $< | \
204 sed -e 's/smartd\.conf\(.*\)(5)/smartd.conf\1(4)/g' \
205 -e 's/syslog\.conf\(.*\)(5)/syslog.conf\1(4)/g' \
206 -e 's/smartctl\(.*\)(8)/smartdctl\1(1m)/g' \
207 -e 's/syslogd\(.*\)(8)/syslogd\1(1m)/g' \
208 -e 's|/var/log/messages|/var/adm/messages|g' \
209 -e 's/smartd\(.*\)(8)/smartd\1(1m)/g' > $@
211 # For systems that adopts traditional manner
212 man_MANS = smartd.conf.5 \
218 docs_DATA = AUTHORS \
228 sysconf_DATA = smartd.conf$(smartd_suffix)
231 smartd.conf$(smartd_suffix): smartd.conf
232 cp ${srcdir}/smartd.conf smartd.conf$(smartd_suffix)
235 EXTRA_DIST = smartd.initd.in \
242 os_darwin/StartupParameters.plist \
243 os_darwin/English_Localizable.strings \
244 os_win32/installer.nsi \
247 CLEANFILES = smartd.conf.5 \
264 CLEANFILES += smartd.conf$(smartd_suffix)
267 # 'make maintainer-clean' also removes files generated by './autogen.sh'
268 MAINTAINERCLEANFILES = \
269 $(srcdir)/Makefile.in \
270 $(srcdir)/aclocal.m4 \
271 $(srcdir)/configure \
272 $(srcdir)/config.guess \
273 $(srcdir)/config.h.in \
274 $(srcdir)/config.h.in~ \
275 $(srcdir)/config.sub \
277 $(srcdir)/install-sh \
279 $(srcdir)/mkinstalldirs
281 utility.o: svnversion.h
284 # Get version info from SVN
285 svnversion.h: CHANGELOG Makefile $(srcdir)/.svn/entries
286 echo '/* svnversion.h. Generated by Makefile from svn info. */' > $@
288 && svnversion 2>/dev/null | sed -n 's,^\([0-9].*\),REV "\1",p' \
289 && TZ= LC_ALL=C svn info 2>/dev/null \
290 | sed -n 'h;s,^.* Date: *\([^ ]*\) .*$$,DATE "\1",p;g;s,^.* Date: *[^ ]* *\([^ ]*\) .*$$,TIME "\1",p') \
291 | sed 's,^,#define SMARTMONTOOLS_SVN_,' >> $@
294 # SVN not available, guess version info from Id strings
295 svnversion.h: CHANGELOG Makefile
296 echo '/* svnversion.h. Generated by Makefile from Id strings. */' > $@
297 (cd $(srcdir) && cat CHANGELOG Makefile.am configure.in smart*.in *.cpp *.h *.s) \
298 | sed -n 's,^.*\$$[I][d]: [^ ]* \([0-9][0-9]* [0-9][-0-9]* [0-9][:0-9]*\)[^:0-9][^$$]*\$$.*$$,\1,p' \
300 | sed -n 'h;s,^\([^ ]*\) .*$$,REV "\1",p;g;s,^[^ ]* \([^ ]*\) .*$$,DATE "\1",p;g;s,^[^ ]* [^ ]* \([^ ]*\)$$,TIME "\1",p;q' \
301 | sed 's,^,#define SMARTMONTOOLS_SVN_,' >> $@
306 drivedb_DATA = drivedb.h
310 # Create $(savestatesdir) only
314 if ENABLE_ATTRIBUTELOG
315 # Create $(attributelogdir) only
319 smartd.conf.5.in: smartd.8.in
320 sed '1,/STARTINCLUDE/ D;/ENDINCLUDE/,$$D' < $(srcdir)/smartd.8.in > $(top_builddir)/tmp.directives
321 sed '/STARTINCLUDE/,$$D' < $(srcdir)/smartd.conf.5.in > $(top_builddir)/tmp.head
322 sed '1,/ENDINCLUDE/D' < $(srcdir)/smartd.conf.5.in > $(top_builddir)/tmp.tail
323 cat $(top_builddir)/tmp.head > $(srcdir)/smartd.conf.5.in
324 echo '.\" STARTINCLUDE' >> $(srcdir)/smartd.conf.5.in
325 cat $(top_builddir)/tmp.directives >> $(srcdir)/smartd.conf.5.in
326 echo '.\" ENDINCLUDE' >> $(srcdir)/smartd.conf.5.in
327 cat $(top_builddir)/tmp.tail >> $(srcdir)/smartd.conf.5.in
328 rm -f $(top_builddir)/tmp.head $(top_builddir)/tmp.tail $(top_builddir)/tmp.directives
330 if INSTALL_INITSCRIPT
333 os_darwin/StartupParameters.plist \
334 os_darwin/English_Localizable.strings
336 initd_install_name = SMART
338 initd_DATA_install = install-initdDATA-darwin
339 initd_DATA_uninstall = uninstall-initdDATA-darwin
341 SMART : os_darwin/SMART.in
342 sed "s|/usr/sbin/|$(sbindir)/|" $< > $@
344 install-initdDATA-darwin: $(initd_DATA)
345 $(mkinstalldirs) $(DESTDIR)$(initddir)
346 $(mkinstalldirs) $(DESTDIR)$(initddir)/SMART
347 $(mkinstalldirs) $(DESTDIR)$(initddir)/SMART/Resources
348 $(INSTALL_SCRIPT) $(top_builddir)/SMART $(DESTDIR)$(initddir)/SMART
349 $(INSTALL_DATA) $(srcdir)/os_darwin/StartupParameters.plist \
350 $(DESTDIR)$(initddir)/SMART/StartupParameters.plist
351 for i in English ; do \
352 RDIR=$(DESTDIR)$(initddir)/SMART/Resources/$${i}.lproj ; \
353 $(mkinstalldirs) $$RDIR ;\
354 $(INSTALL_DATA) $(srcdir)/os_darwin/$${i}_Localizable.strings \
355 $$RDIR/Localizable.strings ; \
357 @echo -e "\n\n####################################################################\n#"
358 @echo -e "# PLEASE READ THIS BOX!\n#"
359 @echo -e "# To manually start the smartd daemon, run:\n# ${initddir}/SMART/SMART start\n#"
360 @echo -e "# To automatically start smartd on bootup, add the line:\n# SMARTd=-YES-\n# to /etc/hostconfig\n#"
361 @echo -e "# smartd can now use a configuration file ${sysconfdir}/smartd.conf. Do:\n# man smartd"
362 @echo -e "# to learn about it. A sample configuration file can be found in:\n# ${docdir}\n#"
363 @echo -e "####################################################################\n\n"
365 uninstall-initdDATA-darwin:
366 rm -rf $(DESTDIR)$(initddir)/$(initd_install_name)
370 initd_DATA = smartd.initd
372 smartd.initd: $(srcdir)/smartd.initd.in Makefile
373 sed "s|/usr/local/sbin/|$(sbindir)/|g" $(srcdir)/smartd.initd.in > $@
375 initd_install_name = smartd$(smartd_suffix)
377 initd_DATA_install = install-initdDATA-generic
378 initd_DATA_uninstall = uninstall-initdDATA-generic
380 install-initdDATA-generic: $(initd_DATA)
381 $(mkinstalldirs) $(DESTDIR)$(initddir)
382 $(INSTALL_SCRIPT) $(top_builddir)/smartd.initd $(DESTDIR)$(initddir)/smartd$(smartd_suffix)
383 @echo -e "\n\n####################################################################\n#"
384 @echo -e "# PLEASE READ THIS BOX!\n#"
385 @echo -e "# To manually start the smartd daemon, run:\n# ${initddir}/smartd start\n#"
386 @echo -e "# To automatically start smartd on bootup, run:\n# /sbin/chkconfig --add smartd\n#"
387 @echo -e "# smartd can now use a configuration file ${sysconfdir}/smartd.conf. Do:\n# man smartd"
388 @echo -e "# to learn about it. A sample configuration file can be found in:\n# ${docdir}\n#"
389 @echo -e "####################################################################\n\n"
392 uninstall-initdDATA-generic:
393 rm -rf $(DESTDIR)$(initddir)/$(initd_install_name)
397 initd_DATA_install = install-initdDATA-null
398 initd_DATA_uninstall = uninstall-initdDATA-null
400 install-initdDATA-null:
401 uninstall-initdDATA-null:
404 install-initdDATA : $(initd_DATA_install)
406 uninstall-initdDATA: $(initd_DATA_uninstall)
408 if ENABLE_CAPABILITIES
409 MAN_CAPABILITIES = cat
411 MAN_CAPABILITIES = sed '/BEGIN ENABLE_CAPABILITIES/,/END ENABLE_CAPABILITIES/d'
415 MAN_DRIVEDB = sed "s|/usr/local/share/smartmontools/drivedb\\.h|$(drivedbdir)/drivedb.h|g"
417 MAN_DRIVEDB = sed '/BEGIN ENABLE_DRIVEDB/,/END ENABLE_DRIVEDB/d'
421 MAN_SAVESTATES = sed "s|/usr/local/var/lib/smartmontools/smartd\\.|$(savestates)|g"
423 MAN_SAVESTATES = sed '/BEGIN ENABLE_SAVESTATES/,/END ENABLE_SAVESTATES/d'
426 if ENABLE_ATTRIBUTELOG
427 MAN_ATTRIBUTELOG = sed "s|/usr/local/var/lib/smartmontools/attrlog\\.|$(attributelog)|g"
429 MAN_ATTRIBUTELOG = sed '/BEGIN ENABLE_ATTRIBUTELOG/,/END ENABLE_ATTRIBUTELOG/d'
433 sed "s|CURRENT_CVS_VERSION|$(releaseversion)|g; \
434 s|CURRENT_CVS_DATE|`sed -n 's,^.*DATE[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g; \
435 s|CURRENT_CVS_TIME|`sed -n 's,^.*TIME[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g; \
436 s|/usr/local/share/man/|$(mandir)/|g; \
437 s|/usr/local/sbin/|$(sbindir)/|g; \
438 s|/usr/local/etc/rc\\.d/init.d/|$(initddir)/|g; \
439 s|/usr/local/share/doc/smartmontools-5.1/|$(docsdir)/|g; \
440 s|/usr/local/etc/smartd\\.conf|$(sysconfdir)/smartd.conf|g; \
441 s|/usr/local/etc/smart_drivedb\\.h|$(sysconfdir)/smart_drivedb\\.h|g" | \
442 $(MAN_CAPABILITIES) | \
444 $(MAN_SAVESTATES) | \
448 .for file in $(man_MANS)
449 ${file}: $(srcdir)/${file}.in Makefile svnversion.h
450 cat ${.ALLSRC:M*.in} | $(MAN_FILTER) > $@
453 smart%: $(srcdir)/smart%.in Makefile svnversion.h
454 cat $< | $(MAN_FILTER) > $@
457 # Commands to convert man pages into .html and .txt
460 #MAN2HTML = groff -man -Thtml
461 MAN2TXT = groff -man -Tascii -P'-bcou'
463 # Remove HTTP header and fix links in man2html output
464 FIXHTML = sed '1s,^Content-type.*,,' \
465 | sed 's,<A HREF="http://[-a-z/]*/man2html?\([1-8]\)+\(smart[cd][.a-z]*\)">,<A HREF="\2.\1.html">,g' \
466 | sed 's,<A HREF="http://[-a-z/]*/man2html">,<A HREF=".">,g' \
467 | sed 's,<A HREF="http://[-a-z/]*/man2html?[^"]*">\([^<]*\)</A>,\1,g' \
468 | sed 's,<A HREF="mailto:[^s][^m][^a][^"]*">\([^<]*\)</A>,\1,g'
470 # Convert man pages into .html and .txt
472 htmlman: smartctl.8.html smartd.8.html smartd.conf.5.html
474 txtman: smartctl.8.txt smartd.8.txt smartd.conf.5.txt
479 $(DOS2UNIX) < $< | $(MAN2HTML) | $(FIXHTML) > $@
482 $(DOS2UNIX) < $< | $(MAN2HTML) | $(FIXHTML) > $@
486 $(MAN2HTML) $< | $(FIXHTML) > $@
489 $(MAN2HTML) $< | $(FIXHTML) > $@
499 # Check drive database syntax
501 @if ./smartctl -B $(srcdir)/drivedb.h -P showall >/dev/null; then \
502 echo "$(srcdir)/drivedb.h: OK"; \
504 echo "$(srcdir)/drivedb.h: Syntax check failed"; exit 1; \
509 # Definitions for Windows distribution
511 distdir_win32 = $(PACKAGE)-$(VERSION).win32
512 distzip_win32 = $(PACKAGE)-$(VERSION).win32.zip
513 distinst_win32= $(PACKAGE)-$(VERSION).win32-setup.exe
515 exedir_win32 = $(distdir_win32)/bin
516 docdir_win32 = $(distdir_win32)/doc
518 FILES_WIN32 = $(exedir_win32)/smartctl.exe \
519 $(exedir_win32)/smartctl-nc.exe \
520 $(exedir_win32)/smartd.exe \
521 $(docdir_win32)/AUTHORS.txt \
522 $(docdir_win32)/CHANGELOG.txt \
523 $(docdir_win32)/COPYING.txt \
524 $(docdir_win32)/INSTALL.txt \
525 $(docdir_win32)/NEWS.txt \
526 $(docdir_win32)/README.txt \
527 $(docdir_win32)/TODO.txt \
528 $(docdir_win32)/WARNINGS.txt \
529 $(docdir_win32)/smartd.conf \
530 $(docdir_win32)/smartctl.8.html \
531 $(docdir_win32)/smartctl.8.txt \
532 $(docdir_win32)/smartd.8.html \
533 $(docdir_win32)/smartd.8.txt \
534 $(docdir_win32)/smartd.conf.5.html \
535 $(docdir_win32)/smartd.conf.5.txt
537 CLEANFILES += $(FILES_WIN32) $(exedir_win32)/syslogevt.exe \
538 smartctl-nc.exe smartctl-nc.exe.tmp \
539 distdir.mkdir syslogevt.check
541 # Textfile converter from cygutils
542 UNIX2DOS = unix2dos -D
543 DOS2UNIX = dos2unix -U
545 # Build Windows distribution
547 dist-win32: $(distzip_win32)
549 install-win32: $(distinst_win32)
552 installer-win32: $(distinst_win32)
554 distdir-win32: distdir.mkdir $(FILES_WIN32) syslogevt.check
556 $(distzip_win32): distdir.mkdir $(FILES_WIN32) syslogevt.check
557 @rm -fv $(distzip_win32)
558 cd $(distdir_win32) && zip -9Dr ../$(distzip_win32) .
560 # Build NSIS installer, try to locate makensis in default location first
561 $(distinst_win32): $(srcdir)/os_win32/installer.nsi distdir.mkdir $(FILES_WIN32) syslogevt.check
562 @makensis="$(MAKENSIS)"; if [ -z "$$makensis" ]; then \
563 if [ ! -z "$$PROGRAMFILES" ] && "$$PROGRAMFILES/NSIS/makensis" /VERSION >/dev/null 2>&1; then \
564 makensis="$$PROGRAMFILES/NSIS/makensis"; \
565 elif makensis /VERSION >/dev/null 2>&1; then \
568 echo 'makensis: command not found. Please download and install NSIS' 1>&2; \
569 echo 'from http://nsis.sourceforge.net/Download' 1>&2; exit 1; \
572 date=`sed -n 's,^.*DATE[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`; \
573 rev=`sed -n 's,^.*REV[^"]*"\([^"]*\)".*$$,r\1,p' svnversion.h`; \
574 verstr="$(PACKAGE_VERSION) $$date $$rev "$(BUILD_INFO); \
575 echo "$$makensis /V2 /NOCD /DINPDIR=$(distdir_win32) /DOUTFILE=$(distinst_win32) /DVERSTR='$$verstr' $(srcdir)/os_win32/installer.nsi"; \
576 "$$makensis" /V2 /NOCD /DINPDIR="$(distdir_win32)" /DOUTFILE="$(distinst_win32)" /DVERSTR="$$verstr" "$(srcdir)/os_win32/installer.nsi"
579 rm -rf $(distdir_win32) distdir.mkdir syslogevt.check
582 @test -d $(exedir_win32) || mkdir -pv $(exedir_win32)
583 @test -d $(docdir_win32) || mkdir -pv $(docdir_win32)
587 @if [ -f $(srcdir)/os_win32/syslogevt.exe ]; then \
588 cp -pv $(srcdir)/os_win32/syslogevt.exe $(exedir_win32)/syslogevt.exe; \
589 else echo "Warning: $(srcdir)/os_win32/syslogevt.exe missing."; fi
592 $(exedir_win32)/%.exe: %.exe
597 $(docdir_win32)/%.html: %.html
598 $(UNIX2DOS) < $< > $@
601 $(docdir_win32)/%.txt: %.txt
602 $(UNIX2DOS) < $< > $@
605 $(docdir_win32)/%.txt: $(srcdir)/%
606 $(UNIX2DOS) < $< > $@
609 $(docdir_win32)/%.conf: $(srcdir)/%.conf
610 $(UNIX2DOS) < $< > $@
613 # Build non-console version of smartctl for GSmartControl.
614 # The script below changes the word at offset 220 (Subsystem) from 3
615 # (Console) to 2 (GUI) in a copy of smartctl.exe.
616 # This will be changed when a tool (like 'editbin') is available in
617 # the Cygwin distribution
618 smartctl-nc.exe: smartctl.exe
620 cp -p smartctl.exe $@.tmp
621 @if test `od -A n -j 220 -N 2 -d $@.tmp` -eq 3; then :; \
622 else echo "invalid EXE header"; exit 1; fi
623 @echo "editbin /subsystem:windows $@.tmp"
624 @echo -ne '\002' | dd bs=1 seek=220 count=1 conv=notrunc of=$@.tmp 2>/dev/null
625 @if test `od -A n -j 220 -N 2 -d $@.tmp` -eq 2; then :; \
626 else echo "EXE patch failed"; exit 1; fi
630 # Build {config,svnversion}_vc8.h for MSVC8 from MinGW {config,svnversion}.h
632 config-vc8: $(srcdir)/os_win32/config_vc8.h $(srcdir)/os_win32/svnversion_vc8.h
634 $(srcdir)/os_win32/config_vc8.h: config.h
635 sed '1i/* config_vc8.h. Generated from config.h by Makefile. */' $< | \
636 sed 's,^#define HAVE_\(ATTR_PACKED\|INTTYPES_H\|STDINT_H\|STRINGS_H\|STRTOULL\|U*INT64_T\|UNISTD_H\|WORKING_SNPRINTF\) 1$$,/* #undef HAVE_\1 */,' | \
637 sed 's,i.86-pc-mingw32,i686-pc-win32vc8,' > $@
639 $(srcdir)/os_win32/svnversion_vc8.h: svnversion.h
644 SUBDIRS= . examplescripts