Makefile 5.58 KB
Newer Older
1 2
# This Makefile started being auto-generated, but now it's hand-crafted and automatically finds all the files.
# YOU SHOULD NOT HAVE TO EDIT THIS FILE.
Ralf Jung's avatar
Ralf Jung committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

.DEFAULT_GOAL := all

# 
# This Makefile may take arguments passed as environment variables:
# COQBIN to specify the directory where Coq binaries resides;
# ZDEBUG/COQDEBUG to specify debug flags for ocamlc&ocamlopt/coqc;
# DSTROOT to specify a prefix to install path.

# Here is a hack to make $(eval $(shell works:
define donewline


endef
includecmdwithout@ = $(eval $(subst @,$(donewline),$(shell { $(1) | tr -d '\r' | tr '\n' '@'; })))
$(call includecmdwithout@,$(COQBIN)coqtop -config)

##########################
#                        #
# Libraries definitions. #
#                        #
##########################

26 27
COQLIBS?=-I . -R lib/ModuRes ModuRes
COQDOCLIBS?=-R lib/ModuRes ModuRes
Ralf Jung's avatar
Ralf Jung committed
28 29 30 31 32 33 34 35 36

##########################
#                        #
# Variables definitions. #
#                        #
##########################


OPT?=
David Swasey's avatar
David Swasey committed
37
COQDEP?="$(COQBIN)coqdep" -c
Ralf Jung's avatar
Ralf Jung committed
38 39 40
COQFLAGS?=-q $(OPT) $(COQLIBS) $(OTHERFLAGS) $(COQ_XML)
COQCHKFLAGS?=-silent -o
COQDOCFLAGS?=-interpolate -utf8
David Swasey's avatar
David Swasey committed
41 42 43 44
COQC?="$(COQBIN)coqc"
GALLINA?="$(COQBIN)gallina"
COQDOC?="$(COQBIN)coqdoc"
COQCHK?="$(COQBIN)coqchk"
Ralf Jung's avatar
Ralf Jung committed
45 46 47 48 49 50 51 52

##################
#                #
# Install Paths. #
#                #
##################

ifdef USERINSTALL
David Swasey's avatar
David Swasey committed
53
XDG_DATA_HOME?="$(HOME)/.local/share"
Ralf Jung's avatar
Ralf Jung committed
54 55 56
COQLIBINSTALL=$(XDG_DATA_HOME)/coq
COQDOCINSTALL=$(XDG_DATA_HOME)/doc/coq
else
David Swasey's avatar
David Swasey committed
57 58
COQLIBINSTALL="${COQLIB}user-contrib"
COQDOCINSTALL="${DOCDIR}user-contrib"
Ralf Jung's avatar
Ralf Jung committed
59 60 61 62 63 64 65 66
endif

######################
#                    #
# Files dispatching. #
#                    #
######################

67
VFILES:=$(wildcard *.v)
Ralf Jung's avatar
Ralf Jung committed
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90

-include $(addsuffix .d,$(VFILES))
.SECONDARY: $(addsuffix .d,$(VFILES))

