Makefile.am 22.3 KB
Newer Older
1
## Process this file with automake to produce Makefile.in
ballen4705's avatar
ballen4705 committed
2
#
3
# $Id$
ballen4705's avatar
ballen4705 committed
4
#
5

6
7
@SET_MAKE@

chrfranke's avatar
chrfranke committed
8
9
10
# Make sure .cpp takes precedence to avoid compiling old .c file
SUFFIXES = .cpp .c .s .o

11
12
# BUILD_INFO can be provided by package maintainers (see INSTALL file)
BUILD_INFO= "(local build)"
chrfranke's avatar
chrfranke committed
13

14
15
16
17
AM_CPPFLAGS = -DBUILD_INFO='$(BUILD_INFO)' -DSMARTMONTOOLS_SYSCONFDIR='"$(sysconfdir)"'
if ENABLE_DRIVEDB
AM_CPPFLAGS += -DSMARTMONTOOLS_DRIVEDBDIR='"$(drivedbdir)"'
endif
18
19
20
if ENABLE_SAVESTATES
AM_CPPFLAGS += -DSMARTMONTOOLS_SAVESTATES='"$(savestates)"'
endif
21
22
23
if ENABLE_ATTRIBUTELOG
AM_CPPFLAGS += -DSMARTMONTOOLS_ATTRIBUTELOG='"$(attributelog)"'
endif
24

25
26
27
sbin_PROGRAMS = smartd 	\
		smartctl

28
29
30
31
32
if ENABLE_DRIVEDB
sbin_SCRIPTS = update-smart-drivedb
endif


chrfranke's avatar
chrfranke committed
33
34
35
36
37
smartd_SOURCES =  smartd.cpp      \
                  atacmdnames.cpp \
                  atacmdnames.h   \
                  atacmds.cpp     \
                  atacmds.h       \
38
39
40
41
42
                  dev_ata_cmd_set.cpp \
                  dev_ata_cmd_set.h   \
                  dev_interface.cpp   \
                  dev_interface.h     \
                  dev_tunnelled.h     \
43
                  drivedb.h           \
chrfranke's avatar
chrfranke committed
44
45
46
47
48
49
50
51
                  extern.h        \
                  int64.h         \
                  knowndrives.cpp \
                  knowndrives.h   \
                  scsicmds.cpp    \
                  scsicmds.h      \
                  scsiata.cpp     \
                  utility.cpp     \
ballen4705's avatar
Oops    
ballen4705 committed
52
                  utility.h
53

54
smartd_LDADD = @os_deps@ @os_libs@ @CAPNG_LDADD@
55
smartd_DEPENDENCIES = @os_deps@
chrfranke's avatar
chrfranke committed
56
57
58
59

EXTRA_smartd_SOURCES = os_darwin.cpp    \
                       os_darwin.h      \
                       os_linux.cpp     \
60
                       os_linux.h       \
chrfranke's avatar
chrfranke committed
61
62
63
64
65
66
67
68
69
70
71
                       os_freebsd.cpp   \
                       os_freebsd.h     \
                       os_netbsd.cpp    \
                       os_netbsd.h      \
                       os_openbsd.cpp   \
                       os_openbsd.h     \
                       os_solaris.cpp   \
                       os_solaris.h     \
                       os_solaris_ata.s \
                       os_win32.cpp     \
                       os_generic.cpp   \
72
73
                       os_generic.h     \
                       cciss.cpp        \
74
                       cciss.h          \
75
76
                       dev_legacy.cpp   \
                       megaraid.h
77

78

chrfranke's avatar
chrfranke committed
79
80
if OS_WIN32_MINGW

chrfranke's avatar
chrfranke committed
81
82
83
84
85
86
87
88
89
smartd_SOURCES +=                           \
                posix/regex.h               \
                posix/regex.c               \
                os_win32/daemon_win32.h     \
                os_win32/daemon_win32.cpp   \
                os_win32/hostname_win32.h   \
                os_win32/hostname_win32.cpp \
                os_win32/syslog.h           \
                os_win32/syslog_win32.cpp
chrfranke's avatar
chrfranke committed
90

