forked from coq/coq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.ide
307 lines (242 loc) · 10.5 KB
/
Makefile.ide
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
176
177
178
179
180
181
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
##########################################################################
## # The Coq Proof Assistant / The Coq Development Team ##
## v # INRIA, CNRS and contributors - Copyright 1999-2019 ##
## <O___,, # (see CREDITS file for the list of authors) ##
## \VV/ ###############################################################
## // # This file is distributed under the terms of the ##
## # GNU Lesser General Public License Version 2.1 ##
## # (see LICENSE file for the text of the license) ##
##########################################################################
## Makefile rules for building the CoqIDE interface
## NB: For the moment, the build system of CoqIDE is part of
## the one of Coq. In particular, this Makefile.ide is included in
## Makefile.build. Please ensure that the rules define here are
## indeed specific to files of the form ide/*
## Coqide-related variables set by ./configure in config/Makefile
#HASCOQIDE : opt / byte / no
#IDEFLAGS : some extra cma, for instance
#IDEOPTCDEPS : on windows, ide/ide_win32_stubs.o ide/coq_icon.o
#IDECDEPS
#IDECDEPSFLAGS
#IDEINT : X11 / QUARTZ / WIN32
## CoqIDE Executable
COQIDEBYTE:=bin/coqide.byte$(EXE)
COQIDE:=bin/coqide$(EXE)
COQIDEAPP:=bin/CoqIDE_$(VERSION).app
COQIDEINAPP:=$(COQIDEAPP)/Contents/MacOS/coqide
## CoqIDE source directory and files
# Note : for just building bin/coqide, we could only consider
# config, lib, ide and ide/utils. But the coqidetop plugin (the
# one that will be loaded by coqidetop) refers to some
# core modules of coq, for instance printing/*.
IDESRCDIRS:= $(CORESRCDIRS) ide ide/protocol
ifeq ($(HASCOQIDE),no)
COQIDEFLAGS=$(addprefix -I , $(IDESRCDIRS))
else
COQIDEFLAGS=$(addprefix -I , $(IDESRCDIRS)) -package lablgtk3-sourceview3
endif
IDEDEPS:=config/config.cma clib/clib.cma lib/lib.cma ide/protocol/ideprotocol.cma
IDECMA:=ide/ide.cma
IDETOPEXE=bin/coqidetop$(EXE)
IDETOP=bin/coqidetop.opt$(EXE)
IDETOPBYTE=bin/coqidetop.byte$(EXE)
LINKIDE:=$(IDEDEPS) $(IDECDEPS) $(IDECMA) ide/coqide_os_specific.cmo ide/coqide_main.mli ide/coqide_main.ml
LINKIDEOPT:=$(IDEOPTCDEPS) $(patsubst %.cma,%.cmxa,$(IDEDEPS:.cmo=.cmx)) $(IDECMA:.cma=.cmxa) ide/coqide_os_specific.cmx ide/coqide_main.mli ide/coqide_main.ml
IDEBINDINGS:=ide/default.bindings
IDEBINDINGSSRC:=ide/default_bindings_src.ml
IDEBINDINGSEXE:=ide/default_bindings_src.exe
IDEFILES=$(wildcard ide/*.lang) ide/coq_style.xml ide/coq.png $(IDEBINDINGS)
## GTK for Coqide MacOS bundle
GTKSHARE=$(shell pkg-config --variable=prefix gtk+-3.0)/share
GTKBIN=$(shell pkg-config --variable=prefix gtk+-3.0)/bin
GTKLIBS=$(shell pkg-config --variable=libdir gtk+-3.0)
PIXBUFBIN=$(shell pkg-config --variable=prefix gdk-pixbuf-2.0)/bin
SOURCEVIEWSHARE=$(shell pkg-config --variable=prefix gtksourceview-3.0)/share
ADWAITASHARE=$(shell ls -d /usr/local/Cellar/adwaita-icon-theme/*)/share
###########################################################################
# CoqIde special targets
###########################################################################
.PHONY: coqide coqide-opt coqide-byte coqide-bindings coqide-files coqide-binaries
.PHONY: ide-toploop ide-byteloop ide-optloop
# target to build CoqIde (native version) and the stuff needed to launch it
coqide: coqide-files coqide-opt theories/Init/Prelude.$(VO) $(TOPBIN)
# target to build CoqIde (in native and byte versions), and no more
# NB: this target is used in the opam package coq-coqide
coqide-binaries: coqide-opt coqide-byte
ifeq ($(HASCOQIDE),opt)
coqide-opt: $(COQIDE) ide-toploop
else
coqide-opt: ide-toploop
endif
ifeq ($(HASCOQIDE),no)
coqide-byte: ide-byteloop
else
coqide-byte: $(COQIDEBYTE) ide-byteloop
endif
coqide-files: $(IDEFILES)
ide-byteloop: $(IDETOPBYTE)
ide-optloop: $(IDETOP)
ide-toploop: $(IDETOPEXE)
ifeq ($(HASCOQIDE),opt)
$(COQIDE): $(LINKIDEOPT)
$(SHOW)'OCAMLOPT -o $@'
$(HIDE)$(OCAMLOPT) $(COQIDEFLAGS) $(OPTFLAGS) -o $@ \
-linkpkg -package str,unix,threads,lablgtk3-sourceview3 $(IDEFLAGS:.cma=.cmxa) $^
$(STRIP_HIDE) $@
else
$(COQIDE): $(COQIDEBYTE)
rm -f $@ && cp $< $@
endif
$(COQIDEBYTE): $(LINKIDE)
$(SHOW)'OCAMLC -o $@'
$(HIDE)$(OCAMLC) $(COQIDEFLAGS) $(BYTEFLAGS) -o $@ \
-linkpkg -package str,unix,threads,lablgtk3-sourceview3 $(IDEFLAGS) $(IDECDEPSFLAGS) $^
ide/coqide_os_specific.ml: ide/coqide_$(IDEINT).ml.in config/Makefile
rm -f $@ && cp $< $@ && chmod a-w $@
ide/%.cmi: ide/%.mli
$(SHOW)'OCAMLC $<'
$(HIDE)$(OCAMLC) $(COQIDEFLAGS) $(BYTEFLAGS) -c $<
ide/%.cmo: ide/%.ml
$(SHOW)'OCAMLC $<'
$(HIDE)$(OCAMLC) $(COQIDEFLAGS) $(BYTEFLAGS) -c $<
ide/%.cmx: ide/%.ml
$(SHOW)'OCAMLOPT $<'
$(HIDE)$(OCAMLOPT) $(COQIDEFLAGS) $(OPTFLAGS) -c $<
# We need to compile this file without -safe-string due mess with
# lablgtk API. Other option is to require lablgtk >= 3.0.0
ide/ideutils.cmo: ide/ideutils.ml
$(SHOW)'OCAMLC $<'
$(HIDE)$(filter-out -safe-string,$(OCAMLC)) $(COQIDEFLAGS) $(BYTEFLAGS) -c $<
ide/ideutils.cmx: ide/ideutils.ml
$(SHOW)'OCAMLOPT $<'
$(HIDE)$(filter-out -safe-string,$(OCAMLOPT)) $(COQIDEFLAGS) $(filter-out -safe-string,$(OPTFLAGS)) -c $<
IDETOPCMA:=ide/ide_common.cma
IDETOPCMX:=$(IDETOPCMA:.cma=.cmxa)
# Special rule for coqidetop
$(IDETOPEXE): $(IDETOP:.opt=.$(BEST))
rm -f $@ && cp $< $@
$(IDETOP): ide/idetop.ml $(LINKCMX) $(LIBCOQRUN) $(IDETOPCMX)
$(SHOW)'COQMKTOP -o $@'
$(HIDE)$(OCAMLOPT) -linkall -linkpkg $(MLINCLUDES) -I ide -I ide/protocol/ \
$(SYSMOD) \
$(LINKCMX) $(IDETOPCMX) $(OPTFLAGS) $(LINKMETADATA) $< -o $@
$(STRIP_HIDE) $@
$(CODESIGN_HIDE) $@
$(IDETOPBYTE): ide/idetop.ml $(LINKCMO) $(LIBCOQRUN) $(IDETOPCMA)
$(SHOW)'COQMKTOP -o $@'
$(HIDE)$(OCAMLC) -linkall -linkpkg $(MLINCLUDES) -I ide -I ide/protocol/ \
-I kernel/byterun/ -cclib -lcoqrun $(VMBYTEFLAGS) \
$(SYSMOD) \
$(LINKCMO) $(IDETOPCMA) $(BYTEFLAGS) $< -o $@
coqide-bindings: $(IDEBINDINGS)
$(IDEBINDINGSEXE): $(IDEBINDINGSSRC)
$(OCAMLC) $< -o $@
$(IDEBINDINGS): $(IDEBINDINGSEXE)
$< $@
####################
## Install targets
####################
.PHONY: install-coqide install-ide-bin install-ide-toploop install-ide-files install-ide-info install-ide-devfiles install-ide-byte install-ide-toploop-byte install-coqide-byte
ifeq ($(HASCOQIDE),no)
install-coqide: install-ide-toploop
else
install-coqide: install-ide-bin install-ide-toploop install-ide-files install-ide-info install-ide-devfiles
endif
ifeq ($(HASCOQIDE),no)
install-coqide-byte: install-ide-toploop-byte
else
install-coqide-byte: install-ide-toploop-byte install-ide-byte
endif
# Apparently, coqide.byte is not meant to be installed
install-ide-byte:
$(MKDIR) $(FULLCOQLIB)
$(INSTALLSH) $(FULLCOQLIB) $(IDECMA)
install-ide-bin:
$(MKDIR) $(FULLBINDIR)
$(INSTALLBIN) $(COQIDE) $(FULLBINDIR)
install-ide-toploop:
ifeq ($(BEST),opt)
$(INSTALLBIN) $(IDETOPEXE) $(IDETOP) $(FULLBINDIR)
endif
install-ide-toploop-byte:
ifneq ($(BEST),opt)
$(INSTALLBIN) $(IDETOPEXE) $(IDETOPBYTE) $(FULLBINDIR)
endif
install-ide-devfiles:
$(MKDIR) $(FULLCOQLIB)
$(INSTALLSH) $(FULLCOQLIB) \
$(foreach lib,$(IDECMA:.cma=_MLLIB_DEPENDENCIES),$(addsuffix .cmi,$($(lib))))
ifeq ($(BEST),opt)
$(INSTALLSH) $(FULLCOQLIB) $(IDECMA:.cma=.cmxa) $(IDECMA:.cma=.a)
endif
install-ide-files: #Please update $(COQIDEAPP)/Contents/Resources/ at the same time
$(MKDIR) $(FULLDATADIR)
$(INSTALLLIB) ide/coq.png ide/*.lang ide/coq_style.xml $(IDEBINDINGS) $(FULLDATADIR)
$(MKDIR) $(FULLCONFIGDIR)
install-ide-info:
$(MKDIR) $(FULLDOCDIR)
$(INSTALLLIB) ide/FAQ $(FULLDOCDIR)/FAQ-CoqIde
###########################################################################
# CoqIde MacOS special targets
###########################################################################
.PHONY: $(COQIDEAPP)/Contents
$(COQIDEAPP)/Contents:
rm -rdf $@
$(MKDIR) $@
sed -e "s/VERSION/$(VERSION4MACOS)/g" ide/MacOS/Info.plist.template > $@/Info.plist
$(MKDIR) "$@/MacOS"
$(COQIDEINAPP): ide/macos_prehook.cmx $(LINKIDEOPT) | $(COQIDEAPP)/Contents
$(SHOW)'OCAMLOPT -o $@'
$(HIDE)$(OCAMLOPT) $(COQIDEFLAGS) $(OPTFLAGS) -o $@ \
-linkpkg -package str,unix,threads,lablgtk3-sourceview3 $(IDEFLAGS:.cma=.cmxa) $^
$(STRIP_HIDE) $@
$(COQIDEAPP)/Contents/Resources/share: $(COQIDEAPP)/Contents
$(MKDIR) $@/coq/
$(INSTALLLIB) ide/coq.png ide/*.lang ide/coq_style.xml $(IDEBINDINGS) $@/coq/
$(MKDIR) $@/gtksourceview-3.0/{language-specs,styles}
$(INSTALLLIB) "$(SOURCEVIEWSHARE)/"gtksourceview-3.0/language-specs/{def.lang,language2.rng} $@/gtksourceview-3.0/language-specs/
$(INSTALLLIB) "$(SOURCEVIEWSHARE)/"gtksourceview-3.0/styles/{styles.rng,classic.xml} $@/gtksourceview-3.0/styles/
cp -R "$(GTKSHARE)/"locale $@
cp -R "$(GTKSHARE)/"themes $@
$(MKDIR) $@/glib-2.0/schemas
glib-compile-schemas --targetdir=$@/glib-2.0/schemas "$(GTKSHARE)/"glib-2.0/schemas/
cp -R "$(ADWAITASHARE)/"icons $@
$(COQIDEAPP)/Contents/Resources/loaders: $(COQIDEAPP)/Contents
$(MKDIR) $@
$(INSTALLLIB) $$("$(PIXBUFBIN)/gdk-pixbuf-query-loaders" | sed -n -e '5 s!.*= \(.*\)$$!\1!p')/libpixbufloader-png.so $@
$(COQIDEAPP)/Contents/Resources/immodules: $(COQIDEAPP)/Contents
$(MKDIR) $@
$(INSTALLLIB) "$(GTKLIBS)/gtk-3.0/3.0.0/immodules/"*.dylib $@
$(COQIDEAPP)/Contents/Resources/etc: $(COQIDEAPP)/Contents/Resources/lib
$(MKDIR) $@/xdg/coq
$(MKDIR) $@/gtk-3.0
{ "$(PIXBUFBIN)/gdk-pixbuf-query-loaders" $@/../loaders/*.so |\
sed -e "s!/.*\(/loaders/.*.so\)!@executable_path/../Resources/\1!"; } \
> $@/gtk-3.0/gdk-pixbuf.loaders
{ "$(GTKBIN)/gtk-query-immodules-3.0" $@/../immodules/*.dylib |\
sed -e "s!/.*\(/immodules/.*.dylib\)!@executable_path/../Resources/\1!" |\
sed -e "s!/.*\(/share/locale\)!@executable_path/../Resources/\1!"; } \
> $@/gtk-3.0/gtk-immodules.loaders
$(MKDIR) $@/pango
echo "[Pango]" > $@/pango/pangorc
$(COQIDEAPP)/Contents/Resources/lib: $(COQIDEAPP)/Contents/Resources/immodules $(COQIDEAPP)/Contents/Resources/loaders $(COQIDEAPP)/Contents $(COQIDEINAPP)
$(MKDIR) $@
macpack -d ../Resources/lib $(COQIDEINAPP)
for i in $@/../loaders/*.so $@/../immodules/*.dylib; \
do \
macpack -d ../lib $$i; \
done
$(COQIDEAPP)/Contents/Resources:$(COQIDEAPP)/Contents/Resources/etc $(COQIDEAPP)/Contents/Resources/share
$(INSTALLLIB) ide/MacOS/*.icns $@
$(COQIDEAPP):$(COQIDEAPP)/Contents/Resources
$(CODESIGN_HIDE) $@
###########################################################################
# CoqIde for Windows special targets
###########################################################################
%.o: %.rc
$(SHOW)'WINDRES $<'
$(HIDE)i686-w64-mingw32-windres -i $< -o $@
# For emacs:
# Local Variables:
# mode: makefile
# End: