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