]> git.proxmox.com Git - mirror_smartmontools-debian.git/blobdiff - Makefile.am
moved smartd_warning.sh in /usr/share/smartmontools/smard_warning.sh
[mirror_smartmontools-debian.git] / Makefile.am
index d2bc9222046e3b830f5b5ec4aec2d8a102278c33..440153711469fea1531749cd2fa44056231ffdf5 100644 (file)
@@ -1,17 +1,23 @@
 ## Process this file with automake to produce Makefile.in
 #
-# $Id: Makefile.am 3074 2010-03-05 23:00:30Z chrfranke $
+# $Id: Makefile.am 3957 2014-07-18 18:39:06Z chrfranke $
 #
 
 @SET_MAKE@
 
+ACLOCAL_AMFLAGS = -I m4
+
 # Make sure .cpp takes precedence to avoid compiling old .c file
 SUFFIXES = .cpp .c .s .o
 
 # BUILD_INFO can be provided by package maintainers (see INSTALL file)
 BUILD_INFO= "(local build)"
 
-AM_CPPFLAGS = -DBUILD_INFO='$(BUILD_INFO)' -DSMARTMONTOOLS_SYSCONFDIR='"$(sysconfdir)"'
+AM_CPPFLAGS = \
+        -DBUILD_INFO='$(BUILD_INFO)' \
+        -DSMARTMONTOOLS_SYSCONFDIR='"$(sysconfdir)"' \
+        -DSMARTMONTOOLS_SMARTDSCRIPTDIR='"$(smartdscriptdir)"'
+
 if ENABLE_DRIVEDB
 AM_CPPFLAGS += -DSMARTMONTOOLS_DRIVEDBDIR='"$(drivedbdir)"'
 endif
@@ -22,142 +28,214 @@ if ENABLE_ATTRIBUTELOG
 AM_CPPFLAGS += -DSMARTMONTOOLS_ATTRIBUTELOG='"$(attributelog)"'
 endif
 
-sbin_PROGRAMS = smartd         \
-               smartctl
+if OS_WIN32_MINGW
+AM_CPPFLAGS += -I$(srcdir)/os_win32
+endif
+if NEED_GETOPT_LONG
+AM_CPPFLAGS += -I$(srcdir)/getopt -DHAVE_GETOPT_LONG -D__GNU_LIBRARY__
+endif
+if NEED_REGEX
+AM_CPPFLAGS += -I$(srcdir)/regex
+endif
+
+sbin_PROGRAMS = \
+        smartctl \
+        smartd
 
 if ENABLE_DRIVEDB
+if OS_WIN32_MINGW
+else
 sbin_SCRIPTS = update-smart-drivedb
 endif
+endif
+
+
+smartctl_SOURCES = \
+        smartctl.cpp \
+        smartctl.h \
+        atacmdnames.cpp \
+        atacmdnames.h \
+        atacmds.cpp \
+        atacmds.h \
+        ataidentify.cpp \
+        ataidentify.h \
+        ataprint.cpp \
+        ataprint.h \
+        dev_ata_cmd_set.cpp \
+        dev_ata_cmd_set.h \
+        dev_interface.cpp \
+        dev_interface.h \
+        dev_tunnelled.h \
+        drivedb.h \
+        int64.h \
+        knowndrives.cpp \
+        knowndrives.h \
+        scsicmds.cpp \
+        scsicmds.h \
+        scsiata.cpp \
+        scsiprint.cpp \
+        scsiprint.h \
+        utility.cpp \
+        utility.h
+
+smartctl_LDADD = @os_deps@ @os_libs@
+smartctl_DEPENDENCIES = @os_deps@
+
+EXTRA_smartctl_SOURCES = \
+        os_darwin.cpp \
+        os_darwin.h \
+        os_linux.cpp \
+        os_linux.h \
+        os_freebsd.cpp \
+        os_freebsd.h \
+        os_netbsd.cpp \
+        os_netbsd.h \
+        os_openbsd.cpp \
+        os_openbsd.h \
+        os_qnxnto.cpp \
+        os_qnxnto.h \
+        os_solaris.cpp \
+        os_solaris.h \
+        os_solaris_ata.s \
+        os_win32.cpp \
+        os_generic.cpp \
+        os_generic.h \
+        aacraid.h \
+        cciss.cpp \
+        cciss.h \
+        cissio_freebsd.h \
+        dev_areca.cpp \
+        dev_areca.h \
+        dev_legacy.cpp \
+        megaraid.h
+
+if OS_WIN32_MINGW
+
+smartctl_LDADD        += smartctl_res.o
+smartctl_DEPENDENCIES += smartctl_res.o
+
+endif
 
 
-smartd_SOURCES =  smartd.cpp      \
-                  atacmdnames.cpp \
-                  atacmdnames.h   \
-                  atacmds.cpp     \
-                  atacmds.h       \
-                  dev_ata_cmd_set.cpp \
-                  dev_ata_cmd_set.h   \
-                  dev_interface.cpp   \
-                  dev_interface.h     \
-                  dev_tunnelled.h     \
-                  drivedb.h           \
-                  extern.h        \
-                  int64.h         \
-                  knowndrives.cpp \
-                  knowndrives.h   \
-                  scsicmds.cpp    \
-                  scsicmds.h      \
-                  scsiata.cpp     \
-                  utility.cpp     \
-                  utility.h
+smartd_SOURCES = \
+        smartd.cpp \
+        atacmdnames.cpp \
+        atacmdnames.h \
+        atacmds.cpp \
+        atacmds.h \
+        dev_ata_cmd_set.cpp \
+        dev_ata_cmd_set.h \
+        dev_interface.cpp \
+        dev_interface.h \
+        dev_tunnelled.h \
+        drivedb.h \
+        int64.h \
+        knowndrives.cpp \
+        knowndrives.h \
+        scsicmds.cpp \
+        scsicmds.h \
+        scsiata.cpp \
+        utility.cpp \
+        utility.h
 
 smartd_LDADD = @os_deps@ @os_libs@ @CAPNG_LDADD@
 smartd_DEPENDENCIES = @os_deps@
 
-EXTRA_smartd_SOURCES = os_darwin.cpp    \
-                       os_darwin.h      \
-                       os_linux.cpp     \
-                       os_linux.h       \
-                       os_freebsd.cpp   \
-                       os_freebsd.h     \
-                       os_netbsd.cpp    \
-                       os_netbsd.h      \
-                       os_openbsd.cpp   \
-                       os_openbsd.h     \
-                       os_solaris.cpp   \
-                       os_solaris.h     \
-                       os_solaris_ata.s \
-                       os_win32.cpp     \
-                       os_generic.cpp   \
-                       os_generic.h     \
-                       cciss.cpp        \
-                       cciss.h          \
-                       dev_legacy.cpp   \
-                       megaraid.h
-
+EXTRA_smartd_SOURCES = \
+        os_darwin.cpp \
+        os_darwin.h \
+        os_linux.cpp \
+        os_linux.h \
+        os_freebsd.cpp \
+        os_freebsd.h \
+        os_netbsd.cpp \
+        os_netbsd.h \
+        os_openbsd.cpp \
+        os_openbsd.h \
+        os_qnxnto.cpp \
+        os_qnxnto.h \
+        os_solaris.cpp \
+        os_solaris.h \
+        os_solaris_ata.s \
+        os_win32.cpp \
+        os_generic.cpp \
+        os_generic.h \
+        aacraid.h \
+        cciss.cpp \
+        cciss.h \
+        cissio_freebsd.h \
+        dev_areca.cpp \
+        dev_areca.h \
+        dev_legacy.cpp \
+        megaraid.h
 
 if OS_WIN32_MINGW
 
