-
Notifications
You must be signed in to change notification settings - Fork 7
/
OMakefile
165 lines (154 loc) · 5.16 KB
/
OMakefile
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
.PHONY: clean all distclean install uninstall lib test examples minimal
VERSION=0.3.3
PROJNAME=uwt
USE_OCAMLFIND= true
BYTE_ENABLED= true
include OMakeIncludes
include OMakeCFLAGS
CompileLibuv(build_jobs)=
if $(equal $(OSTYPE),Win32)
x=$(shell-code sh libuv-compile.sh "$(OCAMLC_CC)" "$(OCAMLC_CC_CFLAGS)" false "$(OCAMLC_SYSTEM)" "$(build_jobs)")
if $(not $(eq $(x), 0))
y[]=
return($(y))
if $(or $(equal $(OCAMLC_SYSTEM),win32), $(equal $(OCAMLC_SYSTEM),win64))
LIBUV_LDFLAGS[]=libuv.lib advapi32.lib iphlpapi.lib psapi.lib shell32.lib userenv.lib ws2_32.lib user32.lib
export
else
LIBUV_LDFLAGS[]=-luv -ladvapi32 -liphlpapi -lpsapi -lshell32 -luserenv -lws2_32 -luser32
export
return($(LIBUV_LDFLAGS))
else
x=$(shell-code ./libuv-compile.sh "$(OCAMLC_CC)" "$(OCAMLC_CC_CFLAGS)" true "$(OCAMLC_SYSTEM)" "$(build_jobs)")
if $(not $(eq $(x), 0))
y[]=
return($(y))
LIBUV_LDFLAGS=$(shell awk $''/^Lib/ {for(i=3;i<NF;i++)printf "%s",$i OFS; if (NF) printf "%s",$NF; printf ORS}'' libuv/libuv.pc )
return($(LIBUV_LDFLAGS))
static.=
PATH_PKG_CONFIG=$(Check_prog_in_path pkg-config)
if $(equal $(PATH_PKG_CONFIG), false)
PATH_PKG_CONFIG=$(Check_prog_in_path pkgconf)
export
pkg_config_libuv=$(pkg_config LIBUV,libuv)
pkg_config_libuv=
if $(not $(pkg_config_libuv))
value false
else
value $(pkg_config_between_vers LIBUV,libuv,1.8,2.0)
force_internal=
x=$(GetVarEnv BUILD_LIBUV)
value $(or $(equal $(x),$'1'), $(equal $(x),$'true'))
LIBUV_CFLAGS=$(GetVarEnv LIBUV_CFLAGS)
LIBUV_LDFLAGS=$(GetVarEnv LIBUV_LDFLAGS)
UWT_BUILD_JOBS=$(GetVarEnv UWT_BUILD_JOBS)
# BUILD_LIBUV comes first, then LIBUV_CFLAGS / LIBUV_LDFLAGS are picked from the environment, then pkg-config
if $(and $(not $(force_internal)), $(or $(not $(equal $(LIBUV_LDFLAGS),$(EMPTY))), $(not $(equal $(LIBUV_CFLAGS),$(EMPTY)))))
CFLAGS_LIBUV=$(LIBUV_CFLAGS)
LDFLAGS_LIBUV=$(LIBUV_LDFLAGS)
INTERNAL_LIBUV=$(EMPTY)
export CFLAGS_LIBUV LDFLAGS_LIBUV INTERNAL_LIBUV
elseif $(and $(pkg_config_libuv), $(not $(force_internal)))
export
INTERNAL_LIBUV=$(EMPTY)
else
x=
try
value $(getvar BUILD_LIBUV)
default
value $''t''
if $(or $(equal $(x),$''0''), $(equal $(x),$''false''))
$(ConfMsgError $''libuv missing'')
if $(not $(or $(equal $(x),$'1'), $(equal $(x),$'true')))
ConfMsgWarn($''libuv not found. I will try to compile it from source'')
LDFLAGS_LIBUV=$(CompileLibuv $(UWT_BUILD_JOBS))
if $(eq 0, $(LDFLAGS_LIBUV.length))
$(ConfMsgError $''couldn't compile libuv'')
if $(not $(or $(equal $(OCAMLC_SYSTEM),win32), $(equal $(OCAMLC_SYSTEM),win64)))
LDFLAGS_LIBUV[]=-L. $(LDFLAGS_LIBUV)
export
CFLAGS_LIBUV=
x=$(absname libuv/include)
if $(or $(equal $(OCAMLC_SYSTEM),win32), $(equal $(OCAMLC_SYSTEM),win64))
value -I$(x)
elseif $(equal $(OSTYPE),Win32)
value -I$(shell cygpath "$(x)")
else
value -I$(x)
if $(or $(equal $(OCAMLC_SYSTEM),win32), $(equal $(OCAMLC_SYSTEM),win64))
INTERNAL_LIBUV=$(file libuv/Release/lib/libuv.lib)
export
else
INTERNAL_LIBUV=$(file libuv/.libs/libuv.a)
export
export CFLAGS_LIBUV LDFLAGS_LIBUV INTERNAL_LIBUV
HAVE_LWT=
t=$(shell-code $(OCAMLFIND) query lwt >$(NULL_DEVICE))
value $(if $(equal $(t),0), true, false)
if $(equal $(Check_prog_in_path cppo), false)
$(ConfMsgError $''cppo missing'')
if $(equal $(BYTE_ENABLED), true)
export
OCAMLCFLAGS= -g -bin-annot
OCAMLOPTFLAGS= -g
else
export
OCAMLCFLAGS= -g
OCAMLOPTFLAGS= -g -bin-annot
if $(not $(equal $(getenv DEBUG_MY_CODE, $(EMPTY)), $(EMPTY)))
export
CFLAGS= $(CFLAGS) $(DEVCFLAGS)
OCAMLFLAGS= -strict-sequence -principal -safe-string -w A-4 -warn-error +1..49-3-4-45
else
export
# omake sets OCAMLFLAGS to '-warn-error A' by default which usually
# breaks compilation every time a new ocaml version is released
OCAMLFLAGS= -safe-string -warn-error +1..49-3-4
if $(not $(or $(equal $(OCAMLC_SYSTEM),win32), $(equal $(OCAMLC_SYSTEM),win64)))
CFLAGS= $(CFLAGS) -O2 -g
export
HAVE_LWT_LOG=$(eq 0,$(shell-code ocamlfind query lwt_log.core >$(NULL_DEVICE)))
if $(equal $(HAVE_LWT_LOG),true)
LOGS_PKG = lwt_log.core
export
else
LOGS_PKG = lwt.log
export
export OCAMLFLAGS OCAMLCFLAGS OCAMLOPTFLAGS CFLAGS LDFLAGS_LIBUV CFLAGS_LIBUV INTERNAL_LIBUV HAVE_LWT INTERNAL_LIBUV UWT_BUILD_JOBS LOGS_PKG
.PHONY: libuv-compile
libuv-compile:
section
echo $(CompileLibuv $(UWT_BUILD_JOBS))
if $(or $(lt $(OCAMLC_VERSION_MAJOR),4),$(and $(eq 4,$(OCAMLC_VERSION_MAJOR)),$(lt $(OCAMLC_VERSION_MINOR),3)))
OCAMLFINDFLAGS+= -open Result
OCAMLPACKS+= result
RESULT_PKG = $'' result''
export
else
RESULT_PKG = $(EMPTY)
export
.DEFAULT: all
.SUBDIRS: src src-log examples test
clean::
clean-helper()
rm -f oUnit*.log setup.data setup.log
distclean:: clean
rm -f *~ .*~ *.xz *.gz *.tar.*
rm -rf libuv-v*
.PHONY: opam-install
opam-install:: install
section
t=
x=$(GetVarEnv PREFIX)
if $(equal $(x),$(EMPTY))
value $(shell opam config var prefix)
else
value $(x)
docdir=$(t)/doc/uwt
mkdir(0o755,-p $(docdir))
cp(CHANGES.md LICENSE.md README.md $(docdir))
if $(not $(equal $(INTERNAL_LIBUV),$(EMPTY)))
cp(libuv/LICENSE $(docdir))
.PHONY: echo-pkg
echo-pkg:
@echo $(PROJNAME)-$(VERSION)