GNUmakefile 8.44 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 export godi opam
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

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

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

export CDPATH=

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

50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
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
fpottier's avatar
fpottier committed
65
GODIMAP  := $(GODIPACK)/release.4.00.map $(GODIPACK)/release.4.01.map
66 67 68 69 70 71 72 73
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
74
DISTRIBUTED_FILES := AUTHORS CHANGES INSTALLATION LICENSE Makefile demos
75 76 77 78 79 80

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

LIBFILES := \
  src/standard.mly \
81
  src/convert.{ml,mli} \
82
  src/engine.{ml,mli} \
83 84
  src/engineTypes.ml \
  src/ErrorReporting.{ml,mli} \
85
  src/general.{ml,mli} \
86 87
  src/IncrementalEngine.ml \
  src/infiniteArray.{ml,mli} \
88 89
  src/inspectionTableFormat.ml \
  src/inspectionTableInterpreter.{ml,mli} \
90 91 92 93
  src/LinearizedArray.{ml,mli} \
  src/packedIntArray.{ml,mli} \
  src/Printers.{ml,mli} \
  src/rowDisplacement.{ml,mli}\
94
  src/tableFormat.ml \
95
  src/tableInterpreter.{ml,mli}
96 97 98

package: clean
# Create a directory to store the distributed files temporarily.
99
# In src/_tags, every line tagged "my_warnings" is removed.
100 101 102
	@ rm -fr $(PACKAGE)
	@ mkdir -p $(PACKAGE)/src
	@ cp -fr $(DISTRIBUTED_FILES) $(PACKAGE)
103 104
	@ cp -fr src/*.ml{,i,y,l,pack} src/Makefile src/META $(PACKAGE)/src
	@ grep -v my_warnings src/_tags > $(PACKAGE)/src/_tags
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
	@ $(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
122
	@ make -C $(PACKAGE)/doc clean all
123 124 125 126 127 128 129
	@ 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."
130
	tar --exclude=.gitignore -cvz -f $(TARBALL) $(PACKAGE)
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
	@ 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.

fpottier's avatar
fpottier committed
156
RSYNC   := scp -p -C
157 158
TARGET  := yquem.inria.fr:public_html/menhir/
PAGE    := /home/fpottier/dev/page
159
API     := convert.mli.html IncrementalEngine.ml.html general.mli.html
160 161 162 163 164 165 166

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.
167
	cd src && $(RSYNC) $(API) $(TARGET)
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 209 210 211 212 213 214 215 216 217 218 219 220 221
# 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
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

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

# 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."