-smartd_SOURCES +=                           \
-                posix/regex.h               \
-                posix/regex.c               \
-                os_win32/daemon_win32.h     \
-                os_win32/daemon_win32.cpp   \
-                os_win32/hostname_win32.h   \
-                os_win32/hostname_win32.cpp \
-                os_win32/syslog.h           \
-                os_win32/syslog_win32.cpp
+smartd_SOURCES += \
+        os_win32/daemon_win32.cpp \
+        os_win32/daemon_win32.h \
+        os_win32/syslog_win32.cpp \
+        os_win32/syslog.h
 
-# Included by regex.c:
-EXTRA_smartd_SOURCES +=                   \
-                posix/regcomp.c           \
-                posix/regexec.c           \
-                posix/regex_internal.c    \
-                posix/regex_internal.h
-
-endif
-
-smartctl_SOURCES= smartctl.cpp    \
-                  smartctl.h      \
-                  atacmdnames.cpp \
-                  atacmdnames.h   \
-                  atacmds.cpp     \
-                  atacmds.h       \
-                  ataprint.cpp    \
-                  ataprint.h      \
-                  dev_ata_cmd_set.cpp \
-                  dev_ata_cmd_set.h   \
-                  dev_interface.cpp   \
-                  dev_interface.h     \
-                  dev_tunnelled.h     \
-                  drivedb.h           \
-                  extern.h        \
-                  int64.h         \
-                  knowndrives.cpp \
-                  knowndrives.h   \
-                  scsicmds.cpp    \
-                  scsicmds.h      \
-                  scsiata.cpp     \
-                  scsiprint.cpp   \
-                  scsiprint.h     \
-                  utility.cpp     \
-                  utility.h
+smartd_LDADD        += smartd_res.o
+smartd_DEPENDENCIES += smartd_res.o
 
+endif
 
-smartctl_LDADD = @os_deps@ @os_libs@
-smartctl_DEPENDENCIES = @os_deps@
 
-EXTRA_smartctl_SOURCES = os_linux.cpp \
-                       os_linux.h     \
-                       os_freebsd.cpp \
-                       os_freebsd.h   \
-                       os_netbsd.cpp  \
-                       os_netbsd.h    \
-                       os_openbsd.cpp \
-                       os_openbsd.h   \
-                       os_solaris.cpp \
-                       os_solaris.h   \
-                       os_win32.cpp   \
-                       os_generic.cpp \
-                       os_generic.h   \
-                       cciss.cpp      \
-                       cciss.h        \
-                       dev_legacy.cpp \
-                       megaraid.h
+if NEED_GETOPT_LONG
 
-if OS_WIN32_MINGW
+smartctl_SOURCES += \
+        getopt/getopt.c \
+        getopt/getopt.h \
+        getopt/getopt1.c
+
+smartd_SOURCES += \
+        getopt/getopt.c \
+        getopt/getopt.h \
+        getopt/getopt1.c
+
+endif
 
-smartctl_SOURCES +=                    \
-                posix/regex.h          \
-                posix/regex.c          \
-                os_win32/syslog.h
+if NEED_REGEX
+
+smartctl_SOURCES += \
+        regex/regex.c \
+        regex/regex.h \
+        regex/regex_internal.h
+
+smartd_SOURCES += \
+        regex/regex.c \
+        regex/regex.h \
+        regex/regex_internal.h
 
 # Included by regex.c:
-EXTRA_smartctl_SOURCES +=              \
-                posix/regcomp.c        \
-                posix/regexec.c        \
-                posix/regex_internal.c \
-                posix/regex_internal.h
+EXTRA_smartctl_SOURCES += \
+        regex/regcomp.c \
+        regex/regexec.c \
+        regex/regex_internal.c
+
+EXTRA_smartd_SOURCES += \
+        regex/regcomp.c \
+        regex/regexec.c \
+        regex/regex_internal.c
+
+endif
+
+if OS_WIN32
+
+smartctl_SOURCES += \
+        csmisas.h \
+        os_win32/wmiquery.cpp \
+        os_win32/wmiquery.h
+
+smartd_SOURCES += \
+        csmisas.h \
+        os_win32/wmiquery.cpp \
+        os_win32/wmiquery.h
+
+smartctl_LDADD += -lole32 -loleaut32
+smartd_LDADD   += -lole32 -loleaut32
 
 endif
 
@@ -170,6 +248,11 @@ if OS_SOLARIS
 extra_MANS =      smartd.conf.4 \
                   smartctl.1m   \
                   smartd.1m
+if ENABLE_DRIVEDB
+extra_MANS += update-smart-drivedb.1m
+endif
+
+all-local: $(extra_MANS)
 install-man: $(extra_MANS)
        @$(NORMAL_INSTALL)
        $(mkinstalldirs) $(DESTDIR)$(mandir)/man4
@@ -196,85 +279,136 @@ uninstall-man:
          echo " rm -f $(DESTDIR)$(mandir)/man$$ext/$$inst"; \
          rm -f $(DESTDIR)$(mandir)/man$$ext/$$inst; \
        done
-%.1m: %.8
-       awk '/^.TH/ {$$3="1m"} {print}' < $< | \
-       sed -e 's/smartd\.conf\(.*\)(5)/smartd.conf\1(4)/g' \
-            -e 's/syslog\.conf\(.*\)(5)/syslog.conf\1(4)/g' \
-           -e 's/smartctl\(.*\)(8)/smartctl\1(1m)/g' \
-           -e 's/syslogd\(.*\)(8)/syslogd\1(1m)/g' \
-            -e 's|/var/log/messages|/var/adm/messages|g' \
-           -e 's/smartd\(.*\)(8)/smartd\1(1m)/g' > $@
-%.4: %.5
-       awk '/^.TH/ {$$3="4"}  {print}' < $< | \
-       sed -e 's/smartd\.conf\(.*\)(5)/smartd.conf\1(4)/g' \
-            -e 's/syslog\.conf\(.*\)(5)/syslog.conf\1(4)/g' \
-           -e 's/smartctl\(.*\)(8)/smartdctl\1(1m)/g' \
-           -e 's/syslogd\(.*\)(8)/syslogd\1(1m)/g' \
-            -e 's|/var/log/messages|/var/adm/messages|g' \
-           -e 's/smartd\(.*\)(8)/smartd\1(1m)/g' > $@
 else
 # For systems that adopts traditional manner
