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