]> git.proxmox.com Git - mirror_smartmontools-debian.git/blame - Makefile.am
Imported Upstream version 5.39.1+svn3077
[mirror_smartmontools-debian.git] / Makefile.am
CommitLineData
832b75ed
GG
1## Process this file with automake to produce Makefile.in
2#
7f0798ef 3# $Id: Makefile.am 3074 2010-03-05 23:00:30Z chrfranke $
832b75ed
GG
4#
5
6@SET_MAKE@
7
4d59bff9
GG
8# Make sure .cpp takes precedence to avoid compiling old .c file
9SUFFIXES = .cpp .c .s .o
10
2127e193
GI
11# BUILD_INFO can be provided by package maintainers (see INSTALL file)
12BUILD_INFO= "(local build)"
4d59bff9 13
2127e193
GI
14AM_CPPFLAGS = -DBUILD_INFO='$(BUILD_INFO)' -DSMARTMONTOOLS_SYSCONFDIR='"$(sysconfdir)"'
15if ENABLE_DRIVEDB
16AM_CPPFLAGS += -DSMARTMONTOOLS_DRIVEDBDIR='"$(drivedbdir)"'
17endif
18if ENABLE_SAVESTATES
19AM_CPPFLAGS += -DSMARTMONTOOLS_SAVESTATES='"$(savestates)"'
20endif
21if ENABLE_ATTRIBUTELOG
22AM_CPPFLAGS += -DSMARTMONTOOLS_ATTRIBUTELOG='"$(attributelog)"'
23endif
832b75ed
GG
24
25sbin_PROGRAMS = smartd \
26 smartctl
27
7f0798ef
GI
28if ENABLE_DRIVEDB
29sbin_SCRIPTS = update-smart-drivedb
30endif
31
32
4d59bff9 33smartd_SOURCES = smartd.cpp \
4d59bff9
GG
34 atacmdnames.cpp \
35 atacmdnames.h \
36 atacmds.cpp \
37 atacmds.h \
2127e193
GI
38 dev_ata_cmd_set.cpp \
39 dev_ata_cmd_set.h \
40 dev_interface.cpp \
41 dev_interface.h \
42 dev_tunnelled.h \
a23d5117 43 drivedb.h \
4d59bff9
GG
44 extern.h \
45 int64.h \
46 knowndrives.cpp \
47 knowndrives.h \
48 scsicmds.cpp \
49 scsicmds.h \
50 scsiata.cpp \
4d59bff9 51 utility.cpp \
832b75ed
GG
52 utility.h
53
a23d5117 54smartd_LDADD = @os_deps@ @os_libs@ @CAPNG_LDADD@
832b75ed 55smartd_DEPENDENCIES = @os_deps@
4d59bff9
GG
56
57EXTRA_smartd_SOURCES = os_darwin.cpp \
58 os_darwin.h \
59 os_linux.cpp \
832b75ed 60 os_linux.h \
4d59bff9
GG
61 os_freebsd.cpp \
62 os_freebsd.h \
63 os_netbsd.cpp \
64 os_netbsd.h \
65 os_openbsd.cpp \
66 os_openbsd.h \
67 os_solaris.cpp \
68 os_solaris.h \
69 os_solaris_ata.s \
70 os_win32.cpp \
71 os_generic.cpp \
a37e7145
GG
72 os_generic.h \
73 cciss.cpp \
2127e193
GI
74 cciss.h \
75 dev_legacy.cpp \
76 megaraid.h
832b75ed
GG
77
78
79if OS_WIN32_MINGW
80
4d59bff9
GG
81smartd_SOURCES += \
82 posix/regex.h \
83 posix/regex.c \
84 os_win32/daemon_win32.h \
85 os_win32/daemon_win32.cpp \
86 os_win32/hostname_win32.h \
87 os_win32/hostname_win32.cpp \
88 os_win32/syslog.h \
89 os_win32/syslog_win32.cpp
832b75ed
GG
90
91# Included by regex.c:
92EXTRA_smartd_SOURCES += \
93 posix/regcomp.c \
94 posix/regexec.c \
95 posix/regex_internal.c \
96 posix/regex_internal.h
97
98endif
99
4d59bff9
GG
100smartctl_SOURCES= smartctl.cpp \
101 smartctl.h \
102 atacmdnames.cpp \
103 atacmdnames.h \
104 atacmds.cpp \
105 atacmds.h \
106 ataprint.cpp \
107 ataprint.h \
2127e193
GI
108 dev_ata_cmd_set.cpp \
109 dev_ata_cmd_set.h \
110 dev_interface.cpp \
111 dev_interface.h \
112 dev_tunnelled.h \
a23d5117 113 drivedb.h \
4d59bff9
GG
114 extern.h \
115 int64.h \
116 knowndrives.cpp \
117 knowndrives.h \
118 scsicmds.cpp \
119 scsicmds.h \
120 scsiata.cpp \
4d59bff9
GG
121 scsiprint.cpp \
122 scsiprint.h \
123 utility.cpp \
832b75ed
GG
124 utility.h
125
2127e193 126
832b75ed
GG
127smartctl_LDADD = @os_deps@ @os_libs@
128smartctl_DEPENDENCIES = @os_deps@
4d59bff9
GG
129
130EXTRA_smartctl_SOURCES = os_linux.cpp \
131 os_linux.h \
132 os_freebsd.cpp \
133 os_freebsd.h \
134 os_netbsd.cpp \
135 os_netbsd.h \
136 os_openbsd.cpp \
137 os_openbsd.h \
138 os_solaris.cpp \
139 os_solaris.h \
140 os_win32.cpp \
141 os_generic.cpp \
a37e7145
GG
142 os_generic.h \
143 cciss.cpp \
2127e193
GI
144 cciss.h \
145 dev_legacy.cpp \
146 megaraid.h
832b75ed
GG
147
148if OS_WIN32_MINGW
149
150smartctl_SOURCES += \
151 posix/regex.h \
152 posix/regex.c \
153 os_win32/syslog.h
154
155# Included by regex.c:
156EXTRA_smartctl_SOURCES += \
157 posix/regcomp.c \
158 posix/regexec.c \
159 posix/regex_internal.c \
160 posix/regex_internal.h
161
162endif
163
164if OS_SOLARIS
165# This block is required because Solaris uses manual page section 1m
166# for administrative command (linux/freebsd use section 8) and Solaris
167# uses manual page section 4 for file formats (linux/freebsd use
168# section 5). Automake can deal cleanly with man page sections 1-8
169# and n, but NOT with sections of the form 1m.
170extra_MANS = smartd.conf.4 \
171 smartctl.1m \
172 smartd.1m
173install-man: $(extra_MANS)
174 @$(NORMAL_INSTALL)
175 $(mkinstalldirs) $(DESTDIR)$(mandir)/man4
176 $(mkinstalldirs) $(DESTDIR)$(mandir)/man1m
177 for i in $(extra_MANS); do \
178 if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
179 else file=$$i; fi; \
180 ext=`echo $$i | sed -e 's/^.*\\.//'`; \
181 inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
182 inst=`echo $$inst | sed -e 's/^.*\///'`; \
183 inst=`echo $$inst | sed '$(transform)'`.$$ext; \
184 echo " $(INSTALL_DATA) $$file $(DESTDIR)$(mandir)/man$$ext/$$inst"; \
185 $(INSTALL_DATA) $$file $(DESTDIR)$(mandir)/man$$ext/$$inst; \
186 done
187uninstall-man:
188 @$(NORMAL_UNINSTALL)
189 for i in $(extra_MANS); do \
190 if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
191 else file=$$i; fi; \
192 ext=`echo $$i | sed -e 's/^.*\\.//'`; \
193 inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
194 inst=`echo $$inst | sed -e 's/^.*\///'`; \
195 inst=`echo $$inst | sed '$(transform)'`.$$ext; \
196 echo " rm -f $(DESTDIR)$(mandir)/man$$ext/$$inst"; \
197 rm -f $(DESTDIR)$(mandir)/man$$ext/$$inst; \
198 done
199%.1m: %.8
200 awk '/^.TH/ {$$3="1m"} {print}' < $< | \
201 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 -e 's/smartd\(.*\)(8)/smartd\1(1m)/g' > $@
207%.4: %.5
208 awk '/^.TH/ {$$3="4"} {print}' < $< | \
209 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 -e 's/smartd\(.*\)(8)/smartd\1(1m)/g' > $@
215else
216# For systems that adopts traditional manner
217man_MANS = smartd.conf.5 \
218 smartctl.8 \
219 smartd.8
220endif
221
222docsdir=$(docdir)
223docs_DATA = AUTHORS \
224 CHANGELOG \
225 COPYING \
226 INSTALL \
227 NEWS \
228 README \
229 TODO \
230 WARNINGS \
231 smartd.conf
232
233sysconf_DATA = smartd.conf$(smartd_suffix)
234
235if SMARTD_SUFFIX
236smartd.conf$(smartd_suffix): smartd.conf
237 cp ${srcdir}/smartd.conf smartd.conf$(smartd_suffix)
238endif
239
2127e193 240EXTRA_DIST = smartd.initd.in \
832b75ed
GG
241 smartd.8.in \
242 smartctl.8.in \
243 smartd.conf.5.in \
244 smartd.conf \
245 autogen.sh \
7f0798ef 246 update-smart-drivedb.in \
832b75ed
GG
247 os_darwin/SMART.in \
248 os_darwin/StartupParameters.plist \
249 os_darwin/English_Localizable.strings \
4d59bff9 250 os_win32/installer.nsi \
832b75ed
GG
251 $(docs_DATA)
252
a23d5117 253CLEANFILES = smartd.conf.5 \
832b75ed
GG
254 smartd.conf.4 \
255 smartd.8 \
256 smartd.1m \
257 smartd.8.html \
258 smartd.8.txt \
259 smartctl.8 \
260 smartctl.1m \
261 smartctl.8.html \
262 smartctl.8.txt \
263 smartd.conf.5.html \
264 smartd.conf.5.txt \
2127e193
GI
265 smartd.initd \
266 svnversion.h \
7f0798ef 267 update-smart-drivedb \
832b75ed
GG
268 SMART
269
270if SMARTD_SUFFIX
271CLEANFILES += smartd.conf$(smartd_suffix)
272endif
273
2127e193
GI
274# 'make maintainer-clean' also removes files generated by './autogen.sh'
275MAINTAINERCLEANFILES = \
276 $(srcdir)/Makefile.in \
277 $(srcdir)/aclocal.m4 \
278 $(srcdir)/configure \
279 $(srcdir)/config.guess \
280 $(srcdir)/config.h.in \
281 $(srcdir)/config.h.in~ \
282 $(srcdir)/config.sub \
283 $(srcdir)/depcomp \
284 $(srcdir)/install-sh \
285 $(srcdir)/missing \
286 $(srcdir)/mkinstalldirs
287
288utility.o: svnversion.h
289
290if IS_SVN_BUILD
291# Get version info from SVN
292svnversion.h: CHANGELOG Makefile $(srcdir)/.svn/entries
293 echo '/* svnversion.h. Generated by Makefile from svn info. */' > $@
294 (cd $(srcdir) \
295 && 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 | sed 's,^,#define SMARTMONTOOLS_SVN_,' >> $@
299else
300
301# SVN not available, guess version info from Id strings
302svnversion.h: CHANGELOG Makefile
303 echo '/* svnversion.h. Generated by Makefile from Id strings. */' > $@
304 (cd $(srcdir) && cat CHANGELOG Makefile.am configure.in smart*.in *.cpp *.h *.s) \
305 | sed -n 's,^.*\$$[I][d]: [^ ]* \([0-9][0-9]* [0-9][-0-9]* [0-9][:0-9]*\)[^:0-9][^$$]*\$$.*$$,\1,p' \
306 | sort -n -r \
307 | sed -n 'h;s,^\([^ ]*\) .*$$,REV "\1",p;g;s,^[^ ]* \([^ ]*\) .*$$,DATE "\1",p;g;s,^[^ ]* [^ ]* \([^ ]*\)$$,TIME "\1",p;q' \
308 | sed 's,^,#define SMARTMONTOOLS_SVN_,' >> $@
309endif
310
311
2127e193
GI
312if ENABLE_DRIVEDB
313drivedb_DATA = drivedb.h
314endif
315
316if ENABLE_SAVESTATES
317# Create $(savestatesdir) only
318savestates_DATA =
319endif
320
321if ENABLE_ATTRIBUTELOG
322# Create $(attributelogdir) only
323attributelog_DATA =
324endif
832b75ed
GG
325
326smartd.conf.5.in: smartd.8.in
327 sed '1,/STARTINCLUDE/ D;/ENDINCLUDE/,$$D' < $(srcdir)/smartd.8.in > $(top_builddir)/tmp.directives
328 sed '/STARTINCLUDE/,$$D' < $(srcdir)/smartd.conf.5.in > $(top_builddir)/tmp.head
329 sed '1,/ENDINCLUDE/D' < $(srcdir)/smartd.conf.5.in > $(top_builddir)/tmp.tail
330 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 rm -f $(top_builddir)/tmp.head $(top_builddir)/tmp.tail $(top_builddir)/tmp.directives
336
7f0798ef
GI
337update-smart-drivedb: update-smart-drivedb.in config.status
338 $(SHELL) ./config.status --file=$@
339 chmod +x $@
340
341
2127e193 342if INSTALL_INITSCRIPT
832b75ed
GG
343if OS_DARWIN
344initd_DATA = SMART \
345 os_darwin/StartupParameters.plist \
346 os_darwin/English_Localizable.strings
347
348initd_install_name = SMART
349
350initd_DATA_install = install-initdDATA-darwin
2127e193 351initd_DATA_uninstall = uninstall-initdDATA-darwin
832b75ed
GG
352
353SMART : os_darwin/SMART.in
354 sed "s|/usr/sbin/|$(sbindir)/|" $< > $@
355
356install-initdDATA-darwin: $(initd_DATA)
357 $(mkinstalldirs) $(DESTDIR)$(initddir)
358 $(mkinstalldirs) $(DESTDIR)$(initddir)/SMART
359 $(mkinstalldirs) $(DESTDIR)$(initddir)/SMART/Resources
360 $(INSTALL_SCRIPT) $(top_builddir)/SMART $(DESTDIR)$(initddir)/SMART
361 $(INSTALL_DATA) $(srcdir)/os_darwin/StartupParameters.plist \
362 $(DESTDIR)$(initddir)/SMART/StartupParameters.plist
363 for i in English ; do \
364 RDIR=$(DESTDIR)$(initddir)/SMART/Resources/$${i}.lproj ; \
365 $(mkinstalldirs) $$RDIR ;\
366 $(INSTALL_DATA) $(srcdir)/os_darwin/$${i}_Localizable.strings \
367 $$RDIR/Localizable.strings ; \
368 done
369 @echo -e "\n\n####################################################################\n#"
370 @echo -e "# PLEASE READ THIS BOX!\n#"
371 @echo -e "# To manually start the smartd daemon, run:\n# ${initddir}/SMART/SMART start\n#"
372 @echo -e "# To automatically start smartd on bootup, add the line:\n# SMARTd=-YES-\n# to /etc/hostconfig\n#"
373 @echo -e "# smartd can now use a configuration file ${sysconfdir}/smartd.conf. Do:\n# man smartd"
374 @echo -e "# to learn about it. A sample configuration file can be found in:\n# ${docdir}\n#"
375 @echo -e "####################################################################\n\n"
376
2127e193
GI
377uninstall-initdDATA-darwin:
378 rm -rf $(DESTDIR)$(initddir)/$(initd_install_name)
379
832b75ed
GG
380else
381
382initd_DATA = smartd.initd
383
384smartd.initd: $(srcdir)/smartd.initd.in Makefile
385 sed "s|/usr/local/sbin/|$(sbindir)/|g" $(srcdir)/smartd.initd.in > $@
386
387initd_install_name = smartd$(smartd_suffix)
388
389initd_DATA_install = install-initdDATA-generic
2127e193 390initd_DATA_uninstall = uninstall-initdDATA-generic
832b75ed
GG
391
392install-initdDATA-generic: $(initd_DATA)
393 $(mkinstalldirs) $(DESTDIR)$(initddir)
394 $(INSTALL_SCRIPT) $(top_builddir)/smartd.initd $(DESTDIR)$(initddir)/smartd$(smartd_suffix)
395 @echo -e "\n\n####################################################################\n#"
396 @echo -e "# PLEASE READ THIS BOX!\n#"
397 @echo -e "# To manually start the smartd daemon, run:\n# ${initddir}/smartd start\n#"
398 @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 @echo -e "# to learn about it. A sample configuration file can be found in:\n# ${docdir}\n#"
401 @echo -e "####################################################################\n\n"
402
2127e193
GI
403
404uninstall-initdDATA-generic:
405 rm -rf $(DESTDIR)$(initddir)/$(initd_install_name)
406endif
407else
408
409initd_DATA_install = install-initdDATA-null
410initd_DATA_uninstall = uninstall-initdDATA-null
411
412install-initdDATA-null:
413uninstall-initdDATA-null:
832b75ed
GG
414endif
415
416install-initdDATA : $(initd_DATA_install)
417
2127e193 418uninstall-initdDATA: $(initd_DATA_uninstall)
832b75ed 419
a23d5117
GI
420if ENABLE_CAPABILITIES
421MAN_CAPABILITIES = cat
422else
423MAN_CAPABILITIES = sed '/BEGIN ENABLE_CAPABILITIES/,/END ENABLE_CAPABILITIES/d'
424endif
425
2127e193
GI
426if ENABLE_DRIVEDB
427MAN_DRIVEDB = sed "s|/usr/local/share/smartmontools/drivedb\\.h|$(drivedbdir)/drivedb.h|g"
428else
429MAN_DRIVEDB = sed '/BEGIN ENABLE_DRIVEDB/,/END ENABLE_DRIVEDB/d'
430endif
832b75ed 431
2127e193
GI
432if ENABLE_SAVESTATES
433MAN_SAVESTATES = sed "s|/usr/local/var/lib/smartmontools/smartd\\.|$(savestates)|g"
434else
435MAN_SAVESTATES = sed '/BEGIN ENABLE_SAVESTATES/,/END ENABLE_SAVESTATES/d'
436endif
437
438if ENABLE_ATTRIBUTELOG
439MAN_ATTRIBUTELOG = sed "s|/usr/local/var/lib/smartmontools/attrlog\\.|$(attributelog)|g"
440else
441MAN_ATTRIBUTELOG = sed '/BEGIN ENABLE_ATTRIBUTELOG/,/END ENABLE_ATTRIBUTELOG/d'
442endif
443
a23d5117
GI
444MAN_FILTER = \
445 sed "s|CURRENT_CVS_VERSION|$(releaseversion)|g; \
446 s|CURRENT_CVS_DATE|`sed -n 's,^.*DATE[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g; \
447 s|CURRENT_CVS_TIME|`sed -n 's,^.*TIME[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g; \
448 s|/usr/local/share/man/|$(mandir)/|g; \
449 s|/usr/local/sbin/|$(sbindir)/|g; \
450 s|/usr/local/etc/rc\\.d/init.d/|$(initddir)/|g; \
451 s|/usr/local/share/doc/smartmontools-5.1/|$(docsdir)/|g; \
452 s|/usr/local/etc/smartd\\.conf|$(sysconfdir)/smartd.conf|g; \
453 s|/usr/local/etc/smart_drivedb\\.h|$(sysconfdir)/smart_drivedb\\.h|g" | \
454 $(MAN_CAPABILITIES) | \
455 $(MAN_DRIVEDB) | \
456 $(MAN_SAVESTATES) | \
457 $(MAN_ATTRIBUTELOG)
458
7f0798ef
GI
459# Implicit rule 'smart%: smart%.in ...' does not work with BSD make
460smartctl.8: smartctl.8.in Makefile svnversion.h
461 cat $(srcdir)/smartctl.8.in | $(MAN_FILTER) > $@
462
463smartd.8: smartd.8.in Makefile svnversion.h
464 cat $(srcdir)/smartd.8.in | $(MAN_FILTER) > $@
465
466smartd.conf.5: smartd.conf.5.in Makefile svnversion.h
467 cat $(srcdir)/smartd.conf.5.in | $(MAN_FILTER) > $@
832b75ed
GG
468
469# Commands to convert man pages into .html and .txt
470# TODO: configure
471MAN2HTML = man2html
472#MAN2HTML = groff -man -Thtml
473MAN2TXT = groff -man -Tascii -P'-bcou'
474
4d59bff9
GG
475# Remove HTTP header and fix links in man2html output
476FIXHTML = sed '1s,^Content-type.*,,' \
477 | sed 's,<A HREF="http://[-a-z/]*/man2html?\([1-8]\)+\(smart[cd][.a-z]*\)">,<A HREF="\2.\1.html">,g' \
832b75ed
GG
478 | sed 's,<A HREF="http://[-a-z/]*/man2html">,<A HREF=".">,g' \
479 | sed 's,<A HREF="http://[-a-z/]*/man2html?[^"]*">\([^<]*\)</A>,\1,g' \
480 | sed 's,<A HREF="mailto:[^s][^m][^a][^"]*">\([^<]*\)</A>,\1,g'
481
482# Convert man pages into .html and .txt
483
484htmlman: smartctl.8.html smartd.8.html smartd.conf.5.html
485
486txtman: smartctl.8.txt smartd.8.txt smartd.conf.5.txt
487
4d59bff9
GG
488if OS_WIN32_MINGW
489
490%.5.html: %.5
491 $(DOS2UNIX) < $< | $(MAN2HTML) | $(FIXHTML) > $@
492
493%.8.html: %.8
494 $(DOS2UNIX) < $< | $(MAN2HTML) | $(FIXHTML) > $@
495else
496
832b75ed
GG
497%.5.html: %.5
498 $(MAN2HTML) $< | $(FIXHTML) > $@
499
500%.8.html: %.8
501 $(MAN2HTML) $< | $(FIXHTML) > $@
4d59bff9 502endif
832b75ed
GG
503
504%.5.txt: %.5
505 $(MAN2TXT) $< > $@
506
507%.8.txt: %.8
508 $(MAN2TXT) $< > $@
509
510
a23d5117
GI
511# Check drive database syntax
512check:
513 @if ./smartctl -B $(srcdir)/drivedb.h -P showall >/dev/null; then \
514 echo "$(srcdir)/drivedb.h: OK"; \
515 else \
516 echo "$(srcdir)/drivedb.h: Syntax check failed"; exit 1; \
517 fi
518
832b75ed
GG
519
520if OS_WIN32_MINGW
521# Definitions for Windows distribution
522
7f0798ef
GI
523if OS_WIN64
524win_bits = 64
525else
526win_bits = 32
527endif
528
529distdir_win32 = $(PACKAGE)-$(VERSION).win$(win_bits)
530distzip_win32 = $(PACKAGE)-$(VERSION).win$(win_bits).zip
531distinst_win32 = $(PACKAGE)-$(VERSION).win$(win_bits)-setup.exe
832b75ed
GG
532
533exedir_win32 = $(distdir_win32)/bin
534docdir_win32 = $(distdir_win32)/doc
535
536FILES_WIN32 = $(exedir_win32)/smartctl.exe \
2127e193 537 $(exedir_win32)/smartctl-nc.exe \
832b75ed
GG
538 $(exedir_win32)/smartd.exe \
539 $(docdir_win32)/AUTHORS.txt \
540 $(docdir_win32)/CHANGELOG.txt \
541 $(docdir_win32)/COPYING.txt \
542 $(docdir_win32)/INSTALL.txt \
543 $(docdir_win32)/NEWS.txt \
544 $(docdir_win32)/README.txt \
545 $(docdir_win32)/TODO.txt \
546 $(docdir_win32)/WARNINGS.txt \
547 $(docdir_win32)/smartd.conf \
548 $(docdir_win32)/smartctl.8.html \
549 $(docdir_win32)/smartctl.8.txt \
550 $(docdir_win32)/smartd.8.html \
551 $(docdir_win32)/smartd.8.txt \
552 $(docdir_win32)/smartd.conf.5.html \
553 $(docdir_win32)/smartd.conf.5.txt
554
2127e193
GI
555CLEANFILES += $(FILES_WIN32) $(exedir_win32)/syslogevt.exe \
556 smartctl-nc.exe smartctl-nc.exe.tmp \
557 distdir.mkdir syslogevt.check
832b75ed 558
7f0798ef
GI
559# Textfile converter from package cygutils or tofrodos
560# Note: Only use without options to be compatible with both packages
561UNIX2DOS = unix2dos
562DOS2UNIX = dos2unix
832b75ed
GG
563
564# Build Windows distribution
565
566dist-win32: $(distzip_win32)
567
4d59bff9
GG
568install-win32: $(distinst_win32)
569 ./$(distinst_win32)
570
571installer-win32: $(distinst_win32)
572
832b75ed
GG
573distdir-win32: distdir.mkdir $(FILES_WIN32) syslogevt.check
574
575$(distzip_win32): distdir.mkdir $(FILES_WIN32) syslogevt.check
576 @rm -fv $(distzip_win32)
577 cd $(distdir_win32) && zip -9Dr ../$(distzip_win32) .
578
4d59bff9 579# Build NSIS installer, try to locate makensis in default location first
7f0798ef 580# Note: Only option character '-' is also compatible with Linux version of makensis
4d59bff9
GG
581$(distinst_win32): $(srcdir)/os_win32/installer.nsi distdir.mkdir $(FILES_WIN32) syslogevt.check
582 @makensis="$(MAKENSIS)"; if [ -z "$$makensis" ]; then \
7f0798ef 583 if [ ! -z "$$PROGRAMFILES" ] && "$$PROGRAMFILES/NSIS/makensis" -VERSION >/dev/null 2>&1; then \
4d59bff9 584 makensis="$$PROGRAMFILES/NSIS/makensis"; \
7f0798ef 585 elif makensis -VERSION >/dev/null 2>&1; then \
4d59bff9
GG
586 makensis=makensis; \
587 else \
588 echo 'makensis: command not found. Please download and install NSIS' 1>&2; \
589 echo 'from http://nsis.sourceforge.net/Download' 1>&2; exit 1; \
590 fi; \
591 fi; \
2127e193
GI
592 date=`sed -n 's,^.*DATE[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`; \
593 rev=`sed -n 's,^.*REV[^"]*"\([^"]*\)".*$$,r\1,p' svnversion.h`; \
594 verstr="$(PACKAGE_VERSION) $$date $$rev "$(BUILD_INFO); \
7f0798ef
GI
595 echo "$$makensis -V2 -NOCD -DINPDIR=$(distdir_win32) -DOUTFILE=$(distinst_win32) -DVERSTR='$$verstr' $(srcdir)/os_win32/installer.nsi"; \
596 "$$makensis" -V2 -NOCD -DINPDIR="$(distdir_win32)" -DOUTFILE="$(distinst_win32)" -DVERSTR="$$verstr" "$(srcdir)/os_win32/installer.nsi"
4d59bff9 597
832b75ed
GG
598cleandist-win32:
599 rm -rf $(distdir_win32) distdir.mkdir syslogevt.check
600
601distdir.mkdir:
602 @test -d $(exedir_win32) || mkdir -pv $(exedir_win32)
603 @test -d $(docdir_win32) || mkdir -pv $(docdir_win32)
604 touch $@
605
606syslogevt.check:
607 @if [ -f $(srcdir)/os_win32/syslogevt.exe ]; then \
608 cp -pv $(srcdir)/os_win32/syslogevt.exe $(exedir_win32)/syslogevt.exe; \
609 else echo "Warning: $(srcdir)/os_win32/syslogevt.exe missing."; fi
610 touch $@
611
612$(exedir_win32)/%.exe: %.exe
613 cp -p $< $@
7f0798ef 614 if test -n '$(STRIP)'; then $(STRIP) -s $@; else strip -s $@; fi
832b75ed
GG
615 touch -r $< $@
616
ba59cff1
GG
617$(docdir_win32)/%.html: %.html
618 $(UNIX2DOS) < $< > $@
619 touch -r $< $@
620
621$(docdir_win32)/%.txt: %.txt
832b75ed
GG
622 $(UNIX2DOS) < $< > $@
623 touch -r $< $@
624
625$(docdir_win32)/%.txt: $(srcdir)/%
626 $(UNIX2DOS) < $< > $@
627 touch -r $< $@
628
629$(docdir_win32)/%.conf: $(srcdir)/%.conf
630 $(UNIX2DOS) < $< > $@
631 touch -r $< $@
632
2127e193
GI
633# Build non-console version of smartctl for GSmartControl.
634# The script below changes the word at offset 220 (Subsystem) from 3
635# (Console) to 2 (GUI) in a copy of smartctl.exe.
636# This will be changed when a tool (like 'editbin') is available in
637# the Cygwin distribution
638smartctl-nc.exe: smartctl.exe
639 @rm -f $@
640 cp -p smartctl.exe $@.tmp
641 @if test `od -A n -j 220 -N 2 -d $@.tmp` -eq 3; then :; \
642 else echo "invalid EXE header"; exit 1; fi
643 @echo "editbin /subsystem:windows $@.tmp"
644 @echo -ne '\002' | dd bs=1 seek=220 count=1 conv=notrunc of=$@.tmp 2>/dev/null
645 @if test `od -A n -j 220 -N 2 -d $@.tmp` -eq 2; then :; \
646 else echo "EXE patch failed"; exit 1; fi
647 mv -f $@.tmp $@
648
649
650# Build {config,svnversion}_vc8.h for MSVC8 from MinGW {config,svnversion}.h
651
652config-vc8: $(srcdir)/os_win32/config_vc8.h $(srcdir)/os_win32/svnversion_vc8.h
653
654$(srcdir)/os_win32/config_vc8.h: config.h
655 sed '1i/* config_vc8.h. Generated from config.h by Makefile. */' $< | \
656 sed 's,^#define HAVE_\(ATTR_PACKED\|INTTYPES_H\|STDINT_H\|STRINGS_H\|STRTOULL\|U*INT64_T\|UNISTD_H\|WORKING_SNPRINTF\) 1$$,/* #undef HAVE_\1 */,' | \
657 sed 's,i.86-pc-mingw32,i686-pc-win32vc8,' > $@
658
659$(srcdir)/os_win32/svnversion_vc8.h: svnversion.h
660 cp svnversion.h $@
832b75ed
GG
661
662endif
663
664SUBDIRS= . examplescripts