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