+
 man_MANS =        smartd.conf.5 \
                   smartctl.8    \
                   smartd.8
+
+if ENABLE_DRIVEDB
+man_MANS += update-smart-drivedb.8
 endif
 
-docsdir=$(docdir)
-docs_DATA = AUTHORS     \
-            CHANGELOG   \
-            COPYING     \
-            INSTALL     \
-            NEWS        \
-            README      \
-            TODO        \
-            WARNINGS    \
-            smartd.conf
-
-sysconf_DATA = smartd.conf$(smartd_suffix)
-
-if SMARTD_SUFFIX
-smartd.conf$(smartd_suffix): smartd.conf
-       cp ${srcdir}/smartd.conf smartd.conf$(smartd_suffix)
-endif
-
-EXTRA_DIST = smartd.initd.in                       \
-             smartd.8.in                           \
-             smartctl.8.in                         \
-             smartd.conf.5.in                      \
-             smartd.conf                           \
-             autogen.sh                            \
-             update-smart-drivedb.in               \
-             os_darwin/SMART.in                    \
-             os_darwin/StartupParameters.plist     \
-             os_darwin/English_Localizable.strings \
-             os_win32/installer.nsi                \
-             $(docs_DATA)
-
-CLEANFILES = smartd.conf.5      \
-             smartd.conf.4      \
-             smartd.8           \
-             smartd.1m          \
-             smartd.8.html      \
-             smartd.8.txt       \
-             smartctl.8         \
-             smartctl.1m        \
-             smartctl.8.html    \
-             smartctl.8.txt     \
-             smartd.conf.5.html \
-             smartd.conf.5.txt  \
-             smartd.initd       \
-             svnversion.h       \
-             update-smart-drivedb \
-             SMART
-
-if SMARTD_SUFFIX
-CLEANFILES += smartd.conf$(smartd_suffix)
 endif
 
+docsdir=$(docdir)
+docs_DATA = \
+        AUTHORS \
+        ChangeLog \
+        ChangeLog-5.0-6.0 \
+        COPYING \
+        INSTALL \
+        NEWS \
+        README \
+        TODO \
+        WARNINGS \
+        smartd.conf
+
+examplesdir=$(exampledir)
+examples_DATA = \
+        examplescripts/README
+examples_SCRIPTS = \
+        examplescripts/Example1 \
+        examplescripts/Example2 \
+        examplescripts/Example3 \
+        examplescripts/Example4 \
+        examplescripts/Example5 \
+        examplescripts/Example6
+
+sysconf_DATA = smartd.conf
+
+# If modified smartd.conf exists install smartd.conf.sample instead
+install-sysconfDATA: $(sysconf_DATA)
+       $(mkinstalldirs) $(DESTDIR)$(sysconfdir)
+       @s="$(srcdir)/smartd.conf"; \
+       f="$(DESTDIR)$(sysconfdir)/smartd.conf$(smartd_suffix)"; \
+       if test -z "$(smartd_suffix)" && test -f "$$f"; then \
+         if cmp "$$s" "$$f" >/dev/null 2>/dev/null; then :; else \
+           echo "************************************************************"; \
+           echo "*** $$f preserved"; \
+           echo "*** installing smartd.conf.sample instead"; \
+           echo "************************************************************"; \
+           f="$$f".sample; \
+         fi; \
+       fi; \
+       echo " $(INSTALL_DATA) $$s $$f"; \
+       $(INSTALL_DATA) "$$s" "$$f"
+
+# If smartd.conf.sample exists preserve smartd.conf
+uninstall-sysconfDATA:
+       @f="$(DESTDIR)$(sysconfdir)/smartd.conf$(smartd_suffix)"; \
+       if test -z "$(smartd_suffix)" && test -f "$$f".sample; then \
+         echo "************************************************************"; \
+         echo "*** $$f preserved"; \
+         echo "*** removing smartd.conf.sample instead"; \
+         echo "************************************************************"; \
+         f="$$f".sample; \
+       fi; \
+       echo " rm -f $$f"; \
+       rm -f "$$f"
+
+smartdscript_SCRIPTS = smartd_warning.sh
+
+EXTRA_DIST = \
+        autogen.sh \
+        smartd.initd.in \
+        smartd.freebsd.initd.in \
+        smartd.8.in \
+        smartctl.8.in \
+        smartd.conf.5.in \
+        smartd.conf \
+        smartd.service.in \
+        smartd_warning.sh.in \
+        update-smart-drivedb.in \
+        update-smart-drivedb.8.in \
+        m4/pkg.m4 \
+        os_darwin/SMART.in \
+        os_darwin/StartupParameters.plist \
+        os_darwin/English_Localizable.strings \
+        os_win32/installer.nsi \
+        os_win32/runcmd.c \
+        os_win32/runcmda.exe.manifest \
+        os_win32/runcmdu.exe.manifest \
+        os_win32/smartctl_res.rc.in \
+        os_win32/smartd_res.rc.in \
+        os_win32/smartd_warning.cmd \
+        os_win32/syslogevt.mc \
+        os_win32/update-smart-drivedb.nsi \
+        os_win32/wbemcli_small.h \
+        os_win32/wtssendmsg.c \
+        $(docs_DATA) \
+        $(examples_DATA) \
+        $(examples_SCRIPTS)
+
+CLEANFILES = \
+        smartd.conf.5 \
+        smartd.conf.4 \
+        smartd.8 \
+        smartd.1m \
+        smartd.8.html \
+        smartd.8.txt \
+        smartctl.8 \
+        smartctl.1m \
+        smartctl.8.html \
+        smartctl.8.txt \
+        smartd.conf.5.html \
+        smartd.conf.5.txt \
+        smartd.initd \
+        smartd.freebsd.initd \
+        smartd.service \
+        smartd_warning.sh \
+        svnversion.h \
+        update-smart-drivedb \
+        update-smart-drivedb.8 \
+        update-smart-drivedb.1m \
+        SMART
+
 # 'make maintainer-clean' also removes files generated by './autogen.sh'
 MAINTAINERCLEANFILES = \
         $(srcdir)/Makefile.in \
         $(srcdir)/aclocal.m4 \
+        $(srcdir)/compile \
         $(srcdir)/configure \
         $(srcdir)/config.guess \
         $(srcdir)/config.h.in \
@@ -283,15 +417,17 @@ MAINTAINERCLEANFILES = \
         $(srcdir)/depcomp \
         $(srcdir)/install-sh \
         $(srcdir)/missing \
-        $(srcdir)/mkinstalldirs
+        $(srcdir)/mkinstalldirs \
+        $(srcdir)/m4/pkg.m4
 
 utility.o: svnversion.h
 
 if IS_SVN_BUILD
 # Get version info from SVN
