1 ## Process this file with automake to produce Makefile.in
3 # $Id: Makefile.am 2878 2009-08-26 20:03:06Z 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 \
48 smartd_LDADD = @os_deps@ @os_libs@
49 smartd_DEPENDENCIES = @os_deps@
51 EXTRA_smartd_SOURCES = os_darwin.cpp \
78 os_win32/daemon_win32.h \
79 os_win32/daemon_win32.cpp \
80 os_win32/hostname_win32.h \
81 os_win32/hostname_win32.cpp \
83 os_win32/syslog_win32.cpp
85 # Included by regex.c:
86 EXTRA_smartd_SOURCES += \
89 posix/regex_internal.c \
90 posix/regex_internal.h
94 smartctl_SOURCES= smartctl.cpp \
102 dev_ata_cmd_set.cpp \
120 smartctl_LDADD = @os_deps@ @os_libs@
121 smartctl_DEPENDENCIES = @os_deps@
123 EXTRA_smartctl_SOURCES = os_linux.cpp \
143 smartctl_SOURCES += \
148 # Included by regex.c:
149 EXTRA_smartctl_SOURCES += \
152 posix/regex_internal.c \
153 posix/regex_internal.h
158 # This block is required because Solaris uses manual page section 1m
159 # for administrative command (linux/freebsd use section 8) and Solaris
160 # uses manual page section 4 for file formats (linux/freebsd use
161 # section 5). Automake can deal cleanly with man page sections 1-8
162 # and n, but NOT with sections of the form 1m.
163 extra_MANS = smartd.conf.4 \
166 install-man: $(extra_MANS)
168 $(mkinstalldirs) $(DESTDIR)$(mandir)/man4
169 $(mkinstalldirs) $(DESTDIR)$(mandir)/man1m
170 for i in $(extra_MANS); do \
171 if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
173 ext=`echo $$i | sed -e 's/^.*\\.//'`; \
174 inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
175 inst=`echo $$inst | sed -e 's/^.*\///'`; \
176 inst=`echo $$inst | sed '$(transform)'`.$$ext; \
177 echo " $(INSTALL_DATA) $$file $(DESTDIR)$(mandir)/man$$ext/$$inst"; \
178 $(INSTALL_DATA) $$file $(DESTDIR)$(mandir)/man$$ext/$$inst; \
182 for i in $(extra_MANS); do \
183 if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
185 ext=`echo $$i | sed -e 's/^.*\\.//'`; \
186 inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
187 inst=`echo $$inst | sed -e 's/^.*\///'`; \
188 inst=`echo $$inst | sed '$(transform)'`.$$ext; \
189 echo " rm -f $(DESTDIR)$(mandir)/man$$ext/$$inst"; \
190 rm -f $(DESTDIR)$(mandir)/man$$ext/$$inst; \
193 awk '/^.TH/ {$$3="1m"} {print}' < $< | \
194 sed -e 's/smartd\.conf\(.*\)(5)/smartd.conf\1(4)/g' \
195 -e 's/syslog\.conf\(.*\)(5)/syslog.conf\1(4)/g' \
196 -e 's/smartctl\(.*\)(8)/smartctl\1(1m)/g' \
197 -e 's/syslogd\(.*\)(8)/syslogd\1(1m)/g' \
198 -e 's|/var/log/messages|/var/adm/messages|g' \
199 -e 's/smartd\(.*\)(8)/smartd\1(1m)/g' > $@
201 awk '/^.TH/ {$$3="4"} {print}' < $< | \
202 sed -e 's/smartd\.conf\(.*\)(5)/smartd.conf\1(4)/g' \
203 -e 's/syslog\.conf\(.*\)(5)/syslog.conf\1(4)/g' \
204 -e 's/smartctl\(.*\)(8)/smartdctl\1(1m)/g' \
205 -e 's/syslogd\(.*\)(8)/syslogd\1(1m)/g' \
206 -e 's|/var/log/messages|/var/adm/messages|g' \
207 -e 's/smartd\(.*\)(8)/smartd\1(1m)/g' > $@
209 # For systems that adopts traditional manner
210 man_MANS = smartd.conf.5 \
216 docs_DATA = AUTHORS \
226 sysconf_DATA = smartd.conf$(smartd_suffix)
229 smartd.conf$(smartd_suffix): smartd.conf
230 cp ${srcdir}/smartd.conf smartd.conf$(smartd_suffix)
233 EXTRA_DIST = smartd.initd.in \
240 os_darwin/StartupParameters.plist \
241 os_darwin/English_Localizable.strings \
242 os_win32/installer.nsi \
245 CLEANFILES = drivedb.h \
263 CLEANFILES += smartd.conf$(smartd_suffix)
266 # 'make maintainer-clean' also removes files generated by './autogen.sh'
267 MAINTAINERCLEANFILES = \
268 $(srcdir)/Makefile.in \
269 $(srcdir)/aclocal.m4 \
270 $(srcdir)/configure \
271 $(srcdir)/config.guess \
272 $(srcdir)/config.h.in \
273 $(srcdir)/config.h.in~ \
274 $(srcdir)/config.sub \
276 $(srcdir)/install-sh \
278 $(srcdir)/mkinstalldirs
280 utility.o: svnversion.h
283 # Get version info from SVN
284 svnversion.h: CHANGELOG Makefile $(srcdir)/.svn/entries
285 echo '/* svnversion.h. Generated by Makefile from svn info. */' > $@
287 && svnversion 2>/dev/null | sed -n 's,^\([0-9].*\),REV "\1",p' \
288 && TZ= LC_ALL=C svn info 2>/dev/null \
289 | sed -n 'h;s,^.* Date: *\([^ ]*\) .*$$,DATE "\1",p;g;s,^.* Date: *[^ ]* *\([^ ]*\) .*$$,TIME "\1",p') \
290 | sed 's,^,#define SMARTMONTOOLS_SVN_,' >> $@
293 # SVN not available, guess version info from Id strings
294 svnversion.h: CHANGELOG Makefile
295 echo '/* svnversion.h. Generated by Makefile from Id strings. */' > $@
296 (cd $(srcdir) && cat CHANGELOG Makefile.am configure.in smart*.in *.cpp *.h *.s) \
297 | sed -n 's,^.*\$$[I][d]: [^ ]* \([0-9][0-9]* [0-9][-0-9]* [0-9][:0-9]*\)[^:0-9][^$$]*\$$.*$$,\1,p' \
299 | sed -n 'h;s,^\([^ ]*\) .*$$,REV "\1",p;g;s,^[^ ]* \([^ ]*\) .*$$,DATE "\1",p;g;s,^[^ ]* [^ ]* \([^ ]*\)$$,TIME "\1",p;q' \
300 | sed 's,^,#define SMARTMONTOOLS_SVN_,' >> $@
305 drivedb.h: knowndrives.cpp Makefile
306 echo '/* drivedb.h. Generated from knowndrives.cpp by Makefile. */' > $@
307 sed '1,/^\/\/ BEGIN drivedb.h/d;/^\/\/ END drivedb.h/,$$d;s/^ //' $(srcdir)/knowndrives.cpp >> $@
310 drivedb_DATA = drivedb.h
314 # Create $(savestatesdir) only
318 if ENABLE_ATTRIBUTELOG
319 # Create $(attributelogdir) only
323 smartd.conf.5.in: smartd.8.in
324 sed '1,/STARTINCLUDE/ D;/ENDINCLUDE/,$$D' < $(srcdir)/smartd.8.in > $(top_builddir)/tmp.directives
325 sed '/STARTINCLUDE/,$$D' < $(srcdir)/smartd.conf.5.in > $(top_builddir)/tmp.head
326 sed '1,/ENDINCLUDE/D' < $(srcdir)/smartd.conf.5.in > $(top_builddir)/tmp.tail
327 cat $(top_builddir)/tmp.head > $(srcdir)/smartd.conf.5.in
328 echo '.\" STARTINCLUDE' >> $(srcdir)/smartd.conf.5.in
329 cat $(top_builddir)/tmp.directives >> $(srcdir)/smartd.conf.5.in
330 echo '.\" ENDINCLUDE' >> $(srcdir)/smartd.conf.5.in
331 cat $(top_builddir)/tmp.tail >> $(srcdir)/smartd.conf.5.in
332 rm -f $(top_builddir)/tmp.head $(top_builddir)/tmp.tail $(top_builddir)/tmp.directives
334 if INSTALL_INITSCRIPT
337 os_darwin/StartupParameters.plist \
338 os_darwin/English_Localizable.strings
340 initd_install_name = SMART
342 initd_DATA_install = install-initdDATA-darwin
343 initd_DATA_uninstall = uninstall-initdDATA-darwin
345 SMART : os_darwin/SMART.in
346 sed "s|/usr/sbin/|$(sbindir)/|" $< > $@
348 install-initdDATA-darwin: $(initd_DATA)
349 $(mkinstalldirs) $(DESTDIR)$(initddir)
350 $(mkinstalldirs) $(DESTDIR)$(initddir)/SMART
351 $(mkinstalldirs) $(DESTDIR)$(initddir)/SMART/Resources
352 $(INSTALL_SCRIPT) $(top_builddir)/SMART $(DESTDIR)$(initddir)/SMART
353 $(INSTALL_DATA) $(srcdir)/os_darwin/StartupParameters.plist \
354 $(DESTDIR)$(initddir)/SMART/StartupParameters.plist
355 for i in English ; do \
356 RDIR=$(DESTDIR)$(initddir)/SMART/Resources/$${i}.lproj ; \
357 $(mkinstalldirs) $$RDIR ;\
358 $(INSTALL_DATA) $(srcdir)/os_darwin/$${i}_Localizable.strings \
359 $$RDIR/Localizable.strings ; \
361 @echo -e "\n\n####################################################################\n#"
362 @echo -e "# PLEASE READ THIS BOX!\n#"
363 @echo -e "# To manually start the smartd daemon, run:\n# ${initddir}/SMART/SMART start\n#"
364 @echo -e "# To automatically start smartd on bootup, add the line:\n# SMARTd=-YES-\n# to /etc/hostconfig\n#"
365 @echo -e "# smartd can now use a configuration file ${sysconfdir}/smartd.conf. Do:\n# man smartd"
366 @echo -e "# to learn about it. A sample configuration file can be found in:\n# ${docdir}\n#"
367 @echo -e "####################################################################\n\n"
369 uninstall-initdDATA-darwin:
370 rm -rf $(DESTDIR)$(initddir)/$(initd_install_name)
374 initd_DATA = smartd.initd
376 smartd.initd: $(srcdir)/smartd.initd.in Makefile
377 sed "s|/usr/local/sbin/|$(sbindir)/|g" $(srcdir)/smartd.initd.in > $@
379 initd_install_name = smartd$(smartd_suffix)
381 initd_DATA_install = install-initdDATA-generic
382 initd_DATA_uninstall = uninstall-initdDATA-generic
384 install-initdDATA-generic: $(initd_DATA)
385 $(mkinstalldirs) $(DESTDIR)$(initddir)
386 $(INSTALL_SCRIPT) $(top_builddir)/smartd.initd $(DESTDIR)$(initddir)/smartd$(smartd_suffix)
387 @echo -e "\n\n####################################################################\n#"
388 @echo -e "# PLEASE READ THIS BOX!\n#"
389 @echo -e "# To manually start the smartd daemon, run:\n# ${initddir}/smartd start\n#"
390 @echo -e "# To automatically start smartd on bootup, run:\n# /sbin/chkconfig --add smartd\n#"
391 @echo -e "# smartd can now use a configuration file ${sysconfdir}/smartd.conf. Do:\n# man smartd"
392 @echo -e "# to learn about it. A sample configuration file can be found in:\n# ${docdir}\n#"
393 @echo -e "####################################################################\n\n"
396 uninstall-initdDATA-generic:
397 rm -rf $(DESTDIR)$(initddir)/$(initd_install_name)
401 initd_DATA_install = install-initdDATA-null
402 initd_DATA_uninstall = uninstall-initdDATA-null
404 install-initdDATA-null:
405 uninstall-initdDATA-null:
408 install-initdDATA : $(initd_DATA_install)
410 uninstall-initdDATA: $(initd_DATA_uninstall)
413 MAN_DRIVEDB = sed "s|/usr/local/share/smartmontools/drivedb\\.h|$(drivedbdir)/drivedb.h|g"
415 MAN_DRIVEDB = sed '/BEGIN ENABLE_DRIVEDB/,/END ENABLE_DRIVEDB/d'
419 MAN_SAVESTATES = sed "s|/usr/local/var/lib/smartmontools/smartd\\.|$(savestates)|g"
421 MAN_SAVESTATES = sed '/BEGIN ENABLE_SAVESTATES/,/END ENABLE_SAVESTATES/d'
424 if ENABLE_ATTRIBUTELOG
425 MAN_ATTRIBUTELOG = sed "s|/usr/local/var/lib/smartmontools/attrlog\\.|$(attributelog)|g"
427 MAN_ATTRIBUTELOG = sed '/BEGIN ENABLE_ATTRIBUTELOG/,/END ENABLE_ATTRIBUTELOG/d'
431 .for file in $(man_MANS)
432 ${file}: $(srcdir)/${file}.in Makefile svnversion.h
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" ${.ALLSRC:M*.in} | \
443 $(MAN_SAVESTATES) | \
444 $(MAN_ATTRIBUTELOG) > $@
447 smart%: $(srcdir)/smart%.in Makefile svnversion.h
448 sed "s|CURRENT_CVS_VERSION|$(releaseversion)|g" $< | \
449 sed "s|CURRENT_CVS_DATE|`sed -n 's,^.*DATE[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g" | \
450 sed "s|CURRENT_CVS_TIME|`sed -n 's,^.*TIME[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g" | \
451 sed "s|/usr/local/share/man/|$(mandir)/|g" | \
452 sed "s|/usr/local/sbin/|$(sbindir)/|g" | \
453 sed "s|/usr/local/etc/rc\\.d/init.d/|$(initddir)/|g" | \
454 sed "s|/usr/local/share/doc/smartmontools-5.1/|$(docsdir)/|g" | \
455 sed "s|/usr/local/etc/smartd\\.conf|$(sysconfdir)/smartd.conf|g" | \
456 sed "s|/usr/local/etc/smart_drivedb\\.h|$(sysconfdir)/smart_drivedb\\.h|g" | \
458 $(MAN_SAVESTATES) | \
459 $(MAN_ATTRIBUTELOG) > $@
462 # Commands to convert man pages into .html and .txt
465 #MAN2HTML = groff -man -Thtml
466 MAN2TXT = groff -man -Tascii -P'-bcou'
468 # Remove HTTP header and fix links in man2html output
469 FIXHTML = sed '1s,^Content-type.*,,' \
470 | sed 's,<A HREF="http://[-a-z/]*/man2html?\([1-8]\)+\(smart[cd][.a-z]*\)">,<A HREF="\2.\1.html">,g' \
471 | sed 's,<A HREF="http://[-a-z/]*/man2html">,<A HREF=".">,g' \
472 | sed 's,<A HREF="http://[-a-z/]*/man2html?[^"]*">\([^<]*\)</A>,\1,g' \
473 | sed 's,<A HREF="mailto:[^s][^m][^a][^"]*">\([^<]*\)</A>,\1,g'
475 # Convert man pages into .html and .txt
477 htmlman: smartctl.8.html smartd.8.html smartd.conf.5.html
479 txtman: smartctl.8.txt smartd.8.txt smartd.conf.5.txt
484 $(DOS2UNIX) < $< | $(MAN2HTML) | $(FIXHTML) > $@
487 $(DOS2UNIX) < $< | $(MAN2HTML) | $(FIXHTML) > $@
491 $(MAN2HTML) $< | $(FIXHTML) > $@
494 $(MAN2HTML) $< | $(FIXHTML) > $@
506 # Definitions for Windows distribution
508 distdir_win32 = $(PACKAGE)-$(VERSION).win32
509 distzip_win32 = $(PACKAGE)-$(VERSION).win32.zip
510 distinst_win32= $(PACKAGE)-$(VERSION).win32-setup.exe
512 exedir_win32 = $(distdir_win32)/bin
513 docdir_win32 = $(distdir_win32)/doc
515 FILES_WIN32 = $(exedir_win32)/smartctl.exe \
516 $(exedir_win32)/smartctl-nc.exe \
517 $(exedir_win32)/smartd.exe \
518 $(docdir_win32)/AUTHORS.txt \
519 $(docdir_win32)/CHANGELOG.txt \
520 $(docdir_win32)/COPYING.txt \
521 $(docdir_win32)/INSTALL.txt \
522 $(docdir_win32)/NEWS.txt \
523 $(docdir_win32)/README.txt \
524 $(docdir_win32)/TODO.txt \
525 $(docdir_win32)/WARNINGS.txt \
526 $(docdir_win32)/smartd.conf \
527 $(docdir_win32)/smartctl.8.html \
528 $(docdir_win32)/smartctl.8.txt \
529 $(docdir_win32)/smartd.8.html \
530 $(docdir_win32)/smartd.8.txt \
531 $(docdir_win32)/smartd.conf.5.html \
532 $(docdir_win32)/smartd.conf.5.txt
534 CLEANFILES += $(FILES_WIN32) $(exedir_win32)/syslogevt.exe \
535 smartctl-nc.exe smartctl-nc.exe.tmp \
536 distdir.mkdir syslogevt.check
538 # Textfile converter from cygutils
539 UNIX2DOS = unix2dos -D
540 DOS2UNIX = dos2unix -U
542 # Build Windows distribution
544 dist-win32: $(distzip_win32)
546 install-win32: $(distinst_win32)
549 installer-win32: $(distinst_win32)
551 distdir-win32: distdir.mkdir $(FILES_WIN32) syslogevt.check
553 $(distzip_win32): distdir.mkdir $(FILES_WIN32) syslogevt.check
554 @rm -fv $(distzip_win32)
555 cd $(distdir_win32) && zip -9Dr ../$(distzip_win32) .
557 # Build NSIS installer, try to locate makensis in default location first
558 $(distinst_win32): $(srcdir)/os_win32/installer.nsi distdir.mkdir $(FILES_WIN32) syslogevt.check
559 @makensis="$(MAKENSIS)"; if [ -z "$$makensis" ]; then \
560 if [ ! -z "$$PROGRAMFILES" ] && "$$PROGRAMFILES/NSIS/makensis" /VERSION >/dev/null 2>&1; then \
561 makensis="$$PROGRAMFILES/NSIS/makensis"; \
562 elif makensis /VERSION >/dev/null 2>&1; then \
565 echo 'makensis: command not found. Please download and install NSIS' 1>&2; \
566 echo 'from http://nsis.sourceforge.net/Download' 1>&2; exit 1; \
569 date=`sed -n 's,^.*DATE[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`; \
570 rev=`sed -n 's,^.*REV[^"]*"\([^"]*\)".*$$,r\1,p' svnversion.h`; \
571 verstr="$(PACKAGE_VERSION) $$date $$rev "$(BUILD_INFO); \
572 echo "$$makensis /V2 /NOCD /DINPDIR=$(distdir_win32) /DOUTFILE=$(distinst_win32) /DVERSTR='$$verstr' $(srcdir)/os_win32/installer.nsi"; \
573 "$$makensis" /V2 /NOCD /DINPDIR="$(distdir_win32)" /DOUTFILE="$(distinst_win32)" /DVERSTR="$$verstr" "$(srcdir)/os_win32/installer.nsi"
576 rm -rf $(distdir_win32) distdir.mkdir syslogevt.check
579 @test -d $(exedir_win32) || mkdir -pv $(exedir_win32)
580 @test -d $(docdir_win32) || mkdir -pv $(docdir_win32)
584 @if [ -f $(srcdir)/os_win32/syslogevt.exe ]; then \
585 cp -pv $(srcdir)/os_win32/syslogevt.exe $(exedir_win32)/syslogevt.exe; \
586 else echo "Warning: $(srcdir)/os_win32/syslogevt.exe missing."; fi
589 $(exedir_win32)/%.exe: %.exe
594 $(docdir_win32)/%.html: %.html
595 $(UNIX2DOS) < $< > $@
598 $(docdir_win32)/%.txt: %.txt
599 $(UNIX2DOS) < $< > $@
602 $(docdir_win32)/%.txt: $(srcdir)/%
603 $(UNIX2DOS) < $< > $@
606 $(docdir_win32)/%.conf: $(srcdir)/%.conf
607 $(UNIX2DOS) < $< > $@
610 # Build non-console version of smartctl for GSmartControl.
611 # The script below changes the word at offset 220 (Subsystem) from 3
612 # (Console) to 2 (GUI) in a copy of smartctl.exe.
613 # This will be changed when a tool (like 'editbin') is available in
614 # the Cygwin distribution
615 smartctl-nc.exe: smartctl.exe
617 cp -p smartctl.exe $@.tmp
618 @if test `od -A n -j 220 -N 2 -d $@.tmp` -eq 3; then :; \
619 else echo "invalid EXE header"; exit 1; fi
620 @echo "editbin /subsystem:windows $@.tmp"
621 @echo -ne '\002' | dd bs=1 seek=220 count=1 conv=notrunc of=$@.tmp 2>/dev/null
622 @if test `od -A n -j 220 -N 2 -d $@.tmp` -eq 2; then :; \
623 else echo "EXE patch failed"; exit 1; fi
627 # Build {config,svnversion}_vc8.h for MSVC8 from MinGW {config,svnversion}.h
629 config-vc8: $(srcdir)/os_win32/config_vc8.h $(srcdir)/os_win32/svnversion_vc8.h
631 $(srcdir)/os_win32/config_vc8.h: config.h
632 sed '1i/* config_vc8.h. Generated from config.h by Makefile. */' $< | \
633 sed 's,^#define HAVE_\(ATTR_PACKED\|INTTYPES_H\|STDINT_H\|STRINGS_H\|STRTOULL\|U*INT64_T\|UNISTD_H\|WORKING_SNPRINTF\) 1$$,/* #undef HAVE_\1 */,' | \
634 sed 's,i.86-pc-mingw32,i686-pc-win32vc8,' > $@
636 $(srcdir)/os_win32/svnversion_vc8.h: svnversion.h
641 SUBDIRS= . examplescripts