]> git.proxmox.com Git - mirror_smartmontools-debian.git/blame - Makefile.am
import smartmontools 7.0
[mirror_smartmontools-debian.git] / Makefile.am
CommitLineData
832b75ed
GG
1## Process this file with automake to produce Makefile.in
2#
ff28b140 3# $Id: Makefile.am 4848 2018-12-05 18:30:46Z chrfranke $
832b75ed
GG
4#
5
6@SET_MAKE@
7
ee38a438 8ACLOCAL_AMFLAGS = -I m4
d008864d 9
4d59bff9
GG
10# Make sure .cpp takes precedence to avoid compiling old .c file
11SUFFIXES = .cpp .c .s .o
12
2127e193
GI
13# BUILD_INFO can be provided by package maintainers (see INSTALL file)
14BUILD_INFO= "(local build)"
4d59bff9 15
d2e702cf
GI
16AM_CPPFLAGS = \
17 -DBUILD_INFO='$(BUILD_INFO)' \
18 -DSMARTMONTOOLS_SYSCONFDIR='"$(sysconfdir)"' \
19 -DSMARTMONTOOLS_SMARTDSCRIPTDIR='"$(smartdscriptdir)"'
20
2127e193
GI
21if ENABLE_DRIVEDB
22AM_CPPFLAGS += -DSMARTMONTOOLS_DRIVEDBDIR='"$(drivedbdir)"'
23endif
24if ENABLE_SAVESTATES
25AM_CPPFLAGS += -DSMARTMONTOOLS_SAVESTATES='"$(savestates)"'
26endif
27if ENABLE_ATTRIBUTELOG
28AM_CPPFLAGS += -DSMARTMONTOOLS_ATTRIBUTELOG='"$(attributelog)"'
29endif
832b75ed 30
d008864d
GI
31if OS_WIN32_MINGW
32AM_CPPFLAGS += -I$(srcdir)/os_win32
33endif
e9583e0c 34if NEED_GETOPT_LONG
ff28b140 35AM_CPPFLAGS += -I$(srcdir)/getopt -D_GETOPT_STANDALONE
e9583e0c
GI
36endif
37if NEED_REGEX
ff28b140 38AM_CPPFLAGS += -I$(srcdir)/regex -D_REGEX_STANDALONE
e9583e0c
GI
39endif
40
ee38a438
GI
41sbin_PROGRAMS = \
42 smartctl \
43 smartd
832b75ed 44
a86ec89e 45if ENABLE_UPDATE_SMART_DRIVEDB
cfbba5b9
GI
46if OS_WIN32_MINGW
47else
7f0798ef
GI
48sbin_SCRIPTS = update-smart-drivedb
49endif
cfbba5b9 50endif
7f0798ef
GI
51
52
ee38a438
GI
53smartctl_SOURCES = \
54 smartctl.cpp \
55 smartctl.h \
56 atacmdnames.cpp \
57 atacmdnames.h \
58 atacmds.cpp \
59 atacmds.h \
60 ataidentify.cpp \
61 ataidentify.h \
62 ataprint.cpp \
63 ataprint.h \
64 dev_ata_cmd_set.cpp \
65 dev_ata_cmd_set.h \
f9e10201
JD
66 dev_intelliprop.cpp \
67 dev_intelliprop.h \
ee38a438
GI
68 dev_interface.cpp \
69 dev_interface.h \
70 dev_tunnelled.h \
71 drivedb.h \
ff28b140
TL
72 json.cpp \
73 json.h \
ee38a438
GI
74 knowndrives.cpp \
75 knowndrives.h \
a86ec89e
GI
76 nvmecmds.cpp \
77 nvmecmds.h \
78 nvmeprint.cpp \
79 nvmeprint.h \
ee38a438
GI
80 scsicmds.cpp \
81 scsicmds.h \
82 scsiata.cpp \
ff28b140 83 scsinvme.cpp \
ee38a438
GI
84 scsiprint.cpp \
85 scsiprint.h \
86 utility.cpp \
ff28b140
TL
87 utility.h \
88 sg_unaligned.h
ee38a438 89
a86ec89e
GI
90smartctl_LDADD = $(os_deps) $(os_libs)
91smartctl_DEPENDENCIES = $(os_deps)
ee38a438
GI
92
93EXTRA_smartctl_SOURCES = \
94 os_darwin.cpp \
95 os_darwin.h \
96 os_linux.cpp \
97 os_linux.h \
98 os_freebsd.cpp \
99 os_freebsd.h \
100 os_netbsd.cpp \
101 os_netbsd.h \
102 os_openbsd.cpp \
103 os_openbsd.h \
f9e10201
JD
104 os_os2.cpp \
105 os_os2.h \
ee38a438
GI
106 os_qnxnto.cpp \
107 os_qnxnto.h \
108 os_solaris.cpp \
109 os_solaris.h \
ee38a438
GI
110 os_win32.cpp \
111 os_generic.cpp \
112 os_generic.h \
d2e702cf 113 aacraid.h \
ee38a438
GI
114 cciss.cpp \
115 cciss.h \
116 cissio_freebsd.h \
117 dev_areca.cpp \
118 dev_areca.h \
119 dev_legacy.cpp \
a86ec89e 120 linux_nvme_ioctl.h \
ee38a438
GI
121 megaraid.h
122
123if OS_WIN32_MINGW
124
ff28b140
TL
125smartctl_SOURCES += \
126 os_win32/popen_win32.cpp \
127 os_win32/popen.h
128
f9e10201
JD
129smartctl_LDADD += smartctl_res.o
130smartctl_DEPENDENCIES += smartctl_res.o
ee38a438
GI
131
132endif
133
134
135smartd_SOURCES = \
136 smartd.cpp \
137 atacmdnames.cpp \
138 atacmdnames.h \
139 atacmds.cpp \
140 atacmds.h \
141 dev_ata_cmd_set.cpp \
142 dev_ata_cmd_set.h \
f9e10201
JD
143 dev_intelliprop.cpp \
144 dev_intelliprop.h \
ee38a438
GI
145 dev_interface.cpp \
146 dev_interface.h \
147 dev_tunnelled.h \
148 drivedb.h \
ee38a438
GI
149 knowndrives.cpp \
150 knowndrives.h \
a86ec89e
GI
151 nvmecmds.cpp \
152 nvmecmds.h \
ee38a438
GI
153 scsicmds.cpp \
154 scsicmds.h \
155 scsiata.cpp \
ff28b140 156 scsinvme.cpp \
ee38a438 157 utility.cpp \
ff28b140
TL
158 utility.h \
159 sg_unaligned.h
832b75ed 160
ff28b140 161smartd_LDADD = $(os_deps) $(os_libs) $(CAPNG_LDADD) $(SYSTEMD_LDADD)
a86ec89e 162smartd_DEPENDENCIES = $(os_deps)
4d59bff9 163
ee38a438
GI
164EXTRA_smartd_SOURCES = \
165 os_darwin.cpp \
166 os_darwin.h \
167 os_linux.cpp \
168 os_linux.h \
169 os_freebsd.cpp \
170 os_freebsd.h \
171 os_netbsd.cpp \
172 os_netbsd.h \
173 os_openbsd.cpp \
174 os_openbsd.h \
f9e10201
JD
175 os_os2.cpp \
176 os_os2.h \
ee38a438
GI
177 os_qnxnto.cpp \
178 os_qnxnto.h \
179 os_solaris.cpp \
180 os_solaris.h \
ee38a438
GI
181 os_win32.cpp \
182 os_generic.cpp \
183 os_generic.h \
d2e702cf 184 aacraid.h \
ee38a438
GI
185 cciss.cpp \
186 cciss.h \
187 cissio_freebsd.h \
188 dev_areca.cpp \
189 dev_areca.h \
190 dev_legacy.cpp \
a86ec89e
GI
191 linux_nvme_ioctl.h \
192 freebsd_nvme_ioctl.h \
f9e10201 193 netbsd_nvme_ioctl.h \
ee38a438 194 megaraid.h
832b75ed
GG
195
196if OS_WIN32_MINGW
197
e9583e0c
GI
198smartd_SOURCES += \
199 os_win32/daemon_win32.cpp \
200 os_win32/daemon_win32.h \
ff28b140
TL
201 os_win32/popen_win32.cpp \
202 os_win32/popen.h \
e9583e0c
GI
203 os_win32/syslog_win32.cpp \
204 os_win32/syslog.h
832b75ed 205
f9e10201
JD
206smartd_LDADD += smartd_res.o
207smartd_DEPENDENCIES += smartd_res.o
2127e193 208
ee38a438 209endif
4d59bff9 210
a86ec89e
GI
211# Exclude from source tarball
212nodist_EXTRA_smartctl_SOURCES = os_solaris_ata.s
213nodist_EXTRA_smartd_SOURCES = os_solaris_ata.s
832b75ed 214
e9583e0c
GI
215if NEED_GETOPT_LONG
216
217smartctl_SOURCES += \
218 getopt/getopt.c \
219 getopt/getopt.h \
ff28b140
TL
220 getopt/getopt1.c \
221 getopt/getopt_int.h \
222 getopt/bits/getopt_core.h \
223 getopt/bits/getopt_ext.h
832b75ed 224
e9583e0c
GI
225smartd_SOURCES += \
226 getopt/getopt.c \
227 getopt/getopt.h \
ff28b140
TL
228 getopt/getopt1.c \
229 getopt/getopt_int.h \
230 getopt/bits/getopt_core.h \
231 getopt/bits/getopt_ext.h
e9583e0c
GI
232
233endif
234
235if NEED_REGEX
236
237smartctl_SOURCES += \
238 regex/regex.c \
239 regex/regex.h \
240 regex/regex_internal.h
241
242smartd_SOURCES += \
243 regex/regex.c \
244 regex/regex.h \
245 regex/regex_internal.h
832b75ed
GG
246
247# Included by regex.c:
e9583e0c
GI
248EXTRA_smartctl_SOURCES += \
249 regex/regcomp.c \
250 regex/regexec.c \
251 regex/regex_internal.c
252
253EXTRA_smartd_SOURCES += \
254 regex/regcomp.c \
255 regex/regexec.c \
256 regex/regex_internal.c
832b75ed
GG
257
258endif
259
cfbba5b9
GI
260if OS_WIN32
261
262smartctl_SOURCES += \
263 csmisas.h \
264 os_win32/wmiquery.cpp \
265 os_win32/wmiquery.h
266
267smartd_SOURCES += \
268 csmisas.h \
269 os_win32/wmiquery.cpp \
270 os_win32/wmiquery.h
271
272smartctl_LDADD += -lole32 -loleaut32
273smartd_LDADD += -lole32 -loleaut32
274
275endif
276
832b75ed
GG
277if OS_SOLARIS
278# This block is required because Solaris uses manual page section 1m
279# for administrative command (linux/freebsd use section 8) and Solaris
280# uses manual page section 4 for file formats (linux/freebsd use
281# section 5). Automake can deal cleanly with man page sections 1-8
282# and n, but NOT with sections of the form 1m.
283extra_MANS = smartd.conf.4 \
284 smartctl.1m \
285 smartd.1m
a86ec89e 286if ENABLE_UPDATE_SMART_DRIVEDB
d2e702cf
GI
287extra_MANS += update-smart-drivedb.1m
288endif
289
290all-local: $(extra_MANS)
832b75ed
GG
291install-man: $(extra_MANS)
292 @$(NORMAL_INSTALL)
a86ec89e
GI
293 $(MKDIR_P) '$(DESTDIR)$(mandir)/man4'
294 $(MKDIR_P) '$(DESTDIR)$(mandir)/man1m'
832b75ed
GG
295 for i in $(extra_MANS); do \
296 if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
297 else file=$$i; fi; \
298 ext=`echo $$i | sed -e 's/^.*\\.//'`; \
299 inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
300 inst=`echo $$inst | sed -e 's/^.*\///'`; \
301 inst=`echo $$inst | sed '$(transform)'`.$$ext; \
a86ec89e
GI
302 echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(mandir)/man$$ext/$$inst'"; \
303 $(INSTALL_DATA) "$$file" "$(DESTDIR)$(mandir)/man$$ext/$$inst"; \
832b75ed
GG
304 done
305uninstall-man:
306 @$(NORMAL_UNINSTALL)
307 for i in $(extra_MANS); do \
308 if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
309 else file=$$i; fi; \
310 ext=`echo $$i | sed -e 's/^.*\\.//'`; \
311 inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
312 inst=`echo $$inst | sed -e 's/^.*\///'`; \
313 inst=`echo $$inst | sed '$(transform)'`.$$ext; \
a86ec89e
GI
314 echo " rm -f '$(DESTDIR)$(mandir)/man$$ext/$$inst'"; \
315 rm -f "$(DESTDIR)$(mandir)/man$$ext/$$inst"; \
832b75ed 316 done
832b75ed
GG
317else
318# For systems that adopts traditional manner
d2e702cf 319
832b75ed
GG
320man_MANS = smartd.conf.5 \
321 smartctl.8 \
322 smartd.8
d2e702cf 323
a86ec89e 324if ENABLE_UPDATE_SMART_DRIVEDB
d2e702cf
GI
325man_MANS += update-smart-drivedb.8
326endif
327
832b75ed
GG
328endif
329
330docsdir=$(docdir)
ee38a438
GI
331docs_DATA = \
332 AUTHORS \
333 ChangeLog \
334 ChangeLog-5.0-6.0 \
335 COPYING \
336 INSTALL \
337 NEWS \
338 README \
339 TODO \
ee38a438 340 smartd.conf
832b75ed 341
cfbba5b9
GI
342examplesdir=$(exampledir)
343examples_DATA = \
344 examplescripts/README
345examples_SCRIPTS = \
346 examplescripts/Example1 \
347 examplescripts/Example2 \
348 examplescripts/Example3 \
d2e702cf
GI
349 examplescripts/Example4 \
350 examplescripts/Example5 \
351 examplescripts/Example6
cfbba5b9
GI
352
353sysconf_DATA = smartd.conf
354
355# If modified smartd.conf exists install smartd.conf.sample instead
356install-sysconfDATA: $(sysconf_DATA)
a86ec89e 357 $(MKDIR_P) '$(DESTDIR)$(sysconfdir)'
cfbba5b9
GI
358 @s="$(srcdir)/smartd.conf"; \
359 f="$(DESTDIR)$(sysconfdir)/smartd.conf$(smartd_suffix)"; \
360 if test -z "$(smartd_suffix)" && test -f "$$f"; then \
361 if cmp "$$s" "$$f" >/dev/null 2>/dev/null; then :; else \
362 echo "************************************************************"; \
363 echo "*** $$f preserved"; \
364 echo "*** installing smartd.conf.sample instead"; \
365 echo "************************************************************"; \
366 f="$$f".sample; \
367 fi; \
368 fi; \
a86ec89e 369 echo " $(INSTALL_DATA) '$$s' '$$f'"; \
cfbba5b9
GI
370 $(INSTALL_DATA) "$$s" "$$f"
371
372# If smartd.conf.sample exists preserve smartd.conf
373uninstall-sysconfDATA:
374 @f="$(DESTDIR)$(sysconfdir)/smartd.conf$(smartd_suffix)"; \
375 if test -z "$(smartd_suffix)" && test -f "$$f".sample; then \
376 echo "************************************************************"; \
377 echo "*** $$f preserved"; \
378 echo "*** removing smartd.conf.sample instead"; \
379 echo "************************************************************"; \
380 f="$$f".sample; \
381 fi; \
a86ec89e 382 echo " rm -f '$$f'"; \
cfbba5b9
GI
383 rm -f "$$f"
384
d2e702cf 385smartdscript_SCRIPTS = smartd_warning.sh
ee38a438 386
cfbba5b9 387EXTRA_DIST = \
f9e10201 388 .editorconfig \
a7e8ffec 389 autogen.sh \
cfbba5b9 390 smartd.initd.in \
ff28b140 391 smartd.cygwin.initd.in \
a7e8ffec 392 smartd.freebsd.initd.in \
cfbba5b9
GI
393 smartd.8.in \
394 smartctl.8.in \
395 smartd.conf.5.in \
396 smartd.conf \
a7e8ffec 397 smartd.service.in \
ee38a438 398 smartd_warning.sh.in \
cfbba5b9 399 update-smart-drivedb.in \
d2e702cf 400 update-smart-drivedb.8.in \
d008864d 401 m4/pkg.m4 \
a86ec89e
GI
402 os_darwin/com.smartmontools.smartd.plist.in \
403 os_darwin/pkg/PackageInfo.in \
404 os_darwin/pkg/Distribution.in \
405 os_darwin/pkg/installer/README.html \
406 os_darwin/pkg/root/usr/local/sbin/smart-pkg-uninstall \
407 os_win32/default.manifest \
cfbba5b9 408 os_win32/installer.nsi \
d008864d 409 os_win32/runcmd.c \
f9e10201
JD
410 os_win32/smartd_mailer.ps1 \
411 os_win32/smartd_mailer.conf.sample.ps1 \
ee38a438 412 os_win32/smartd_warning.cmd \
cfbba5b9
GI
413 os_win32/syslogevt.mc \
414 os_win32/update-smart-drivedb.nsi \
f9e10201 415 os_win32/versioninfo.rc.in \
ee38a438 416 os_win32/wtssendmsg.c \
cfbba5b9
GI
417 $(docs_DATA) \
418 $(examples_DATA) \
419 $(examples_SCRIPTS)
832b75ed 420
a7e8ffec 421CLEANFILES = \
a7e8ffec
GI
422 smartd.8 \
423 smartd.1m \
424 smartd.8.html \
a86ec89e 425 smartd.8.html.tmp \
f9e10201 426 smartd.8.pdf \
a7e8ffec
GI
427 smartd.8.txt \
428 smartctl.8 \
429 smartctl.1m \
430 smartctl.8.html \
a86ec89e 431 smartctl.8.html.tmp \
f9e10201 432 smartctl.8.pdf \
a7e8ffec 433 smartctl.8.txt \
f9e10201
JD
434 smartd.conf.5 \
435 smartd.conf.4 \
a7e8ffec 436 smartd.conf.5.html \
a86ec89e 437 smartd.conf.5.html.tmp \
f9e10201 438 smartd.conf.5.pdf \
a7e8ffec
GI
439 smartd.conf.5.txt \
440 smartd.initd \
ff28b140 441 smartd.cygwin.initd \
a7e8ffec
GI
442 smartd.freebsd.initd \
443 smartd.service \
ee38a438 444 smartd_warning.sh \
a7e8ffec
GI
445 svnversion.h \
446 update-smart-drivedb \
d2e702cf
GI
447 update-smart-drivedb.8 \
448 update-smart-drivedb.1m \
f9e10201
JD
449 update-smart-drivedb.8.html \
450 update-smart-drivedb.8.html.tmp \
451 update-smart-drivedb.8.pdf \
452 update-smart-drivedb.8.txt \
a7e8ffec 453 SMART
832b75ed 454
2127e193
GI
455# 'make maintainer-clean' also removes files generated by './autogen.sh'
456MAINTAINERCLEANFILES = \
457 $(srcdir)/Makefile.in \
458 $(srcdir)/aclocal.m4 \
d2e702cf 459 $(srcdir)/compile \
2127e193
GI
460 $(srcdir)/configure \
461 $(srcdir)/config.guess \
462 $(srcdir)/config.h.in \
463 $(srcdir)/config.h.in~ \
464 $(srcdir)/config.sub \
465 $(srcdir)/depcomp \
466 $(srcdir)/install-sh \
467 $(srcdir)/missing \
d008864d 468 $(srcdir)/m4/pkg.m4
2127e193 469
ff28b140 470smartctl.o utility.o: svnversion.h
2127e193
GI
471
472if IS_SVN_BUILD
473# Get version info from SVN
ee38a438 474svnversion.h: ChangeLog Makefile $(svn_deps)
a86ec89e 475 @echo ' svn info | $$(VERSION_FROM_SVN_INFO) > $@'
d2e702cf
GI
476 @echo '/* svnversion.h. Generated by Makefile from svn info. */' > $@
477 @(cd $(srcdir) \
2127e193
GI
478 && svnversion 2>/dev/null | sed -n 's,^\([0-9].*\),REV "\1",p' \
479 && TZ= LC_ALL=C svn info 2>/dev/null \
480 | sed -n 'h;s,^.* Date: *\([^ ]*\) .*$$,DATE "\1",p;g;s,^.* Date: *[^ ]* *\([^ ]*\) .*$$,TIME "\1",p') \
481 | sed 's,^,#define SMARTMONTOOLS_SVN_,' >> $@
482else
483
484# SVN not available, guess version info from Id strings
a86ec89e
GI
485svnversion.h: ChangeLog Makefile NEWS
486 @echo ' cat ChangeLog NEWS $$(SOURCES) | $$(VERSION_FROM_SVN_IDS) > $@'
d2e702cf 487 @echo '/* svnversion.h. Generated by Makefile from Id strings. */' > $@
a86ec89e 488 @(cd $(srcdir) && cat ChangeLog NEWS Makefile.am configure.ac smart*.in *.cpp *.h) \
2127e193
GI
489 | sed -n 's,^.*\$$[I][d]: [^ ]* \([0-9][0-9]* [0-9][-0-9]* [0-9][:0-9]*\)[^:0-9][^$$]*\$$.*$$,\1,p' \
490 | sort -n -r \
491 | sed -n 'h;s,^\([^ ]*\) .*$$,REV "\1",p;g;s,^[^ ]* \([^ ]*\) .*$$,DATE "\1",p;g;s,^[^ ]* [^ ]* \([^ ]*\)$$,TIME "\1",p;q' \
492 | sed 's,^,#define SMARTMONTOOLS_SVN_,' >> $@
493endif
494
495
2127e193
GI
496if ENABLE_DRIVEDB
497drivedb_DATA = drivedb.h
498endif
499
7f0798ef
GI
500update-smart-drivedb: update-smart-drivedb.in config.status
501 $(SHELL) ./config.status --file=$@
502 chmod +x $@
503
ee38a438
GI
504smartd_warning.sh: smartd_warning.sh.in config.status
505 $(SHELL) ./config.status --file=$@
506 chmod +x $@
7f0798ef 507
2127e193 508if INSTALL_INITSCRIPT
832b75ed 509if OS_DARWIN
a86ec89e 510initd_DATA = com.smartmontools.smartd.plist
832b75ed
GG
511
512initd_DATA_install = install-initdDATA-darwin
2127e193 513initd_DATA_uninstall = uninstall-initdDATA-darwin
832b75ed 514
a86ec89e 515com.smartmontools.smartd.plist : os_darwin/com.smartmontools.smartd.plist.in
832b75ed
GG
516 sed "s|/usr/sbin/|$(sbindir)/|" $< > $@
517
518install-initdDATA-darwin: $(initd_DATA)
a86ec89e
GI
519 $(MKDIR_P) '$(DESTDIR)$(initddir)'
520 $(INSTALL_DATA) $(top_builddir)/$(initd_DATA) $(DESTDIR)$(initddir)/$(initd_DATA)
832b75ed 521
2127e193 522uninstall-initdDATA-darwin:
a86ec89e 523 rm -f $(DESTDIR)$(initddir)/$(initd_DATA)
2127e193 524
832b75ed
GG
525else
526
a86ec89e 527initd_DATA = $(initdfile)
832b75ed 528
a86ec89e
GI
529$(initdfile): $(srcdir)/$(initdfile).in Makefile
530 sed 's|/usr/local/sbin/|$(sbindir)/|g' $(srcdir)/$(initdfile).in > $@
832b75ed
GG
531
532initd_install_name = smartd$(smartd_suffix)
533
534initd_DATA_install = install-initdDATA-generic
2127e193 535initd_DATA_uninstall = uninstall-initdDATA-generic
832b75ed
GG
536
537install-initdDATA-generic: $(initd_DATA)
a86ec89e
GI
538 $(MKDIR_P) '$(DESTDIR)$(initddir)'
539 $(INSTALL_SCRIPT) '$(top_builddir)/$(initdfile)' '$(DESTDIR)$(initddir)/smartd$(smartd_suffix)'
2127e193
GI
540
541uninstall-initdDATA-generic:
a86ec89e 542 rm -f '$(DESTDIR)$(initddir)/$(initd_install_name)'
2127e193
GI
543endif
544else
545
546initd_DATA_install = install-initdDATA-null
547initd_DATA_uninstall = uninstall-initdDATA-null
548
549install-initdDATA-null:
550uninstall-initdDATA-null:
832b75ed
GG
551endif
552
553install-initdDATA : $(initd_DATA_install)
554
2127e193 555uninstall-initdDATA: $(initd_DATA_uninstall)
832b75ed 556
a7e8ffec
GI
557if INSTALL_SYSTEMDUNIT
558systemdsystemunit_DATA = smartd.service
559endif
560
561smartd.service: smartd.service.in Makefile
a86ec89e
GI
562 @echo ' $$(SMARTD_SERVICE_FILTER) < $(srcdir)/smartd.service.in > $@'
563 @{ \
d2e702cf
GI
564 sed 's|/usr/local/sbin/smartd|$(sbindir)/smartd|' | \
565 if test -n '$(systemdenvfile)'; then \
566 sed 's|/usr/local/etc/sysconfig/smartmontools|$(systemdenvfile)|'; \
567 else \
568 sed -e '/^EnvironmentFile=/d' -e 's| *\$$smartd[_a-z]* *||g'; \
a86ec89e 569 fi; } < $(srcdir)/smartd.service.in > $@
d2e702cf
GI
570
571
572# Create empty directories if configured.
573# Default install rules no longer create empty directories since automake 1.11.
d2e702cf
GI
574installdirs-local:
575 @for d in '$(smartdplugindir)' '$(savestatesdir)' '$(attributelogdir)'; do \
576 test -n "$$d" || continue; \
a86ec89e
GI
577 echo " $(MKDIR_P) '$(DESTDIR)$$d'"; \
578 $(MKDIR_P) "$(DESTDIR)$$d" || exit 1; \
d2e702cf
GI
579 done
580
581install-data-local: installdirs-local
a7e8ffec 582
d2e702cf
GI
583#
584# Build man pages
585#
a86ec89e 586MAN_FILTER = { \
ee38a438
GI
587 sed -e 's|CURRENT_SVN_VERSION|$(releaseversion)|g' \
588 -e "s|CURRENT_SVN_DATE|`sed -n 's,^.*DATE[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g" \
589 -e "s|CURRENT_SVN_REV|`sed -n 's,^.*REV[^"]*"\([^"]*\)".*$$,r\1,p' svnversion.h`|g" \
590 -e 's|/usr/local/share/man/|$(mandir)/|g' \
591 -e 's|/usr/local/sbin/|$(sbindir)/|g' \
ee38a438
GI
592 -e 's|/usr/local/share/doc/smartmontools/examplescripts/|!exampledir!|g' \
593 -e 's|/usr/local/share/doc/smartmontools/|$(docsdir)/|g' \
594 -e 's|!exampledir!|$(exampledir)/|g' \
595 -e 's|/usr/local/etc/smartd\.conf|$(sysconfdir)/smartd.conf|g' \
d2e702cf
GI
596 -e 's|/usr/local/etc/smart_drivedb\.h|$(sysconfdir)/smart_drivedb.h|g' \
597 -e 's|/usr/local/etc/smartd_warning\.sh|$(smartdscriptdir)/smartd_warning.sh|g' \
598 -e 's|\\fBmail\\fP|\\fB$(os_mailer)\\fP|g' \
599 -e 's|\\'\''mail\\'\''|\\'\''$(os_mailer)\\'\''|g' \
600 -e 's|/usr/bin/mail|/usr/bin/$(os_mailer)|g' \
a86ec89e
GI
601 -e 's|RELEASE_6_0_DRIVEDB|$(DRIVEDB_BRANCH)|g' | \
602 if test -n '$(drivedbdir)'; then \
603 sed 's|/usr/local/share/smartmontools/drivedb\.h|$(drivedbdir)/drivedb.h|g' ; \
604 else \
605 sed '/^\.\\" %IF ENABLE_DRIVEDB/,/^\.\\" %ENDIF ENABLE_DRIVEDB/ s,^,.\\"\# ,' ; \
606 fi | \
607 if test '$(with_update_smart_drivedb)' = 'yes'; then \
608 cat; \
609 else \
610 sed '/^\.\\" %IF ENABLE_UPDATE_SMART_DRIVEDB/,/^\.\\" %ENDIF ENABLE_UPDATE_SMART_DRIVEDB/ s,^,.\\"\# ,' ; \
611 fi | \
612 if test -n '$(initddir)'; then \
613 sed 's|/usr/local/etc/rc\.d/init\.d/|$(initddir)/|g' ; \
614 else \
615 sed '/^\.\\" %IF ENABLE_INITSCRIPT/,/^\.\\" %ENDIF ENABLE_INITSCRIPT/ s,^,.\\"\# ,' ; \
616 fi | \
617 if test -n '$(savestates)'; then \
618 sed 's|/usr/local/var/lib/smartmontools/smartd\.|$(savestates)|g' ; \
619 else \
620 sed '/^\.\\" %IF ENABLE_SAVESTATES/,/^\.\\" %ENDIF ENABLE_SAVESTATES/ s,^,.\\"\# ,' ; \
621 fi | \
622 if test -n '$(attributelog)'; then \
623 sed 's|/usr/local/var/lib/smartmontools/attrlog\.|$(attributelog)|g' ; \
624 else \
625 sed '/^\.\\" %IF ENABLE_ATTRIBUTELOG/,/^\.\\" %ENDIF ENABLE_ATTRIBUTELOG/ s,^,.\\"\# ,' ; \
626 fi | \
d2e702cf
GI
627 if test -n '$(smartdplugindir)'; then \
628 sed 's|/usr/local/etc/smartd_warning\.d|$(smartdplugindir)|g' ; \
629 else \
630 sed '/^\.\\" %IF ENABLE_SMARTDPLUGINDIR/,/^\.\\" %ENDIF ENABLE_SMARTDPLUGINDIR/ s,^,.\\"\# ,' ; \
631 fi | \
a86ec89e
GI
632 if test -n '$(CAPNG_LDADD)'; then \
633 cat; \
634 else \
635 sed '/^\.\\" %IF ENABLE_CAPABILITIES/,/^\.\\" %ENDIF ENABLE_CAPABILITIES/ s,^,.\\"\# ,' ; \
636 fi | \
ff28b140
TL
637 if test -n '$(SYSTEMD_LDADD)'; then \
638 cat; \
639 else \
640 sed '/^\.\\" %IF ENABLE_SYSTEMD_NOTIFY/,/^\.\\" %ENDIF ENABLE_SYSTEMD_NOTIFY/ s,^,.\\"\# ,' ; \
641 fi | \
a86ec89e
GI
642 if test '$(with_nvme_devicescan)' = 'yes'; then \
643 cat; \
644 else \
645 sed '/^\.\\" %IF ENABLE_NVME_DEVICESCAN/,/^\.\\" %ENDIF ENABLE_NVME_DEVICESCAN/ s,^,.\\"\# ,' ; \
646 fi | \
d008864d
GI
647 if test -n '$(os_man_filter)'; then \
648 sed -e 's,OS_MAN_FILTER,$(os_man_filter),g' \
649 -e '/^\.\\" %IF NOT OS .*$(os_man_filter)/,/^.\\" %ENDIF NOT OS .*$(os_man_filter)/ s,^,.\\"\# ,' \
650 -e '/^\.\\" %IF OS .*$(os_man_filter)/,/^\.\\" %ENDIF OS .*$(os_man_filter)/ s,^,!!,' \
651 -e '/^\.\\" %IF OS ./,/^\.\\" %ENDIF OS ./ s,^,.\\"\# ,' \
652 -e '/^!*\.\\" %IF NOT OS ./,/^!*\.\\" %ENDIF NOT OS ./ s,^,!!,' \
653 -e 's,^!!!*\.\\"! \(.*\)$$,\1 \\"\#,' \
654 -e 's,^!!!*,,' ; \
655 else \
656 cat; \
a86ec89e 657 fi; }
a23d5117 658
7f0798ef
GI
659# Implicit rule 'smart%: smart%.in ...' does not work with BSD make
660smartctl.8: smartctl.8.in Makefile svnversion.h
a86ec89e
GI
661 @echo ' $$(MAN_FILTER) < $(srcdir)/smartctl.8.in > $@'
662 @$(MAN_FILTER) < $(srcdir)/smartctl.8.in > $@
7f0798ef
GI
663
664smartd.8: smartd.8.in Makefile svnversion.h
a86ec89e
GI
665 @echo ' $$(MAN_FILTER) < $(srcdir)/smartd.8.in > $@'
666 @$(MAN_FILTER) < $(srcdir)/smartd.8.in > $@
7f0798ef
GI
667
668smartd.conf.5: smartd.conf.5.in Makefile svnversion.h
a86ec89e
GI
669 @echo ' $$(MAN_FILTER) < $(srcdir)/smartd.conf.5.in > $@'
670 @$(MAN_FILTER) < $(srcdir)/smartd.conf.5.in > $@
d2e702cf
GI
671
672update-smart-drivedb.8: update-smart-drivedb.8.in Makefile svnversion.h
a86ec89e
GI
673 @echo ' $$(MAN_FILTER) < $(srcdir)/update-smart-drivedb.8.in > $@'
674 @$(MAN_FILTER) < $(srcdir)/update-smart-drivedb.8.in > $@
d2e702cf
GI
675
676# Build Solaris specific man pages
677SOLARIS_MAN_FILTER = \
678 sed -e '/^\.TH/s, \([58]\) , !!\1!! ,' \
679 -e '/^\.BR/s, (\([578]\)), (!!\1!!),' \
680 -e 's,\\fP(\([578]\)),\\fP(!!\1!!),g' \
681 -e 's,!!5!!,4,g' -e 's,!!7!!,5,g' -e 's,!!8!!,1m,g' \
682 -e 's,/var/log/messages,/var/adm/messages,g'
683
684smartctl.1m: smartctl.8
a86ec89e
GI
685 @echo ' $$(SOLARIS_MAN_FILTER) < smartctl.8 > $@'
686 @$(SOLARIS_MAN_FILTER) < smartctl.8 > $@
d2e702cf
GI
687
688smartd.1m: smartd.8
a86ec89e
GI
689 @echo ' $$(SOLARIS_MAN_FILTER) < smartd.8 > $@'
690 @$(SOLARIS_MAN_FILTER) < smartd.8 > $@
d2e702cf
GI
691
692smartd.conf.4: smartd.conf.5
a86ec89e
GI
693 @echo ' $$(SOLARIS_MAN_FILTER) < smartd.conf.5 > $@'
694 @$(SOLARIS_MAN_FILTER) < smartd.conf.5 > $@
d2e702cf
GI
695
696update-smart-drivedb.1m: update-smart-drivedb.8
a86ec89e
GI
697 @echo ' $$(SOLARIS_MAN_FILTER) < update-smart-drivedb.8 > $@'
698 @$(SOLARIS_MAN_FILTER) < update-smart-drivedb.8 > $@
d2e702cf 699
832b75ed 700
f9e10201 701# Convert man pages into .html, .pdf and .txt
832b75ed
GG
702# TODO: configure
703MAN2HTML = man2html
704#MAN2HTML = groff -man -Thtml
f9e10201
JD
705MAN2PDF = man -Tpdf -l
706#MAN2PDF = groff -man -Tpdf
832b75ed
GG
707MAN2TXT = groff -man -Tascii -P'-bcou'
708
4d59bff9 709# Remove HTTP header and fix links in man2html output
ee38a438
GI
710FIXHTML = sed -e '1s,^Content-type.*,,' \
711 -e 's,<A HREF="[^"]*/man2html?\([1-8]\)+\(smart[cd][.a-z]*\)">,<A HREF="\2.\1.html">,g' \
712 -e 's,<A HREF="[^"]*/man2html">,<A HREF=".">,g' \
713 -e 's,<A HREF="[^"]*/man2html?[^"]*">\([^<]*\)</A>,\1,g' \
714 -e 's,<A HREF="mailto:[^s][^m][^a][^"]*">\([^<]*\)</A>,\1,g'
832b75ed 715
f9e10201 716htmlman: smartctl.8.html smartd.8.html smartd.conf.5.html update-smart-drivedb.8.html
832b75ed 717
f9e10201 718pdfman: smartctl.8.pdf smartd.8.pdf smartd.conf.5.pdf update-smart-drivedb.8.pdf
832b75ed 719
f9e10201 720txtman: smartctl.8.txt smartd.8.txt smartd.conf.5.txt update-smart-drivedb.8.txt
832b75ed 721
4d59bff9 722%.5.html: %.5
a86ec89e
GI
723 $(MAN2HTML) $< > $@.tmp
724 @echo ' $$(FIXHTML) < $@.tmp > $@'
725 @$(FIXHTML) < $@.tmp > $@
4d59bff9
GG
726
727%.8.html: %.8
a86ec89e
GI
728 $(MAN2HTML) $< > $@.tmp
729 @echo ' $$(FIXHTML) < $@.tmp > $@'
730 @$(FIXHTML) < $@.tmp > $@
832b75ed 731
f9e10201
JD
732%.5.pdf: %.5
733 $(MAN2PDF) $< > $@
734
735%.8.pdf: %.8
736 $(MAN2PDF) $< > $@
737
832b75ed
GG
738%.5.txt: %.5
739 $(MAN2TXT) $< > $@
740
741%.8.txt: %.8
742 $(MAN2TXT) $< > $@
743
744
a23d5117
GI
745# Check drive database syntax
746check:
747 @if ./smartctl -B $(srcdir)/drivedb.h -P showall >/dev/null; then \
748 echo "$(srcdir)/drivedb.h: OK"; \
749 else \
750 echo "$(srcdir)/drivedb.h: Syntax check failed"; exit 1; \
751 fi
752
832b75ed
GG
753
754if OS_WIN32_MINGW
ee38a438
GI
755# Windows resources
756
f9e10201
JD
757smartctl_res.o: smartctl_res.rc $(os_win32_manifest)
758 $(WINDRES) $< $@
759
760smartd_res.o: smartd_res.rc syslogevt.rc $(os_win32_manifest)
ee38a438
GI
761 $(WINDRES) $< $@
762
f9e10201
JD
763runcmda_res.o: runcmda_res.rc defadmin.manifest
764 $(WINDRES) $< $@
765
766runcmdu_res.o: runcmdu_res.rc $(os_win32_manifest)
767 $(WINDRES) $< $@
768
769wtssendmsg_res.o: wtssendmsg_res.rc $(os_win32_manifest)
770 $(WINDRES) $< $@
ee38a438 771
f9e10201
JD
772# Convert version for VERSIONINFO resource: 6.6 r4519 -> 6.6.0.4519,
773# set description, name, version and year
a86ec89e
GI
774WIN_RC_FILTER = { \
775 ver=`echo '$(PACKAGE_VERSION).0' | sed -n 's,^\([0-9]*\.[0-9]*\.[0-9]*\).*$$,\1,p'` && \
776 rev=`sed -n 's,^.*REV[^"]*"\([0-9]*\).*$$,\1,p' svnversion.h` && \
777 txtver="$${ver:-0.0.0}.$${rev:-0}" && binver=`echo "$$txtver" | sed 's|\.|,|g'` && \
778 yy=`sed -n 's,^.*DATE[^"]*"20\([0-9][0-9]\).*$$,\1,p' svnversion.h` && yy="$${yy:-XX}" && \
f9e10201
JD
779 sed -e "s|@DESC@|$$d|" -e "s|@NAME@|$$n|" -e "s|@BINARY_VERSION@|$$binver|g" \
780 -e "s|@TEXT_VERSION@|$$txtver|g" -e "s|@YY@|$$yy|g"; }
ee38a438 781
f9e10201
JD
782WIN_MAKE_RES = \
783 echo "n=$$n d=\"$$d"'"; $$(WIN_RC_FILTER) < $< > $@'; \
784 $(WIN_RC_FILTER) < $< > $@
ee38a438 785
f9e10201
JD
786WIN_APP_MANIFEST = \
787 if test -n '$(os_win32_manifest)'; then \
788 echo "echo '1 24 \"$(srcdir)/$(os_win32_manifest)\"' >> $@"; \
789 echo '1 24 "$(srcdir)/$(os_win32_manifest)"' >> $@; \
790 fi
ee38a438 791
f9e10201
JD
792smartctl_res.rc: os_win32/versioninfo.rc.in Makefile svnversion.h
793 @n=smartctl d="Control and Monitor Utility for SMART Disks"; $(WIN_MAKE_RES)
794 @$(WIN_APP_MANIFEST)
795
796smartd_res.rc: os_win32/versioninfo.rc.in Makefile svnversion.h
797 @n=smartd d="SMART Disk Monitoring Daemon"; $(WIN_MAKE_RES)
798 echo '#include "./syslogevt.rc"' >> $@
799 @$(WIN_APP_MANIFEST)
ee38a438 800
f9e10201
JD
801runcmdu_res.rc: os_win32/versioninfo.rc.in Makefile svnversion.h
802 @n=runcmdu d="Run console command"; $(WIN_MAKE_RES)
803 @$(WIN_APP_MANIFEST)
a86ec89e 804
f9e10201
JD
805runcmda_res.rc: os_win32/versioninfo.rc.in Makefile svnversion.h
806 @n=runcmda d="Run console command as admin"; $(WIN_MAKE_RES)
807 echo '1 24 "./defadmin.manifest"' >> $@
a86ec89e 808
f9e10201
JD
809wtssendmsg_res.rc: os_win32/versioninfo.rc.in Makefile svnversion.h
810 @n=wtssendmsg d="Send console messages"; $(WIN_MAKE_RES)
811 @$(WIN_APP_MANIFEST)
812
813syslogevt.rc: os_win32/syslogevt.mc
814 $(WINDMC) -b $<
a86ec89e
GI
815
816defadmin.manifest: os_win32/default.manifest
817 sed 's,"asInvoker","requireAdministrator",' $< > $@
818
832b75ed
GG
819# Definitions for Windows distribution
820
7f0798ef
GI
821if OS_WIN64
822win_bits = 64
823else
824win_bits = 32
825endif
826
827distdir_win32 = $(PACKAGE)-$(VERSION).win$(win_bits)
828distzip_win32 = $(PACKAGE)-$(VERSION).win$(win_bits).zip
829distinst_win32 = $(PACKAGE)-$(VERSION).win$(win_bits)-setup.exe
832b75ed
GG
830
831exedir_win32 = $(distdir_win32)/bin
832docdir_win32 = $(distdir_win32)/doc
833
cfbba5b9
GI
834EXEFILES_WIN32 = \
835 $(exedir_win32)/smartctl.exe \
836 $(exedir_win32)/smartctl-nc.exe \
d008864d 837 $(exedir_win32)/smartd.exe \
f9e10201
JD
838 $(exedir_win32)/smartd_mailer.ps1 \
839 $(exedir_win32)/smartd_mailer.conf.sample.ps1 \
ee38a438 840 $(exedir_win32)/smartd_warning.cmd \
d008864d 841 $(exedir_win32)/runcmda.exe \
ee38a438
GI
842 $(exedir_win32)/runcmdu.exe \
843 $(exedir_win32)/wtssendmsg.exe
cfbba5b9
GI
844
845if ENABLE_DRIVEDB
846if OS_WIN32_NSIS
847EXEFILES_WIN32 += \
848 $(exedir_win32)/update-smart-drivedb.exe
849endif
850endif
851
852FILES_WIN32 = \
853 $(EXEFILES_WIN32) \
854 $(docdir_win32)/AUTHORS.txt \
ee38a438
GI
855 $(docdir_win32)/ChangeLog.txt \
856 $(docdir_win32)/ChangeLog-5.0-6.0.txt \
cfbba5b9
GI
857 $(docdir_win32)/COPYING.txt \
858 $(docdir_win32)/INSTALL.txt \
859 $(docdir_win32)/NEWS.txt \
860 $(docdir_win32)/README.txt \
861 $(docdir_win32)/TODO.txt \
f4e463df 862 $(docdir_win32)/checksums$(win_bits).txt \
cfbba5b9
GI
863 $(docdir_win32)/smartd.conf \
864 $(docdir_win32)/smartctl.8.html \
f9e10201 865 $(docdir_win32)/smartctl.8.pdf \
cfbba5b9 866 $(docdir_win32)/smartd.8.html \
f9e10201 867 $(docdir_win32)/smartd.8.pdf \
cfbba5b9 868 $(docdir_win32)/smartd.conf.5.html \
f9e10201 869 $(docdir_win32)/smartd.conf.5.pdf
cfbba5b9
GI
870
871if ENABLE_DRIVEDB
872FILES_WIN32 += \
873 $(exedir_win32)/drivedb.h
874endif
875
876CLEANFILES += \
877 $(FILES_WIN32) \
a86ec89e
GI
878 defadmin.manifest \
879 distdir.mkdir \
f9e10201
JD
880 runcmda.exe runcmda_res.rc \
881 runcmdu.exe runcmdu_res.rc \
cfbba5b9 882 smartctl-nc.exe smartctl-nc.exe.tmp \
a86ec89e
GI
883 smartctl_res.rc smartd_res.rc \
884 syslogevt.h \
ee38a438 885 syslogevt.rc syslogevt_*.bin \
cfbba5b9 886 update-smart-drivedb.exe \
f9e10201 887 wtssendmsg.exe wtssendmsg_res.rc
832b75ed 888
a86ec89e 889# Note: Only use without options to be compatible with all variants
7f0798ef 890UNIX2DOS = unix2dos
832b75ed
GG
891
892# Build Windows distribution
893
894dist-win32: $(distzip_win32)
895
4d59bff9
GG
896install-win32: $(distinst_win32)
897 ./$(distinst_win32)
898
899installer-win32: $(distinst_win32)
900
cfbba5b9 901distdir-win32: distdir.mkdir $(FILES_WIN32)
832b75ed 902
cfbba5b9 903$(distzip_win32): distdir.mkdir $(FILES_WIN32)
832b75ed 904 @rm -fv $(distzip_win32)
cfbba5b9
GI
905 cd $(distdir_win32) && zip -9 ../$(distzip_win32) bin/* doc/*
906 md5sum $@ > $@.md5
907 sha1sum $@ > $@.sha1
908 sha256sum $@ > $@.sha256
832b75ed 909
cfbba5b9
GI
910if OS_WIN32_NSIS
911# Build NSIS installer
7f0798ef 912# Note: Only option character '-' is also compatible with Linux version of makensis
ff28b140 913$(distinst_win32): os_win32/installer.nsi smartctl_res.rc distdir.mkdir $(FILES_WIN32)
f4e463df 914 test -z '$(builddir_win64)' || ( cd $(builddir_win64) && make distdir-win32 )
a86ec89e
GI
915 @date=`sed -n 's,^.*DATE[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h` && \
916 rev=`sed -n 's,^.*REV[^"]*"\([^"]*\)".*$$,r\1,p' svnversion.h` && \
ff28b140
TL
917 version=`sed -n 's|^ *VALUE "FileVersion", "\([0-9.]*\)".*$$|\1|p' smartctl_res.rc` && \
918 yy=`echo "$$date" | sed -n 's,^20\([0-9][0-9]\).*$$,\1,p'`; yy="$${yy:-XX}" && \
a86ec89e
GI
919 verstr="$(PACKAGE_VERSION) $$date $$rev "$(BUILD_INFO) && \
920 d64= && if [ -n '$(builddir_win64)' ]; then d64='-DINPDIR64=$(builddir_win64)/$(PACKAGE)-$(VERSION).win64'; fi && \
ff28b140
TL
921 echo "'$(MAKENSIS)' -V2 -NOCD -DINPDIR=$(distdir_win32) $$d64 -DOUTFILE=$@ -DVERSION=$$version -DYY=$$yy -DVERSTR='$$verstr' $<" && \
922 '$(MAKENSIS)' -V2 -NOCD -DINPDIR=$(distdir_win32) $$d64 -DOUTFILE=$@ -DVERSION=$$version -DYY=$$yy -DVERSTR="$$verstr" $<
cfbba5b9
GI
923 md5sum $@ > $@.md5
924 sha1sum $@ > $@.sha1
925 sha256sum $@ > $@.sha256
926
927# Build drivedb.h update tool
928update-smart-drivedb.exe: os_win32/update-smart-drivedb.nsi
929 "$(MAKENSIS)" -V2 -NOCD -DBRANCH=$(DRIVEDB_BRANCH) $<
930
931else
932$(distinst_win32):
933 @echo "makensis: command not found. Please install NSIS from http://nsis.sourceforge.net/" 1>&2
934 @exit 1
935endif
4d59bff9 936
832b75ed 937cleandist-win32:
cfbba5b9 938 rm -rf $(distdir_win32) distdir.mkdir
832b75ed
GG
939
940distdir.mkdir:
941 @test -d $(exedir_win32) || mkdir -pv $(exedir_win32)
942 @test -d $(docdir_win32) || mkdir -pv $(docdir_win32)
943 touch $@
944
832b75ed
GG
945$(exedir_win32)/%.exe: %.exe
946 cp -p $< $@
7f0798ef 947 if test -n '$(STRIP)'; then $(STRIP) -s $@; else strip -s $@; fi
832b75ed
GG
948 touch -r $< $@
949
cfbba5b9
GI
950# strip would break NSIS integrity check
951$(exedir_win32)/update-smart-drivedb.exe: update-smart-drivedb.exe
952 cp -p $< $@
953
954$(exedir_win32)/%.h: $(srcdir)/%.h
955 $(UNIX2DOS) < $< > $@
956 touch -r $< $@
957
ee38a438
GI
958$(exedir_win32)/%.cmd: $(srcdir)/os_win32/%.cmd
959 $(UNIX2DOS) < $< > $@
960 touch -r $< $@
961
f9e10201 962$(exedir_win32)/%.ps1: $(srcdir)/os_win32/%.ps1
ba59cff1
GG
963 $(UNIX2DOS) < $< > $@
964 touch -r $< $@
965
f9e10201 966$(docdir_win32)/%.html: %.html
832b75ed
GG
967 $(UNIX2DOS) < $< > $@
968 touch -r $< $@
969
f9e10201
JD
970$(docdir_win32)/%.pdf: %.pdf
971 cp -p $< $@
972
832b75ed
GG
973$(docdir_win32)/%.txt: $(srcdir)/%
974 $(UNIX2DOS) < $< > $@
975 touch -r $< $@
976
977$(docdir_win32)/%.conf: $(srcdir)/%.conf
978 $(UNIX2DOS) < $< > $@
979 touch -r $< $@
980
f4e463df 981$(docdir_win32)/checksums$(win_bits).txt: $(EXEFILES_WIN32)
cfbba5b9
GI
982 (cd $(exedir_win32) && md5sum *.exe && sha1sum *.exe && sha256sum *.exe) \
983 | $(UNIX2DOS) > $@
984
2127e193
GI
985# Build non-console version of smartctl for GSmartControl.
986# The script below changes the word at offset 220 (Subsystem) from 3
987# (Console) to 2 (GUI) in a copy of smartctl.exe.
988# This will be changed when a tool (like 'editbin') is available in
989# the Cygwin distribution
990smartctl-nc.exe: smartctl.exe
991 @rm -f $@
992 cp -p smartctl.exe $@.tmp
993 @if test `od -A n -j 220 -N 2 -d $@.tmp` -eq 3; then :; \
994 else echo "invalid EXE header"; exit 1; fi
995 @echo "editbin /subsystem:windows $@.tmp"
996 @echo -ne '\002' | dd bs=1 seek=220 count=1 conv=notrunc of=$@.tmp 2>/dev/null
997 @if test `od -A n -j 220 -N 2 -d $@.tmp` -eq 2; then :; \
998 else echo "EXE patch failed"; exit 1; fi
999 mv -f $@.tmp $@
1000
ee38a438 1001# Build runcmd?.exe and wtssendmsg.exe
a86ec89e
GI
1002runcmd.o: os_win32/runcmd.c
1003 $(CC) -c -Os $<
1004
f9e10201 1005runcmdu.exe: runcmd.o runcmdu_res.o
a86ec89e 1006 $(CC) -o $@ $^
d008864d 1007
f9e10201 1008runcmda.exe: runcmd.o runcmda_res.o
a86ec89e
GI
1009 $(CC) -o $@ $^
1010
f9e10201
JD
1011wtssendmsg.exe: os_win32/wtssendmsg.c wtssendmsg_res.o
1012 $(CC) -Os -o $@ $^ -lwtsapi32
cfbba5b9 1013
f9e10201 1014# Build os_win32/vc14/{config.h,smart*.rc,svnversion.h} for MSVC14 from MinGW files
cfbba5b9 1015
f9e10201 1016vcver = 14
2127e193 1017
f9e10201
JD
1018CONFIG_VC_FILES = \
1019 $(srcdir)/os_win32/vc$(vcver)/config.h \
1020 $(srcdir)/os_win32/vc$(vcver)/smartctl_res.rc \
1021 $(srcdir)/os_win32/vc$(vcver)/smartd_res.rc \
1022 $(srcdir)/os_win32/vc$(vcver)/svnversion.h
2127e193 1023
f9e10201 1024config-vc$(vcver): $(CONFIG_VC_FILES)
ee38a438 1025
f9e10201
JD
1026$(srcdir)/os_win32/vc$(vcver)/config.h: config.h Makefile
1027 sed -e '1i/* os_win32/vc$(vcver)/config.h. Generated from config.h by Makefile. */' \
ff28b140 1028 -e 's,^#define HAVE_\(ATTR_PACKED\|GETTIMEOFDAY\|[DK_]*NTDDDISK_H\|LONG_DOUBLE_WIDER\|STRINGS_H\|UNISTD_H\) 1$$,/* #undef HAVE_\1 */ /* VC$(vcver) */,' \
f9e10201 1029 -e 's,^\(#define SMARTMONTOOLS_BUILD_HOST "[^-]*\)[^"]*,\1-pc-w32vc$(vcver),' $< > $@
ee38a438 1030
f9e10201 1031$(srcdir)/os_win32/vc$(vcver)/svnversion.h: svnversion.h
d008864d 1032 cp $< $@
832b75ed 1033
f9e10201
JD
1034$(srcdir)/os_win32/vc$(vcver)/smartctl_res.rc: smartctl_res.rc
1035 sed '/^1 24 /d' $< > $@
1036
1037$(srcdir)/os_win32/vc$(vcver)/smartd_res.rc: smartd_res.rc
1038 sed '/^1 24 /d' $< > $@
1039
1040clean-vc$(vcver):
1041 rm -f $(srcdir)/os_win32/vc$(vcver)/smartmontools.VC.VC.opendb
1042 rm -f $(srcdir)/os_win32/vc$(vcver)/smartmontools.VC.db
1043 rm -f $(srcdir)/os_win32/vc$(vcver)/syslogevt.h
1044 rm -rf $(srcdir)/os_win32/vc$(vcver)/Debug
1045 rm -rf $(srcdir)/os_win32/vc$(vcver)/Release
1046 rm -rf $(srcdir)/os_win32/vc$(vcver)/x64
1047
1048distclean-vc$(vcver): clean-vc$(vcver)
1049 rm -f $(CONFIG_VC_FILES)
1050
1051maintainer-clean-vc$(vcver): distclean-vc$(vcver)
1052 rm -rf $(srcdir)/os_win32/vc$(vcver)/.vs
1053
832b75ed 1054endif
f9e10201
JD
1055
1056
a86ec89e
GI
1057if OS_DARWIN
1058# Definitions for OSX distribution
1059distdir_darwin = $(PACKAGE)-$(VERSION).darwin
1060dmg_darwin = $(PACKAGE)-$(VERSION).dmg
1061pkg_darwin = $(PACKAGE)-$(VERSION).pkg
1062
1063# build darwin installer
1064$(pkg_darwin):
1065 ${MAKE} install DESTDIR=$(distdir_darwin)/root
1066 @cp $(srcdir)/os_darwin/pkg/root/usr/local/sbin/smart-pkg-uninstall $(distdir_darwin)/root$(sbindir)
1067 @mkdir -p $(distdir_darwin)/pkg
1068 @( cd $(distdir_darwin)/root && find . | cpio -o --format odc --owner 0:80 | gzip -c ) > $(distdir_darwin)/pkg/Payload
1069 PAYLOAD_FILES=`find $(distdir_darwin)/root | wc -l` &&\
1070 PAYLOAD_SIZEKB=`du -BK -s $(distdir_darwin)/root|${AWK} '{print $$1}'|tr -d 'K'` &&\
1071 sed -e "s|@version@|$(VERSION)|" -e "s|@files@|$${PAYLOAD_FILES}|" \
1072 -e "s|@size@|$${PAYLOAD_SIZEKB}|" $(srcdir)/os_darwin/pkg/PackageInfo.in \
1073 > $(distdir_darwin)/pkg/PackageInfo &&\
1074 sed -e "s|@version@|$(VERSION)|" -e "s|@files@|$${PAYLOAD_FILES}|" -e "s|@size@|$${PAYLOAD_SIZEKB}|" \
1075 -e "s|@pkgname@|$(pkg_darwin)|" \
1076 $(srcdir)/os_darwin/pkg/Distribution.in > $(distdir_darwin)/pkg/Distribution
1077 @mkdir -p $(distdir_darwin)/pkg/Resources/English.lproj
1078 @cp $(srcdir)/COPYING $(distdir_darwin)/pkg/Resources/English.lproj/license.txt
1079 @mkbom -u 0 -g 80 $(distdir_darwin)/root $(distdir_darwin)/pkg/Bom
1080 @mkdir -p $(distdir_darwin)/dmg
1081 @( cd $(distdir_darwin)/pkg && xar --compression none -cf "../dmg/$(pkg_darwin)" * )
1082
1083# build darwon dmg image
1084$(dmg_darwin):
1085 @cp $(srcdir)/os_darwin/pkg/installer/README.html $(distdir_darwin)/dmg
1086 @mkisofs -V 'smartmontools' -no-pad -r -apple -o $(distdir_darwin)/smartmontools-$(VERSION).iso \
1087 -hfs-bless "$(distdir_darwin)/dmg/" "$(distdir_darwin)/dmg/"
1088 @dmg dmg $(distdir_darwin)/smartmontools-$(VERSION).iso $(dmg_darwin)
1089 md5sum $@ > $@.md5
1090 sha1sum $@ > $@.sha1
1091 sha256sum $@ > $@.sha256
1092
1093install-darwin: install-darwin-cleanup $(pkg_darwin) $(dmg_darwin)
1094
1095install-darwin-cleanup:
1096 @rm -rf $(distdir_darwin)
1097endif