GNUmakefile 7.62 KB
Newer Older
1
2
3
4
5
6
7
8
# -------------------------------------------------------------------------

# This is the development Makefile. It is used for compiling
# development versions and for creating the distributed package.
# This Makefile is not distributed.

SHELL := bash

9
.PHONY: all test clean package check api export godi opam local
10
11
12

# -------------------------------------------------------------------------

fpottier's avatar
fpottier committed
13
# A dummy entry.
14
15

all:
fpottier's avatar
fpottier committed
16
	@echo Please go down into src/ if you wish to compile Menhir.
17
18
19
20

# -------------------------------------------------------------------------

# Testing.
21
22
# Assumes that "make bootstrap" has been run in src/
# or that MENHIR is properly set.
23
24
25
26
27
28
29
30
31
32

test:
	$(MAKE) -C bench

# -------------------------------------------------------------------------

# Cleaning up.

clean:
	@ for i in bench demos src ; do \
fpottier's avatar
fpottier committed
33
	  $(MAKE) -C $$i $@ ; \
34
	done
POTTIER Francois's avatar
POTTIER Francois committed
35
	@ $(MAKE) -rs -C doc $@
36
37
38
39
40
41
42

# -------------------------------------------------------------------------

# Prevent the built-in bash cd from displaying information.

export CDPATH=

43
44
# -------------------------------------------------------------------------

45
# Distribution.
fpottier's avatar
fpottier committed
46
# The version number is automatically set to the current date,
POTTIER Francois's avatar
Typo.    
POTTIER Francois committed
47
# unless DATE is defined on the command line.
fpottier's avatar
fpottier committed
48
ifndef $(DATE)
49
DATE     := $(shell /bin/date +%Y%m%d)
fpottier's avatar
fpottier committed
50
51
endif

52
53
54
55
56
57
58
PACKAGE  := menhir-$(DATE)
CURRENT  := $(shell pwd)
TARBALL  := $(CURRENT)/$(PACKAGE).tar.gz
HEADACHE := headache
SRCHEAD  := $(CURRENT)/header
LIBHEAD  := $(CURRENT)/lgpl-header

59
# -------------------------------------------------------------------------
60
61
62
63
64
65

# A list of files to copy without changes to the package.
#
# This does not include the src/ and doc/ directories, which require
# special treatment.

fpottier's avatar
fpottier committed
66
DISTRIBUTED_FILES := AUTHORS CHANGES INSTALLATION LICENSE Makefile demos
67

68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# -------------------------------------------------------------------------

# The names of the modules in MenhirLib are obtained by reading the
# non-comment lines in menhirLib.mlpack.

MENHIRLIB_MODULES := $(shell grep -ve "^[ \t\n\r]*\#" src/menhirLib.mlpack)

# The names of the source files in MenhirLib are obtained by adding
# an .ml or .mli extension to the module name. (We assume that the
# first letter of the file name is a capital letter.)

MENHIRLIB_FILES   := $(shell for m in $(MENHIRLIB_MODULES) ; do \
	                       ls src/$$m.{ml,mli} 2>/dev/null ; \
	                     done)

# -------------------------------------------------------------------------

# Creating a tarball for distribution.
86
87
88

package: clean
# Create a directory to store the distributed files temporarily.
89
# In src/_tags, every line tagged "my_warnings" is removed.
90
91
92
	@ rm -fr $(PACKAGE)
	@ mkdir -p $(PACKAGE)/src
	@ cp -fr $(DISTRIBUTED_FILES) $(PACKAGE)