-svnversion.h: CHANGELOG Makefile $(srcdir)/.svn/entries
-       echo '/* svnversion.h.  Generated by Makefile from svn info.  */' > $@
-       (cd $(srcdir) \
+svnversion.h: ChangeLog Makefile $(svn_deps)
+       @echo '  svn info | $$(VERSION_FROM_SVN_INFO) > $@'
+       @echo '/* svnversion.h.  Generated by Makefile from svn info.  */' > $@
+       @(cd $(srcdir) \
         && svnversion 2>/dev/null | sed -n 's,^\([0-9].*\),REV  "\1",p' \
         && TZ= LC_ALL=C svn info 2>/dev/null \
         | sed -n 'h;s,^.* Date: *\([^ ]*\) .*$$,DATE "\1",p;g;s,^.* Date: *[^ ]* *\([^ ]*\) .*$$,TIME "\1",p') \
@@ -299,9 +435,10 @@ svnversion.h: CHANGELOG Makefile $(srcdir)/.svn/entries
 else
 
 # SVN not available, guess version info from Id strings
-svnversion.h: CHANGELOG Makefile
-       echo '/* svnversion.h.  Generated by Makefile from Id strings.  */' > $@
-       (cd $(srcdir) && cat CHANGELOG Makefile.am configure.in smart*.in *.cpp *.h *.s) \
+svnversion.h: ChangeLog Makefile
+       @echo '  cat ChangeLog $$(SOURCES) | $$(VERSION_FROM_SVN_IDS) > $@'
+       @echo '/* svnversion.h.  Generated by Makefile from Id strings.  */' > $@
+       @(cd $(srcdir) && cat ChangeLog Makefile.am configure.ac smart*.in *.cpp *.h *.s) \
        | sed -n 's,^.*\$$[I][d]: [^ ]* \([0-9][0-9]* [0-9][-0-9]* [0-9][:0-9]*\)[^:0-9][^$$]*\$$.*$$,\1,p' \
        | sort -n -r \
        | sed -n 'h;s,^\([^ ]*\) .*$$,REV  "\1",p;g;s,^[^ ]* \([^ ]*\) .*$$,DATE "\1",p;g;s,^[^ ]* [^ ]* \([^ ]*\)$$,TIME "\1",p;q' \
@@ -313,31 +450,13 @@ if ENABLE_DRIVEDB
 drivedb_DATA = drivedb.h
 endif
 
-if ENABLE_SAVESTATES
-# Create $(savestatesdir) only
-savestates_DATA =
-endif
-
-if ENABLE_ATTRIBUTELOG
-# Create $(attributelogdir) only
-attributelog_DATA =
-endif
-
-smartd.conf.5.in: smartd.8.in
-       sed '1,/STARTINCLUDE/ D;/ENDINCLUDE/,$$D' < $(srcdir)/smartd.8.in > $(top_builddir)/tmp.directives
-       sed '/STARTINCLUDE/,$$D'  < $(srcdir)/smartd.conf.5.in > $(top_builddir)/tmp.head
-       sed '1,/ENDINCLUDE/D'   < $(srcdir)/smartd.conf.5.in > $(top_builddir)/tmp.tail
-       cat $(top_builddir)/tmp.head > $(srcdir)/smartd.conf.5.in
-       echo '.\" STARTINCLUDE' >> $(srcdir)/smartd.conf.5.in
-       cat $(top_builddir)/tmp.directives >> $(srcdir)/smartd.conf.5.in
-       echo '.\" ENDINCLUDE'   >> $(srcdir)/smartd.conf.5.in
-       cat $(top_builddir)/tmp.tail >> $(srcdir)/smartd.conf.5.in
-       rm -f $(top_builddir)/tmp.head $(top_builddir)/tmp.tail $(top_builddir)/tmp.directives
-
 update-smart-drivedb: update-smart-drivedb.in config.status
        $(SHELL) ./config.status --file=$@
        chmod +x $@
 
+smartd_warning.sh: smartd_warning.sh.in config.status
+       $(SHELL) ./config.status --file=$@
+       chmod +x $@
 
 if INSTALL_INITSCRIPT
 if OS_DARWIN
@@ -366,23 +485,16 @@ install-initdDATA-darwin: $(initd_DATA)
          $(INSTALL_DATA) $(srcdir)/os_darwin/$${i}_Localizable.strings \
            $$RDIR/Localizable.strings ; \
        done
-       @echo -e "\n\n####################################################################\n#"
-       @echo -e "#                       PLEASE READ THIS BOX!\n#"
-       @echo -e "#   To manually start the smartd daemon, run:\n#   ${initddir}/SMART/SMART start\n#"
-       @echo -e "#   To automatically start smartd on bootup, add the line:\n#   SMARTd=-YES-\n#   to /etc/hostconfig\n#"
-       @echo -e "#   smartd can now use a configuration file ${sysconfdir}/smartd.conf. Do:\n#   man smartd"
-       @echo -e "#   to learn about it. A sample configuration file can be found in:\n#   ${docdir}\n#"
-       @echo -e "####################################################################\n\n"
 
 uninstall-initdDATA-darwin:
        rm -rf $(DESTDIR)$(initddir)/$(initd_install_name)
 
 else
 
-initd_DATA = smartd.initd
+initd_DATA = @initdfile@
 
-smartd.initd: $(srcdir)/smartd.initd.in Makefile
-       sed "s|/usr/local/sbin/|$(sbindir)/|g" $(srcdir)/smartd.initd.in > $@
+@initdfile@: $(srcdir)/@initdfile@.in Makefile
+       sed "s|/usr/local/sbin/|$(sbindir)/|g" $(srcdir)/@initdfile@.in > $@
 
 initd_install_name = smartd$(smartd_suffix)
 
@@ -391,14 +503,7 @@ initd_DATA_uninstall = uninstall-initdDATA-generic
 
 install-initdDATA-generic: $(initd_DATA)
        $(mkinstalldirs) $(DESTDIR)$(initddir)
-       $(INSTALL_SCRIPT) $(top_builddir)/smartd.initd $(DESTDIR)$(initddir)/smartd$(smartd_suffix)
-       @echo -e "\n\n####################################################################\n#"
-       @echo -e "#                       PLEASE READ THIS BOX!\n#"
-       @echo -e "#   To manually start the smartd daemon, run:\n#   ${initddir}/smartd start\n#"
-       @echo -e "#   To automatically start smartd on bootup, run:\n#   /sbin/chkconfig --add smartd\n#"
-       @echo -e "#   smartd can now use a configuration file ${sysconfdir}/smartd.conf. Do:\n#   man smartd"
-       @echo -e "#   to learn about it. A sample configuration file can be found in:\n#   ${docdir}\n#"
-       @echo -e "####################################################################\n\n"
+       $(INSTALL_SCRIPT) $(top_builddir)/@initdfile@ $(DESTDIR)$(initddir)/smartd$(smartd_suffix)
 
 
 uninstall-initdDATA-generic:
@@ -417,54 +522,138 @@ install-initdDATA : $(initd_DATA_install)
 
 uninstall-initdDATA: $(initd_DATA_uninstall)
 
+if INSTALL_SYSTEMDUNIT
+systemdsystemunit_DATA = smartd.service
+endif
+
+smartd.service: smartd.service.in Makefile
+       cat $(srcdir)/smartd.service.in | \
+       sed 's|/usr/local/sbin/smartd|$(sbindir)/smartd|' | \
+       if test -n '$(systemdenvfile)'; then \
+         sed 's|/usr/local/etc/sysconfig/smartmontools|$(systemdenvfile)|'; \
+       else \
+         sed -e '/^EnvironmentFile=/d' -e 's| *\$$smartd[_a-z]* *||g'; \
+       fi > $@
+
+
+# Create empty directories if configured.
+# Default install rules no longer create empty directories since automake 1.11.
+# Uses $(mkinstalldirs) instead of $(MKDIR_P) to preserve support for automake 1.7 - 1.9.
+installdirs-local:
+       @for d in '$(smartdplugindir)' '$(savestatesdir)' '$(attributelogdir)'; do \
+         test -n "$$d" || continue; \
+         echo "$(mkinstalldirs) $(DESTDIR)$$d"; \
+         $(mkinstalldirs) "$(DESTDIR)$$d" || exit 1; \
+       done
+
+install-data-local: installdirs-local
+
+#
+# Build man pages
+#
 if ENABLE_CAPABILITIES
 MAN_CAPABILITIES = cat
 else
-MAN_CAPABILITIES = sed '/BEGIN ENABLE_CAPABILITIES/,/END ENABLE_CAPABILITIES/d'
+MAN_CAPABILITIES = sed '/^\.\\" %IF ENABLE_CAPABILITIES/,/^\.\\" %ENDIF ENABLE_CAPABILITIES/ s,^,.\\"\# ,'
 endif
 
 if ENABLE_DRIVEDB
 MAN_DRIVEDB = sed "s|/usr/local/share/smartmontools/drivedb\\.h|$(drivedbdir)/drivedb.h|g"
 else
-MAN_DRIVEDB = sed '/BEGIN ENABLE_DRIVEDB/,/END ENABLE_DRIVEDB/d'
+MAN_DRIVEDB = sed '/^\.\\" %IF ENABLE_DRIVEDB/,/^\.\\" %ENDIF ENABLE_DRIVEDB/ s,^,.\\"\# ,'
 endif
 
 if ENABLE_SAVESTATES
 MAN_SAVESTATES = sed "s|/usr/local/var/lib/smartmontools/smartd\\.|$(savestates)|g"
 else
-MAN_SAVESTATES = sed '/BEGIN ENABLE_SAVESTATES/,/END ENABLE_SAVESTATES/d'
+MAN_SAVESTATES = sed '/^\.\\" %IF ENABLE_SAVESTATES/,/^\.\\" %ENDIF ENABLE_SAVESTATES/ s,^,.\\"\# ,'
 endif
 
 if ENABLE_ATTRIBUTELOG
 MAN_ATTRIBUTELOG = sed "s|/usr/local/var/lib/smartmontools/attrlog\\.|$(attributelog)|g"
 else
-MAN_ATTRIBUTELOG = sed '/BEGIN ENABLE_ATTRIBUTELOG/,/END ENABLE_ATTRIBUTELOG/d'
+MAN_ATTRIBUTELOG = sed '/^\.\\" %IF ENABLE_ATTRIBUTELOG/,/^\.\\" %ENDIF ENABLE_ATTRIBUTELOG/ s,^,.\\"\# ,'
 endif
 
 MAN_FILTER = \
-    sed "s|CURRENT_CVS_VERSION|$(releaseversion)|g; \
-         s|CURRENT_CVS_DATE|`sed -n 's,^.*DATE[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g; \
-         s|CURRENT_CVS_TIME|`sed -n 's,^.*TIME[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g; \
-         s|/usr/local/share/man/|$(mandir)/|g; \
-         s|/usr/local/sbin/|$(sbindir)/|g; \
-         s|/usr/local/etc/rc\\.d/init.d/|$(initddir)/|g; \
-         s|/usr/local/share/doc/smartmontools-5.1/|$(docsdir)/|g;  \
-         s|/usr/local/etc/smartd\\.conf|$(sysconfdir)/smartd.conf|g; \
-         s|/usr/local/etc/smart_drivedb\\.h|$(sysconfdir)/smart_drivedb\\.h|g" | \
+    sed -e 's|CURRENT_SVN_VERSION|$(releaseversion)|g' \
+        -e "s|CURRENT_SVN_DATE|`sed -n 's,^.*DATE[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g" \
+        -e "s|CURRENT_SVN_REV|`sed -n 's,^.*REV[^"]*"\([^"]*\)".*$$,r\1,p' svnversion.h`|g" \
+        -e 's|/usr/local/share/man/|$(mandir)/|g' \
+        -e 's|/usr/local/sbin/|$(sbindir)/|g' \
+        -e 's|/usr/local/etc/rc\.d/init.d/|$(initddir)/|g' \
+        -e 's|/usr/local/share/doc/smartmontools/examplescripts/|!exampledir!|g' \
+        -e 's|/usr/local/share/doc/smartmontools/|$(docsdir)/|g' \
+        -e 's|!exampledir!|$(exampledir)/|g' \
+        -e 's|/usr/local/etc/smartd\.conf|$(sysconfdir)/smartd.conf|g' \
+        -e 's|/usr/local/etc/smart_drivedb\.h|$(sysconfdir)/smart_drivedb.h|g' \
+        -e 's|/usr/local/etc/smartd_warning\.sh|$(smartdscriptdir)/smartd_warning.sh|g' \
+        -e 's|\\fBmail\\fP|\\fB$(os_mailer)\\fP|g' \
+        -e 's|\\'\''mail\\'\''|\\'\''$(os_mailer)\\'\''|g' \
+        -e 's|/usr/bin/mail|/usr/bin/$(os_mailer)|g' \
+        -e 's|RELEASE_6_0_DRIVEDB|@DRIVEDB_BRANCH@|g' | \
+    if test -n '$(smartdplugindir)'; then \
+      sed 's|/usr/local/etc/smartd_warning\.d|$(smartdplugindir)|g' ; \
+    else \
+      sed '/^\.\\" %IF ENABLE_SMARTDPLUGINDIR/,/^\.\\" %ENDIF ENABLE_SMARTDPLUGINDIR/ s,^,.\\"\# ,' ; \
+    fi | \
+    $(MAN_ATTRIBUTELOG) | \
     $(MAN_CAPABILITIES) | \
     $(MAN_DRIVEDB) | \
     $(MAN_SAVESTATES) | \
-    $(MAN_ATTRIBUTELOG)
+    if test -n '$(os_man_filter)'; then \
+      sed -e 's,OS_MAN_FILTER,$(os_man_filter),g' \
+          -e '/^\.\\" %IF NOT OS .*$(os_man_filter)/,/^.\\" %ENDIF NOT OS .*$(os_man_filter)/ s,^,.\\"\# ,' \
+          -e '/^\.\\" %IF OS .*$(os_man_filter)/,/^\.\\" %ENDIF OS .*$(os_man_filter)/ s,^,!!,' \
+          -e '/^\.\\" %IF OS ./,/^\.\\" %ENDIF OS ./ s,^,.\\"\# ,' \
+          -e '/^!*\.\\" %IF NOT OS ./,/^!*\.\\" %ENDIF NOT OS ./ s,^,!!,' \
+          -e 's,^!!!*\.\\"! \(.*\)$$,\1 \\"\#,' \
+          -e 's,^!!!*,,' ; \
+    else \
+      cat; \
+    fi
 
 # Implicit rule 'smart%: smart%.in ...' does not work with BSD make
 smartctl.8: smartctl.8.in Makefile svnversion.h
