Makefile 9.82 KB
Newer Older
1
# Copyright (C) 1991-2002  Lysator Academic Computer Association.
Linus Tolke's avatar
Linus Tolke committed
2
#
3
# This file is part of the LysKOM Emacs LISP client.
Linus Tolke's avatar
Linus Tolke committed
4
5
6
# 
# LysKOM is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by 
7
# the Free Software Foundation; either version 2, or (at your option) 
Linus Tolke's avatar
Linus Tolke committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# any later version.
# 
# LysKOM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
# 
# You should have received a copy of the GNU General Public License
# along with LysKOM; see the file COPYING.  If not, write to
# Lysator, c/o ISY, Linkoping University, S-581 83 Linkoping, SWEDEN,
# or the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, 
# MA 02139, USA.
#
# Please mail bug reports to bug-lyskom@lysator.liu.se. 
#
23
# $Id$
Per Cederqvist's avatar
.    
Per Cederqvist committed
24

25
26
27
28
29
30
31
32
# Useful targets:
#
#   all      - Build lyskom.el from source files and compile it with $(EMACS).
#   verbose  - Same as above, but also print some progress messages.
#   fast     - Separately compile each uncompiled source file with $(EMACS)
#              and produce lyskom.elc from the results.
#   check    - Perform test cases.
#   release  - Make distribution archives.
33

34
######################################################################
David Byers's avatar
David Byers committed
35

36
# Version of the client.
David Byers's avatar
David Byers committed
37
#
38
# Also remember to change version number in ../doc/Makefile!
David Byers's avatar
David Byers committed
39
CLIENTVERSION = 0.48
40

41
######################################################################
Kent Engström's avatar
Kent Engström committed
42

43
44
45
46
# Default Emacs to use for compilation by developers.
EMACS = xemacs

# The available languages.
47
LANGUAGES = swedish english
48
49

# These files are included in all distribution archives.
David Byers's avatar
David Byers committed
50
DOCFILES = ../doc/NEWS-$(CLIENTVERSION)
51
52
53
54
55
56
57
58
59
60
61
62

# Default target.
TARGET = lyskom.elc
TARGET-EL := $(TARGET:%.elc=%.el)

# These will be placed first in lyskom.el.
HEADER = 	header.el \
		defvar.el \
		feature.el \
		$(VARS-EL) \
		macros.el \
		compatibility.el \
David Byers's avatar
David Byers committed
63
64
65
		language.el \
		help.el

66
67

# Next come the language definitions.
David Byers's avatar
David Byers committed
68
LANGUAGE-EL := $(LANGUAGES:=-strings.el) $(LANGUAGES:=-help.el)
69
70
71

# Finally, other source files.
SOURCES	 = 	komtypes.el \
David Byers's avatar
David Byers committed
72
		clienttypes.el \
73
		faces.el \
David Byers's avatar
David Byers committed
74
75
		deferred-insert.el \
		utilities.el \
76
		completing-read.el \
77
		keyboard-menu.el \
78
		command.el \
David Byers's avatar
David Byers committed
79
		buffers.el \
80
		aux-items.el \
81
		mime.el \
David Byers's avatar
David Byers committed
82
83
84
85
86
87
88
		prefetch.el \
		startup.el \
		reading.el \
		internal.el \
		services.el \
		parse.el \
		cache.el \
David Byers's avatar
David Byers committed
89
		view-mode.el \
90
		names.el \
David Byers's avatar
David Byers committed
91
92
93
94
95
96
97
98
99
		commands1.el \
		commands2.el \
		review.el \
		edit-text.el \
		filter.el \
		filter-edit.el \
		lyskom-buttons.el \
		view-text.el \
		async.el \
100
		mship-edit.el \
David Byers's avatar
David Byers committed
101
102
103
104
105
106
107
		flags.el \
		messages.el \
		ansaphone.el \
		remote-control.el \
		menus.el slow.el \
		elib-string.el \
		option-edit.el \
David Byers's avatar
David Byers committed
108
		talkback.el \
David Byers's avatar
David Byers committed
109
		faqs.el \
David Byers's avatar
David Byers committed
110
		user-hooks.el \
David Byers's avatar
David Byers committed
111
		lyskom-rest.el