91
92
93
94
95
96
97
# Included by regex.c:
EXTRA_smartd_SOURCES +=                   \
                posix/regcomp.c           \
                posix/regexec.c           \
                posix/regex_internal.c    \
                posix/regex_internal.h

chrfranke's avatar
chrfranke committed
98
99
endif

chrfranke's avatar
chrfranke committed
100
101
102
103
104
105
106
107
smartctl_SOURCES= smartctl.cpp    \
                  smartctl.h      \
                  atacmdnames.cpp \
                  atacmdnames.h   \
                  atacmds.cpp     \
                  atacmds.h       \
                  ataprint.cpp    \
                  ataprint.h      \
108
109
110
111
112
                  dev_ata_cmd_set.cpp \
                  dev_ata_cmd_set.h   \
                  dev_interface.cpp   \
                  dev_interface.h     \
                  dev_tunnelled.h     \
113
                  drivedb.h           \
chrfranke's avatar
chrfranke committed
114
115
116
117
118
119
120
121
122
123
                  extern.h        \
                  int64.h         \
                  knowndrives.cpp \
                  knowndrives.h   \
                  scsicmds.cpp    \
                  scsicmds.h      \
                  scsiata.cpp     \
                  scsiprint.cpp   \
                  scsiprint.h     \
                  utility.cpp     \
ballen4705's avatar
Oops    
ballen4705 committed
124
                  utility.h
125

126

127
smartctl_LDADD = @os_deps@ @os_libs@
128
smartctl_DEPENDENCIES = @os_deps@
chrfranke's avatar
chrfranke committed
129
130
131
132
133
134
135
136
137
138
139
140
141

EXTRA_smartctl_SOURCES = os_linux.cpp \
                       os_linux.h     \
                       os_freebsd.cpp \
                       os_freebsd.h   \
                       os_netbsd.cpp  \
                       os_netbsd.h    \
                       os_openbsd.cpp \
                       os_openbsd.h   \
                       os_solaris.cpp \
                       os_solaris.h   \
                       os_win32.cpp   \
                       os_generic.cpp \
142
143
                       os_generic.h   \
                       cciss.cpp      \
144
                       cciss.h        \
145
146
                       dev_legacy.cpp \
                       megaraid.h
147

chrfranke's avatar
chrfranke committed
148
149
if OS_WIN32_MINGW

150
smartctl_SOURCES +=                    \
151
152
                posix/regex.h          \
                posix/regex.c          \
153
154
155
156
                os_win32/syslog.h

# Included by regex.c:
EXTRA_smartctl_SOURCES +=              \
157
158
                posix/regcomp.c        \
                posix/regexec.c        \
159
                posix/regex_internal.c \
160
                posix/regex_internal.h
161

chrfranke's avatar
chrfranke committed
162
endif
163

164
if OS_SOLARIS
165
166
167
168
169
# This block is required because Solaris uses manual page section 1m
# for administrative command (linux/freebsd use section 8) and Solaris
# uses manual page section 4 for file formats (linux/freebsd use
# section 5).  Automake can deal cleanly with man page sections 1-8
# and n, but NOT with sections of the form 1m.
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
extra_MANS =      smartd.conf.4 \
                  smartctl.1m   \
                  smartd.1m
install-man: $(extra_MANS)
	@$(NORMAL_INSTALL)
	$(mkinstalldirs) $(DESTDIR)$(mandir)/man4
	$(mkinstalldirs) $(DESTDIR)$(mandir)/man1m
	for i in $(extra_MANS); do \
	  if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
	  else file=$$i; fi; \
	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
	  echo " $(INSTALL_DATA) $$file $(DESTDIR)$(mandir)/man$$ext/$$inst"; \
	  $(INSTALL_DATA) $$file $(DESTDIR)$(mandir)/man$$ext/$$inst; \
	done
uninstall-man:
	@$(NORMAL_UNINSTALL)
	for i in $(extra_MANS); do \
	  if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
	  else file=$$i; fi; \
	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
	  echo " rm -f $(DESTDIR)$(mandir)/man$$ext/$$inst"; \
	  rm -f $(DESTDIR)$(mandir)/man$$ext/$$inst; \
	done
