-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
133 lines (91 loc) · 3.06 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
## Sample Makefile for eliom application.
APP_NAME := portal
STATICDIR := static/
## Packages required to build the server part of the application
SERVER_PACKAGES := yojson curl
## Packages to be linked in the client part
CLIENT_PACKAGES :=
## Source files for the server part
SERVER_FILES := \
tools.eliom \
github.ml \
gCal.eliom \
portal.eliom \
\
## Source files for the client part
CLIENT_FILES := \
tools.eliom \
portal.eliom \
\
## Required binaries
ELIOMC := eliomc
ELIOMOPT := eliomopt
ELIOMDEP := eliomdep
JS_OF_ELIOM := js_of_eliom
## Where to put intermediate object files.
## - ELIOM_{SERVER,CLIENT}_DIR must be distinct
## - ELIOM_CLIENT_DIR mustn't be the local dir.
## - ELIOM_SERVER_DIR could be ".", but you need to
## remove it from the "clean" rules...
export ELIOM_SERVER_DIR := _server
export ELIOM_CLIENT_DIR := _client
export ELIOM_TYPE_DIR := .
#####################################
all: byte install
byte:: ${APP_NAME}.cma ${APP_NAME}.js
opt:: ${APP_NAME}.cmxs ${APP_NAME}.js
#### Server side compilation #######
SERVER_INC := ${addprefix -package ,${SERVER_PACKAGES}}
SERVER_OBJS := $(patsubst %.eliom,${ELIOM_SERVER_DIR}/%.cmo, ${SERVER_FILES})
SERVER_OBJS := $(patsubst %.ml,${ELIOM_SERVER_DIR}/%.cmo, ${SERVER_OBJS})
${APP_NAME}.cma: ${SERVER_OBJS}
${ELIOMC} -a -o $@ $^
${APP_NAME}.cmxa: ${SERVER_OBJS:.cmo=.cmx}
${ELIOMOPT} -a -o $@ $^
${ELIOM_TYPE_DIR}/%.type_mli: %.eliom
${ELIOMC} -infer ${SERVER_INC} $<
${ELIOM_SERVER_DIR}/%.cmi: %.mli
${ELIOMC} -c ${SERVER_INC} $<
${ELIOM_SERVER_DIR}/%.cmo: %.ml
${ELIOMC} -c ${SERVER_INC} $<
${ELIOM_SERVER_DIR}/%.cmo: %.eliom
${ELIOMC} -c -noinfer ${SERVER_INC} $<
${ELIOM_SERVER_DIR}/%.cmx: %.ml
${ELIOMOPT} -c ${SERVER_INC} $<
${ELIOM_SERVER_DIR}/%.cmx: %.eliom
${ELIOMOPT} -c -noinfer ${SERVER_INC} $<
%.cmxs: %.cmxa
$(ELIOMOPT) -shared -linkall -o $@ $<
##### Client side compilation ####
CLIENT_LIBS := ${addprefix -package ,${CLIENT_PACKAGES}}
CLIENT_INC := ${addprefix -package ,${CLIENT_PACKAGES}}
CLIENT_OBJS := $(patsubst %.eliom,${ELIOM_CLIENT_DIR}/%.cmo, ${CLIENT_FILES})
CLIENT_OBJS := $(patsubst %.ml,${ELIOM_CLIENT_DIR}/%.cmo, ${CLIENT_OBJS})
${APP_NAME}.js: ${CLIENT_OBJS}
${JS_OF_ELIOM} -o $@ ${CLIENT_LIBS} $^
${ELIOM_CLIENT_DIR}/%.cmi: %.mli
${JS_OF_ELIOM} -c ${CLIENT_INC} $<
${ELIOM_CLIENT_DIR}/%.cmo: %.eliom
${JS_OF_ELIOM} -c ${CLIENT_INC} $<
${ELIOM_CLIENT_DIR}/%.cmo: %.ml
${JS_OF_ELIOM} -c ${CLIENT_INC} $<
############
## Clean up
clean:
-rm -f *.cm[ioax] *.cmxa *.cmxs *.o *.a *.annot
-rm -f *.type_mli
-rm -f ${APP_NAME}.js
-rm -rf ${ELIOM_CLIENT_DIR} ${ELIOM_SERVER_DIR}
distclean: clean.local
-rm -f *~ \#* .\#*
## Dependencies
## Dependencies
make_depend: ${SERVER_FILES} ${CLIENT_FILES}
$(ELIOMDEP) -server ${SERVER_INC} ${SERVER_FILES} > .depend
$(ELIOMDEP) -client ${CLIENT_INC} ${CLIENT_FILES} >> .depend
## Warning: Dependencies towards *.eliom are not handled by eliomdep yet.
include .depend
## installation #########
install:
@mkdir -p $(STATICDIR)/
@cp $(APP_NAME).js $(STATICDIR)/$(APP_NAME).js