GNUmakefile 4.52 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's avatar
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's avatar
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
	) > $$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/

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

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

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

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

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

116 117 118 119 120 121 122 123
# Updating the opam package.

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

CSUM  = $(shell $(MD5SUM) visitors-$(DATE).tar.gz | cut -d ' ' -f 1)

opam:
POTTIER Francois's avatar
POTTIER Francois committed
124
	echo "This GNUmakefile entry needs to be updated to use opam publish."
125 126 127 128 129 130 131 132 133 134

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

# Pinning.

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

unpin:
	opam pin remove visitors
135 136 137 138 139

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

# Trying out compilation under multiple versions of OCaml.

POTTIER Francois's avatar
POTTIER Francois committed
140 141
# TEMPORARY (ppx_import currently unavailable on 4.08)

142
versions:
POTTIER Francois's avatar
POTTIER Francois committed
143
	for i in 4.02.3 4.03.0 4.04.0 4.05.0 4.06.0 4.07.0 4.08.0 ; do \
144
	  opam switch $$i && eval `opam config env` && ocamlc -v && \
POTTIER Francois's avatar
POTTIER Francois committed
145
	  opam install hashcons ppx_deriving ocp-indent && \
146 147 148 149
	  make clean && \
	  make && \
	  make reinstall ; \
	done