%.1m: %.8
	awk '/^.TH/ {$$3="1m"} {print}' < $< | \
	sed -e 's/smartd\.conf\(.*\)(5)/smartd.conf\1(4)/g' \
202
            -e 's/syslog\.conf\(.*\)(5)/syslog.conf\1(4)/g' \
203
	    -e 's/smartctl\(.*\)(8)/smartctl\1(1m)/g' \
204
	    -e 's/syslogd\(.*\)(8)/syslogd\1(1m)/g' \
205
            -e 's|/var/log/messages|/var/adm/messages|g' \
206
207
208
209
	    -e 's/smartd\(.*\)(8)/smartd\1(1m)/g' > $@
%.4: %.5
	awk '/^.TH/ {$$3="4"}  {print}' < $< | \
	sed -e 's/smartd\.conf\(.*\)(5)/smartd.conf\1(4)/g' \
210
            -e 's/syslog\.conf\(.*\)(5)/syslog.conf\1(4)/g' \
211
	    -e 's/smartctl\(.*\)(8)/smartdctl\1(1m)/g' \
212
	    -e 's/syslogd\(.*\)(8)/syslogd\1(1m)/g' \
213
            -e 's|/var/log/messages|/var/adm/messages|g' \
214
215
216
	    -e 's/smartd\(.*\)(8)/smartd\1(1m)/g' > $@
else
# For systems that adopts traditional manner
217
218
219
man_MANS =        smartd.conf.5 \
                  smartctl.8    \
                  smartd.8
220
endif
221
222

docsdir=$(docdir)
223
224
225
226
227
228
229
230
docs_DATA = AUTHORS     \
            CHANGELOG   \
            COPYING     \
            INSTALL     \
            NEWS        \
            README      \
            TODO        \
            WARNINGS    \
231
            smartd.conf
232

arvoreen's avatar
arvoreen committed
233
234
235
236
sysconf_DATA = smartd.conf$(smartd_suffix)

if SMARTD_SUFFIX
smartd.conf$(smartd_suffix): smartd.conf
237
	cp ${srcdir}/smartd.conf smartd.conf$(smartd_suffix)
arvoreen's avatar
arvoreen committed
238
endif
239

240
EXTRA_DIST = smartd.initd.in                       \
241
242
243
244
245
             smartd.8.in                           \
             smartctl.8.in                         \
             smartd.conf.5.in                      \
             smartd.conf                           \
             autogen.sh                            \
246
             update-smart-drivedb.in               \
247
248
249
             os_darwin/SMART.in                    \
             os_darwin/StartupParameters.plist     \
             os_darwin/English_Localizable.strings \
250
             os_win32/installer.nsi                \
251
             $(docs_DATA)
252

253
CLEANFILES = smartd.conf.5      \
254
255
256
257
258
259
260
             smartd.conf.4      \
             smartd.8           \
             smartd.1m          \
             smartd.8.html      \
             smartd.8.txt       \
             smartctl.8         \
             smartctl.1m        \
261
262
263
264
             smartctl.8.html    \
             smartctl.8.txt     \
             smartd.conf.5.html \
             smartd.conf.5.txt  \
265
266
             smartd.initd       \
             svnversion.h       \
267
             update-smart-drivedb \
268
269
             SMART

270
271
272
if SMARTD_SUFFIX
CLEANFILES += smartd.conf$(smartd_suffix)
endif
273

274
275
276
277
278
279
280
# 'make maintainer-clean' also removes files generated by './autogen.sh'
MAINTAINERCLEANFILES = \
        $(srcdir)/Makefile.in \
        $(srcdir)/aclocal.m4 \
        $(srcdir)/configure \
        $(srcdir)/config.guess \
        $(srcdir)/config.h.in \
281
        $(srcdir)/config.h.in~ \
282
283
284
285
286
287
        $(srcdir)/config.sub \
        $(srcdir)/depcomp \
        $(srcdir)/install-sh \
        $(srcdir)/missing \
        $(srcdir)/mkinstalldirs

288
utility.o: svnversion.h
289

290
291
292
293
if IS_SVN_BUILD
# Get version info from SVN
svnversion.h: CHANGELOG Makefile $(srcdir)/.svn/entries
	echo '/* svnversion.h.  Generated by Makefile from svn info.  */' > $@
