1 ################################################################################
2 # Variables to override #
3 ################################################################################
11 ################################################################################
12 # OS-dependent stuff #
13 ################################################################################
19 INOTIFY
=third-party
/inotify
20 FSNOTIFY
=fsnotify_linux
28 FSNOTIFY
=fsnotify_darwin
31 FRAMEWORKS
=CoreServices CoreFoundation
32 SECTCREATE
=-cclib
-sectcreate
-cclib __text
-cclib hhi
-cclib
$(ROOT
)/..
/bin
/hhi.
tar.gz
41 ################################################################################
43 ################################################################################
56 hackfmt
/line_splitter\
64 injection
/default_injector\
95 hhi
/hhi_win32res_stubs.c\
96 libancillary
/libancillary-stubs.c\
97 third-party
/libancillary
/fd_recv.c\
98 third-party
/libancillary
/fd_send.c\
100 utils
/get_build_id.c\
101 utils
/handle_stubs.c\
106 $(INOTIFY
)/$(notdir $(INOTIFY
))_stubs.c
118 TARGETS_BASE
=_build
/hh_server _build
/hh_client \
119 _build
/hh_single_type_check \
123 TARGETS
=$(foreach target
,$(TARGETS_BASE
),$(target
).
$(TARGET_EXT
))
125 # Find all source files (all files not in _build dir)
126 ALL_SRC_FILES
=$(call rwildcard
,$(patsubst _build
,,$(wildcard *)),*.
*)
128 ################################################################################
130 ################################################################################
132 OBJECT_FILES_TO_BUILD
=$(patsubst %.c
,%.o
,$(NATIVE_C_FILES
))
133 NATIVE_OBJECT_FILES
=$(OBJECT_FILES_TO_BUILD
) utils
/get_build_id.gen.o
134 INCLUDE_OPTS
=$(foreach dir,$(MODULES
),-I
$(dir))
135 LIB_OPTS
=$(foreach lib
,$(OCAML_LIBRARIES
),-lib
$(lib
))
136 NATIVE_LIB_OPTS
=$(foreach lib
, $(NATIVE_LIBRARIES
),-cclib
-l
$(lib
))
137 EXTRA_NATIVE_LIB_OPTS
=$(foreach lib
, $(EXTRA_NATIVE_LIBRARIES
),-cclib
-l
$(lib
))
138 EXTRA_INCLUDE_OPTS
=$(foreach dir, $(EXTRA_INCLUDE_PATHS
),-ccopt
-I
$(dir))
139 EXTRA_CC_OPTS
=$(foreach opt
, $(EXTRA_CC_FLAGS
),-ccopt
$(opt
))
140 EXTRA_LINK
=$(EXTRA_LINK_OPTS
) $(foreach dir, $(EXTRA_LIB_PATHS
),-cclib
-L
$(dir))
141 FRAMEWORK_OPTS
=$(foreach framework
, $(FRAMEWORKS
),-cclib
-framework
-cclib
$(framework
))
143 LINKER_FLAGS
=$(NATIVE_OBJECT_FILES
) $(NATIVE_LIB_OPTS
) $(EXTRA_LINK
) \
144 $(EXTRA_NATIVE_LIB_OPTS
) $(FRAMEWORK_OPTS
) $(SECTCREATE
)
145 # Function to recursively find files, eg: $(call rwildcard,dir/to/look/in/,*.c)
146 rwildcard
=$(wildcard $1$2) $(foreach d
,$(wildcard $1*),$(call rwildcard
,$d/,$2))
148 all: build-hhi-archive build-hack copy-hack-files
149 all-ocp
: build-hhi-archive build-hack-with-ocp copy-hack-files-ocp
153 find ..
/bin
-mindepth
1 -not
-path ..
/bin
/README
-delete
154 rm -f utils
/get_build_id.gen.c
156 build-hack
: $(TARGETS
) build-hhi-archive
158 build-hack-with-ocp
: build-hhi-archive _build
/utils
/get_build_id.gen.o
159 [ -d
${ROOT}/..
/_obuild
] ||
( cd
${ROOT}/..
&& ocp-build init
)
162 # These are needed so we can turn OCAMLBUILD from 'a,b,c' into 'a b c' below
167 # All targets are built in one time, so no parallelization is necessary
168 .NOTPARALLEL
: $(TARGETS
)
169 # As there is no efficient way to calculate the dependencies of
170 # the targets, we make them dependent on all files. In doing this
171 # we ensure that no rebuild is necessary if nothing has changed
172 $(TARGETS
): $(ALL_SRC_FILES
)
173 # build-hack-native-deps is a dependency of $(TARGETS) but as it is phony
174 # we place it here to avoid unnecessary rebuilds
175 $(MAKE
) build-hack-native-deps build-hhi-archive
176 $(OCAMLBUILD
) $(subst $(comma
),$(space
),$(OCAMLBUILD_FLAGS
)) -no-links
-cflag
-g
$(INCLUDE_OPTS
) $(LIB_OPTS
) \
177 -lflags "-g $(LINKER_FLAGS)" -tag custom \
178 $(patsubst _build
/%,%,$(TARGETS
))
179 # Touching the targets is necessary because the ocaml build
180 # doesn't change the modification dates of the targets if
181 # the new binaries are exactly the same as the old ones
184 build-hack-native-deps
: $(NATIVE_C_FILES
) _build
/utils
/get_build_id.gen.o
185 $(OCAMLBUILD
) $(subst $(comma
),$(space
),$(OCAMLBUILD_FLAGS
)) -cflags "-g $(EXTRA_INCLUDE_OPTS) $(EXTRA_CC_OPTS)" $(OBJECT_FILES_TO_BUILD
)
187 .PHONY
: _build
/utils
/get_build_id.gen.c
# run every time, depends on git commit
188 _build
/utils
/get_build_id.gen.c
:
191 $(OCAML
) -I scripts
-w
-3 unix.cma scripts
/gen_build_id.ml src
/_build
/utils
/get_build_id.gen.c
193 _build
/utils
/get_build_id.gen.o
: _build
/utils
/get_build_id.gen.c
194 cd
$(dir $@
) && $(OCAMLC
) $(EXTRA_INCLUDE_OPTS
) $(EXTRA_CC_OPTS
) -c
$(notdir $<)
200 copy-hack-files
: build-hack
202 ifeq ($(OS
)$(BYTECODE
), Linux
)
203 objcopy
--add-section hhi
=..
/bin
/hhi.
tar.gz _build
/hh_server.
$(TARGET_EXT
) ..
/bin
/hh_server
205 cp _build
/hh_server.
$(TARGET_EXT
) ..
/bin
/hh_server
207 cp _build
/hh_client.
$(TARGET_EXT
) ..
/bin
/hh_client
208 cp _build
/hh_single_type_check.
$(TARGET_EXT
) ..
/bin
/hh_single_type_check
209 cp _build
/hackfmt.
$(TARGET_EXT
) ..
/bin
/hackfmt
210 cp _build
/hh_format.
$(TARGET_EXT
) ..
/bin
/hh_format
212 copy-hack-files-ocp
: build-hack-with-ocp
215 objcopy
--add-section hhi
=..
/bin
/hhi.
tar.gz ..
/_obuild
/hh_server
/hh_server.asm ..
/bin
/hh_server
217 cp ..
/_obuild
/hh_server
/hh_server.asm ..
/bin
/hh_server
219 cp ..
/_obuild
/hh_client
/hh_client.asm ..
/bin
/hh_client
220 cp ..
/_obuild
/hh_single_type_check
/hh_single_type_check.asm ..
/bin
/hh_single_type_check
221 cp ..
/_obuild
/hh_format
/hackfmt.asm ..
/bin
/hackfmt
222 cp ..
/_obuild
/hh_format
/hh_format.asm ..
/bin
/hh_format
224 .PHONY
: test test-ocp do-test
225 test: build-hack copy-hack-files
228 test-ocp
: build-hack-with-ocp copy-hack-files-ocp
232 python3 ..
/test/verify.py
--program ..
/bin
/hh_single_type_check ..
/test/autocomplete
233 python3 ..
/test/verify.py
--program ..
/bin
/hh_single_type_check ..
/test/color
234 python3 ..
/test/verify.py
--program ..
/bin
/hh_single_type_check ..
/test/colour
235 python3 ..
/test/verify.py
--program ..
/bin
/hh_single_type_check ..
/test/coverage
236 python3 ..
/test/verify.py
--program ..
/bin
/hh_single_type_check ..
/test/dumpsymbolinfo
237 python3 ..
/test/verify.py
--program ..
/bin
/hh_single_type_check ..
/test/dump_inheritance
238 python3 ..
/test/verify.py
--program ..
/bin
/hh_format ..
/test/format
239 python3 ..
/test/verify.py
--program ..
/bin
/hh_single_type_check ..
/test/suggest
240 python3 ..
/test/verify.py
--program ..
/bin
/hh_single_type_check ..
/test/typecheck
241 python3 ..
/test/verify.py
--program ..
/bin
/hh_format ..
/test/typecheck \
242 --disabled-extension .no_format \
243 --out-extension .format_out \
244 --expect-extension
'' \
246 python3 ..
/test/integration
/runner.py ..
/bin
/hh_server ..
/bin
/hh_client