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