294
295
	(cd $(srcdir) \
	 && svnversion 2>/dev/null | sed -n 's,^\([0-9].*\),REV  "\1",p' \
296
	 && TZ= LC_ALL=C svn info 2>/dev/null \
297
	 | sed -n 'h;s,^.* Date: *\([^ ]*\) .*$$,DATE "\1",p;g;s,^.* Date: *[^ ]* *\([^ ]*\) .*$$,TIME "\1",p') \
298
299
	| sed 's,^,#define SMARTMONTOOLS_SVN_,' >> $@
else
300

chrfranke's avatar
chrfranke committed
301
# SVN not available, guess version info from Id strings
302
303
svnversion.h: CHANGELOG Makefile
	echo '/* svnversion.h.  Generated by Makefile from Id strings.  */' > $@
304
	(cd $(srcdir) && cat CHANGELOG Makefile.am configure.in smart*.in *.cpp *.h *.s) \
305
306
	| sed -n 's,^.*\$$[I][d]: [^ ]* \([0-9][0-9]* [0-9][-0-9]* [0-9][:0-9]*\)[^:0-9][^$$]*\$$.*$$,\1,p' \
	| sort -n -r \
307
	| sed -n 'h;s,^\([^ ]*\) .*$$,REV  "\1",p;g;s,^[^ ]* \([^ ]*\) .*$$,DATE "\1",p;g;s,^[^ ]* [^ ]* \([^ ]*\)$$,TIME "\1",p;q' \
308
309
	| sed 's,^,#define SMARTMONTOOLS_SVN_,' >> $@
endif
310

311
312
313
314
315

if ENABLE_DRIVEDB
drivedb_DATA = drivedb.h
endif

316
317
318
319
if ENABLE_SAVESTATES
# Create $(savestatesdir) only
savestates_DATA =
endif
320

321
322
323
324
325
if ENABLE_ATTRIBUTELOG
# Create $(attributelogdir) only
attributelog_DATA =
endif

ballen4705's avatar
oops    
ballen4705 committed
326
smartd.conf.5.in: smartd.8.in
327
328
329
330
	sed '1,/STARTINCLUDE/ D;/ENDINCLUDE/,$$D' < $(srcdir)/smartd.8.in > $(top_builddir)/tmp.directives
	sed '/STARTINCLUDE/,$$D'  < $(srcdir)/smartd.conf.5.in > $(top_builddir)/tmp.head
	sed '1,/ENDINCLUDE/D'   < $(srcdir)/smartd.conf.5.in > $(top_builddir)/tmp.tail
	cat $(top_builddir)/tmp.head > $(srcdir)/smartd.conf.5.in
331
	echo '.\" STARTINCLUDE' >> $(srcdir)/smartd.conf.5.in
332
	cat $(top_builddir)/tmp.directives >> $(srcdir)/smartd.conf.5.in
333
	echo '.\" ENDINCLUDE'   >> $(srcdir)/smartd.conf.5.in
334
	cat $(top_builddir)/tmp.tail >> $(srcdir)/smartd.conf.5.in
335
336
	rm -f $(top_builddir)/tmp.head $(top_builddir)/tmp.tail $(top_builddir)/tmp.directives

337
338
update-smart-drivedb: update-smart-drivedb.in config.status
	$(SHELL) ./config.status --file=$@
339
	chmod +x $@
340
341


dlukes's avatar
   
dlukes committed
342
if INSTALL_INITSCRIPT
343
if OS_DARWIN
344
345
initd_DATA = SMART                            \
	os_darwin/StartupParameters.plist     \
346
347
348
349
350
	os_darwin/English_Localizable.strings

initd_install_name = SMART

initd_DATA_install = install-initdDATA-darwin
dlukes's avatar
   
dlukes committed
351
initd_DATA_uninstall = uninstall-initdDATA-darwin
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376

SMART : os_darwin/SMART.in
	sed "s|/usr/sbin/|$(sbindir)/|" $< > $@

