]> git.proxmox.com Git - mirror_smartmontools-debian.git/blobdiff - Makefile.am
Imported Upstream version 6.4+svn4214
[mirror_smartmontools-debian.git] / Makefile.am
index dafe35856c2cafc1b33e885b3c7795bfc3bd6298..48127015426f720d9626654b99ec5de4cda42d14 100644 (file)
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 #
-# $Id: Makefile.am 4102 2015-06-01 19:25:47Z chrfranke $
+# $Id: Makefile.am 4192 2015-12-19 13:59:40Z chrfranke $
 #
 
 @SET_MAKE@
@@ -96,7 +96,6 @@ EXTRA_smartctl_SOURCES = \
         os_qnxnto.h \
         os_solaris.cpp \
         os_solaris.h \
-        os_solaris_ata.s \
         os_win32.cpp \
         os_generic.cpp \
         os_generic.h \
@@ -111,8 +110,8 @@ EXTRA_smartctl_SOURCES = \
 
 if OS_WIN32_MINGW
 
-smartctl_LDADD        += smartctl_res.o
-smartctl_DEPENDENCIES += smartctl_res.o
+smartctl_LDADD        += smartctl_res.o $(os_win32_manifest)
+smartctl_DEPENDENCIES += smartctl_res.o $(os_win32_manifest)
 
 endif
 
@@ -156,7 +155,6 @@ EXTRA_smartd_SOURCES = \
         os_qnxnto.h \
         os_solaris.cpp \
         os_solaris.h \
-        os_solaris_ata.s \
         os_win32.cpp \
         os_generic.cpp \
         os_generic.h \
@@ -177,11 +175,14 @@ smartd_SOURCES += \
         os_win32/syslog_win32.cpp \
         os_win32/syslog.h
 
-smartd_LDADD        += smartd_res.o
-smartd_DEPENDENCIES += smartd_res.o
+smartd_LDADD        += smartd_res.o $(os_win32_manifest)
+smartd_DEPENDENCIES += smartd_res.o $(os_win32_manifest)
 
 endif
 
+# Exclude from source tarball
+nodist_EXTRA_smartctl_SOURCES = os_solaris_ata.s
+nodist_EXTRA_smartd_SOURCES   = os_solaris_ata.s
 
 if NEED_GETOPT_LONG
 
@@ -255,8 +256,8 @@ endif
 all-local: $(extra_MANS)
 install-man: $(extra_MANS)
        @$(NORMAL_INSTALL)
-       $(mkinstalldirs) '$(DESTDIR)$(mandir)/man4'
-       $(mkinstalldirs) '$(DESTDIR)$(mandir)/man1m'
+       $(MKDIR_P) '$(DESTDIR)$(mandir)/man4'
+       $(MKDIR_P) '$(DESTDIR)$(mandir)/man1m'
        for i in $(extra_MANS); do \
          if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
          else file=$$i; fi; \
@@ -319,7 +320,7 @@ sysconf_DATA = smartd.conf
 
 # If modified smartd.conf exists install smartd.conf.sample instead
 install-sysconfDATA: $(sysconf_DATA)
-       $(mkinstalldirs) '$(DESTDIR)$(sysconfdir)'
+       $(MKDIR_P) '$(DESTDIR)$(sysconfdir)'
        @s="$(srcdir)/smartd.conf"; \
        f="$(DESTDIR)$(sysconfdir)/smartd.conf$(smartd_suffix)"; \
        if test -z "$(smartd_suffix)" && test -f "$$f"; then \
@@ -365,10 +366,13 @@ EXTRA_DIST = \
         os_darwin/SMART.in \
         os_darwin/StartupParameters.plist \
         os_darwin/English_Localizable.strings \
+        os_darwin/pkg/PackageInfo.in \
+        os_darwin/pkg/Distribution.in \
+        os_darwin/pkg/installer/README.html \
+        os_darwin/pkg/root/usr/local/sbin/smart-pkg-uninstall \
+        os_win32/default.manifest \
         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 \
@@ -386,12 +390,15 @@ CLEANFILES = \
         smartd.8 \
         smartd.1m \
         smartd.8.html \