David Byers's avatar
David Byers committed
112
                # lyskom-rest.el must be the last file!
David Byers's avatar
David Byers committed
113

114
115
116
117
118
119
# Included in the source distribution archive.
EXTRA-SRCDIST = \
	distribution-COPYING distribution-configure.in \
	distribution-Makefile.in
EXTRA-SRCVERBATIM = \
	envcheck.el lpath.el autoconf.el \
120
121
	help-swedish.xml help-english.xml \
	help-compile.el \
122
	$(DOCFILES)
David Byers's avatar
David Byers committed
123

124
125
126
127
128
# Included in the non-source distribution archives.
EXTRA-NONSRCDIST = \
	distribution-COPYING
EXTRA-NONSRCVERBATIM = \
	$(DOCFILES)
David Byers's avatar
David Byers committed
129

130
131
# Base name of distribution packages.
PACKAGENAME = lyskom-elisp-client
David Byers's avatar
David Byers committed
132

133
134
135
# Default paths in the source dist Makefile.
DEFAULTLISPDIR = /usr/local/share/emacs/site-lisp
DEFAULTPREFIX = /usr/local
136

137
138
139
140
141
142
143
ifeq ($(MAKECMDGOALS),release)
    VARS-EL = vars.el-release
else
    VARS-EL = vars.el
endif

EMACS-BATCH := $(EMACS) -batch
Per Cederqvist's avatar
.    
Per Cederqvist committed
144

145
all: $(TARGET)
146

147
vars.el: vars.el.in Makefile
148
	rm -f $@
149
	sed "s/@@CLIENTVERSION@@/$(CLIENTVERSION) (`date +%Y-%m-%d`; Git)/g" <$< >$@
150
	chmod 444 $@
151

152
153
vars.el-release: vars.el.in Makefile
	sed 's/@@CLIENTVERSION@@/$(CLIENTVERSION)/g' <$< >$@
154

155
156
$(TARGET-EL) lyskom-all-$(CLIENTVERSION).el: \
		$(HEADER) $(LANGUAGE-EL) $(SOURCES)
157
158
	rm -f $(VARS-EL)
	$(MAKE) $(VARS-EL)
David Byers's avatar
David Byers committed
159
160
	echo ";;;;; -*-coding: x-ctext;-*-" >$@
	cat $^ >>$@
161

David Byers's avatar
David Byers committed
162
%-help.el: help-%.xml
163
	$(EMACS) -batch -l help-compile.el $^ -f lyskom-help-compile-to-el
David Byers's avatar
David Byers committed
164

David Byers's avatar
David Byers committed
165
lyskom-%-$(CLIENTVERSION).el: $(HEADER) %-strings.el %-help.el $(SOURCES)
David Byers's avatar
David Byers committed
166
167
	echo ";;;;; -*-coding: x-ctext;-*-" >$@
	cat $^ >>$@
168

169
170
171
verbose: verbose-el $(TARGET)

verbose-el: $(HEADER) $(LANGUAGE-EL) $(SOURCES)
David Byers's avatar
David Byers committed
172
	echo ";;;;; -*-coding: x-ctext;-*-" >$(TARGET-EL)
173
174
	for i in $^ ; do \
		echo '(eval-when-compile (message "Compiling %s" "'$$i'"))' \
175
176
			>>$(TARGET-EL) ; \
		cat $$i >>$(TARGET-EL) ; \
177
178
179
180
	    done

%.elc: %.el _header.el
	$(EMACS-BATCH) -l lpath.el -l _header.el -f batch-byte-compile $<
181

182
$(TARGET): $(TARGET-EL)
183
	LYSKOM_DEBUG_COMPILE=yes $(EMACS-BATCH) -l lpath.el -f batch-byte-compile $<
184
185
186
187
188
189

HEADER-ELC = $(HEADER:%.el=%.elc)
LANGUAGE-ELC = $(LANGUAGE-EL:.el%.elc)
SOURCES-ELC = $(SOURCES:%.el=%.elc)

_header.el: $(HEADER)
David Byers's avatar
David Byers committed
190
191
	echo ";;;;; -*-coding: x-ctext;-*-" >_header.el
	cat $(HEADER) >>_header.el