93
	@ cp -fr src/*.ml{,i,y,l,pack} src/*.messages src/Makefile src/META $(PACKAGE)/src
94
	@ grep -v my_warnings src/_tags > $(PACKAGE)/src/_tags
95
96
	@ $(MAKE) -C $(PACKAGE)/demos clean
# Insert headers.
97
98
99
# Note that standard.mly as well as the source files in MenhirLib carry the
# "library" license, while every other file carries the regular "source code"
# license.
100
101
102
	@ echo "-> Inserting headers."
	@ cd $(PACKAGE) && find . -regex ".*\.ml\(i\|y\|l\)?" \
	    -exec $(HEADACHE) -h $(SRCHEAD) "{}" ";"
103
	@ cd $(PACKAGE) && for file in src/standard.mly $(MENHIRLIB_FILES) ; do \
104
105
106
107
108
109
110
111
112
113
114
	    $(HEADACHE) -h $(LIBHEAD) $$file ; \
	  done
# Set the version number into the files that mention it. These
# include version.ml, version.tex, META.
	@ echo "-> Setting version to $(DATE)."
	@ echo let version = \"$(DATE)\" > $(PACKAGE)/src/version.ml
	@ echo version = \"$(DATE)\" >> $(PACKAGE)/src/META
# Copy and compile the documentation.
	@ echo "-> Generating the documentation."
	@ cp -r doc $(PACKAGE)
	@ echo '\gdef\menhirversion{$(DATE)}' > $(PACKAGE)/doc/version.tex
fpottier's avatar
fpottier committed
115
	@ make -C $(PACKAGE)/doc clean all
116
117
118
119
120
	@ mv $(PACKAGE)/doc/main.pdf $(PACKAGE)/manual.pdf
	@ mv $(PACKAGE)/doc/menhir.1 $(PACKAGE)/
	@ rm -rf $(PACKAGE)/doc
# Create the tarball.
	@ echo "-> Tarball creation."
121
	tar --exclude=.gitignore -cvz -f $(TARBALL) $(PACKAGE)
122
123
	@ echo "-> Package $(PACKAGE).tar.gz is ready."

124
125
126
127
# -------------------------------------------------------------------------

# Checking the tarball that was created above.

128
129
130
check:
	@ echo "-> Checking the package ..."
# Create a temporary directory; extract, build, and install the
131
132
# package into it; build the demos and run the test suite using
# the installed binary.
133
134
135
136
137
	@ TEMPDIR=`mktemp -d /tmp/menhir-test.XXXXXX` && { \
	echo "   * Extracting. " && \
	(cd $$TEMPDIR && tar xfz $(TARBALL)) && \
	echo "   * Compiling and installing." && \
	mkdir $$TEMPDIR/install && \
138
	(cd $$TEMPDIR/$(PACKAGE) \
139
140
141
		&& make PREFIX=$$TEMPDIR/install USE_OCAMLFIND=false all install \
	) > $$TEMPDIR/install.log 2>&1 \
		|| (cat $$TEMPDIR/install.log; exit 1) && \
142
143
144
145
146
	echo "   * Building the demos." && \
	(cd $$TEMPDIR/$(PACKAGE) \
		&& $(MAKE) MENHIR=$$TEMPDIR/install/bin/menhir -C demos \
	) > $$TEMPDIR/demos.log 2>&1 \
		|| (cat $$TEMPDIR/demos.log; exit 1) && \
147
148
149
150
151
152
153
154
	echo "   * Running the test suite." && \
	$(MAKE) MENHIR=$$TEMPDIR/install/bin/menhir test > $$TEMPDIR/test.log 2>&1 \
		|| (cat $$TEMPDIR/test.log; exit 1) && \
	rm -fr $$TEMPDIR ; }
	@ echo "-> Package $(PACKAGE) seems ready for distribution!"

# -------------------------------------------------------------------------

155
156
157
158
159
160
161
162
163
164
165
# Generating HTML documentation for certain API files.

%.mli.html: %.mli
	caml2html -nf $<

%.ml.html: %.ml
	caml2html -nf $<

# -------------------------------------------------------------------------

# Copying the tarball to my Web site.
166

fpottier's avatar
fpottier committed
167
RSYNC   := scp -p -C
168
169
TARGET  := yquem.inria.fr:public_html/menhir/
PAGE    := /home/fpottier/dev/page
170
171
172
173
174
API     := src/Convert.mli.html \
	   src/IncrementalEngine.ml.html \
	   src/General.mli.html

api: $(API)
175

176
export: api
177
178
179
180
181
# Copier l'archive et la doc vers yquem.
	$(RSYNC) $(TARBALL) $(TARGET)
	$(RSYNC) $(PACKAGE)/manual.pdf $(TARGET)
	$(RSYNC) CHANGES $(TARGET)
# Copier l'API vers la page Web.
182
	$(RSYNC) $(API) $(TARGET)
183
184
185
186
187
188
189
190
# Mettre  jour la page Web de Menhir avec le nouveau numro de version.
	cd $(PAGE) && \
	  sed --in-place=.bak "s/menhir-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/$(PACKAGE)/" menhir.xml && \
	  $(MAKE) export && \
	  cvs commit -m "Updated Menhir's version number."

# -------------------------------------------------------------------------

191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# Updating the opam package.

# This entry assumes that "make package" and "make export" have been
# run on the same day.

OPAM := $(HOME)/dev/opam-repository
CSUM  = $(shell md5sum menhir-$(DATE).tar.gz | cut -d ' ' -f 1)

opam:
# Update my local copy of the opam repository.
	@ echo "Updating local opam repository..."
	@ cd $(OPAM) && \
	  git fetch upstream && \
	  git merge upstream/master
# Create a new Menhir package, based on the last one.
	@ echo "Creating a new package description menhir-$(DATE)..."
	@ cd $(OPAM)/packages/menhir && \
	  cp -r `ls | grep menhir | tail -1` menhir.$(DATE)
# Update the file "url".
	@ cd $(OPAM)/packages/menhir/menhir.$(DATE) && \
	  rm url && \
	  echo 'archive: "http://gallium.inria.fr/~fpottier/menhir/menhir-$(DATE).tar.gz"' >> url && \
	  echo 'checksum: "$(CSUM)"' >> url
# Prepare a commit.
	@ echo "Preparing a new commit..."
	@ cd $(OPAM)/packages/menhir && \
	  git add menhir.$(DATE) && \
	  git status
# Ask for review.
	@ echo "If happy, please run:"
	@ echo "  cd $(OPAM)/packages/menhir && git commit -a && git push && firefox https://github.com/"
	@ echo "and issue a pull request."
223
224
225
226
227
228
229
230
231

# -------------------------------------------------------------------------

# Re-installing locally. This can overwrite an existing local installation.

local:
	$(MAKE) package
	$(MAKE) -C $(PACKAGE) PREFIX=/usr/local USE_OCAMLFIND=false all
	sudo $(MAKE) -C $(PACKAGE) PREFIX=/usr/local USE_OCAMLFIND=false install