+        smartd.8.html.tmp \
         smartd.8.txt \
         smartctl.8 \
         smartctl.1m \
         smartctl.8.html \
+        smartctl.8.html.tmp \
         smartctl.8.txt \
         smartd.conf.5.html \
+        smartd.conf.5.html.tmp \
         smartd.conf.5.txt \
         smartd.initd \
         smartd.freebsd.initd \
@@ -416,7 +423,6 @@ MAINTAINERCLEANFILES = \
         $(srcdir)/depcomp \
         $(srcdir)/install-sh \
         $(srcdir)/missing \
-        $(srcdir)/mkinstalldirs \
         $(srcdir)/m4/pkg.m4
 
 utility.o: svnversion.h
@@ -424,7 +430,7 @@ utility.o: svnversion.h
 if IS_SVN_BUILD
 # Get version info from SVN
 svnversion.h: ChangeLog Makefile $(svn_deps)
-       @echo '  svn info | $$(VERSION_FROM_SVN_INFO) > $@'
+       @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' \
@@ -434,10 +440,10 @@ svnversion.h: ChangeLog Makefile $(svn_deps)
 else
 
 # SVN not available, guess version info from Id strings
-svnversion.h: ChangeLog Makefile
-       @echo '  cat ChangeLog $$(SOURCES) | $$(VERSION_FROM_SVN_IDS) > $@'
+svnversion.h: ChangeLog Makefile NEWS
+       @echo ' cat ChangeLog NEWS $$(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) \
+       @(cd $(srcdir) && cat ChangeLog NEWS Makefile.am configure.ac smart*.in *.cpp *.h) \
        | 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' \
@@ -472,15 +478,15 @@ SMART : os_darwin/SMART.in
        sed "s|/usr/sbin/|$(sbindir)/|" $< > $@
 
 install-initdDATA-darwin: $(initd_DATA)
-       $(mkinstalldirs) $(DESTDIR)$(initddir)
-       $(mkinstalldirs) $(DESTDIR)$(initddir)/SMART
-       $(mkinstalldirs) $(DESTDIR)$(initddir)/SMART/Resources
+       $(MKDIR_P) $(DESTDIR)$(initddir)
+       $(MKDIR_P) $(DESTDIR)$(initddir)/SMART
+       $(MKDIR_P) $(DESTDIR)$(initddir)/SMART/Resources
        $(INSTALL_SCRIPT) $(top_builddir)/SMART $(DESTDIR)$(initddir)/SMART
        $(INSTALL_DATA) $(srcdir)/os_darwin/StartupParameters.plist \
            $(DESTDIR)$(initddir)/SMART/StartupParameters.plist
        for i in English ; do \
          RDIR=$(DESTDIR)$(initddir)/SMART/Resources/$${i}.lproj ; \
-         $(mkinstalldirs) $$RDIR ;\
+         $(MKDIR_P) $$RDIR ;\
          $(INSTALL_DATA) $(srcdir)/os_darwin/$${i}_Localizable.strings \
            $$RDIR/Localizable.strings ; \
        done
@@ -501,7 +507,7 @@ initd_DATA_install = install-initdDATA-generic
 initd_DATA_uninstall = uninstall-initdDATA-generic
 
 install-initdDATA-generic: $(initd_DATA)
-       $(mkinstalldirs) '$(DESTDIR)$(initddir)'
+       $(MKDIR_P) '$(DESTDIR)$(initddir)'
        $(INSTALL_SCRIPT) '$(top_builddir)/$(initdfile)' '$(DESTDIR)$(initddir)/smartd$(smartd_suffix)'
 
 uninstall-initdDATA-generic:
@@ -525,24 +531,23 @@ systemdsystemunit_DATA = smartd.service
 endif
 
 smartd.service: smartd.service.in Makefile
-       @echo '  cat $(srcdir)/smartd.service.in | $$(SMARTD_SERVICE_FILTER) > $@'
-       @cat $(srcdir)/smartd.service.in | \
+       @echo ' $$(SMARTD_SERVICE_FILTER) < $(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 > $@
+       fi; } < $(srcdir)/smartd.service.in > $@
 
 
 # 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; \
