]> git.proxmox.com Git - mirror_smartmontools-debian.git/blame - Makefile.am
Updated changelog
[mirror_smartmontools-debian.git] / Makefile.am
CommitLineData
832b75ed
GG
1## Process this file with automake to produce Makefile.in
2#
e165493d 3# $Id: Makefile.am 3527 2012-03-25 16:42:24Z chrfranke $
832b75ed
GG
4#
5
6@SET_MAKE@
7
d008864d
GI
8ACLOCAL_AM_FLAGS = -I m4
9
4d59bff9
GG
10# Make sure .cpp takes precedence to avoid compiling old .c file
11SUFFIXES = .cpp .c .s .o
12
2127e193
GI
13# BUILD_INFO can be provided by package maintainers (see INSTALL file)
14BUILD_INFO= "(local build)"
4d59bff9 15
2127e193
GI
16AM_CPPFLAGS = -DBUILD_INFO='$(BUILD_INFO)' -DSMARTMONTOOLS_SYSCONFDIR='"$(sysconfdir)"'
17if ENABLE_DRIVEDB
18AM_CPPFLAGS += -DSMARTMONTOOLS_DRIVEDBDIR='"$(drivedbdir)"'
19endif
20if ENABLE_SAVESTATES
21AM_CPPFLAGS += -DSMARTMONTOOLS_SAVESTATES='"$(savestates)"'
22endif
23if ENABLE_ATTRIBUTELOG
24AM_CPPFLAGS += -DSMARTMONTOOLS_ATTRIBUTELOG='"$(attributelog)"'
25endif
832b75ed 26
d008864d
GI
27if OS_WIN32_MINGW
28AM_CPPFLAGS += -I$(srcdir)/os_win32
29endif
e9583e0c
GI
30if NEED_GETOPT_LONG
31AM_CPPFLAGS += -I$(srcdir)/getopt -DHAVE_GETOPT_LONG -D__GNU_LIBRARY__
32endif
33if NEED_REGEX
34AM_CPPFLAGS += -I$(srcdir)/regex
35endif
36
832b75ed
GG
37sbin_PROGRAMS = smartd \
38 smartctl
39
7f0798ef 40if ENABLE_DRIVEDB
cfbba5b9
GI
41if OS_WIN32_MINGW
42else
7f0798ef
GI
43sbin_SCRIPTS = update-smart-drivedb
44endif
cfbba5b9 45endif
7f0798ef
GI
46
47
4d59bff9 48smartd_SOURCES = smartd.cpp \
4d59bff9
GG
49 atacmdnames.cpp \
50 atacmdnames.h \
51 atacmds.cpp \
52 atacmds.h \
2127e193
GI
53 dev_ata_cmd_set.cpp \
54 dev_ata_cmd_set.h \
55 dev_interface.cpp \
56 dev_interface.h \
57 dev_tunnelled.h \
a23d5117 58 drivedb.h \
4d59bff9
GG
59 int64.h \
60 knowndrives.cpp \
61 knowndrives.h \
62 scsicmds.cpp \
63 scsicmds.h \
64 scsiata.cpp \
4d59bff9 65 utility.cpp \
832b75ed
GG
66 utility.h
67
a23d5117 68smartd_LDADD = @os_deps@ @os_libs@ @CAPNG_LDADD@
832b75ed 69smartd_DEPENDENCIES = @os_deps@
4d59bff9
GG
70
71EXTRA_smartd_SOURCES = os_darwin.cpp \
72 os_darwin.h \
73 os_linux.cpp \
832b75ed 74 os_linux.h \
4d59bff9
GG
75 os_freebsd.cpp \
76 os_freebsd.h \
77 os_netbsd.cpp \
78 os_netbsd.h \
79 os_openbsd.cpp \
80 os_openbsd.h \
e9583e0c
GI
81 os_qnxnto.cpp \
82 os_qnxnto.h \
4d59bff9
GG
83 os_solaris.cpp \
84 os_solaris.h \
85 os_solaris_ata.s \
86 os_win32.cpp \
87 os_generic.cpp \
a37e7145
GG
88 os_generic.h \
89 cciss.cpp \
2127e193 90 cciss.h \
d008864d 91 cissio_freebsd.h \
2127e193
GI
92 dev_legacy.cpp \
93 megaraid.h
832b75ed
GG
94
95
96if OS_WIN32_MINGW
97
e9583e0c
GI
98smartd_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
832b75ed
GG
105
106endif
107
4d59bff9
GG
108smartctl_SOURCES= smartctl.cpp \
109 smartctl.h \
110 atacmdnames.cpp \
111 atacmdnames.h \
112 atacmds.cpp \
113 atacmds.h \
114 ataprint.cpp \
115 ataprint.h \
2127e193
GI
116 dev_ata_cmd_set.cpp \
117 dev_ata_cmd_set.h \
118 dev_interface.cpp \
119 dev_interface.h \
120 dev_tunnelled.h \
a23d5117 121 drivedb.h \
4d59bff9
GG
122 int64.h \
123 knowndrives.cpp \
124 knowndrives.h \
125 scsicmds.cpp \
126 scsicmds.h \
127 scsiata.cpp \
4d59bff9
GG
128 scsiprint.cpp \
129 scsiprint.h \
130 utility.cpp \
832b75ed
GG
131 utility.h
132
2127e193 133
832b75ed
GG
134smartctl_LDADD = @os_deps@ @os_libs@
135smartctl_DEPENDENCIES = @os_deps@
4d59bff9
GG
136
137EXTRA_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 \
e9583e0c
GI
145 os_qnxnto.cpp \
146 os_qnxnto.h \
4d59bff9
GG
147 os_solaris.cpp \
148 os_solaris.h \
149 os_win32.cpp \
150 os_generic.cpp \
a37e7145
GG
151 os_generic.h \
152 cciss.cpp \
2127e193 153 cciss.h \
d008864d 154 cissio_freebsd.h \
2127e193
GI
155 dev_legacy.cpp \
156 megaraid.h
832b75ed 157
e9583e0c
GI
158if NEED_GETOPT_LONG
159
160smartctl_SOURCES += \
161 getopt/getopt.c \
162 getopt/getopt.h \
163 getopt/getopt1.c
832b75ed 164
e9583e0c
GI
165smartd_SOURCES += \
166 getopt/getopt.c \
167 getopt/getopt.h \
168 getopt/getopt1.c
169
170endif
171
172if NEED_REGEX
173
174smartctl_SOURCES += \
175 regex/regex.c \
176 regex/regex.h \
177 regex/regex_internal.h
178
179smartd_SOURCES += \
180 regex/regex.c \
181 regex/regex.h \
182 regex/regex_internal.h
832b75ed
GG
183
184# Included by regex.c:
e9583e0c
GI
185EXTRA_smartctl_SOURCES += \
186 regex/regcomp.c \
187 regex/regexec.c \
188 regex/regex_internal.c
189
190EXTRA_smartd_SOURCES += \
191 regex/regcomp.c \
192 regex/regexec.c \
193 regex/regex_internal.c
832b75ed
GG
194
195endif
196
cfbba5b9
GI
197if OS_WIN32
198
199smartctl_SOURCES += \
200 csmisas.h \
201 os_win32/wmiquery.cpp \
202 os_win32/wmiquery.h
203
204smartd_SOURCES += \
205 csmisas.h \
206 os_win32/wmiquery.cpp \
207 os_win32/wmiquery.h
208
209smartctl_LDADD += -lole32 -loleaut32
210smartd_LDADD += -lole32 -loleaut32
211
212endif
213
832b75ed
GG
214if 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.
220extra_MANS = smartd.conf.4 \
221 smartctl.1m \
222 smartd.1m
223install-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
237uninstall-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' > $@
265else
266# For systems that adopts traditional manner
267man_MANS = smartd.conf.5 \
268 smartctl.8 \
269 smartd.8
270endif
271
272docsdir=$(docdir)
273docs_DATA = AUTHORS \
274 CHANGELOG \
275 COPYING \
276 INSTALL \
277 NEWS \
278 README \
279 TODO \
280 WARNINGS \
281 smartd.conf
282
cfbba5b9
GI
283examplesdir=$(exampledir)
284examples_DATA = \
285 examplescripts/README
286examples_SCRIPTS = \
287 examplescripts/Example1 \
288 examplescripts/Example2 \
289 examplescripts/Example3 \
290 examplescripts/Example4
291
292sysconf_DATA = smartd.conf
293
294# If modified smartd.conf exists install smartd.conf.sample instead
295install-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
312uninstall-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
324EXTRA_DIST = \
a7e8ffec 325 autogen.sh \
cfbba5b9 326 smartd.initd.in \
a7e8ffec 327 smartd.freebsd.initd.in \
cfbba5b9
GI
328 smartd.8.in \
329 smartctl.8.in \
330 smartd.conf.5.in \
331 smartd.conf \
a7e8ffec 332 smartd.service.in \
cfbba5b9 333 update-smart-drivedb.in \
d008864d 334 m4/pkg.m4 \
cfbba5b9
GI
335 os_darwin/SMART.in \
336 os_darwin/StartupParameters.plist \
337 os_darwin/English_Localizable.strings \
338 os_win32/installer.nsi \
d008864d
GI
339 os_win32/runcmd.c \
340 os_win32/runcmda.exe.manifest \
341 os_win32/runcmdu.exe.manifest \
cfbba5b9
GI
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)
832b75ed 349
a7e8ffec
GI
350CLEANFILES = \
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
832b75ed 369
2127e193
GI
370# 'make maintainer-clean' also removes files generated by './autogen.sh'
371MAINTAINERCLEANFILES = \
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 \
d008864d
GI
382 $(srcdir)/mkinstalldirs \
383 $(srcdir)/m4/pkg.m4
2127e193
GI
384
385utility.o: svnversion.h
386
387if IS_SVN_BUILD
388# Get version info from SVN
e165493d 389svnversion.h: CHANGELOG Makefile $(svn_deps)
2127e193
GI
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_,' >> $@
396else
397
398# SVN not available, guess version info from Id strings
399svnversion.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_,' >> $@
406endif
407
408
2127e193
GI
409if ENABLE_DRIVEDB
410drivedb_DATA = drivedb.h
411endif
412
413if ENABLE_SAVESTATES
414# Create $(savestatesdir) only
415savestates_DATA =
416endif
417
418if ENABLE_ATTRIBUTELOG
419# Create $(attributelogdir) only
420attributelog_DATA =
421endif
832b75ed 422
7f0798ef
GI
423update-smart-drivedb: update-smart-drivedb.in config.status
424 $(SHELL) ./config.status --file=$@
425 chmod +x $@
426
427
2127e193 428if INSTALL_INITSCRIPT
832b75ed
GG
429if OS_DARWIN
430initd_DATA = SMART \
431 os_darwin/StartupParameters.plist \
432 os_darwin/English_Localizable.strings
433
434initd_install_name = SMART
435
436initd_DATA_install = install-initdDATA-darwin
2127e193 437initd_DATA_uninstall = uninstall-initdDATA-darwin
832b75ed
GG
438
439SMART : os_darwin/SMART.in
440 sed "s|/usr/sbin/|$(sbindir)/|" $< > $@
441
442install-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
832b75ed 455
2127e193
GI
456uninstall-initdDATA-darwin:
457 rm -rf $(DESTDIR)$(initddir)/$(initd_install_name)
458
832b75ed
GG
459else
460
a7e8ffec 461initd_DATA = @initdfile@
832b75ed 462
a7e8ffec
GI
463@initdfile@: $(srcdir)/@initdfile@.in Makefile
464 sed "s|/usr/local/sbin/|$(sbindir)/|g" $(srcdir)/@initdfile@.in > $@
832b75ed
GG
465
466initd_install_name = smartd$(smartd_suffix)
467
468initd_DATA_install = install-initdDATA-generic
2127e193 469initd_DATA_uninstall = uninstall-initdDATA-generic
832b75ed
GG
470
471install-initdDATA-generic: $(initd_DATA)
472 $(mkinstalldirs) $(DESTDIR)$(initddir)
a7e8ffec 473 $(INSTALL_SCRIPT) $(top_builddir)/@initdfile@ $(DESTDIR)$(initddir)/smartd$(smartd_suffix)
832b75ed 474
2127e193
GI
475
476uninstall-initdDATA-generic:
477 rm -rf $(DESTDIR)$(initddir)/$(initd_install_name)
478endif
479else
480
481initd_DATA_install = install-initdDATA-null
482initd_DATA_uninstall = uninstall-initdDATA-null
483
484install-initdDATA-null:
485uninstall-initdDATA-null:
832b75ed
GG
486endif
487
488install-initdDATA : $(initd_DATA_install)
489
2127e193 490uninstall-initdDATA: $(initd_DATA_uninstall)
832b75ed 491
a7e8ffec
GI
492if INSTALL_SYSTEMDUNIT
493systemdsystemunit_DATA = smartd.service
494endif
495
496smartd.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
a23d5117
GI
501if ENABLE_CAPABILITIES
502MAN_CAPABILITIES = cat
503else
d008864d 504MAN_CAPABILITIES = sed '/^\.\\" %IF ENABLE_CAPABILITIES/,/^\.\\" %ENDIF ENABLE_CAPABILITIES/ s,^,.\\"\# ,'
a23d5117
GI
505endif
506
2127e193
GI
507if ENABLE_DRIVEDB
508MAN_DRIVEDB = sed "s|/usr/local/share/smartmontools/drivedb\\.h|$(drivedbdir)/drivedb.h|g"
509else
d008864d 510MAN_DRIVEDB = sed '/^\.\\" %IF ENABLE_DRIVEDB/,/^\.\\" %ENDIF ENABLE_DRIVEDB/ s,^,.\\"\# ,'
2127e193 511endif
832b75ed 512
2127e193
GI
513if ENABLE_SAVESTATES
514MAN_SAVESTATES = sed "s|/usr/local/var/lib/smartmontools/smartd\\.|$(savestates)|g"
515else
d008864d 516MAN_SAVESTATES = sed '/^\.\\" %IF ENABLE_SAVESTATES/,/^\.\\" %ENDIF ENABLE_SAVESTATES/ s,^,.\\"\# ,'
2127e193
GI
517endif
518
519if ENABLE_ATTRIBUTELOG
520MAN_ATTRIBUTELOG = sed "s|/usr/local/var/lib/smartmontools/attrlog\\.|$(attributelog)|g"
521else
d008864d 522MAN_ATTRIBUTELOG = sed '/^\.\\" %IF ENABLE_ATTRIBUTELOG/,/^\.\\" %ENDIF ENABLE_ATTRIBUTELOG/ s,^,.\\"\# ,'
2127e193
GI
523endif
524
a23d5117 525MAN_FILTER = \
e9583e0c
GI
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; \
a23d5117
GI
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; \
cfbba5b9
GI
532 s|/usr/local/share/doc/smartmontools/examplescripts/|!exampledir!|g; \
533 s|/usr/local/share/doc/smartmontools/|$(docsdir)/|g; \
534 s|!exampledir!|$(exampledir)/|g; \
a23d5117
GI
535 s|/usr/local/etc/smartd\\.conf|$(sysconfdir)/smartd.conf|g; \
536 s|/usr/local/etc/smart_drivedb\\.h|$(sysconfdir)/smart_drivedb\\.h|g" | \
d008864d 537 $(MAN_ATTRIBUTELOG) | \
a23d5117
GI
538 $(MAN_CAPABILITIES) | \
539 $(MAN_DRIVEDB) | \
540 $(MAN_SAVESTATES) | \
d008864d
GI
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
a23d5117 552
7f0798ef
GI
553# Implicit rule 'smart%: smart%.in ...' does not work with BSD make
554smartctl.8: smartctl.8.in Makefile svnversion.h
555 cat $(srcdir)/smartctl.8.in | $(MAN_FILTER) > $@
556
557smartd.8: smartd.8.in Makefile svnversion.h
558 cat $(srcdir)/smartd.8.in | $(MAN_FILTER) > $@
559
560smartd.conf.5: smartd.conf.5.in Makefile svnversion.h
561 cat $(srcdir)/smartd.conf.5.in | $(MAN_FILTER) > $@
832b75ed
GG
562
563# Commands to convert man pages into .html and .txt
564# TODO: configure
565MAN2HTML = man2html
566#MAN2HTML = groff -man -Thtml
567MAN2TXT = groff -man -Tascii -P'-bcou'
568
4d59bff9
GG
569# Remove HTTP header and fix links in man2html output
570FIXHTML = 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' \
832b75ed
GG
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
578htmlman: smartctl.8.html smartd.8.html smartd.conf.5.html
579
580txtman: smartctl.8.txt smartd.8.txt smartd.conf.5.txt
581
4d59bff9
GG
582if OS_WIN32_MINGW
583
584%.5.html: %.5
585 $(DOS2UNIX) < $< | $(MAN2HTML) | $(FIXHTML) > $@
586
587%.8.html: %.8
588 $(DOS2UNIX) < $< | $(MAN2HTML) | $(FIXHTML) > $@
589else
590
832b75ed
GG
591%.5.html: %.5
592 $(MAN2HTML) $< | $(FIXHTML) > $@
593
594%.8.html: %.8
595 $(MAN2HTML) $< | $(FIXHTML) > $@
4d59bff9 596endif
832b75ed
GG
597
598%.5.txt: %.5
599 $(MAN2TXT) $< > $@
600
601%.8.txt: %.8
602 $(MAN2TXT) $< > $@
603
604
a23d5117
GI
605# Check drive database syntax
606check:
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
832b75ed
GG
613
614if OS_WIN32_MINGW
615# Definitions for Windows distribution
616
7f0798ef
GI
617if OS_WIN64
618win_bits = 64
619else
620win_bits = 32
621endif
622
623distdir_win32 = $(PACKAGE)-$(VERSION).win$(win_bits)
624distzip_win32 = $(PACKAGE)-$(VERSION).win$(win_bits).zip
625distinst_win32 = $(PACKAGE)-$(VERSION).win$(win_bits)-setup.exe
832b75ed
GG
626
627exedir_win32 = $(distdir_win32)/bin
628docdir_win32 = $(distdir_win32)/doc
629
cfbba5b9
GI
630EXEFILES_WIN32 = \
631 $(exedir_win32)/smartctl.exe \
632 $(exedir_win32)/smartctl-nc.exe \
d008864d
GI
633 $(exedir_win32)/smartd.exe \
634 $(exedir_win32)/runcmda.exe \
635 $(exedir_win32)/runcmdu.exe
cfbba5b9
GI
636
637if OS_WIN32_WINDMC
638EXEFILES_WIN32 += \
639 $(exedir_win32)/syslogevt.exe
640endif
641
642if ENABLE_DRIVEDB
643if OS_WIN32_NSIS
644EXEFILES_WIN32 += \
645 $(exedir_win32)/update-smart-drivedb.exe
646endif
647endif
648
649FILES_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.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 \
d008864d
GI
666 $(docdir_win32)/smartd.conf.5.txt \
667 $(exedir_win32)/runcmda.exe.manifest \
668 $(exedir_win32)/runcmdu.exe.manifest
cfbba5b9
GI
669
670if ENABLE_DRIVEDB
671FILES_WIN32 += \
672 $(exedir_win32)/drivedb.h
673endif
674
675CLEANFILES += \
676 $(FILES_WIN32) \
d008864d 677 runcmdu.exe \
cfbba5b9
GI
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
832b75ed 683
7f0798ef
GI
684# Textfile converter from package cygutils or tofrodos
685# Note: Only use without options to be compatible with both packages
686UNIX2DOS = unix2dos
687DOS2UNIX = dos2unix
832b75ed
GG
688
689# Build Windows distribution
690
691dist-win32: $(distzip_win32)
692
4d59bff9
GG
693install-win32: $(distinst_win32)
694 ./$(distinst_win32)
695
696installer-win32: $(distinst_win32)
697
cfbba5b9 698distdir-win32: distdir.mkdir $(FILES_WIN32)
832b75ed 699
cfbba5b9 700$(distzip_win32): distdir.mkdir $(FILES_WIN32)
832b75ed 701 @rm -fv $(distzip_win32)
cfbba5b9
GI
702 cd $(distdir_win32) && zip -9 ../$(distzip_win32) bin/* doc/*
703 md5sum $@ > $@.md5
704 sha1sum $@ > $@.sha1
705 sha256sum $@ > $@.sha256
832b75ed 706
cfbba5b9
GI
707if OS_WIN32_NSIS
708# Build NSIS installer
7f0798ef 709# Note: Only option character '-' is also compatible with Linux version of makensis
cfbba5b9
GI
710$(distinst_win32): os_win32/installer.nsi distdir.mkdir $(FILES_WIN32)
711 @date=`sed -n 's,^.*DATE[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`; \
2127e193
GI
712 rev=`sed -n 's,^.*REV[^"]*"\([^"]*\)".*$$,r\1,p' svnversion.h`; \
713 verstr="$(PACKAGE_VERSION) $$date $$rev "$(BUILD_INFO); \
cfbba5b9
GI
714 echo "'$(MAKENSIS)' -V2 -NOCD -DINPDIR=$(distdir_win32) -DOUTFILE=$@ -DVERSTR='$$verstr' $<"; \
715 '$(MAKENSIS)' -V2 -NOCD -DINPDIR=$(distdir_win32) -DOUTFILE=$@ -DVERSTR="$$verstr" $<
716 md5sum $@ > $@.md5
717 sha1sum $@ > $@.sha1
718 sha256sum $@ > $@.sha256
719
720# Build drivedb.h update tool
721update-smart-drivedb.exe: os_win32/update-smart-drivedb.nsi
722 "$(MAKENSIS)" -V2 -NOCD -DBRANCH=$(DRIVEDB_BRANCH) $<
723
724else
725$(distinst_win32):
726 @echo "makensis: command not found. Please install NSIS from http://nsis.sourceforge.net/" 1>&2
727 @exit 1
728endif
4d59bff9 729
832b75ed 730cleandist-win32:
cfbba5b9 731 rm -rf $(distdir_win32) distdir.mkdir
832b75ed
GG
732
733distdir.mkdir:
734 @test -d $(exedir_win32) || mkdir -pv $(exedir_win32)
735 @test -d $(docdir_win32) || mkdir -pv $(docdir_win32)
736 touch $@
737
832b75ed
GG
738$(exedir_win32)/%.exe: %.exe
739 cp -p $< $@
7f0798ef 740 if test -n '$(STRIP)'; then $(STRIP) -s $@; else strip -s $@; fi
832b75ed
GG
741 touch -r $< $@
742
cfbba5b9
GI
743# strip would break NSIS integrity check
744$(exedir_win32)/update-smart-drivedb.exe: update-smart-drivedb.exe
745 cp -p $< $@
746
d008864d
GI
747# runcmd?.exe only differ by .exe.manifest files
748$(exedir_win32)/runcmda.exe: $(exedir_win32)/runcmdu.exe
749 cp -p $< $@
750
cfbba5b9
GI
751$(exedir_win32)/%.h: $(srcdir)/%.h
752 $(UNIX2DOS) < $< > $@
753 touch -r $< $@
754
d008864d
GI
755$(exedir_win32)/%.exe.manifest: $(srcdir)/os_win32/%.exe.manifest
756 $(UNIX2DOS) < $< > $@
757 touch -r $< $@
758
ba59cff1
GG
759$(docdir_win32)/%.html: %.html
760 $(UNIX2DOS) < $< > $@
761 touch -r $< $@
762
763$(docdir_win32)/%.txt: %.txt
832b75ed
GG
764 $(UNIX2DOS) < $< > $@
765 touch -r $< $@
766
767$(docdir_win32)/%.txt: $(srcdir)/%
768 $(UNIX2DOS) < $< > $@
769 touch -r $< $@
770
771$(docdir_win32)/%.conf: $(srcdir)/%.conf
772 $(UNIX2DOS) < $< > $@
773 touch -r $< $@
774
cfbba5b9
GI
775$(docdir_win32)/checksums.txt: $(EXEFILES_WIN32)
776 (cd $(exedir_win32) && md5sum *.exe && sha1sum *.exe && sha256sum *.exe) \
777 | $(UNIX2DOS) > $@
778
2127e193
GI
779# Build non-console version of smartctl for GSmartControl.
780# The script below changes the word at offset 220 (Subsystem) from 3
781# (Console) to 2 (GUI) in a copy of smartctl.exe.
782# This will be changed when a tool (like 'editbin') is available in
783# the Cygwin distribution
784smartctl-nc.exe: smartctl.exe
785 @rm -f $@
786 cp -p smartctl.exe $@.tmp
787 @if test `od -A n -j 220 -N 2 -d $@.tmp` -eq 3; then :; \
788 else echo "invalid EXE header"; exit 1; fi
789 @echo "editbin /subsystem:windows $@.tmp"
790 @echo -ne '\002' | dd bs=1 seek=220 count=1 conv=notrunc of=$@.tmp 2>/dev/null
791 @if test `od -A n -j 220 -N 2 -d $@.tmp` -eq 2; then :; \
792 else echo "EXE patch failed"; exit 1; fi
793 mv -f $@.tmp $@
794
d008864d
GI
795# Build runcmd?.exe
796runcmdu.exe: os_win32/runcmd.c
797 $(CC) -Os -o $@ $<
798
cfbba5b9
GI
799if OS_WIN32_WINDMC
800# Build syslogevt.exe event message file tool
801
802syslogevt.exe: syslogevt.o syslogevt.res.o
803 $(LINK) $^
804
805syslogevt.o: os_win32/syslogevt.c syslogevt.rc
806 $(CC) -c -I. -Os -o $@ $<
807
808syslogevt.res.o: syslogevt.rc
809 $(WINDRES) $< $@
810
811syslogevt.rc: os_win32/syslogevt.mc
812 $(WINDMC) -b $<
813endif
2127e193 814
d008864d 815# Build {config,svnversion}_vc10.h for MSVC10 from MinGW {config,svnversion}.h
2127e193 816
d008864d 817config-vc10: $(srcdir)/os_win32/config_vc10.h $(srcdir)/os_win32/svnversion_vc10.h
2127e193 818
d008864d
GI
819$(srcdir)/os_win32/config_vc10.h: config.h Makefile
820 sed -e '1i/* config_vc10.h. Generated from config.h by Makefile. */' \
e165493d 821 -e 's,^#define HAVE_\(ATTR_PACKED\|GETTIMEOFDAY\|INTTYPES_H\|[DK_]*NTDDDISK_H\|STRINGS_H\|STRTOULL\|UNISTD_H\|WORKING_SNPRINTF\) 1$$,/* #undef HAVE_\1 */,' \
d008864d 822 -e 's,^\(#define SMARTMONTOOLS_BUILD_HOST "[^-]*\)[^"]*,\1-pc-w32vc10,' $< > $@
2127e193 823
d008864d
GI
824$(srcdir)/os_win32/svnversion_vc10.h: svnversion.h
825 cp $< $@
832b75ed
GG
826
827endif