-       cat $(srcdir)/smartctl.8.in | $(MAN_FILTER) > $@
+       @echo '  cat $(srcdir)/smartctl.8.in | $$(MAN_FILTER) > $@'
+       @cat $(srcdir)/smartctl.8.in | $(MAN_FILTER) > $@
 
 smartd.8: smartd.8.in Makefile svnversion.h
-       cat $(srcdir)/smartd.8.in | $(MAN_FILTER) > $@
+       @echo '  cat $(srcdir)/smartd.8.in | $$(MAN_FILTER) > $@'
+       @cat $(srcdir)/smartd.8.in | $(MAN_FILTER) > $@
 
 smartd.conf.5: smartd.conf.5.in Makefile svnversion.h
-       cat $(srcdir)/smartd.conf.5.in | $(MAN_FILTER) > $@
+       @echo '  cat $(srcdir)/smartd.conf.5.in | $$(MAN_FILTER) > $@'
+       @cat $(srcdir)/smartd.conf.5.in | $(MAN_FILTER) > $@
+
+update-smart-drivedb.8: update-smart-drivedb.8.in Makefile svnversion.h
+       @echo '  cat $(srcdir)/update-smart-drivedb.8.in | $$(MAN_FILTER) > $@'
+       @cat $(srcdir)/update-smart-drivedb.8.in | $(MAN_FILTER) > $@
+
+# Build Solaris specific man pages
+SOLARIS_MAN_FILTER = \
+    sed -e '/^\.TH/s, \([58]\) , !!\1!! ,' \
+        -e '/^\.BR/s, (\([578]\)), (!!\1!!),' \
+        -e 's,\\fP(\([578]\)),\\fP(!!\1!!),g' \
+        -e 's,!!5!!,4,g' -e 's,!!7!!,5,g' -e 's,!!8!!,1m,g' \
+        -e 's,/var/log/messages,/var/adm/messages,g'
+
+smartctl.1m: smartctl.8
+       @echo '  cat smartctl.8 | $$(SOLARIS_MAN_FILTER) > $@'
+       @cat smartctl.8 | $(SOLARIS_MAN_FILTER) > $@
+
+smartd.1m: smartd.8
+       @echo '  cat smartd.8 | $$(SOLARIS_MAN_FILTER) > $@'
+       @cat smartd.8 | $(SOLARIS_MAN_FILTER) > $@
+
+smartd.conf.4: smartd.conf.5
+       @echo '  cat smartd.conf.5 | $$(SOLARIS_MAN_FILTER) > $@'
+       @cat smartd.conf.5 | $(SOLARIS_MAN_FILTER) > $@
+
+update-smart-drivedb.1m: update-smart-drivedb.8
+       @echo '  cat update-smart-drivedb.8 | $$(SOLARIS_MAN_FILTER) > $@'
+       @cat update-smart-drivedb.8 | $(SOLARIS_MAN_FILTER) > $@
+
 
 # Commands to convert man pages into .html and .txt
 # TODO: configure