192
193
194
195

fast: $(HEADER-ELC) $(LANGUAGE-ELC) $(SOURCES-ELC)
	cat $^ >$(TARGET)

David Kågedal's avatar
David Kågedal committed
196

197
check: $(TARGET-EL) check-eof
David Byers's avatar
David Byers committed
198
	$(EMACS-BATCH) -l lpath.el -l $< -l check-strings.el \
David Byers's avatar
David Byers committed
199
			-f lyskom-check-strings
200

201
202
203
204
205
206
207
208
209
210
211
212
213
214
check-eof:
	for i in $(HEADER) $(LANGUAGE-EL) $(SOURCES); \
	do \
	    sz=`wc -c < $$i`; \
	    sz=`expr $$sz - 1`; \
	    lastchar=`od -t d1 -j $$sz $$i|awk 'NF==2 {print $$2}'`; \
	    if [ $$lastchar != 10 ]; \
	    then \
		echo $$i:`wc -l < $$i`: bad file ending >&2; \
		exit 1; \
	    fi \
	done


215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
TAGS: $(HEADER) $(LANGUAGE-EL) $(SOURCES)
	etags $^

distribution-README-%: \
		distribution-README.begin \
		distribution-README.install-% \
		distribution-README.end
	cat $^ >$@

RELEASE-DIST-FLAVOURS := src all $(LANGUAGES)

RELEASE-DIST-ARCHIVES := \
    $(patsubst %,$(PACKAGENAME)-%-$(CLIENTVERSION).tar.gz,$(RELEASE-DIST-FLAVOURS)) \
    $(patsubst %,$(PACKAGENAME)-%-$(CLIENTVERSION).zip,$(RELEASE-DIST-FLAVOURS))

release: $(VARS-EL) $(RELEASE-DIST-ARCHIVES)
	@echo
	@echo
	@echo "Release archives created:"
	@echo
	@for i in $(RELEASE-DIST-ARCHIVES); do \
		echo "    $$i" ; \
	    done
	@echo

%.tar: %.buildstamp
	tar cvf $@ $*

%.gz: %
	gzip -f --best $<

%.zip: %.buildstamp
	zip -R9y $@ $*/*

############################################################
# Source dist.

RELEASE-SOURCE-SRC = $(HEADER) $(LANGUAGE-EL) $(SOURCES) $(MISC)
RELEASE-BASE-SRC = $(PACKAGENAME)-src-$(CLIENTVERSION)

$(RELEASE-BASE-SRC).buildstamp: \
		$(RELEASE-SOURCE-SRC) $(EXTRA-SRCDIST) $(EXTRA-SRCVERBATIM) \
		distribution-README-src
	mkdir -p $(RELEASE-BASE-SRC)
	cp $(RELEASE-SOURCE-SRC) $(RELEASE-BASE-SRC)
	sed 's/@@CLIENTVERSION@@/$(CLIENTVERSION)/g' \
		<distribution-README-src \
		>$(RELEASE-BASE-SRC)/README
	for i in $(subst distribution-,,$(EXTRA-SRCDIST)); do \
	    sed -e 's/@@CLIENTVERSION@@/$(CLIENTVERSION)/g' \
		-e 's/@@HEADER@@/$(HEADER)/g' \
		-e 's/@@SOURCES@@/$(SOURCES)/g' \
		<distribution-$$i \
		>$(RELEASE-BASE-SRC)/$$i ; \
	    done
	cp $(EXTRA-SRCVERBATIM) $(RELEASE-BASE-SRC)
	sed -e "s/#CLIENTVERSION#/$(CLIENTVERSION)/" \
	    -e "s/#REDHATCLIENTVERSION#/$(REDHATCLIENTVERSION)/" \
	    <$(PACKAGENAME).spec \
	    >$(RELEASE-BASE-SRC)/$(PACKAGENAME)-$(REDHATCLIENTVERSION).spec
	cd $(RELEASE-BASE-SRC) && autoconf
	cd $(RELEASE-BASE-SRC) && ./configure --prefix=$(DEFAULTPREFIX) \
					      --with-lispdir=$(DEFAULTLISPDIR)
278
	cd $(RELEASE-BASE-SRC) && rm -f config.log config.status config.cache
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
	touch $@

############################################################
# Normal dist.

RELEASE-BASE-NONSRC = $(PACKAGENAME)-$*-$(CLIENTVERSION)

$(PACKAGENAME)-%-$(CLIENTVERSION).buildstamp: \
		lyskom-%-$(CLIENTVERSION).el $(EXTRA-NONSRCDIST) \
		distribution-README-nonsrc
	mkdir -p $(RELEASE-BASE-NONSRC)
	cp $< $(RELEASE-BASE-NONSRC)
	sed -e 's/@@CLIENTVERSION@@/$(CLIENTVERSION)/g' \
	    -e 's/@@FLAVOUR@@/$*/g' \
		<distribution-README-nonsrc \
		>$(RELEASE-BASE-NONSRC)/README
	for i in $(subst distribution-,,$(EXTRA-NONSRCDIST)); do \
	    sed 's/@@CLIENTVERSION@@/$(CLIENTVERSION)/g' \
		<distribution-$$i \
		>$(RELEASE-BASE-NONSRC)/$$i ; \
	    done
	cp $(EXTRA-NONSRCVERBATIM) $(RELEASE-BASE-NONSRC)
	touch $@