+         echo " $(MKDIR_P) '$(DESTDIR)$$d'"; \
+         $(MKDIR_P) "$(DESTDIR)$$d" || exit 1; \
        done
 
 install-data-local: installdirs-local
@@ -550,7 +555,7 @@ install-data-local: installdirs-local
 #
 # Build man pages
 #
-MAN_FILTER = \
+MAN_FILTER = \
     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" \
@@ -606,24 +611,24 @@ MAN_FILTER = \
           -e 's,^!!!*,,' ; \
     else \
       cat; \
-    fi
+    fi; }
 
 # Implicit rule 'smart%: smart%.in ...' does not work with BSD make
 smartctl.8: smartctl.8.in Makefile svnversion.h
-       @echo '  cat $(srcdir)/smartctl.8.in | $$(MAN_FILTER) > $@'
-       @cat $(srcdir)/smartctl.8.in | $(MAN_FILTER) > $@
+       @echo ' $$(MAN_FILTER) < $(srcdir)/smartctl.8.in > $@'
+       @$(MAN_FILTER) < $(srcdir)/smartctl.8.in > $@
 
 smartd.8: smartd.8.in Makefile svnversion.h
-       @echo '  cat $(srcdir)/smartd.8.in | $$(MAN_FILTER) > $@'
-       @cat $(srcdir)/smartd.8.in | $(MAN_FILTER) > $@
+       @echo ' $$(MAN_FILTER) < $(srcdir)/smartd.8.in > $@'
+       @$(MAN_FILTER) < $(srcdir)/smartd.8.in > $@
 
 smartd.conf.5: smartd.conf.5.in Makefile svnversion.h
-       @echo '  cat $(srcdir)/smartd.conf.5.in | $$(MAN_FILTER) > $@'
-       @cat $(srcdir)/smartd.conf.5.in | $(MAN_FILTER) > $@
+       @echo ' $$(MAN_FILTER) < $(srcdir)/smartd.conf.5.in > $@'
+       @$(MAN_FILTER) < $(srcdir)/smartd.conf.5.in > $@
 
 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) > $@
+       @echo ' $$(MAN_FILTER) < $(srcdir)/update-smart-drivedb.8.in > $@'
+       @$(MAN_FILTER) < $(srcdir)/update-smart-drivedb.8.in > $@
 
 # Build Solaris specific man pages
 SOLARIS_MAN_FILTER = \
@@ -634,20 +639,20 @@ SOLARIS_MAN_FILTER = \
         -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) > $@
+       @echo ' $$(SOLARIS_MAN_FILTER) < smartctl.8 > $@'
+       @$(SOLARIS_MAN_FILTER) < smartctl.8 > $@
 
 smartd.1m: smartd.8
-       @echo '  cat smartd.8 | $$(SOLARIS_MAN_FILTER) > $@'
-       @cat smartd.8 | $(SOLARIS_MAN_FILTER) > $@
+       @echo ' $$(SOLARIS_MAN_FILTER) < smartd.8 > $@'
+       @$(SOLARIS_MAN_FILTER) < smartd.8 > $@
 
 smartd.conf.4: smartd.conf.5
-       @echo '  cat smartd.conf.5 | $$(SOLARIS_MAN_FILTER) > $@'
-       @cat smartd.conf.5 | $(SOLARIS_MAN_FILTER) > $@
+       @echo ' $$(SOLARIS_MAN_FILTER) < smartd.conf.5 > $@'
+       @$(SOLARIS_MAN_FILTER) < smartd.conf.5 > $@
 
 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) > $@
+       @echo ' $$(SOLARIS_MAN_FILTER) < update-smart-drivedb.8 > $@'
+       @$(SOLARIS_MAN_FILTER) < update-smart-drivedb.8 > $@
 
 
 # Commands to convert man pages into .html and .txt
@@ -669,21 +674,15 @@ htmlman: smartctl.8.html smartd.8.html smartd.conf.5.html
 
 txtman:  smartctl.8.txt smartd.8.txt smartd.conf.5.txt
 
-if OS_WIN32_MINGW
-
 %.5.html: %.5