@@ -473,11 +662,11 @@ MAN2HTML = man2html
 MAN2TXT = groff -man -Tascii -P'-bcou'
 
 # Remove HTTP header and fix links in man2html output
-FIXHTML = sed '1s,^Content-type.*,,' \
-        | sed 's,<A HREF="http://[-a-z/]*/man2html?\([1-8]\)+\(smart[cd][.a-z]*\)">,<A HREF="\2.\1.html">,g' \
-        | sed 's,<A HREF="http://[-a-z/]*/man2html">,<A HREF=".">,g' \
-        | sed 's,<A HREF="http://[-a-z/]*/man2html?[^"]*">\([^<]*\)</A>,\1,g' \
-        | sed 's,<A HREF="mailto:[^s][^m][^a][^"]*">\([^<]*\)</A>,\1,g'
+FIXHTML = sed -e '1s,^Content-type.*,,' \
+              -e 's,<A HREF="[^"]*/man2html?\([1-8]\)+\(smart[cd][.a-z]*\)">,<A HREF="\2.\1.html">,g' \
+              -e 's,<A HREF="[^"]*/man2html">,<A HREF=".">,g' \
+              -e 's,<A HREF="[^"]*/man2html?[^"]*">\([^<]*\)</A>,\1,g' \
+              -e 's,<A HREF="mailto:[^s][^m][^a][^"]*">\([^<]*\)</A>,\1,g'
 
 # Convert man pages into .html and .txt
 
@@ -518,6 +707,31 @@ check:
 
 
 if OS_WIN32_MINGW
+# Windows resources
+
+smartctl_res.o: smartctl_res.rc
+       $(WINDRES) $< $@
+
+smartd_res.o: smartd_res.rc syslogevt.rc
+       $(WINDRES) -I. $< $@
+
+# Convert version for VERSIONINFO resource: 6.1 r3754 -> 6.1.0.3754, set Copyright year
+WIN_RC_FILTER = \
+    ( ver=`echo '$(PACKAGE_VERSION).0' | sed -n 's,^\([0-9]*\.[0-9]*\.[0-9]*\).*$$,\1,p'`; \
+      rev=`sed -n 's,^.*REV[^"]*"\([0-9]*\).*$$,\1,p' svnversion.h`; \
+      txtver="$${ver:-0.0.0}.$${rev:-0}"; binver=`echo "$$txtver" | sed 's|\.|,|g'`; \
+      yy=`sed -n 's,^.*DATE[^"]*"20\([0-9][0-9]\).*$$,\1,p' svnversion.h`; yy="$${yy:-XX}"; \
+      sed -e "s|@BINARY_VERSION@|$$binver|g" -e "s|@TEXT_VERSION@|$$txtver|g" -e "s|@YY@|$$yy|g"; )
+
+smartctl_res.rc: os_win32/smartctl_res.rc.in Makefile svnversion.h
+       cat $< | $(WIN_RC_FILTER) > $@
+
+smartd_res.rc: os_win32/smartd_res.rc.in Makefile svnversion.h
+       cat $< | $(WIN_RC_FILTER) > $@
+
+syslogevt.rc: os_win32/syslogevt.mc
+       $(WINDMC) -b $<
+
 # Definitions for Windows distribution
 
 if OS_WIN64