VOFILES:=$(VFILES:.v=.vo)
VOFILESINC=$(filter $(wildcard ./*),$(VOFILES)) 
GLOBFILES:=$(VFILES:.v=.glob)
VIFILES:=$(VFILES:.v=.vi)
GFILES:=$(VFILES:.v=.g)
HTMLFILES:=$(VFILES:.v=.html)
GHTMLFILES:=$(VFILES:.v=.g.html)
ifeq '$(HASNATDYNLINK)' 'true'
HASNATDYNLINK_OR_EMPTY := yes
else
HASNATDYNLINK_OR_EMPTY :=
endif

#######################################
#                                     #
# Definition of the toplevel targets. #
#                                     #
#######################################

91
all: $(VOFILES) ./lib/ModuRes
Ralf Jung's avatar
Ralf Jung committed
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

spec: $(VIFILES)

gallina: $(GFILES)

html: $(GLOBFILES) $(VFILES)
	- mkdir -p html
	$(COQDOC) -toc $(COQDOCFLAGS) -html $(COQDOCLIBS) -d html $(VFILES)

gallinahtml: $(GLOBFILES) $(VFILES)
	- mkdir -p html
	$(COQDOC) -toc $(COQDOCFLAGS) -html -g $(COQDOCLIBS) -d html $(VFILES)

all.ps: $(VFILES)
	$(COQDOC) -toc $(COQDOCFLAGS) -ps $(COQDOCLIBS) -o $@ `$(COQDEP) -sort -suffix .v $^`

all-gal.ps: $(VFILES)
	$(COQDOC) -toc $(COQDOCFLAGS) -ps -g $(COQDOCLIBS) -o $@ `$(COQDEP) -sort -suffix .v $^`

all.pdf: $(VFILES)
	$(COQDOC) -toc $(COQDOCFLAGS) -pdf $(COQDOCLIBS) -o $@ `$(COQDEP) -sort -suffix .v $^`

all-gal.pdf: $(VFILES)
	$(COQDOC) -toc $(COQDOCFLAGS) -pdf -g $(COQDOCLIBS) -o $@ `$(COQDEP) -sort -suffix .v $^`

validate: $(VOFILES)
	$(COQCHK) $(COQCHKFLAGS) $(COQLIBS) $(notdir $(^:.vo=))

beautify: $(VFILES:=.beautified)
	for file in $^; do mv $${file%.beautified} $${file%beautified}old && mv $${file} $${file%.beautified}; done
	@echo 'Do not do "make clean" until you are sure that everything went well!'
	@echo 'If there were a problem, execute "for file in $$(find . -name \*.v.old -print); do mv $${file} $${file%.old}; done" in your shell/'

125
.PHONY: all opt byte archclean clean install userinstall depend html validate ./lib/ModuRes
Ralf Jung's avatar
Ralf Jung committed
126 127 128 129 130 131 132

###################
#                 #
# Subdirectories. #
#                 #
###################

133 134
./lib/ModuRes:
	cd ./lib/ModuRes ; $(MAKE) all
Ralf Jung's avatar
Ralf Jung committed
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151

####################
#                  #
# Special targets. #
#                  #
####################

byte:
	$(MAKE) all "OPT:=-byte"

opt:
	$(MAKE) all "OPT:=-opt"

userinstall:
	+$(MAKE) USERINSTALL=true install

install:
152
	install -d $(DSTROOT)$(COQLIBINSTALL)/ModuRes; \
Ralf Jung's avatar
Ralf Jung committed
153
	for i in $(VOFILESINC); do \
154
	 install -m 0644 $$i $(DSTROOT)$(COQLIBINSTALL)/ModuRes/`basename $$i`; \
Ralf Jung's avatar
Ralf Jung committed
155
	done
David Swasey's avatar
David Swasey committed
156
	+cd ./lib/ModuRes && $(MAKE) DSTROOT="$(DSTROOT)" INSTALLDEFAULTROOT="$(INSTALLDEFAULTROOT)/./lib/ModuRes" install
Ralf Jung's avatar
Ralf Jung committed
157 158

install-doc:
David Swasey's avatar
David Swasey committed
159
	install -d "$(DSTROOT)"$(COQDOCINSTALL)/ModuRes/html
Ralf Jung's avatar
Ralf Jung committed
160
	for i in html/*; do \
David Swasey's avatar
David Swasey committed
161
	 install -m 0644 $$i "$(DSTROOT)"$(COQDOCINSTALL)/ModuRes/$$i;\
Ralf Jung's avatar
Ralf Jung committed
162 163 164 165 166 167
	done

clean:
	rm -f $(VOFILES) $(VIFILES) $(GFILES) $(VFILES:.v=.v.d) $(VFILES:=.beautified) $(VFILES:=.old)
	rm -f all.ps all-gal.ps all.pdf all-gal.pdf all.glob $(VFILES:.v=.glob) $(VFILES:.v=.tex) $(VFILES:.v=.g.tex) all-mli.tex
	- rm -rf html mlihtml
168
	(cd ./lib/ModuRes ; $(MAKE) clean)
Ralf Jung's avatar
Ralf Jung committed
169 170 171

archclean:
	rm -f *.cmx *.o
172
	(cd ./lib/ModuRes ; $(MAKE) archclean)
Ralf Jung's avatar
Ralf Jung committed
173 174

printenv:
David Swasey's avatar
David Swasey committed
175 176 177 178 179 180 181
	@"$(COQBIN)coqtop" -config
	@echo 'CAMLC =	$(CAMLC)'
	@echo 'CAMLOPTC =	$(CAMLOPTC)'
	@echo 'PP =	$(PP)'
	@echo 'COQFLAGS =	$(COQFLAGS)'
	@echo 'COQLIBINSTALL =	$(COQLIBINSTALL)'
	@echo 'COQDOCINSTALL =	$(COQDOCINSTALL)'
Ralf Jung's avatar
Ralf Jung committed
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207

###################
#                 #
# Implicit rules. #
#                 #
###################

%.vo %.glob: %.v
	$(COQC) $(COQDEBUG) $(COQFLAGS) $*

%.vi: %.v
	$(COQC) -i $(COQDEBUG) $(COQFLAGS) $*

%.g: %.v
	$(GALLINA) $<

%.tex: %.v
	$(COQDOC) $(COQDOCFLAGS) -latex $< -o $@

%.html: %.v %.glob
	$(COQDOC) $(COQDOCFLAGS) -html $< -o $@

%.g.tex: %.v
	$(COQDOC) $(COQDOCFLAGS) -latex -g $< -o $@

%.g.html: %.v %.glob
David Swasey's avatar
David Swasey committed
208
	$(COQDOC) $(COQDOCFLAGS)  -html -g $< -o $@
Ralf Jung's avatar
Ralf Jung committed
209 210 211 212 213 214 215 216 217 218 219 220 221 222

%.v.d: %.v
	$(COQDEP) -slash $(COQLIBS) "$<" > "$@" || ( RV=$$?; rm -f "$@"; exit $${RV} )

%.v.beautified:
	$(COQC) $(COQDEBUG) $(COQFLAGS) -beautify $*

# WARNING
#
# This Makefile has been automagically generated
# Edit at your own risks !
#
# END OF WARNING