]> git.proxmox.com Git - mirror_smartmontools-debian.git/blob - Makefile.am
Correct maintscript syntax
[mirror_smartmontools-debian.git] / Makefile.am
1 ## Process this file with automake to produce Makefile.in
2 #
3 # $Id: Makefile.am 3957 2014-07-18 18:39:06Z 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 WARNINGS \
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 $(mkinstalldirs) $(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_win32/installer.nsi \
370 os_win32/runcmd.c \
371 os_win32/runcmda.exe.manifest \
372 os_win32/runcmdu.exe.manifest \
373 os_win32/smartctl_res.rc.in \
374 os_win32/smartd_res.rc.in \
375 os_win32/smartd_warning.cmd \
376 os_win32/syslogevt.mc \
377 os_win32/update-smart-drivedb.nsi \
378 os_win32/wbemcli_small.h \
379 os_win32/wtssendmsg.c \
380 $(docs_DATA) \
381 $(examples_DATA) \
382 $(examples_SCRIPTS)
383
384 CLEANFILES = \
385 smartd.conf.5 \
386 smartd.conf.4 \
387 smartd.8 \
388 smartd.1m \
389 smartd.8.html \
390 smartd.8.txt \
391 smartctl.8 \
392 smartctl.1m \
393 smartctl.8.html \
394 smartctl.8.txt \
395 smartd.conf.5.html \
396 smartd.conf.5.txt \
397 smartd.initd \
398 smartd.freebsd.initd \
399 smartd.service \
400 smartd_warning.sh \
401 svnversion.h \
402 update-smart-drivedb \
403 update-smart-drivedb.8 \
404 update-smart-drivedb.1m \
405 SMART
406
407 # 'make maintainer-clean' also removes files generated by './autogen.sh'
408 MAINTAINERCLEANFILES = \
409 $(srcdir)/Makefile.in \
410 $(srcdir)/aclocal.m4 \
411 $(srcdir)/compile \
412 $(srcdir)/configure \
413 $(srcdir)/config.guess \
414 $(srcdir)/config.h.in \
415 $(srcdir)/config.h.in~ \
416 $(srcdir)/config.sub \
417 $(srcdir)/depcomp \
418 $(srcdir)/install-sh \
419 $(srcdir)/missing \
420 $(srcdir)/mkinstalldirs \
421 $(srcdir)/m4/pkg.m4
422
423 utility.o: svnversion.h
424
425 if IS_SVN_BUILD
426 # Get version info from SVN
427 svnversion.h: ChangeLog Makefile $(svn_deps)
428 @echo ' svn info | $$(VERSION_FROM_SVN_INFO) > $@'
429 @echo '/* svnversion.h. Generated by Makefile from svn info. */' > $@
430 @(cd $(srcdir) \
431 && svnversion 2>/dev/null | sed -n 's,^\([0-9].*\),REV "\1",p' \
432 && TZ= LC_ALL=C svn info 2>/dev/null \
433 | sed -n 'h;s,^.* Date: *\([^ ]*\) .*$$,DATE "\1",p;g;s,^.* Date: *[^ ]* *\([^ ]*\) .*$$,TIME "\1",p') \
434 | sed 's,^,#define SMARTMONTOOLS_SVN_,' >> $@
435 else
436
437 # SVN not available, guess version info from Id strings
438 svnversion.h: ChangeLog Makefile
439 @echo ' cat ChangeLog $$(SOURCES) | $$(VERSION_FROM_SVN_IDS) > $@'
440 @echo '/* svnversion.h. Generated by Makefile from Id strings. */' > $@
441 @(cd $(srcdir) && cat ChangeLog Makefile.am configure.ac smart*.in *.cpp *.h *.s) \
442 | sed -n 's,^.*\$$[I][d]: [^ ]* \([0-9][0-9]* [0-9][-0-9]* [0-9][:0-9]*\)[^:0-9][^$$]*\$$.*$$,\1,p' \
443 | sort -n -r \
444 | sed -n 'h;s,^\([^ ]*\) .*$$,REV "\1",p;g;s,^[^ ]* \([^ ]*\) .*$$,DATE "\1",p;g;s,^[^ ]* [^ ]* \([^ ]*\)$$,TIME "\1",p;q' \
445 | sed 's,^,#define SMARTMONTOOLS_SVN_,' >> $@
446 endif
447
448
449 if ENABLE_DRIVEDB
450 drivedb_DATA = drivedb.h
451 endif
452
453 update-smart-drivedb: update-smart-drivedb.in config.status
454 $(SHELL) ./config.status --file=$@
455 chmod +x $@
456
457 smartd_warning.sh: smartd_warning.sh.in config.status
458 $(SHELL) ./config.status --file=$@
459 chmod +x $@
460
461 if INSTALL_INITSCRIPT
462 if OS_DARWIN
463 initd_DATA = SMART \
464 os_darwin/StartupParameters.plist \
465 os_darwin/English_Localizable.strings
466
467 initd_install_name = SMART
468
469 initd_DATA_install = install-initdDATA-darwin
470 initd_DATA_uninstall = uninstall-initdDATA-darwin
471
472 SMART : os_darwin/SMART.in
473 sed "s|/usr/sbin/|$(sbindir)/|" $< > $@
474
475 install-initdDATA-darwin: $(initd_DATA)
476 $(mkinstalldirs) $(DESTDIR)$(initddir)
477 $(mkinstalldirs) $(DESTDIR)$(initddir)/SMART
478 $(mkinstalldirs) $(DESTDIR)$(initddir)/SMART/Resources
479 $(INSTALL_SCRIPT) $(top_builddir)/SMART $(DESTDIR)$(initddir)/SMART
480 $(INSTALL_DATA) $(srcdir)/os_darwin/StartupParameters.plist \
481 $(DESTDIR)$(initddir)/SMART/StartupParameters.plist
482 for i in English ; do \
483 RDIR=$(DESTDIR)$(initddir)/SMART/Resources/$${i}.lproj ; \
484 $(mkinstalldirs) $$RDIR ;\
485 $(INSTALL_DATA) $(srcdir)/os_darwin/$${i}_Localizable.strings \
486 $$RDIR/Localizable.strings ; \
487 done
488
489 uninstall-initdDATA-darwin:
490 rm -rf $(DESTDIR)$(initddir)/$(initd_install_name)
491
492 else
493
494 initd_DATA = @initdfile@
495
496 @initdfile@: $(srcdir)/@initdfile@.in Makefile
497 sed "s|/usr/local/sbin/|$(sbindir)/|g" $(srcdir)/@initdfile@.in > $@
498
499 initd_install_name = smartd$(smartd_suffix)
500
501 initd_DATA_install = install-initdDATA-generic
502 initd_DATA_uninstall = uninstall-initdDATA-generic
503
504 install-initdDATA-generic: $(initd_DATA)
505 $(mkinstalldirs) $(DESTDIR)$(initddir)
506 $(INSTALL_SCRIPT) $(top_builddir)/@initdfile@ $(DESTDIR)$(initddir)/smartd$(smartd_suffix)
507
508
509 uninstall-initdDATA-generic:
510 rm -rf $(DESTDIR)$(initddir)/$(initd_install_name)
511 endif
512 else
513
514 initd_DATA_install = install-initdDATA-null
515 initd_DATA_uninstall = uninstall-initdDATA-null
516
517 install-initdDATA-null:
518 uninstall-initdDATA-null:
519 endif
520
521 install-initdDATA : $(initd_DATA_install)
522
523 uninstall-initdDATA: $(initd_DATA_uninstall)
524
525 if INSTALL_SYSTEMDUNIT
526 systemdsystemunit_DATA = smartd.service
527 endif
528
529 smartd.service: smartd.service.in Makefile
530 cat $(srcdir)/smartd.service.in | \
531 sed 's|/usr/local/sbin/smartd|$(sbindir)/smartd|' | \
532 if test -n '$(systemdenvfile)'; then \
533 sed 's|/usr/local/etc/sysconfig/smartmontools|$(systemdenvfile)|'; \
534 else \
535 sed -e '/^EnvironmentFile=/d' -e 's| *\$$smartd[_a-z]* *||g'; \
536 fi > $@
537
538
539 # Create empty directories if configured.
540 # Default install rules no longer create empty directories since automake 1.11.
541 # Uses $(mkinstalldirs) instead of $(MKDIR_P) to preserve support for automake 1.7 - 1.9.
542 installdirs-local:
543 @for d in '$(smartdplugindir)' '$(savestatesdir)' '$(attributelogdir)'; do \
544 test -n "$$d" || continue; \
545 echo "$(mkinstalldirs) $(DESTDIR)$$d"; \
546 $(mkinstalldirs) "$(DESTDIR)$$d" || exit 1; \
547 done
548
549 install-data-local: installdirs-local
550
551 #
552 # Build man pages
553 #
554 if ENABLE_CAPABILITIES
555 MAN_CAPABILITIES = cat
556 else
557 MAN_CAPABILITIES = sed '/^\.\\" %IF ENABLE_CAPABILITIES/,/^\.\\" %ENDIF ENABLE_CAPABILITIES/ s,^,.\\"\# ,'
558 endif
559
560 if ENABLE_DRIVEDB
561 MAN_DRIVEDB = sed "s|/usr/local/share/smartmontools/drivedb\\.h|$(drivedbdir)/drivedb.h|g"
562 else
563 MAN_DRIVEDB = sed '/^\.\\" %IF ENABLE_DRIVEDB/,/^\.\\" %ENDIF ENABLE_DRIVEDB/ s,^,.\\"\# ,'
564 endif
565
566 if ENABLE_SAVESTATES
567 MAN_SAVESTATES = sed "s|/usr/local/var/lib/smartmontools/smartd\\.|$(savestates)|g"
568 else
569 MAN_SAVESTATES = sed '/^\.\\" %IF ENABLE_SAVESTATES/,/^\.\\" %ENDIF ENABLE_SAVESTATES/ s,^,.\\"\# ,'
570 endif
571
572 if ENABLE_ATTRIBUTELOG
573 MAN_ATTRIBUTELOG = sed "s|/usr/local/var/lib/smartmontools/attrlog\\.|$(attributelog)|g"
574 else
575 MAN_ATTRIBUTELOG = sed '/^\.\\" %IF ENABLE_ATTRIBUTELOG/,/^\.\\" %ENDIF ENABLE_ATTRIBUTELOG/ s,^,.\\"\# ,'
576 endif
577
578 MAN_FILTER = \
579 sed -e 's|CURRENT_SVN_VERSION|$(releaseversion)|g' \
580 -e "s|CURRENT_SVN_DATE|`sed -n 's,^.*DATE[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g" \
581 -e "s|CURRENT_SVN_REV|`sed -n 's,^.*REV[^"]*"\([^"]*\)".*$$,r\1,p' svnversion.h`|g" \
582 -e 's|/usr/local/share/man/|$(mandir)/|g' \
583 -e 's|/usr/local/sbin/|$(sbindir)/|g' \
584 -e 's|/usr/local/etc/rc\.d/init.d/|$(initddir)/|g' \
585 -e 's|/usr/local/share/doc/smartmontools/examplescripts/|!exampledir!|g' \
586 -e 's|/usr/local/share/doc/smartmontools/|$(docsdir)/|g' \
587 -e 's|!exampledir!|$(exampledir)/|g' \
588 -e 's|/usr/local/etc/smartd\.conf|$(sysconfdir)/smartd.conf|g' \
589 -e 's|/usr/local/etc/smart_drivedb\.h|$(sysconfdir)/smart_drivedb.h|g' \
590 -e 's|/usr/local/etc/smartd_warning\.sh|$(smartdscriptdir)/smartd_warning.sh|g' \
591 -e 's|\\fBmail\\fP|\\fB$(os_mailer)\\fP|g' \
592 -e 's|\\'\''mail\\'\''|\\'\''$(os_mailer)\\'\''|g' \
593 -e 's|/usr/bin/mail|/usr/bin/$(os_mailer)|g' \
594 -e 's|RELEASE_6_0_DRIVEDB|@DRIVEDB_BRANCH@|g' | \
595 if test -n '$(smartdplugindir)'; then \
596 sed 's|/usr/local/etc/smartd_warning\.d|$(smartdplugindir)|g' ; \
597 else \
598 sed '/^\.\\" %IF ENABLE_SMARTDPLUGINDIR/,/^\.\\" %ENDIF ENABLE_SMARTDPLUGINDIR/ s,^,.\\"\# ,' ; \
599 fi | \
600 $(MAN_ATTRIBUTELOG) | \
601 $(MAN_CAPABILITIES) | \
602 $(MAN_DRIVEDB) | \
603 $(MAN_SAVESTATES) | \
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 ' cat $(srcdir)/smartctl.8.in | $$(MAN_FILTER) > $@'
619 @cat $(srcdir)/smartctl.8.in | $(MAN_FILTER) > $@
620
621 smartd.8: smartd.8.in Makefile svnversion.h
622 @echo ' cat $(srcdir)/smartd.8.in | $$(MAN_FILTER) > $@'
623 @cat $(srcdir)/smartd.8.in | $(MAN_FILTER) > $@
624
625 smartd.conf.5: smartd.conf.5.in Makefile svnversion.h
626 @echo ' cat $(srcdir)/smartd.conf.5.in | $$(MAN_FILTER) > $@'
627 @cat $(srcdir)/smartd.conf.5.in | $(MAN_FILTER) > $@
628
629 update-smart-drivedb.8: update-smart-drivedb.8.in Makefile svnversion.h
630 @echo ' cat $(srcdir)/update-smart-drivedb.8.in | $$(MAN_FILTER) > $@'
631 @cat $(srcdir)/update-smart-drivedb.8.in | $(MAN_FILTER) > $@
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 ' cat smartctl.8 | $$(SOLARIS_MAN_FILTER) > $@'
643 @cat smartctl.8 | $(SOLARIS_MAN_FILTER) > $@
644
645 smartd.1m: smartd.8
646 @echo ' cat smartd.8 | $$(SOLARIS_MAN_FILTER) > $@'
647 @cat smartd.8 | $(SOLARIS_MAN_FILTER) > $@
648
649 smartd.conf.4: smartd.conf.5
650 @echo ' cat smartd.conf.5 | $$(SOLARIS_MAN_FILTER) > $@'
651 @cat smartd.conf.5 | $(SOLARIS_MAN_FILTER) > $@
652
653 update-smart-drivedb.1m: update-smart-drivedb.8
654 @echo ' cat update-smart-drivedb.8 | $$(SOLARIS_MAN_FILTER) > $@'
655 @cat update-smart-drivedb.8 | $(SOLARIS_MAN_FILTER) > $@
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 if OS_WIN32_MINGW
678
679 %.5.html: %.5
680 $(DOS2UNIX) < $< | $(MAN2HTML) | $(FIXHTML) > $@
681
682 %.8.html: %.8
683 $(DOS2UNIX) < $< | $(MAN2HTML) | $(FIXHTML) > $@
684 else
685
686 %.5.html: %.5
687 $(MAN2HTML) $< | $(FIXHTML) > $@
688
689 %.8.html: %.8
690 $(MAN2HTML) $< | $(FIXHTML) > $@
691 endif
692
693 %.5.txt: %.5
694 $(MAN2TXT) $< > $@
695
696 %.8.txt: %.8
697 $(MAN2TXT) $< > $@
698
699
700 # Check drive database syntax
701 check:
702 @if ./smartctl -B $(srcdir)/drivedb.h -P showall >/dev/null; then \
703 echo "$(srcdir)/drivedb.h: OK"; \
704 else \
705 echo "$(srcdir)/drivedb.h: Syntax check failed"; exit 1; \
706 fi
707
708
709 if OS_WIN32_MINGW
710 # Windows resources
711
712 smartctl_res.o: smartctl_res.rc
713 $(WINDRES) $< $@
714
715 smartd_res.o: smartd_res.rc syslogevt.rc
716 $(WINDRES) -I. $< $@
717
718 # Convert version for VERSIONINFO resource: 6.1 r3754 -> 6.1.0.3754, set Copyright year
719 WIN_RC_FILTER = \
720 ( ver=`echo '$(PACKAGE_VERSION).0' | sed -n 's,^\([0-9]*\.[0-9]*\.[0-9]*\).*$$,\1,p'`; \
721 rev=`sed -n 's,^.*REV[^"]*"\([0-9]*\).*$$,\1,p' svnversion.h`; \
722 txtver="$${ver:-0.0.0}.$${rev:-0}"; binver=`echo "$$txtver" | sed 's|\.|,|g'`; \
723 yy=`sed -n 's,^.*DATE[^"]*"20\([0-9][0-9]\).*$$,\1,p' svnversion.h`; yy="$${yy:-XX}"; \
724 sed -e "s|@BINARY_VERSION@|$$binver|g" -e "s|@TEXT_VERSION@|$$txtver|g" -e "s|@YY@|$$yy|g"; )
725
726 smartctl_res.rc: os_win32/smartctl_res.rc.in Makefile svnversion.h
727 cat $< | $(WIN_RC_FILTER) > $@
728
729 smartd_res.rc: os_win32/smartd_res.rc.in Makefile svnversion.h
730 cat $< | $(WIN_RC_FILTER) > $@
731
732 syslogevt.rc: os_win32/syslogevt.mc
733 $(WINDMC) -b $<
734
735 # Definitions for Windows distribution
736
737 if OS_WIN64
738 win_bits = 64
739 else
740 win_bits = 32
741 endif
742
743 distdir_win32 = $(PACKAGE)-$(VERSION).win$(win_bits)
744 distzip_win32 = $(PACKAGE)-$(VERSION).win$(win_bits).zip
745 distinst_win32 = $(PACKAGE)-$(VERSION).win$(win_bits)-setup.exe
746
747 exedir_win32 = $(distdir_win32)/bin
748 docdir_win32 = $(distdir_win32)/doc
749
750 EXEFILES_WIN32 = \
751 $(exedir_win32)/smartctl.exe \
752 $(exedir_win32)/smartctl-nc.exe \
753 $(exedir_win32)/smartd.exe \
754 $(exedir_win32)/smartd_warning.cmd \
755 $(exedir_win32)/runcmda.exe \
756 $(exedir_win32)/runcmdu.exe \
757 $(exedir_win32)/wtssendmsg.exe
758
759 if ENABLE_DRIVEDB
760 if OS_WIN32_NSIS
761 EXEFILES_WIN32 += \
762 $(exedir_win32)/update-smart-drivedb.exe
763 endif
764 endif
765
766 FILES_WIN32 = \
767 $(EXEFILES_WIN32) \
768 $(docdir_win32)/AUTHORS.txt \
769 $(docdir_win32)/ChangeLog.txt \
770 $(docdir_win32)/ChangeLog-5.0-6.0.txt \
771 $(docdir_win32)/COPYING.txt \
772 $(docdir_win32)/INSTALL.txt \
773 $(docdir_win32)/NEWS.txt \
774 $(docdir_win32)/README.txt \
775 $(docdir_win32)/TODO.txt \
776 $(docdir_win32)/WARNINGS.txt \
777 $(docdir_win32)/checksums$(win_bits).txt \
778 $(docdir_win32)/smartd.conf \
779 $(docdir_win32)/smartctl.8.html \
780 $(docdir_win32)/smartctl.8.txt \
781 $(docdir_win32)/smartd.8.html \
782 $(docdir_win32)/smartd.8.txt \
783 $(docdir_win32)/smartd.conf.5.html \
784 $(docdir_win32)/smartd.conf.5.txt \
785 $(exedir_win32)/runcmda.exe.manifest \
786 $(exedir_win32)/runcmdu.exe.manifest
787
788 if ENABLE_DRIVEDB
789 FILES_WIN32 += \
790 $(exedir_win32)/drivedb.h
791 endif
792
793 CLEANFILES += \
794 $(FILES_WIN32) \
795 runcmdu.exe \
796 smartctl-nc.exe smartctl-nc.exe.tmp \
797 smartctl_res.rc smartctl_res.o \
798 smartd_res.rc smartd_res.o \
799 syslogevt.h syslogevt.o \
800 syslogevt.rc syslogevt_*.bin \
801 wtssendmsg.exe \
802 update-smart-drivedb.exe \
803 distdir.mkdir
804
805 # Textfile converter from package cygutils or tofrodos
806 # Note: Only use without options to be compatible with both packages
807 UNIX2DOS = unix2dos
808 DOS2UNIX = dos2unix
809
810 # Build Windows distribution
811
812 dist-win32: $(distzip_win32)
813
814 install-win32: $(distinst_win32)
815 ./$(distinst_win32)
816
817 installer-win32: $(distinst_win32)
818
819 distdir-win32: distdir.mkdir $(FILES_WIN32)
820
821 $(distzip_win32): distdir.mkdir $(FILES_WIN32)
822 @rm -fv $(distzip_win32)
823 cd $(distdir_win32) && zip -9 ../$(distzip_win32) bin/* doc/*
824 md5sum $@ > $@.md5
825 sha1sum $@ > $@.sha1
826 sha256sum $@ > $@.sha256
827
828 if OS_WIN32_NSIS
829 # Build NSIS installer
830 # Note: Only option character '-' is also compatible with Linux version of makensis
831 $(distinst_win32): os_win32/installer.nsi distdir.mkdir $(FILES_WIN32)
832 test -z '$(builddir_win64)' || ( cd $(builddir_win64) && make distdir-win32 )
833 @date=`sed -n 's,^.*DATE[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`; \
834 rev=`sed -n 's,^.*REV[^"]*"\([^"]*\)".*$$,r\1,p' svnversion.h`; \
835 verstr="$(PACKAGE_VERSION) $$date $$rev "$(BUILD_INFO); \
836 d64=; test -z '$(builddir_win64)' || d64='-DINPDIR64=$(builddir_win64)/$(PACKAGE)-$(VERSION).win64'; \
837 echo "'$(MAKENSIS)' -V2 -NOCD -DINPDIR=$(distdir_win32) $$d64 -DOUTFILE=$@ -DVERSTR='$$verstr' $<"; \
838 '$(MAKENSIS)' -V2 -NOCD -DINPDIR=$(distdir_win32) $$d64 -DOUTFILE=$@ -DVERSTR="$$verstr" $<
839 md5sum $@ > $@.md5
840 sha1sum $@ > $@.sha1
841 sha256sum $@ > $@.sha256
842
843 # Build drivedb.h update tool
844 update-smart-drivedb.exe: os_win32/update-smart-drivedb.nsi
845 "$(MAKENSIS)" -V2 -NOCD -DBRANCH=$(DRIVEDB_BRANCH) $<
846
847 else
848 $(distinst_win32):
849 @echo "makensis: command not found. Please install NSIS from http://nsis.sourceforge.net/" 1>&2
850 @exit 1
851 endif
852
853 cleandist-win32:
854 rm -rf $(distdir_win32) distdir.mkdir
855
856 distdir.mkdir:
857 @test -d $(exedir_win32) || mkdir -pv $(exedir_win32)
858 @test -d $(docdir_win32) || mkdir -pv $(docdir_win32)
859 touch $@
860
861 $(exedir_win32)/%.exe: %.exe
862 cp -p $< $@
863 if test -n '$(STRIP)'; then $(STRIP) -s $@; else strip -s $@; fi
864 touch -r $< $@
865
866 # strip would break NSIS integrity check
867 $(exedir_win32)/update-smart-drivedb.exe: update-smart-drivedb.exe
868 cp -p $< $@
869
870 # runcmd?.exe only differ by .exe.manifest files
871 $(exedir_win32)/runcmda.exe: $(exedir_win32)/runcmdu.exe
872 cp -p $< $@
873
874 $(exedir_win32)/%.h: $(srcdir)/%.h
875 $(UNIX2DOS) < $< > $@
876 touch -r $< $@
877
878 $(exedir_win32)/%.exe.manifest: $(srcdir)/os_win32/%.exe.manifest
879 $(UNIX2DOS) < $< > $@
880 touch -r $< $@
881
882 $(exedir_win32)/%.cmd: $(srcdir)/os_win32/%.cmd
883 $(UNIX2DOS) < $< > $@
884 touch -r $< $@
885
886 $(docdir_win32)/%.html: %.html
887 $(UNIX2DOS) < $< > $@
888 touch -r $< $@
889
890 $(docdir_win32)/%.txt: %.txt
891 $(UNIX2DOS) < $< > $@
892 touch -r $< $@
893
894 $(docdir_win32)/%.txt: $(srcdir)/%
895 $(UNIX2DOS) < $< > $@
896 touch -r $< $@
897
898 $(docdir_win32)/%.conf: $(srcdir)/%.conf
899 $(UNIX2DOS) < $< > $@
900 touch -r $< $@
901
902 $(docdir_win32)/checksums$(win_bits).txt: $(EXEFILES_WIN32)
903 (cd $(exedir_win32) && md5sum *.exe && sha1sum *.exe && sha256sum *.exe) \
904 | $(UNIX2DOS) > $@
905
906 # Build non-console version of smartctl for GSmartControl.
907 # The script below changes the word at offset 220 (Subsystem) from 3
908 # (Console) to 2 (GUI) in a copy of smartctl.exe.
909 # This will be changed when a tool (like 'editbin') is available in
910 # the Cygwin distribution
911 smartctl-nc.exe: smartctl.exe
912 @rm -f $@
913 cp -p smartctl.exe $@.tmp
914 @if test `od -A n -j 220 -N 2 -d $@.tmp` -eq 3; then :; \
915 else echo "invalid EXE header"; exit 1; fi
916 @echo "editbin /subsystem:windows $@.tmp"
917 @echo -ne '\002' | dd bs=1 seek=220 count=1 conv=notrunc of=$@.tmp 2>/dev/null
918 @if test `od -A n -j 220 -N 2 -d $@.tmp` -eq 2; then :; \
919 else echo "EXE patch failed"; exit 1; fi
920 mv -f $@.tmp $@
921
922 # Build runcmd?.exe and wtssendmsg.exe
923 runcmdu.exe: os_win32/runcmd.c
924 $(CC) -Os -o $@ $<
925
926 wtssendmsg.exe: os_win32/wtssendmsg.c
927 $(CC) -Os -o $@ $< -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