@@ -533,28 +747,60 @@ distinst_win32 = $(PACKAGE)-$(VERSION).win$(win_bits)-setup.exe
 exedir_win32 = $(distdir_win32)/bin
 docdir_win32 = $(distdir_win32)/doc
 
-FILES_WIN32 = $(exedir_win32)/smartctl.exe \
-              $(exedir_win32)/smartctl-nc.exe \
-              $(exedir_win32)/smartd.exe \
-              $(docdir_win32)/AUTHORS.txt \
-              $(docdir_win32)/CHANGELOG.txt \
-              $(docdir_win32)/COPYING.txt \
-              $(docdir_win32)/INSTALL.txt \
-              $(docdir_win32)/NEWS.txt \
-              $(docdir_win32)/README.txt \
-              $(docdir_win32)/TODO.txt \
-              $(docdir_win32)/WARNINGS.txt \
-              $(docdir_win32)/smartd.conf \
-              $(docdir_win32)/smartctl.8.html \
-              $(docdir_win32)/smartctl.8.txt \
-              $(docdir_win32)/smartd.8.html \
-              $(docdir_win32)/smartd.8.txt \
-              $(docdir_win32)/smartd.conf.5.html \
-              $(docdir_win32)/smartd.conf.5.txt
-
-CLEANFILES += $(FILES_WIN32) $(exedir_win32)/syslogevt.exe \
-              smartctl-nc.exe smartctl-nc.exe.tmp \
-              distdir.mkdir syslogevt.check
+EXEFILES_WIN32 = \
+        $(exedir_win32)/smartctl.exe \
+        $(exedir_win32)/smartctl-nc.exe \
+        $(exedir_win32)/smartd.exe \
+        $(exedir_win32)/smartd_warning.cmd \
+        $(exedir_win32)/runcmda.exe \
+        $(exedir_win32)/runcmdu.exe \
+        $(exedir_win32)/wtssendmsg.exe
+
+if ENABLE_DRIVEDB
+if OS_WIN32_NSIS
+EXEFILES_WIN32 += \
+        $(exedir_win32)/update-smart-drivedb.exe
+endif
+endif
+
+FILES_WIN32 = \
+        $(EXEFILES_WIN32) \
+        $(docdir_win32)/AUTHORS.txt \
+        $(docdir_win32)/ChangeLog.txt \
+        $(docdir_win32)/ChangeLog-5.0-6.0.txt \
+        $(docdir_win32)/COPYING.txt \
+        $(docdir_win32)/INSTALL.txt \
+        $(docdir_win32)/NEWS.txt \
+        $(docdir_win32)/README.txt \
+        $(docdir_win32)/TODO.txt \
+        $(docdir_win32)/WARNINGS.txt \
+        $(docdir_win32)/checksums$(win_bits).txt \
+        $(docdir_win32)/smartd.conf \
+        $(docdir_win32)/smartctl.8.html \
+        $(docdir_win32)/smartctl.8.txt \
+        $(docdir_win32)/smartd.8.html \
+        $(docdir_win32)/smartd.8.txt \
+        $(docdir_win32)/smartd.conf.5.html \
+        $(docdir_win32)/smartd.conf.5.txt \
+        $(exedir_win32)/runcmda.exe.manifest \
+        $(exedir_win32)/runcmdu.exe.manifest
+
+if ENABLE_DRIVEDB
+FILES_WIN32 += \
+        $(exedir_win32)/drivedb.h
+endif
+
+CLEANFILES += \
+        $(FILES_WIN32) \
+        runcmdu.exe \
+        smartctl-nc.exe smartctl-nc.exe.tmp \
+        smartctl_res.rc smartctl_res.o \
+        smartd_res.rc smartd_res.o \
+        syslogevt.h syslogevt.o \
+        syslogevt.rc syslogevt_*.bin \
+        wtssendmsg.exe \
+        update-smart-drivedb.exe \
+        distdir.mkdir
 
 # Textfile converter from package cygutils or tofrodos
 # Note: Only use without options to be compatible with both packages
@@ -570,50 +816,73 @@ install-win32: $(distinst_win32)
 
 installer-win32: $(distinst_win32)
 
-distdir-win32: distdir.mkdir $(FILES_WIN32) syslogevt.check
+distdir-win32: distdir.mkdir $(FILES_WIN32)
 
-$(distzip_win32): distdir.mkdir $(FILES_WIN32) syslogevt.check
+$(distzip_win32): distdir.mkdir $(FILES_WIN32)
        @rm -fv $(distzip_win32)