-       $(DOS2UNIX) < $< | $(MAN2HTML) | $(FIXHTML) > $@
+       $(MAN2HTML) $< > $@.tmp
+       @echo ' $$(FIXHTML) < $@.tmp > $@'
+       @$(FIXHTML) < $@.tmp > $@
 
 %.8.html: %.8
-       $(DOS2UNIX) < $< | $(MAN2HTML) | $(FIXHTML) > $@
-else
-
-%.5.html: %.5
-       $(MAN2HTML) $< | $(FIXHTML) > $@
-
-%.8.html: %.8
-       $(MAN2HTML) $< | $(FIXHTML) > $@
-endif
+       $(MAN2HTML) $< > $@.tmp
+       @echo ' $$(FIXHTML) < $@.tmp > $@'
+       @$(FIXHTML) < $@.tmp > $@
 
 %.5.txt: %.5
        $(MAN2TXT) $< > $@
@@ -711,22 +710,35 @@ 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"; )
+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) > $@
+       @echo ' $$(WIN_RC_FILTER) < $< > $@'
+       @$(WIN_RC_FILTER) < $< > $@
 
 smartd_res.rc: os_win32/smartd_res.rc.in Makefile svnversion.h
-       cat $< | $(WIN_RC_FILTER) > $@
+       @echo ' $$(WIN_RC_FILTER) < $< > $@'
+       @$(WIN_RC_FILTER) < $< > $@
 
 syslogevt.rc: os_win32/syslogevt.mc
        $(WINDMC) -b $<
 
+# Application manifests
+
+default.manifest.o: os_win32/default.manifest
+       echo '1 24 "$<"' | $(WINDRES) -J rc -o $@
+
+defadmin.manifest.o: defadmin.manifest
+       echo '1 24 "$<"' | $(WINDRES) -J rc -o $@
+
+defadmin.manifest: os_win32/default.manifest
+       sed 's,"asInvoker","requireAdministrator",' $< > $@
+
 # Definitions for Windows distribution
 
 if OS_WIN64