install-initdDATA-darwin: $(initd_DATA)
	$(mkinstalldirs) $(DESTDIR)$(initddir)
	$(mkinstalldirs) $(DESTDIR)$(initddir)/SMART
	$(mkinstalldirs) $(DESTDIR)$(initddir)/SMART/Resources
	$(INSTALL_SCRIPT) $(top_builddir)/SMART $(DESTDIR)$(initddir)/SMART
	$(INSTALL_DATA) $(srcdir)/os_darwin/StartupParameters.plist \
	    $(DESTDIR)$(initddir)/SMART/StartupParameters.plist
	for i in English ; do \
	  RDIR=$(DESTDIR)$(initddir)/SMART/Resources/$${i}.lproj ; \
	  $(mkinstalldirs) $$RDIR ;\
	  $(INSTALL_DATA) $(srcdir)/os_darwin/$${i}_Localizable.strings \
	    $$RDIR/Localizable.strings ; \
	done
	@echo -e "\n\n####################################################################\n#"
	@echo -e "#                       PLEASE READ THIS BOX!\n#"
	@echo -e "#   To manually start the smartd daemon, run:\n#   ${initddir}/SMART/SMART start\n#"
	@echo -e "#   To automatically start smartd on bootup, add the line:\n#   SMARTd=-YES-\n#   to /etc/hostconfig\n#"
	@echo -e "#   smartd can now use a configuration file ${sysconfdir}/smartd.conf. Do:\n#   man smartd"
	@echo -e "#   to learn about it. A sample configuration file can be found in:\n#   ${docdir}\n#"
	@echo -e "####################################################################\n\n"

dlukes's avatar
   
dlukes committed
377
378
379
uninstall-initdDATA-darwin:
	rm -rf $(DESTDIR)$(initddir)/$(initd_install_name)

380
381
382
383
else

initd_DATA = smartd.initd

384
smartd.initd: $(srcdir)/smartd.initd.in Makefile
385
	sed "s|/usr/local/sbin/|$(sbindir)/|g" $(srcdir)/smartd.initd.in > $@
386

387
388
389
initd_install_name = smartd$(smartd_suffix)

initd_DATA_install = install-initdDATA-generic
dlukes's avatar
   
dlukes committed
390
initd_DATA_uninstall = uninstall-initdDATA-generic
391
392

install-initdDATA-generic: $(initd_DATA)
guidog's avatar
guidog committed
393
	$(mkinstalldirs) $(DESTDIR)$(initddir)
guidog's avatar
guidog committed
394
	$(INSTALL_SCRIPT) $(top_builddir)/smartd.initd $(DESTDIR)$(initddir)/smartd$(smartd_suffix)
395
396
397
398
	@echo -e "\n\n####################################################################\n#"
	@echo -e "#                       PLEASE READ THIS BOX!\n#"
	@echo -e "#   To manually start the smartd daemon, run:\n#   ${initddir}/smartd start\n#"
	@echo -e "#   To automatically start smartd on bootup, run:\n#   /sbin/chkconfig --add smartd\n#"
399
	@echo -e "#   smartd can now use a configuration file ${sysconfdir}/smartd.conf. Do:\n#   man smartd"
400
401
	@echo -e "#   to learn about it. A sample configuration file can be found in:\n#   ${docdir}\n#"
	@echo -e "####################################################################\n\n"
402

dlukes's avatar
   
dlukes committed
403
404
405
406
407
408
409
410
411
412
413

uninstall-initdDATA-generic:
	rm -rf $(DESTDIR)$(initddir)/$(initd_install_name)
endif
else

initd_DATA_install = install-initdDATA-null
initd_DATA_uninstall = uninstall-initdDATA-null

install-initdDATA-null:
uninstall-initdDATA-null:
414
415
416
417
endif

install-initdDATA : $(initd_DATA_install)

dlukes's avatar
   
dlukes committed
418
uninstall-initdDATA: $(initd_DATA_uninstall)
419

420
421
422
423
424
425
if ENABLE_CAPABILITIES
MAN_CAPABILITIES = cat
else
MAN_CAPABILITIES = sed '/BEGIN ENABLE_CAPABILITIES/,/END ENABLE_CAPABILITIES/d'
endif