######################################################################
# RPM packages

REDHATCLIENTVERSION := $(subst -,.,$(CLIENTVERSION))
RPMROOT = /usr/src/redhat
David Byers's avatar
David Byers committed
308

309
310
311
312
313
314
redhat-packages: $(PACKAGENAME)-src-$(CLIENTVERSION).tar.gz
	cp $< $(RPMROOT)/SOURCES/
	sed -e "s/#CLIENTVERSION#/$(CLIENTVERSION)/" \
	    -e "s/#REDHATCLIENTVERSION#/$(REDHATCLIENTVERSION)/" \
	    <$(PACKAGENAME).spec \
	    >$(RPMROOT)/SPECS/$(PACKAGENAME)-$(REDHATCLIENTVERSION).spec
David Byers's avatar
David Byers committed
315
	rpmbuild -ba $(RPMROOT)/SPECS/$(PACKAGENAME)-$(REDHATCLIENTVERSION).spec
316
317
318
######################################################################
# Debian packages

319
320
321
322
323
324
# Keeping the suffix in it's own variable lets you easily replace it
# from the commandline. This is useful when you're building a package
# just for your self and don't want it replaced by the package in the
# distribution. (make DEBIANCLIENTVERSIONSUFFIX=qha1 debian-packages).
DEBIANCLIENTVERSIONSUFFIX = 1

325
326
327
# and when you're the only one who'll use the package and you're not
# really the maintainer you might want to set this to something like
# '-us -uc' and perhaps -rfakeroot aswell.
328
DPKG_BUILDPACKAGE_OPTIONS =
329

330
331
332
333
334
DEBIANCLIENTVERSION := $(subst -,.,$(CLIENTVERSION))

debian-packages: $(RELEASE-BASE-SRC).buildstamp
	cp -R debian $(RELEASE-BASE-SRC)
	$(RM) -rf $(RELEASE-BASE-SRC)/debian/CVS
335
	sed '1s/(.*)/($(DEBIANCLIENTVERSION)-$(DEBIANCLIENTVERSIONSUFFIX))/' <debian/changelog >$(RELEASE-BASE-SRC)/debian/changelog
336
	sed 's/@@CLIENTVERSION@@/$(CLIENTVERSION)/g' <debian/rules >$(RELEASE-BASE-SRC)/debian/rules
337
	cd $(RELEASE-BASE-SRC) && dpkg-buildpackage $(DPKG_BUILDPACKAGE_OPTIONS)
338
339


340
clean:
341
342
343
344
345
	rm -f *~ *.gz *.zip *.buildstamp *.elc* _header.el $(TARGET-EL)
	rm -rf $(PACKAGENAME)-*-$(CLIENTVERSION)* lyskom-*-$(CLIENTVERSION).el
	rm -f vars.el vars.el-release
	rm -f distribution-README-src distribution-README-nonsrc

346
.PHONY: all verbose verbose-el fast check release redhat-packages clean debian-packages