-       cd $(distdir_win32) && zip -9Dr ../$(distzip_win32) .
+       cd $(distdir_win32) && zip -9 ../$(distzip_win32) bin/* doc/*
+       md5sum $@ > $@.md5
+       sha1sum $@ > $@.sha1
+       sha256sum $@ > $@.sha256
 
-# Build NSIS installer, try to locate makensis in default location first
+if OS_WIN32_NSIS
+# Build NSIS installer
 # Note: Only option character '-' is also compatible with Linux version of makensis
-$(distinst_win32): $(srcdir)/os_win32/installer.nsi distdir.mkdir $(FILES_WIN32) syslogevt.check
-       @makensis="$(MAKENSIS)"; if [ -z "$$makensis" ]; then \
-         if [ ! -z "$$PROGRAMFILES" ] && "$$PROGRAMFILES/NSIS/makensis" -VERSION >/dev/null 2>&1; then \
-           makensis="$$PROGRAMFILES/NSIS/makensis"; \
-         elif makensis -VERSION >/dev/null 2>&1; then \
-           makensis=makensis; \
-         else \
-           echo 'makensis: command not found. Please download and install NSIS' 1>&2; \
-           echo 'from http://nsis.sourceforge.net/Download' 1>&2; exit 1; \
-         fi; \
-       fi; \
-       date=`sed -n 's,^.*DATE[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`; \
+$(distinst_win32): os_win32/installer.nsi distdir.mkdir $(FILES_WIN32)
+       test -z '$(builddir_win64)' || ( cd $(builddir_win64) && make distdir-win32 )
+       @date=`sed -n 's,^.*DATE[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`; \
        rev=`sed -n 's,^.*REV[^"]*"\([^"]*\)".*$$,r\1,p' svnversion.h`; \
        verstr="$(PACKAGE_VERSION) $$date $$rev "$(BUILD_INFO); \
-       echo "$$makensis -V2 -NOCD -DINPDIR=$(distdir_win32) -DOUTFILE=$(distinst_win32) -DVERSTR='$$verstr' $(srcdir)/os_win32/installer.nsi"; \
-       "$$makensis" -V2 -NOCD -DINPDIR="$(distdir_win32)" -DOUTFILE="$(distinst_win32)" -DVERSTR="$$verstr" "$(srcdir)/os_win32/installer.nsi"
+       d64=; test -z '$(builddir_win64)' || d64='-DINPDIR64=$(builddir_win64)/$(PACKAGE)-$(VERSION).win64'; \
+       echo "'$(MAKENSIS)' -V2 -NOCD -DINPDIR=$(distdir_win32) $$d64 -DOUTFILE=$@ -DVERSTR='$$verstr' $<"; \
+       '$(MAKENSIS)' -V2 -NOCD -DINPDIR=$(distdir_win32) $$d64 -DOUTFILE=$@ -DVERSTR="$$verstr" $<
+       md5sum $@ > $@.md5
+       sha1sum $@ > $@.sha1
+       sha256sum $@ > $@.sha256
+
+# Build drivedb.h update tool
+update-smart-drivedb.exe: os_win32/update-smart-drivedb.nsi
+       "$(MAKENSIS)" -V2 -NOCD -DBRANCH=$(DRIVEDB_BRANCH) $<
+
+else
+$(distinst_win32):
+       @echo "makensis: command not found. Please install NSIS from http://nsis.sourceforge.net/" 1>&2
+       @exit 1
+endif
 
 cleandist-win32:
-       rm -rf $(distdir_win32) distdir.mkdir syslogevt.check
+       rm -rf $(distdir_win32) distdir.mkdir
 
 distdir.mkdir:
        @test -d $(exedir_win32) || mkdir -pv $(exedir_win32)
        @test -d $(docdir_win32) || mkdir -pv $(docdir_win32)
        touch $@
 
-syslogevt.check:
-       @if [ -f $(srcdir)/os_win32/syslogevt.exe ]; then \
-         cp -pv $(srcdir)/os_win32/syslogevt.exe $(exedir_win32)/syslogevt.exe; \
-        else echo "Warning: $(srcdir)/os_win32/syslogevt.exe missing."; fi
-       touch $@
-
 $(exedir_win32)/%.exe: %.exe
        cp -p $< $@
        if test -n '$(STRIP)'; then $(STRIP) -s $@; else strip -s $@; fi
        touch -r $< $@
 
+# strip would break NSIS integrity check
+$(exedir_win32)/update-smart-drivedb.exe: update-smart-drivedb.exe
+       cp -p $< $@
+
+# runcmd?.exe only differ by .exe.manifest files
+$(exedir_win32)/runcmda.exe: $(exedir_win32)/runcmdu.exe
+       cp -p $< $@
+
+$(exedir_win32)/%.h: $(srcdir)/%.h
+       $(UNIX2DOS) < $< > $@
+       touch -r $< $@
+
+$(exedir_win32)/%.exe.manifest: $(srcdir)/os_win32/%.exe.manifest
+       $(UNIX2DOS) < $< > $@
+       touch -r $< $@
+
+$(exedir_win32)/%.cmd: $(srcdir)/os_win32/%.cmd
+       $(UNIX2DOS) < $< > $@
+       touch -r $< $@
+
 $(docdir_win32)/%.html: %.html
        $(UNIX2DOS) < $< > $@
        touch -r $< $@
@@ -630,6 +899,10 @@ $(docdir_win32)/%.conf: $(srcdir)/%.conf
        $(UNIX2DOS) < $< > $@
        touch -r $< $@
 
+$(docdir_win32)/checksums$(win_bits).txt: $(EXEFILES_WIN32)
+       (cd $(exedir_win32) && md5sum *.exe && sha1sum *.exe && sha256sum *.exe) \
+       | $(UNIX2DOS) > $@
+
 # Build non-console version of smartctl for GSmartControl.
 # The script below changes the word at offset 220 (Subsystem) from 3
 # (Console) to 2 (GUI) in a copy of smartctl.exe.
@@ -646,19 +919,32 @@ smartctl-nc.exe: smartctl.exe
          else echo "EXE patch failed"; exit 1; fi
        mv -f $@.tmp $@
 
+# Build runcmd?.exe and wtssendmsg.exe
+runcmdu.exe: os_win32/runcmd.c
+       $(CC) -Os -o $@ $<
 
-# Build {config,svnversion}_vc8.h for MSVC8 from MinGW {config,svnversion}.h
+wtssendmsg.exe: os_win32/wtssendmsg.c
+       $(CC) -Os -o $@ $< -lwtsapi32
 
-config-vc8: $(srcdir)/os_win32/config_vc8.h  $(srcdir)/os_win32/svnversion_vc8.h
+# Build os_win32/vc10/{config.h,smart*.rc,svnversion.h} for MSVC10 from MinGW files
 
-$(srcdir)/os_win32/config_vc8.h: config.h
-       sed '1i/* config_vc8.h.  Generated from config.h by Makefile.  */' $< | \
-       sed 's,^#define HAVE_\(ATTR_PACKED\|INTTYPES_H\|STDINT_H\|STRINGS_H\|STRTOULL\|U*INT64_T\|UNISTD_H\|WORKING_SNPRINTF\) 1$$,/* #undef HAVE_\1 */,' | \
-       sed 's,i.86-pc-mingw32,i686-pc-win32vc8,' > $@
+config-vc10: $(srcdir)/os_win32/vc10/config.h \
+             $(srcdir)/os_win32/vc10/smartctl_res.rc \
+             $(srcdir)/os_win32/vc10/smartd_res.rc \
+             $(srcdir)/os_win32/vc10/svnversion.h
 
-$(srcdir)/os_win32/svnversion_vc8.h: svnversion.h
-       cp svnversion.h $@
+$(srcdir)/os_win32/vc10/config.h: config.h Makefile
+       sed -e '1i/* os_win32/vc10/config.h.  Generated from config.h by Makefile.  */' \
+           -e 's,^#define HAVE_\(ATTR_PACKED\|GETTIMEOFDAY\|INTTYPES_H\|[DK_]*NTDDDISK_H\|STRINGS_H\|STRTOULL\|UNISTD_H\|WORKING_SNPRINTF\) 1$$,/* #undef HAVE_\1 */,' \
+           -e 's,^\(#define SMARTMONTOOLS_BUILD_HOST "[^-]*\)[^"]*,\1-pc-w32vc10,' $< > $@
 
-endif
+$(srcdir)/os_win32/vc10/svnversion.h: svnversion.h
+       cp $< $@
 
-SUBDIRS= . examplescripts
+$(srcdir)/os_win32/vc10/smartctl_res.rc: smartctl_res.rc
+       cp $< $@
+
+$(srcdir)/os_win32/vc10/smartd_res.rc: smartd_res.rc
+       cp $< $@
+
+endif