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