426
427
428
429
430
431
if ENABLE_DRIVEDB
MAN_DRIVEDB = sed "s|/usr/local/share/smartmontools/drivedb\\.h|$(drivedbdir)/drivedb.h|g"
else
MAN_DRIVEDB = sed '/BEGIN ENABLE_DRIVEDB/,/END ENABLE_DRIVEDB/d'
endif

432
433
434
435
436
437
if ENABLE_SAVESTATES
MAN_SAVESTATES = sed "s|/usr/local/var/lib/smartmontools/smartd\\.|$(savestates)|g"
else
MAN_SAVESTATES = sed '/BEGIN ENABLE_SAVESTATES/,/END ENABLE_SAVESTATES/d'
endif

438
439
440
441
442
443
if ENABLE_ATTRIBUTELOG
MAN_ATTRIBUTELOG = sed "s|/usr/local/var/lib/smartmontools/attrlog\\.|$(attributelog)|g"
else
MAN_ATTRIBUTELOG = sed '/BEGIN ENABLE_ATTRIBUTELOG/,/END ENABLE_ATTRIBUTELOG/d'
endif

444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
MAN_FILTER = \
    sed "s|CURRENT_CVS_VERSION|$(releaseversion)|g; \
         s|CURRENT_CVS_DATE|`sed -n 's,^.*DATE[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g; \
         s|CURRENT_CVS_TIME|`sed -n 's,^.*TIME[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g; \
         s|/usr/local/share/man/|$(mandir)/|g; \
         s|/usr/local/sbin/|$(sbindir)/|g; \
         s|/usr/local/etc/rc\\.d/init.d/|$(initddir)/|g; \
         s|/usr/local/share/doc/smartmontools-5.1/|$(docsdir)/|g;  \
         s|/usr/local/etc/smartd\\.conf|$(sysconfdir)/smartd.conf|g; \
         s|/usr/local/etc/smart_drivedb\\.h|$(sysconfdir)/smart_drivedb\\.h|g" | \
    $(MAN_CAPABILITIES) | \
    $(MAN_DRIVEDB) | \
    $(MAN_SAVESTATES) | \
    $(MAN_ATTRIBUTELOG)

459
460
461
462
463
464
465
466
467
# Implicit rule 'smart%: smart%.in ...' does not work with BSD make
smartctl.8: smartctl.8.in Makefile svnversion.h
	cat $(srcdir)/smartctl.8.in | $(MAN_FILTER) > $@

smartd.8: smartd.8.in Makefile svnversion.h
	cat $(srcdir)/smartd.8.in | $(MAN_FILTER) > $@

smartd.conf.5: smartd.conf.5.in Makefile svnversion.h
	cat $(srcdir)/smartd.conf.5.in | $(MAN_FILTER) > $@
468
469
470
471
472
473
474

# Commands to convert man pages into .html and .txt
# TODO: configure
MAN2HTML = man2html
#MAN2HTML = groff -man -Thtml
MAN2TXT = groff -man -Tascii -P'-bcou'

475
476
477
# Remove HTTP header and fix links in man2html output
FIXHTML = sed '1s,^Content-type.*,,' \
        | sed 's,<A HREF="http://[-a-z/]*/man2html?\([1-8]\)+\(smart[cd][.a-z]*\)">,<A HREF="\2.\1.html">,g' \
478
479
480
        | sed 's,<A HREF="http://[-a-z/]*/man2html">,<A HREF=".">,g' \
        | sed 's,<A HREF="http://[-a-z/]*/man2html?[^"]*">\([^<]*\)</A>,\1,g' \
        | sed 's,<A HREF="mailto:[^s][^m][^a][^"]*">\([^<]*\)</A>,\1,g'
481
482
483
484
485
486
487

# Convert man pages into .html and .txt

htmlman: smartctl.8.html smartd.8.html smartd.conf.5.html

txtman:  smartctl.8.txt smartd.8.txt smartd.conf.5.txt

488
489
490
491
492
493
494
495
496
if OS_WIN32_MINGW

%.5.html: %.5
	$(DOS2UNIX) < $< | $(MAN2HTML) | $(FIXHTML) > $@

%.8.html: %.8
	$(DOS2UNIX) < $< | $(MAN2HTML) | $(FIXHTML) > $@
