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

# This Makefile is not distributed.

SHELL := bash
export CDPATH=

8
.PHONY: package check export tag opam pin unpin versions
9 10 11

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

12
include Makefile
13 14 15 16 17

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

# Utilities.

POTTIER Francois committed
18 19
MD5SUM  := $(shell if command -v md5 >/dev/null 2>/dev/null ; \
                   then echo "md5 -r" ; else echo md5sum ; fi)
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39

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

# Distribution.

# The version number is automatically set to the current date,
# unless DATE is defined on the command line.
DATE     := $(shell /bin/date +%Y%m%d)

PACKAGE  := visitors-$(DATE)
CURRENT  := $(shell pwd)
TARBALL  := $(CURRENT)/$(PACKAGE).tar.gz

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

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

POTTIER Francois committed
40
DISTRIBUTED_FILES := AUTHORS CHANGES.md LICENSE Makefile
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58

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

# Creating a tarball for distribution.

package:
# Make sure the correct version is installed.
	@ make -C src reinstall
# Create a directory to store the distributed files temporarily.
	@ rm -rf $(PACKAGE)
	@ mkdir -p $(PACKAGE)/src
	@ cp $(DISTRIBUTED_FILES) $(PACKAGE)
	@ cp src/*.ml{,i,lib} src/Makefile src/Makefile.preprocess src/META src/_tags $(PACKAGE)/src
# Set the version number into the files that mention it.
# These include version.tex, META.
	@ echo "Setting version to $(DATE)."
	@ echo version = \"$(DATE)\" >> $(PACKAGE)/src/META
# Copy and compile the documentation.
59 60
# This requires %.processed.ml files in the test/ directory,
# which in turn requires building (and installing) in src/.
61 62 63 64 65 66 67
	@ echo "Generating the documentation."
	@ cp -r doc test $(PACKAGE)
	@ make -C $(PACKAGE)/test clean processed
	@ echo '\gdef\visitorsversion{$(DATE)}' > $(PACKAGE)/doc/version.tex
	@ make -C $(PACKAGE)/doc clean all
	@ mv $(PACKAGE)/doc/main.pdf $(PACKAGE)/manual.pdf
	@ rm -rf $(PACKAGE)/doc $(PACKAGE)/test
68
	@ make -C $(PACKAGE)/src clean
69 70
# Create the tarball.
	@ echo "Creating a tarball."
71
	tar --exclude-from=.gitignore -cvz -f $(TARBALL) $(PACKAGE)
72 73 74 75 76 77 78 79 80 81 82 83 84
	@ echo "The package $(PACKAGE).tar.gz is ready."

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

# Checking the tarball that was created above.

check:
	@ echo "Checking the package ..."
# Create a temporary directory; extract, build, and install.
	@ TEMPDIR=`mktemp -d /tmp/visitors-test.XXXXXX` && { \
	echo "   * Extracting. " && \
	(cd $$TEMPDIR && tar xfz $(TARBALL)) && \
	echo "   * Compiling and installing." && \
85
	(cd $$TEMPDIR/$(PACKAGE) && make reinstall \
86 87 88
	) > $$TEMPDIR/install.log 2>&1 \
		|| (cat $$TEMPDIR/install.log; exit 1) && \
	echo "   * Uninstalling." && \
89
	(cd $$TEMPDIR/$(PACKAGE) && make uninstall \
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
	) > $$TEMPDIR/uninstall.log 2>&1 \
		|| (cat $$TEMPDIR/uninstall.log; exit 1) && \
	rm -rf $$TEMPDIR ; }
	@ echo "The package $(PACKAGE) seems ready for distribution!"

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

# Copying the tarball to my Web site.

RSYNC   := scp -p -C
TARGET  := yquem.inria.fr:public_html/visitors/
PAGE    := $(HOME)/dev/page

export:
# Copier l'archive et la doc vers yquem.
	$(RSYNC) $(TARBALL) $(TARGET)
	$(RSYNC) $(PACKAGE)/manual.pdf $(TARGET)

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

110 111 112 113 114 115 116
# Creating a git tag.

tag:
	git tag -a $(DATE) -m "Release $(DATE)."

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

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
# 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) visitors-$(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 package, based on the last one.
	@ echo "Creating a new package description visitors-$(DATE)..."
	@ cd $(OPAM)/packages/visitors && \
	  cp -r `ls | grep visitors | tail -1` visitors.$(DATE)
# Update the file "url".
	@ cd $(OPAM)/packages/visitors/visitors.$(DATE) && \
	  rm url && \
	  echo 'archive: "http://gallium.inria.fr/~fpottier/visitors/visitors-$(DATE).tar.gz"' >> url && \
	  echo 'checksum: "$(CSUM)"' >> url
# Copy the file "opam" from Visitors's repository to opam's.
	@ cp -f opam $(OPAM)/packages/visitors/visitors.$(DATE)
# Prepare a commit.
	@ echo "Preparing a new commit..."
	@ cd $(OPAM)/packages/visitors && \
	  git add visitors.$(DATE) && \
	  git status
# Ask for review.
	@ echo "If happy, please run:"
	@ echo "  cd $(OPAM)/packages/visitors && git commit -a && git push && firefox https://github.com/"
	@ echo "and issue a pull request."

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

# Pinning.

pin:
	opam pin add visitors `pwd` -k git

unpin:
	opam pin remove visitors
161 162 163 164 165 166 167 168 169 170 171 172 173

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

# Trying out compilation under multiple versions of OCaml.

versions:
	for i in 4.02.3 4.03.0 4.04.0 4.05.0 4.06.0 ; do \
	  opam switch $$i && eval `opam config env` && ocamlc -v && \
	  opam install hashcons ppx_deriving ppx_import ocp-indent && \
	  make clean && \
	  make && \
	  make reinstall ; \
	done