forked from math-comp/hierarchy-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
150 lines (116 loc) · 4.53 KB
/
Makefile
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
148
149
150
# -*- Makefile -*-
######################################################################
# USAGE: #
# #
# make all: Build the MathComp library entirely, #
# make test-suite: Run the test suite, #
# make only TGTS="...vo": Build the selected libraries of MathComp. #
# #
# The rules this-config::, this-build::, this-only::, #
# this-test-suite::, this-distclean::, this-clean:: #
# and __always__:: may be extended. #
# #
# Additionally, the following variables may be customized: #
SUBDIRS?=
COQBIN?=$(dir $(shell which coqtop))
COQMAKEFILE?=$(COQBIN)coq_makefile
COQDEP?=$(COQBIN)coqdep
COQPROJECT?=_CoqProject
COQMAKEOPTIONS?=
COQMAKEFILEOPTIONS?=
V?=
VERBOSE?=V
TGTS?=
######################################################################
# local context: -----------------------------------------------------
.PHONY: all config build only test-suite clean distclean __always__
.SUFFIXES:
H:= $(if $(VERBOSE),,@) # not used yet
TOP = $(dir $(lastword $(MAKEFILE_LIST)))
COQMAKE = $(MAKE) -f Makefile.coq $(COQMAKEOPTIONS)
COQMAKE_TESTSUITE = $(MAKE) -f Makefile.test-suite.coq $(COQMAKEOPTIONS)
BRANCH_coq:= $(shell $(COQBIN)coqtop -v | head -1 | grep -E '(trunk|master)' \
| wc -l | sed 's/ *//g')
# coq version:
ifneq "$(BRANCH_coq)" "0"
COQVVV:= dev
else
COQVVV:=$(shell $(COQBIN)coqtop --print-version | cut -d" " -f1)
endif
COQV:= $(shell echo $(COQVVV) | cut -d"." -f1)
COQVV:= $(shell echo $(COQVVV) | cut -d"." -f1-2)
ifneq "$(DESTDIR)" ""
HB_INSTALLDIR := $(DESTDIR)/bin
else
HB_INSTALLDIR := $(dir $(shell which $(COQBIN)coqc))
endif
# export to sub- targets
export COQBIN
export COQMAKEFILE
export COQV
export COQVV
export COQVVV
# all: ---------------------------------------------------------------
all:
$(MAKE) config
$(MAKE) build
$(MAKE) test-suite
# Makefile.coq: ------------------------------------------------------
Makefile.coq: $(COQPROJECT) Makefile
$(COQMAKEFILE) $(COQMAKEFILEOPTIONS) -f $(COQPROJECT) -o Makefile.coq
# Test suite ---------------------------------------------------------
Makefile.test-suite.coq: $(COQPROJECT).test-suite Makefile
$(COQMAKEFILE) $(COQMAKEFILEOPTIONS) -f $(COQPROJECT).test-suite -o Makefile.test-suite.coq
# Global config, build, clean and distclean --------------------------
config: sub-config this-config
build: sub-build this-build
only: sub-only this-only
test-suite: sub-test-suite this-test-suite
clean: sub-clean this-clean
rm -f coq.hb
distclean: sub-distclean this-distclean
# Local config, build, clean and distclean ---------------------------
.PHONY: this-config this-build this-only this-test-suite this-distclean this-clean
this-config:: __always__
this-build:: this-config coq.hb Makefile.coq
+$(COQMAKE)
this-only:: this-config Makefile.coq
+$(COQMAKE) only "TGTS=$(TGTS)"
this-test-suite:: build Makefile.test-suite.coq
+$(COQMAKE_TESTSUITE)
this-distclean:: this-clean
rm -f Makefile.coq Makefile.coq.conf
rm -f Makefile.test-suite.coq Makefile.test-suite.coq.conf
this-clean:: __always__
@if [ -f Makefile.coq ]; then $(COQMAKE) cleanall; fi
@if [ -f Makefile.test-suite.coq ]; then $(COQMAKE_TESTSUITE) cleanall; fi
# Install target -----------------------------------------------------
.PHONY: install
install: __always__ Makefile.coq
$(COQMAKE) install
install -d $(HB_INSTALLDIR)
install -m 0755 coq.hb $(HB_INSTALLDIR)
# counting lines of Coq code -----------------------------------------
.PHONY: count
COQFILES = $(shell grep '.v$$' $(COQPROJECT))
count:
@coqwc $(COQFILES) | tail -1 | \
awk '{printf ("%d (spec=%d+proof=%d)\n", $$1+$$2, $$1, $$2)}'
# Additionally cleaning backup (*~) files ----------------------------
this-distclean::
rm -f $(shell find . -name '*~')
# Make in SUBDIRS ----------------------------------------------------
ifdef SUBDIRS
sub-%: __always__
@set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d $(@:sub-%=%); done
else
sub-%: __always__
@true
endif
# Make of individual .vo ---------------------------------------------
structures.vo : %.vo: __always__ Makefile.coq
+$(COQMAKE) $@
coq.hb: hb.ml
ocamlc unix.cma str.cma -g hb.ml -o coq.hb
$(addsuffix o,$(wildcard examples/*.v examples/*/*.v tests/*.v)): __always__ config build Makefile.test-suite.coq
+$(COQMAKE_TESTSUITE) $@