else

497
498
499
500
501
%.5.html: %.5
	$(MAN2HTML) $< | $(FIXHTML) > $@

%.8.html: %.8
	$(MAN2HTML) $< | $(FIXHTML) > $@
502
endif
503
504
505
506
507
508
509
510

%.5.txt: %.5
	$(MAN2TXT) $< > $@

%.8.txt: %.8
	$(MAN2TXT) $< > $@


511
512
513
514
515
516
517
518
# Check drive database syntax
check:
	@if ./smartctl -B $(srcdir)/drivedb.h -P showall >/dev/null; then \
	  echo "$(srcdir)/drivedb.h: OK"; \
	else \
	  echo "$(srcdir)/drivedb.h: Syntax check failed"; exit 1; \
	fi

519
520
521
522
523
524

if OS_WIN32_MINGW
# Definitions for Windows distribution

distdir_win32 = $(PACKAGE)-$(VERSION).win32
distzip_win32 = $(PACKAGE)-$(VERSION).win32.zip
525
distinst_win32= $(PACKAGE)-$(VERSION).win32-setup.exe
526
527
528
529
530

exedir_win32 = $(distdir_win32)/bin
docdir_win32 = $(distdir_win32)/doc

FILES_WIN32 = $(exedir_win32)/smartctl.exe \
531
              $(exedir_win32)/smartctl-nc.exe \
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
              $(exedir_win32)/smartd.exe \
              $(docdir_win32)/AUTHORS.txt \
              $(docdir_win32)/CHANGELOG.txt \
              $(docdir_win32)/COPYING.txt \
              $(docdir_win32)/INSTALL.txt \
              $(docdir_win32)/NEWS.txt \
              $(docdir_win32)/README.txt \
              $(docdir_win32)/TODO.txt \
              $(docdir_win32)/WARNINGS.txt \
              $(docdir_win32)/smartd.conf \
              $(docdir_win32)/smartctl.8.html \
              $(docdir_win32)/smartctl.8.txt \
              $(docdir_win32)/smartd.8.html \
              $(docdir_win32)/smartd.8.txt \
              $(docdir_win32)/smartd.conf.5.html \
              $(docdir_win32)/smartd.conf.5.txt

549
550
551
CLEANFILES += $(FILES_WIN32) $(exedir_win32)/syslogevt.exe \
              smartctl-nc.exe smartctl-nc.exe.tmp \
              distdir.mkdir syslogevt.check
552

553
554
555
556
# Textfile converter from package cygutils or tofrodos
# Note: Only use without options to be compatible with both packages
UNIX2DOS = unix2dos
DOS2UNIX = dos2unix
557
558
559
560
561

# Build Windows distribution

dist-win32: $(distzip_win32)

562
563
564
565
566
install-win32: $(distinst_win32)
	./$(distinst_win32)

installer-win32: $(distinst_win32)

567
568
569
570
571
572
distdir-win32: distdir.mkdir $(FILES_WIN32) syslogevt.check

$(distzip_win32): distdir.mkdir $(FILES_WIN32) syslogevt.check
	@rm -fv $(distzip_win32)
	cd $(distdir_win32) && zip -9Dr ../$(distzip_win32) .

573
# Build NSIS installer, try to locate makensis in default location first
574
# Note: Only option character '-' is also compatible with Linux version of makensis
575
576
$(distinst_win32): $(srcdir)/os_win32/installer.nsi distdir.mkdir $(FILES_WIN32) syslogevt.check
	@makensis="$(MAKENSIS)"; if [ -z "$$makensis" ]; then \
577
	  if [ ! -z "$$PROGRAMFILES" ] && "$$PROGRAMFILES/NSIS/makensis" -VERSION >/dev/null 2>&1; then \
578
	    makensis="$$PROGRAMFILES/NSIS/makensis"; \
579
	  elif makensis -VERSION >/dev/null 2>&1; then \
580
581
582
583
584
585
	    makensis=makensis; \
	  else \
	    echo 'makensis: command not found. Please download and install NSIS' 1>&2; \
	    echo 'from http://nsis.sourceforge.net/Download' 1>&2; exit 1; \
	  fi; \
	fi; \
