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

# This Makefile is not distributed.

SHELL := bash
export CDPATH=

8
.PHONY: package export tag opam pin unpin
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

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

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)

29
# The project name.
30
PROJECT  := inferno
31
32
33
34
35
36
# The repository URL (https).
REPO     := https://gitlab.inria.fr/fpottier/$(PROJECT)
# The archive URL (https).
ARCHIVE  := $(REPO)/repository/$(DATE)/archive.tar.gz
# The local repository directory.
PWD      := $(shell pwd)
37
38
39

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

40
# Prepare a release.
41
42

package:
43
# Make sure the correct version can be installed.
44
	@ make -C src reinstall
45
# Update the version number in src/META.
46
	@ echo "Setting version to $(DATE)."
47
48
49
50
51
	@ mv src/META src/META.bak
	@ grep -v version src/META.bak > src/META
	@ echo version = \"$(DATE)\" >> src/META
	@ rm -f src/META.bak
	@ git commit -m "Update the version number." src/META
52
53
54

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

55
# Publish a release. (Remember to commit everything first!)
56
57

export:
58
# Check if everything has been committed.
POTTIER Francois's avatar
POTTIER Francois committed
59
	@ if [ -n "$$(git status --porcelain)" ] ; then \
60
61
62
	    echo "Error: there remain uncommitted changes." ; \
	    git status ; \
	    exit 1 ; \
POTTIER Francois's avatar
POTTIER Francois committed
63
64
	  else \
	    echo "Now making a release..." ; \
65
66
67
68
69
70
	  fi
# Create a git tag.
	@ git tag -a $(DATE) -m "Release $(DATE)."
# Upload. (This automatically makes a .tar.gz archive available on gitlab.)
	@ git push
	@ git push --tags
71
72
73
74
75
76
77
78
79

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

# 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
80
CSUM  = $(shell $(MD5SUM) $(PWD)/archive.tar.gz | cut -d ' ' -f 1)
81
82

opam:
83
84
# Get the .tar.gz archive, so as to compute its checksum.
	@ wget $(ARCHIVE)
85
86
87
88
89
90
91
92
93
94
95
96
# 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 && \
97
	  echo 'archive: "$(ARCHIVE)"' >> url && \
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
	  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)