-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile.in
175 lines (149 loc) · 5.48 KB
/
Makefile.in
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#
# sample Makefile for Objective Caml
# Copyright (C) 2001 Jean-Christophe FILLIATRE
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License version 2, as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See the GNU Library General Public License version 2 for more details
# (enclosed in the file LGPL).
# where to install the binaries
prefix=@prefix@
exec_prefix=@exec_prefix@
BINDIR=@bindir@
# where to install the man page
MANDIR=@mandir@
# other variables set by ./configure
OCAMLC = @OCAMLC@
OCAMLOPT = @OCAMLOPT@
OCAMLDEP = @OCAMLDEP@
OCAMLLEX = @OCAMLLEX@
OCAMLYACC= @OCAMLYACC@
OCAMLLIB = @OCAMLLIB@
OCAMLBEST= @OCAMLBEST@
OCAMLVERSION = @OCAMLVERSION@
OCAMLWEB = @OCAMLWEB@
OCAMLWIN32 = @OCAMLWIN32@
EXE = @EXE@
OPAM = @OPAM@
OPAMBINDIR = @OPAMBINDIR@
OPAMLIBDIR = @OPAMLIBDIR@
OCAMLBUILD = @OCAMLBUILD@
OCAMLFIND = @OCAMLFIND@
OPAM = @OPAM@
######################################
SRC_DIR := src
NAME := fjs_of_fml
STDLIB_DIR := $(SRC_DIR)/stdlib_fml
OCAMLBUILDCMD := $(OCAMLBUILD) -j 4 -classic-display -use-ocamlfind -I $(SRC_DIR) -I $(STDLIB_DIR) -no-hygiene
TESTS_DIR := tests
EXECUTABLES := $(NAME) monad_ppx displayed_sources lineof assembly
BYTES := $(addsuffix .byte,$(EXECUTABLES))
NATIVES := $(addsuffix .native,$(EXECUTABLES))
OCAMLDOT_DIR := $(SRC_DIR)/utils/ocamldot
OCAMLDOT := $(OCAMLDOT_DIR)/ocamldot
FJS_OPAM_LIB_DIR := $(OPAMLIBDIR)/$(NAME)
FJS_OPAM_STD_LIB := $(FJS_OPAM_LIB_DIR)/stdlib_fml
FJS_OPAM_TESTS_DIR := $(FJS_OPAM_LIB_DIR)/tests
BYTES_OPAM := $(addprefix $(OPAMBINDIR)/,$(BYTES))
NATIVES_OPAM := $(addprefix $(OPAMBINDIR)/,$(NATIVES))
GIT_REPO := https://github.com/jscert/$(NAME).git
GIT_BRANCH := $$(git rev-parse --abbrev-ref HEAD)
TMP_DIR := /tmp
TMP_NAME := $(TMP_DIR)/$(NAME)
VERSION := 1.0
TGZ := $(NAME)-$(VERSION).tar.gz
MD5TXT := $(TGZ).md5sum.txt
OPAM_REPO_GIT := ~/git/opam-repository
DATE_ARCHIVE := $(shell date +%Y-%m-%d-%H-%M-%S)
TGZ_ARCHIVE := $(NAME)-$(VERSION)-$(DATE_ARCHIVE).tar.gz
# Maybe fjs_of_fml could have its own repository
OPAM_PROD_DIR := /home/groups/jsexplain/htdocs/opam/$(NAME)
######################################
default: ocamlbuild byte stdlib
all: ocamlbuild byte native stdlib
byte: $(BYTES)
native: $(NATIVES)
test: byte stdlib
$(MAKE) -C $(TESTS_DIR) test
stdlib:
$(MAKE) -C $(STDLIB_DIR)
ocamlbuild :
eval $$(opam env)
# Rules
%.native: FORCE
$(OCAMLBUILDCMD) $@
%.byte: FORCE
$(OCAMLBUILDCMD) $@
# Debug
debug: $(addsuffix .d.byte,$(EXECUTABLES)) .ocamldebug
.ocamldebug: _tags
grep -o "package([^)]*)" _tags | sed "s/package(\([^)]*\))/\1/" | xargs $(OCAMLFIND) query -recursive | sed "s/^/directory /" > .ocamldebug
# Archi
ocamldot :
$(MAKE) -C $(OCAMLDOT_DIR)
archi : ocamldot
cd $(SRC_DIR) ; $(OCAMLDEP) *.ml > .depend
cat $(SRC_DIR)/.depend | $(OCAMLDOT) | dot -Tpdf > archi_generator.pdf
# Opam Install
opam_install : all
ifeq ($(OPAM),opam)
ifneq ($(OPAMBINDIR),)
ifneq ($(OPAMLIBDIR),)
@cp $(BYTES) $(NATIVES) $(OPAMBINDIR)
@mkdir -p $(FJS_OPAM_LIB_DIR)
@mkdir -p $(FJS_OPAM_STD_LIB)
@cp $(STDLIB_DIR)/*.cm* $(FJS_OPAM_STD_LIB)
@cp $(STDLIB_DIR)/stdlib_fml.js $(FJS_OPAM_STD_LIB)
endif
endif
endif
# Deployment
# Inria gorge : https://gforge.inria.fr/
# INFO : ssh connexion can be done this way ssh scm.gforge.inria.fr -l <LOGIN>
# files are in /home/groups/jsexplain
# Caution : One could say that these commands should be remove from the Makefile for security
# reasons.
# WARNING : Archive file is based on current branch !
$(TGZ) :
rm -rf $(TMP_NAME) $(TGZ)
mkdir $(TMP_NAME)
git clone $(GIT_REPO) $(TMP_NAME)
git -C $(TMP_NAME)/ checkout $(GIT_BRANCH)
rm -rf $(TMP_NAME)/.git
tar -cvzf $(TGZ) -C $(TMP_DIR) $(NAME)
md5sum $(TGZ) > $(MD5TXT)
# WARNING : md5sum of opam file in the tgz archive won't ever be the same
# as the one in opam-repository.
# This should not be an issue since the md5sum checked is the one in
# in Opam repository not the one in the archive.
# And it's done only at dowload time, not when the package is pinned.
opam_file_update : $(TGZ)
sed -i -r 's|^(\schecksum: "md5\s*=\s*).*"|\1'$$(cat *.txt | cut -d" " -f 1)'"|' opam
cp opam $(OPAM_REPO_GIT)/packages/$(NAME)/$(NAME).$(VERSION)
# WARNING/FIXME : On version upgrade archive will fail.
# Manual backup on forge will be needed.
# scp copy could be based on $(NAME)-*.tar.gz but deletion would still remain a problem ...
deploy : opam_file_update
read -p "User ?" FORGE_USER; \
scp -p [email protected]:$(OPAM_PROD_DIR)/$(TGZ) $(TMP_DIR)/$(TGZ_ARCHIVE); \
scp -p $(TMP_DIR)/$(TGZ_ARCHIVE) [email protected]:$(OPAM_PROD_DIR)/old/$(TGZ_ARCHIVE); \
scp -p $(TGZ) [email protected]:$(OPAM_PROD_DIR)
# Clean
clean:
$(OCAMLBUILD) -clean
rm -f .ocamldebug $(SRC_DIR)/.depend archi_generator.pdf configure $(TGZ) $(TGZ).md5sum.txt $(SRC_DIR)/*.cmi
rm -f $(BYTES_OPAM) $(NATIVES_OPAM)
rm -rf $(FJS_OPAM_LIB_DIR)
$(MAKE) -C $(STDLIB_DIR) clean
$(MAKE) -C $(OCAMLDOT_DIR) clean
$(MAKE) -C $(TESTS_DIR) clean
rm -rf autom4te.cache config.log config.status
.PHONY: default all byte native stdlib debug clean ocamldot archi opam_install opam_file_update deploy
FORCE: # Force rebuilds of OCaml targets via ocamlbuild, the FORCE file must not exist.
.NOTPARALLEL: # Only one ocamlbuild can be run at a time