586
587
588
	date=`sed -n 's,^.*DATE[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`; \
	rev=`sed -n 's,^.*REV[^"]*"\([^"]*\)".*$$,r\1,p' svnversion.h`; \
	verstr="$(PACKAGE_VERSION) $$date $$rev "$(BUILD_INFO); \
589
590
	echo "$$makensis -V2 -NOCD -DINPDIR=$(distdir_win32) -DOUTFILE=$(distinst_win32) -DVERSTR='$$verstr' $(srcdir)/os_win32/installer.nsi"; \
	"$$makensis" -V2 -NOCD -DINPDIR="$(distdir_win32)" -DOUTFILE="$(distinst_win32)" -DVERSTR="$$verstr" "$(srcdir)/os_win32/installer.nsi"
591

592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
cleandist-win32:
	rm -rf $(distdir_win32) distdir.mkdir syslogevt.check

distdir.mkdir:
	@test -d $(exedir_win32) || mkdir -pv $(exedir_win32)
	@test -d $(docdir_win32) || mkdir -pv $(docdir_win32)
	touch $@

syslogevt.check:
	@if [ -f $(srcdir)/os_win32/syslogevt.exe ]; then \
	  cp -pv $(srcdir)/os_win32/syslogevt.exe $(exedir_win32)/syslogevt.exe; \
	 else echo "Warning: $(srcdir)/os_win32/syslogevt.exe missing."; fi
	touch $@

$(exedir_win32)/%.exe: %.exe
	cp -p $< $@
608
609
	strip -s $@
	touch -r $< $@
610

611
612
613
614
615
$(docdir_win32)/%.html: %.html
	$(UNIX2DOS) < $< > $@
	touch -r $< $@

$(docdir_win32)/%.txt: %.txt
616
617
618
	$(UNIX2DOS) < $< > $@
	touch -r $< $@

619
$(docdir_win32)/%.txt: $(srcdir)/%
620
621
622
	$(UNIX2DOS) < $< > $@
	touch -r $< $@

623
$(docdir_win32)/%.conf: $(srcdir)/%.conf
624
625
626
	$(UNIX2DOS) < $< > $@
	touch -r $< $@

627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
# Build non-console version of smartctl for GSmartControl.
# The script below changes the word at offset 220 (Subsystem) from 3
# (Console) to 2 (GUI) in a copy of smartctl.exe.
# This will be changed when a tool (like 'editbin') is available in
# the Cygwin distribution
smartctl-nc.exe: smartctl.exe
	@rm -f $@
	cp -p smartctl.exe $@.tmp
	@if test `od -A n -j 220 -N 2 -d $@.tmp` -eq 3; then :; \
	  else echo "invalid EXE header"; exit 1; fi
	@echo "editbin /subsystem:windows $@.tmp"
	@echo -ne '\002' | dd bs=1 seek=220 count=1 conv=notrunc of=$@.tmp 2>/dev/null
	@if test `od -A n -j 220 -N 2 -d $@.tmp` -eq 2; then :; \
	  else echo "EXE patch failed"; exit 1; fi
	mv -f $@.tmp $@

643

644
# Build {config,svnversion}_vc8.h for MSVC8 from MinGW {config,svnversion}.h
645

646
config-vc8: $(srcdir)/os_win32/config_vc8.h  $(srcdir)/os_win32/svnversion_vc8.h
647

648
649
650
651
652
$(srcdir)/os_win32/config_vc8.h: config.h
	sed '1i/* config_vc8.h.  Generated from config.h by Makefile.  */' $< | \
	sed 's,^#define HAVE_\(ATTR_PACKED\|INTTYPES_H\|STDINT_H\|STRINGS_H\|STRTOULL\|U*INT64_T\|UNISTD_H\|WORKING_SNPRINTF\) 1$$,/* #undef HAVE_\1 */,' | \
	sed 's,i.86-pc-mingw32,i686-pc-win32vc8,' > $@

653
654
$(srcdir)/os_win32/svnversion_vc8.h: svnversion.h
	cp svnversion.h $@
655
656
657

endif

658
SUBDIRS= . examplescripts