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