GNUmakefile 4.52 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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
# -------------------------------------------------------------------------

# This Makefile is not distributed.

SHELL := bash
export CDPATH=

.PHONY: package check export tag opam pin unpin

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

include Makefile

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

# Utilities.

MD5SUM  := $(shell if command -v md5 >/dev/null 2>/dev/null ; \
                   then echo "md5 -r" ; else echo md5sum ; fi)

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

# 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)

PROJECT  := inferno
PACKAGE  := $(PROJECT)-$(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/ directory, which requires
# special treatment.

DISTRIBUTED_FILES := AUTHORS LICENSE Makefile README.md

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

# 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/lib
	@ cp $(DISTRIBUTED_FILES) $(PACKAGE)
	@ cp src/Makefile src/META src/_tags $(PACKAGE)/src
	@ cp src/lib/*.{ml,mli,mlpack} $(PACKAGE)/src/lib
# Set the version number into the files that mention it.
	@ echo "Setting version to $(DATE)."
	@ echo version = \"$(DATE)\" >> $(PACKAGE)/src/META
# Create the tarball.
	@ echo "Creating a tarball."
	tar --exclude-from=.gitignore -cvz -f $(TARBALL) $(PACKAGE)
	@ 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/$(PROJECT)-test.XXXXXX` && { \
	echo "   * Extracting. " && \
	(cd $$TEMPDIR && tar xfz $(TARBALL)) && \
	echo "   * Compiling and installing." && \
	(cd $$TEMPDIR/$(PACKAGE) && make reinstall \
	) > $$TEMPDIR/install.log 2>&1 \
		|| (cat $$TEMPDIR/install.log; exit 1) && \
	echo "   * Uninstalling." && \
	(cd $$TEMPDIR/$(PACKAGE) && make uninstall \
	) > $$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/$(PROJECT)/

export:
	$(RSYNC) $(TARBALL) $(TARGET)

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

# Creating a git tag.

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

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

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

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

# Pinning.

pin:
	opam pin add $(PROJECT) `pwd` -k git

unpin:
	opam pin remove $(PROJECT)