@@ -775,9 +787,7 @@ FILES_WIN32 = \
         $(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
+        $(docdir_win32)/smartd.conf.5.txt
 
 if ENABLE_DRIVEDB
 FILES_WIN32 += \
@@ -786,20 +796,18 @@ endif
 
 CLEANFILES += \
         $(FILES_WIN32) \
-        runcmdu.exe \
+        defadmin.manifest \
+        distdir.mkdir \
+        runcmda.exe 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 \
+        smartctl_res.rc smartd_res.rc \
+        syslogevt.h \
         syslogevt.rc syslogevt_*.bin \
-        wtssendmsg.exe \
         update-smart-drivedb.exe \
-        distdir.mkdir
+        wtssendmsg.exe
 
-# Textfile converter from package cygutils or tofrodos
-# Note: Only use without options to be compatible with both packages
+# Note: Only use without options to be compatible with all variants
 UNIX2DOS = unix2dos
-DOS2UNIX = dos2unix
 
 # Build Windows distribution
 
@@ -824,11 +832,11 @@ if OS_WIN32_NSIS
 # Note: Only option character '-' is also compatible with Linux version of makensis
 $(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); \
-       d64=; test -z '$(builddir_win64)' || d64='-DINPDIR64=$(builddir_win64)/$(PACKAGE)-$(VERSION).win64'; \
-       echo "'$(MAKENSIS)' -V2 -NOCD -DINPDIR=$(distdir_win32) $$d64 -DOUTFILE=$@ -DVERSTR='$$verstr' $<"; \
+       @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) && \
+       d64= && if [ -n '$(builddir_win64)' ]; then d64='-DINPDIR64=$(builddir_win64)/$(PACKAGE)-$(VERSION).win64'; fi && \
+       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
@@ -861,18 +869,10 @@ $(exedir_win32)/%.exe: %.exe
 $(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 $< $@
@@ -914,11 +914,17 @@ smartctl-nc.exe: smartctl.exe
        mv -f $@.tmp $@
 
 # Build runcmd?.exe and wtssendmsg.exe
-runcmdu.exe: os_win32/runcmd.c
-       $(CC) -Os -o $@ $<
+runcmd.o: os_win32/runcmd.c
+       $(CC) -c -Os $<
 
-wtssendmsg.exe: os_win32/wtssendmsg.c
-       $(CC) -Os -o $@ $< -lwtsapi32
+runcmdu.exe: runcmd.o $(os_win32_manifest)
+       $(CC) -o $@ $^
+
+runcmda.exe: runcmd.o defadmin.manifest.o
+       $(CC) -o $@ $^
+
+wtssendmsg.exe: os_win32/wtssendmsg.c $(os_win32_manifest)
+       $(CC) -Os -o $@ $< $(os_win32_manifest) -lwtsapi32
 
 # Build os_win32/vc10/{config.h,smart*.rc,svnversion.h} for MSVC10 from MinGW files
 
@@ -942,3 +948,44 @@ $(srcdir)/os_win32/vc10/smartd_res.rc: smartd_res.rc
        cp $< $@
 
 endif
+if OS_DARWIN
+# Definitions for OSX distribution
+distdir_darwin  = $(PACKAGE)-$(VERSION).darwin
+dmg_darwin =  $(PACKAGE)-$(VERSION).dmg
+pkg_darwin = $(PACKAGE)-$(VERSION).pkg
+
+# build darwin installer 
+$(pkg_darwin):
+       ${MAKE} install DESTDIR=$(distdir_darwin)/root
+       @cp $(srcdir)/os_darwin/pkg/root/usr/local/sbin/smart-pkg-uninstall $(distdir_darwin)/root$(sbindir)
+       @mkdir -p $(distdir_darwin)/pkg
+       @( cd $(distdir_darwin)/root && find . | cpio -o --format odc --owner 0:80 | gzip -c ) > $(distdir_darwin)/pkg/Payload
+       PAYLOAD_FILES=`find $(distdir_darwin)/root | wc -l` &&\
+       PAYLOAD_SIZEKB=`du -BK  -s $(distdir_darwin)/root|${AWK} '{print $$1}'|tr -d 'K'` &&\
+       sed -e "s|@version@|$(VERSION)|" -e "s|@files@|$${PAYLOAD_FILES}|" \
+               -e "s|@size@|$${PAYLOAD_SIZEKB}|" $(srcdir)/os_darwin/pkg/PackageInfo.in \
+               > $(distdir_darwin)/pkg/PackageInfo &&\
+       sed -e "s|@version@|$(VERSION)|" -e "s|@files@|$${PAYLOAD_FILES}|" -e "s|@size@|$${PAYLOAD_SIZEKB}|" \
+               -e "s|@pkgname@|$(pkg_darwin)|" \
+               $(srcdir)/os_darwin/pkg/Distribution.in > $(distdir_darwin)/pkg/Distribution
+       @mkdir -p $(distdir_darwin)/pkg/Resources/English.lproj
+       @cp $(srcdir)/COPYING $(distdir_darwin)/pkg/Resources/English.lproj/license.txt
+       @mkbom -u 0 -g 80 $(distdir_darwin)/root $(distdir_darwin)/pkg/Bom
+       @mkdir -p $(distdir_darwin)/dmg
+       @( cd $(distdir_darwin)/pkg && xar --compression none -cf "../dmg/$(pkg_darwin)" * )
+
+# build darwon dmg image
+$(dmg_darwin):
+       @cp $(srcdir)/os_darwin/pkg/installer/README.html $(distdir_darwin)/dmg
+       @mkisofs -V 'smartmontools' -no-pad -r -apple -o $(distdir_darwin)/smartmontools-$(VERSION).iso \
+               -hfs-bless "$(distdir_darwin)/dmg/" "$(distdir_darwin)/dmg/"
+       @dmg dmg $(distdir_darwin)/smartmontools-$(VERSION).iso $(dmg_darwin)
+       md5sum $@ > $@.md5
+       sha1sum $@ > $@.sha1
+       sha256sum $@ > $@.sha256
+
+install-darwin: install-darwin-cleanup $(pkg_darwin) $(dmg_darwin)
+
+install-darwin-cleanup: 
+       @rm -rf $(distdir_darwin)
+endif