forked from ocaml/v2.ocaml.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.common
126 lines (100 loc) · 4.74 KB
/
Makefile.common
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
# -*- mode: Makefile-gmake -*-
ifeq ($(LATEST_OCAML_VERSION),)
export LATEST_OCAML_VERSION := $(shell opam list -V ocaml-base-compiler --no-switch -s --columns version | tail -n 1)
export LATEST_OCAML_MAJOR := $(shell echo $(LATEST_OCAML_VERSION) | cut -d . -f 1)
export LATEST_OCAML_MINOR := $(shell echo $(LATEST_OCAML_VERSION) | cut -d . -f 2)
export LATEST_OCAML_VERSION_MAIN := $(LATEST_OCAML_MAJOR).$(LATEST_OCAML_MINOR)
endif
MPP_OPTIONS = -so '((!' -sc '!))' -son '{{!' -scn '!}}' -soc '' -scc '' -sec '' -sos '{{<' -scs '>}}' -its -set "LATEST_OCAML_VERSION=$(LATEST_OCAML_VERSION)" -set "LATEST_OCAML_VERSION_MAIN=$(LATEST_OCAML_VERSION_MAIN)" $(SET_STAGING)
MPP = mpp ${MPP_OPTIONS}
OMD_OPTIONS = -r ocaml=script/ocamltohtml -r tryocaml=script/ocamlapplet.bash
OMD = omd ${OMD_OPTIONS}
OMD_PP = script/md_preprocess
OCAML_VERSION = $(shell ocamlc -config | grep version | sed -e "s/version: *//")
OCAMLFLAGS = -annot -g
OCAMLOPT = ocamlfind ocamlopt $(OCAMLFLAGS)
OCAMLC = ocamlfind ocamlc $(OCAMLFLAGS)
HAS_SAFE_STRING=$(shell ocaml --help|grep safe-string)
ifneq ($(HAS_SAFE_STRING),)
OCAMLFLAGS := $(OCAMLFLAGS) -safe-string
endif
# Things to create before launching the parallel page build
pre-build: template/main.mpp template/footer.mpp \
template/front_code_snippet.html template/learn_code_snippet.html \
script/breadcrumb script/translations \
script/code_top script/ocamltohtml script/rss2html script/weekly_news \
script/lang_of_filename script/translate script/link_of_lang \
opam_update_list $(OMD_PP)
UTILS_DEP = $(addprefix script/utils., cmi cmo cmx)
CODE_TYPE_DEP = $(addprefix script/code_types., cmi cmo cmx)
template/%_code_snippet.html:template/%_code_snippet.md $(OMD_PP)
cat "$<" | $(OMD_PP) | ${OMD} -o $@
opam_update_list: script/generate_opam_update_list
curl -O https://opam.ocaml.org/json/last10_updates.json
script/generate_opam_update_list
script/generate_opam_update_list: script/generate_opam_update_list.ml
cd script && \
$(OCAMLOPT) -o ../"$@" -package cow \
-linkpkg generate_opam_update_list.ml
script/lang_of_filename: script/lang_of_filename.ml $(UTILS_DEP)
cd script && \
$(OCAMLOPT) -o ../"$@" -package str,netstring -linkpkg \
utils.cmx lang_of_filename.ml
script/translate: script/translate.ml $(UTILS_DEP)
cd script && \
$(OCAMLOPT) -o ../"$@" -package str,netstring -linkpkg \
utils.cmx translate.ml
script/link_of_lang: script/link_of_lang.ml $(UTILS_DEP)
cd script && \
$(OCAMLOPT) -o ../"$@" -package str,netstring -linkpkg \
utils.cmx link_of_lang.ml
script/breadcrumb: script/breadcrumb.ml $(UTILS_DEP)
cd script && \
$(OCAMLOPT) -o ../"$@" -package str,netstring -linkpkg \
utils.cmx breadcrumb.ml
script/rss2html: script/rss2html.ml script/http.ml $(UTILS_DEP)
cd script && \
$(OCAMLOPT) -package cohttp-lwt-unix,netstring,syndic \
-thread -linkpkg utils.cmx http.ml rss2html.ml -o ../"$@"
script/weekly_news: script/weekly_news.ml script/http.ml $(UTILS_DEP)
cd script && \
$(OCAMLOPT) -package cohttp-lwt-unix,netstring,syndic \
-thread -linkpkg utils.cmx http.ml weekly_news.ml -o ../"$@"
script/ocamltohtml:script/lexer.ml script/ocamltohtml.ml
cd script && \
$(OCAMLOPT) -o ../$@ lexer.ml ocamltohtml.ml
script/md_preprocess: $(CODE_TYPE_DEP) script/code.ml \
script/md_preprocess.ml $(UTILS_DEP)
cd script && \
$(OCAMLOPT) -o ../"$@" -package omd,str,netstring -linkpkg \
utils.cmx code_types.cmx code.ml md_preprocess.ml
script/code_top: $(CODE_TYPE_DEP) script/code_top.ml $(UTILS_DEP)
cd script && \
$(OCAMLC) -o ../"$@" -package unix,netstring,dynlink,compiler-libs.toplevel \
-linkpkg utils.cmo code_types.cmo code_top.ml
RELATIVE_URLS_DEP=script/urlfun.ml script/urlfun.mli $(UTILS_DEP)
script/relative_urls: script/relative_urls.ml $(RELATIVE_URLS_DEP)
cd script && \
$(OCAMLOPT) -package uri,netstring -linkpkg \
utils.cmx urlfun.mli urlfun.ml relative_urls.ml -o ../"$@"
RELATIVE_URLS_DEP=script/urlfun.ml script/urlfun.mli $(UTILS_DEP)
script/absolute_urls: script/absolute_urls.ml $(RELATIVE_URLS_DEP)
cd script && \
$(OCAMLOPT) -package uri,netstring -linkpkg \
utils.cmx urlfun.mli urlfun.ml absolute_urls.ml -o ../"$@"
htmlescape:htmlescape.ml
$(OCAMLOPT) $< -o $@
script/translations: script/translations.ml $(UTILS_DEP)
cd script && \
$(OCAMLOPT) -o ../"$@" -package str,netstring -linkpkg \
utils.cmx translations.ml
script/%.cmx: script/%.ml script/%.cmi
$(OCAMLOPT) -package netstring,syndic \
-c $< -o $@
script/%.cmi script/%.cmo: script/%.ml
$(OCAMLC) -package netstring,syndic -c $< -o $@
TRASH += template/front_code_snippet.html opam_update_list \
$(addprefix script/, generate_opam_update_list lang_of_filename translate \
link_of_lang breadcrumb rss2html ocamltohtml md_preprocess \
code_top relative_urls translations )
.PHONY: pre-build