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