GNUmakefile 6.77 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

fpottier's avatar
fpottier committed
9
.PHONY: all test clean package check export godi
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
fpottier's avatar
fpottier committed
35
	$(MAKE) -rs -C doc $@
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

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

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

export CDPATH=

# Distribution.
# The version number is automatically set to the current date.

DATE     := $(shell /bin/date +%Y%m%d)
PACKAGE  := menhir-$(DATE)
CURRENT  := $(shell pwd)
TARBALL  := $(CURRENT)/$(PACKAGE).tar.gz
HEADACHE := headache
SRCHEAD  := $(CURRENT)/header
LIBHEAD  := $(CURRENT)/lgpl-header

# GODI settings. We assume $(GODI_HOME) is defined and points
# to the host machine's GODI installation.

GODINAME := godi/godi-menhir
GODIWORK := /home/fpottier/dev/godi-build
GODISVN  := $(GODIWORK)/trunk/$(GODINAME)
GODIH    := $(GODI_HOME)/build/$(GODINAME)
GODIPACK := $(GODIWORK)/pack
GODIMAP  := $(GODIPACK)/release.4.00.map
GODIURL  := https://godirepo.camlcity.org/godi_admin
GODIVA   := $(GODI_HOME)/bin/godiva

# 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
71
DISTRIBUTED_FILES := AUTHORS CHANGES INSTALLATION LICENSE Makefile demos
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

# Some source files carry the "library" license, while others carry
# the regular "source code" license.

LIBFILES := \
  src/standard.mly \
  src/infiniteArray.{ml,mli} \
  src/packedIntArray.{ml,mli} \
  src/rowDisplacement.{ml,mli} \
  src/engineTypes.ml \
  src/engine.{ml,mli} \
  src/tableFormat.ml \
  src/tableInterpreter.{ml,mli} \
  src/convert.{ml,mli}

package: clean
# Create a directory to store the distributed files temporarily.
	@ rm -fr $(PACKAGE)
	@ mkdir -p $(PACKAGE)/src
	@ cp -fr $(DISTRIBUTED_FILES) $(PACKAGE)
fpottier's avatar
fpottier committed
92
	@ cp -fr src/*.ml{,i,y,l,pack} src/Makefile src/_tags src/META $(PACKAGE)/src
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
	@ $(MAKE) -C $(PACKAGE)/demos clean
# Insert headers.
	@ echo "-> Inserting headers."
	@ cd $(PACKAGE) && find . -regex ".*\.ml\(i\|y\|l\)?" \
	    -exec $(HEADACHE) -h $(SRCHEAD) "{}" ";"
	@ cd $(PACKAGE) && for file in $(LIBFILES) ; do \
	    $(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
110
	@ make -C $(PACKAGE)/doc clean all
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
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
202
203
204
205
206
207
208
	@ mv $(PACKAGE)/doc/main.pdf $(PACKAGE)/manual.pdf
	@ mv $(PACKAGE)/doc/menhir.1 $(PACKAGE)/
	@ rm -rf $(PACKAGE)/doc
# Create the API documentation.
	@ $(MAKE) -C src api
# Create the tarball.
	@ echo "-> Tarball creation."
	tar --exclude=.svn -cvz -f $(TARBALL) $(PACKAGE)
	@ echo "-> Package $(PACKAGE).tar.gz is ready."

check:
	@ echo "-> Checking the package ..."
# Create a temporary directory; extract, build, and install the
# package into it; run the test suite using the installed binary.
	@ TEMPDIR=`mktemp -d /tmp/menhir-test.XXXXXX` && { \
	echo "   * Extracting. " && \
	(cd $$TEMPDIR && tar xfz $(TARBALL)) && \
	echo "   * Compiling and installing." && \
	mkdir $$TEMPDIR/install && \
	(cd $(PACKAGE) \
		&& make PREFIX=$$TEMPDIR/install USE_OCAMLFIND=false all install \
	) > $$TEMPDIR/install.log 2>&1 \
		|| (cat $$TEMPDIR/install.log; exit 1) && \
	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!"

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

# Copying to my Web site.

RSYNC   := scp -p -B -C
TARGET  := yquem.inria.fr:public_html/menhir/
PAGE    := /home/fpottier/dev/page

export:
# 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.
	cd src && $(RSYNC) convert.mli.html $(TARGET)
# 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."

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

# Creating a GODI package.

# This entry assumes that "make package" and "make export" have been
# run on the same day. It must have sufficient rights to write into
# the local GODI hierarchy.

godi:
	@ if [ `whoami` != "root" ] ; then \
	  echo "make godi must be run with root privileges. Try running ./godi" ; \
	  exit 1 ; \
	fi
	@ sed -e s/VERSION/$(DATE)/ < spec.godiva > $(GODISVN)/spec.godiva
	@ cd $(GODIWORK) && svn up
	@ cd $(GODISVN) && \
          $(GODIVA) -refetch -localbase $(GODI_HOME) spec.godiva && \
	  rsync -v -r $(GODIH)/ $(GODISVN) && \
	  chown -R fpottier $(GODISVN)
	@ echo "Do you wish to proceed and commit changes to GODI (yes or no)?"
	@ read answer && if [ "$$answer" != "yes" ] ; then \
	  echo Aborting. ; \
	  exit 1 ; \
	fi
	@ cd $(GODISVN) && \
	  svn commit -m "Changes to Menhir package." && \
	  export revision=`svn info Makefile | sed -n 's/^R.vision \?: \([0-9]\+\)$$/\1/p'` && \
	  echo Revision is now $$revision. && \
	  for map in $(GODIMAP) ; do \
	    sed --in-place=.bak "s/^\(.*menhir[^0-9]*\)[0-9]\+$$/\1$$revision/" $$map ; \
	  done
	@ echo Here are my changes to the release maps:
	@ cd $(GODIPACK) && svn diff --diff-cmd diff -x "-C0"
	@ echo "Do you wish to proceed and commit changes to GODI (yes or no)?"
	@ read answer && if [ "$$answer" != "yes" ] ; then \
	  echo Aborting. ; \
	  exit 1 ; \
	fi
	@ cd $(GODIPACK) && svn commit -m "Updated release map for Menhir."
	@ echo "You may now open GODI's release tool at"
	@ echo "        $(GODIURL)"
	@ echo "and proceed as directed. I will try to open this URL for you."
	@ case $$OSTYPE in \
	(linux*) \
	  su fpottier -c "firefox $(GODIURL)" ;; \
	(*) \
	  open $(GODIURL) ;; \
	esac