Makefile 10.3 KB
Newer Older
1
# Copyright (C) 1991-2002  Lysator Academic Computer Association.
Linus Tolke Y's avatar
Linus Tolke Y committed
2
#
3
# This file is part of the LysKOM Emacs LISP client.
Linus Tolke Y's avatar
Linus Tolke Y 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 Y's avatar
Linus Tolke Y committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 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. 
Per Cederqvist's avatar
.    
Per Cederqvist committed
22

23
24
25
26
27
28
# Useful targets:
#
#   all      - Build lyskom.el from source files and compile it with $(EMACS).
#   verbose  - Same as above, but also print some progress messages.
#   check    - Perform test cases.
#   release  - Make distribution archives.
29

30
######################################################################
David Byers's avatar
David Byers committed
31

32
# Version of the client.
David Byers's avatar
David Byers committed
33
#
34
35
36
37
38
39
40
# LASTRELEASE is the latest released version.
# NEXTRELEASE is a guess what the next release would be.
#
# Remember to change LASTRELEASE to NEXTRELEASE when doing a new
# release. The commit taged as a release should have LASTRELEASE ==
# NEXTRELEASE.
#
41
# Also remember to change version number in ../doc/Makefile!
42
43
44
LASTRELEASE = 0.48
NEXTRELEASE = 0.49
CLIENTVERSION = $(shell (git describe --exact-match --tags HEAD 2>/dev/null || git rev-parse --short HEAD) | sed -e 's/^v//')
45

46
######################################################################
Kent Engström's avatar
Kent Engström committed
47

48
49
50
51
# Default Emacs to use for compilation by developers.
EMACS = xemacs

# The available languages.
52
LANGUAGES = swedish english
53
54

# These files are included in all distribution archives.
55
DOCFILES = ../doc/NEWS-$(NEXTRELEASE)
56
57
58
59
60
61

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

# These will be placed first in lyskom.el.
62
HEADER1 = 	header.el \
63
		defvar.el \
64
65
		feature.el
HEADER2 =	vars.el \
66
67
		macros.el \
		compatibility.el \
David Byers's avatar
David Byers committed
68
69
70
		language.el \
		help.el

71
72

# Next come the language definitions.
David Byers's avatar
David Byers committed
73
LANGUAGE-EL := $(LANGUAGES:=-strings.el) $(LANGUAGES:=-help.el)
74
75
76

# Finally, other source files.
SOURCES	 = 	komtypes.el \
David Byers's avatar
David Byers committed
77
		clienttypes.el \
78
		faces.el \
David Byers's avatar
David Byers committed
79
80
		deferred-insert.el \
		utilities.el \
81
		completing-read.el \
82
		keyboard-menu.el \
83
		command.el \
David Byers's avatar
David Byers committed
84
		buffers.el \
85
		aux-items.el \
86
		mime.el \
David Byers's avatar
David Byers committed
87
88
89
90
91
92
93
		prefetch.el \
		startup.el \
		reading.el \
		internal.el \
		services.el \
		parse.el \
		cache.el \
David Byers's avatar
David Byers committed
94
		view-mode.el \
95
		names.el \
David Byers's avatar
David Byers committed
96
97
98
99
100
101
102
103
104
		commands1.el \
		commands2.el \
		review.el \
		edit-text.el \
		filter.el \
		filter-edit.el \
		lyskom-buttons.el \
		view-text.el \
		async.el \
105
		mship-edit.el \
David Byers's avatar
David Byers committed
106
107
108
109
110
111
112
		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
113
		talkback.el \
David Byers's avatar
David Byers committed
114
		faqs.el \
David Byers's avatar
David Byers committed
115
		user-hooks.el \
David Byers's avatar
David Byers committed
116
		lyskom-rest.el
David Byers's avatar
David Byers committed
117
                # lyskom-rest.el must be the last file!
David Byers's avatar
David Byers committed
118

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

129
130
131
132
133
# Included in the non-source distribution archives.
EXTRA-NONSRCDIST = \
	distribution-COPYING
EXTRA-NONSRCVERBATIM = \
	$(DOCFILES)
David Byers's avatar
David Byers committed
134

135
136
# Base name of distribution packages.
PACKAGENAME = lyskom-elisp-client
David Byers's avatar
David Byers committed
137

138
139
140
# Default paths in the source dist Makefile.
DEFAULTLISPDIR = /usr/local/share/emacs/site-lisp
DEFAULTPREFIX = /usr/local
141

