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