142
ifeq ($(MAKECMDGOALS),release)
143
144
145
146
147
    ifeq ($(CLIENTVERSION),$(LASTRELEASE))
        VERSION-EL = version.el-release
    else
        VERSION-EL = version.el
    endif
148
149
150
151
else
    VERSION-EL = version.el
endif

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

154
all: $(TARGET)
155

156
version.el: version.el.in Makefile $(HEADER1) $(HEADER2) $(LANGUAGE-EL) $(SOURCES)
157
	rm -f $@
158
	sed "s/@@CLIENTVERSION@@/$(LASTRELEASE) (`date +%Y-%m-%d`; Git `git rev-parse --short HEAD``git diff --quiet HEAD||echo '*'`)/g" <$< >$@
159
	chmod 444 $@
160

161
version.el-release: version.el.in Makefile $(HEADER1) $(HEADER2) $(LANGUAGE-EL) $(SOURCES)
162
	rm -f $@
163
	sed 's/@@CLIENTVERSION@@/$(CLIENTVERSION)/g' <$< >$@
164
	chmod 444 $@
165

166
$(TARGET-EL) lyskom-all-$(CLIENTVERSION).el: \
167
		$(HEADER1) $(VERSION-EL) $(HEADER2) $(LANGUAGE-EL) $(SOURCES)
168
	rm -f $@
David Byers's avatar
David Byers committed
169
170
	echo ";;;;; -*-coding: x-ctext;-*-" >$@
	cat $^ >>$@
171
	chmod 444 $@
172

David Byers's avatar
David Byers committed
173
%-help.el: help-%.xml
174
	rm -f $@
175
	$(EMACS) -batch -l help-compile.el $^ -f lyskom-help-compile-to-el
176
	chmod 444 $@
David Byers's avatar
David Byers committed
177

178
lyskom-%-$(CLIENTVERSION).el: $(HEADER1) $(VERSION-EL) $(HEADER2) %-strings.el %-help.el $(SOURCES)
179
	rm -f $@
David Byers's avatar
David Byers committed
180
181
	echo ";;;;; -*-coding: x-ctext;-*-" >$@
	cat $^ >>$@
182
	chmod 444 $@
183

184
185
verbose: verbose-el $(TARGET)

186
verbose-el: $(HEADER1) $(VERSION-EL) $(HEADER2) $(LANGUAGE-EL) $(SOURCES)
David Byers's avatar
David Byers committed
187
	echo ";;;;; -*-coding: x-ctext;-*-" >$(TARGET-EL)
188
189
	for i in $^ ; do \
		echo '(eval-when-compile (message "Compiling %s" "'$$i'"))' \
190
191
			>>$(TARGET-EL) ; \
		cat $$i >>$(TARGET-EL) ; \
192
193
	    done

194
$(TARGET): $(TARGET-EL)
195
	LYSKOM_DEBUG_COMPILE=yes $(EMACS-BATCH) -l lpath.el -f batch-byte-compile $<
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
check-eof:
202
	for i in $(HEADER1) $(VERSION-EL) $(HEADER2) $(LANGUAGE-EL) $(SOURCES); \
203
204
205
206
207
208
209
210
211
212
213
214
	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
TAGS: $(HEADER1) $(VERSION-EL) $(HEADER2) $(LANGUAGE-EL) $(SOURCES)
216
217
218
219
220
221
222
223
224
225
226
227
228
229
	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))

230
release: $(VERSION-EL) $(RELEASE-DIST-ARCHIVES)
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
	@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.

252
RELEASE-SOURCE-SRC = $(HEADER1) $(VERSION-EL) $(HEADER2) $(LANGUAGE-EL) $(SOURCES) $(MISC)
253
254
255
256
257
258
259
260
261
262
263
264
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' \
265
266
267
		-e 's/@@HEADER1@@/$(HEADER1)/g' \
		-e 's/@@HEADER2@@/$(HEADER2)/g' \
		-e 's/@@VERSION-EL@@/$(VERSION-EL)/g' \
268
269
270
271
272
273
274
275
276
277
278
279
		-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)
280
	cd $(RELEASE-BASE-SRC) && rm -f config.log config.status config.cache
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
308
309
	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
310

311
312
313
314
315
316
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
317
	rpmbuild -ba $(RPMROOT)/SPECS/$(PACKAGENAME)-$(REDHATCLIENTVERSION).spec
318
319
320
######################################################################
# Debian packages

321
322
323
324
325
326
# 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

327
328
329
# 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.
330
DPKG_BUILDPACKAGE_OPTIONS =
331

332
333
334
335
336
DEBIANCLIENTVERSION := $(subst -,.,$(CLIENTVERSION))

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


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

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