forked from facebook/flow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
129 lines (106 loc) · 3.49 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
# Copyright (c) 2014, Facebook, Inc.
# All rights reserved.
################################################################################
# Variables to override #
################################################################################
EXTRA_INCLUDE_PATHS=
EXTRA_LIB_PATHS=
################################################################################
# OS-dependent stuff #
################################################################################
OS=$(shell uname -s)
ifeq ($(OS), Linux)
INOTIFY=inotify
FSNOTIFY=fsnotify_linux
ELF=elf
FRAMEWORKS=
SECTCREATE=
endif
ifeq ($(OS), Darwin)
INOTIFY=fsevents
FSNOTIFY=fsnotify_darwin
ELF=
FRAMEWORKS=CoreServices CoreFoundation
SECTCREATE=-cclib -sectcreate -cclib __text -cclib flowlib -cclib $(abspath bin/flowlib.tar.gz)
endif
################################################################################
# Definitions #
################################################################################
MODULES=\
src/stubs\
src/commands\
src/common\
src/embedded\
src/dts\
src/typing\
src/parser\
src/server\
src/parsing\
hack/utils\
hack/client\
hack/socket\
hack/server\
hack/stubs\
hack/typing\
hack/naming\
hack/parsing\
hack/deps\
hack/heap\
hack/globals\
hack/procs\
hack/search\
hack/hhi\
hack/dfind\
hack/avl\
hack/$(INOTIFY)\
hack/$(FSNOTIFY)
NATIVE_OBJECT_FILES=\
src/embedded/flowlib_elf.o\
hack/heap/hh_shared.o\
hack/utils/realpath.o\
hack/$(INOTIFY)/$(INOTIFY)_stubs.o\
hack/utils/nproc.o\
hack/hhi/hhi_elf.o\
hack/utils/get_build_id.gen.o\
hack/utils/get_build_id.o
OCAML_LIBRARIES=\
unix\
str
NATIVE_LIBRARIES=\
$(ELF)
FILES_TO_COPY=\
$(wildcard lib/*.js)
################################################################################
# Rules #
################################################################################
INCLUDE_OPTS=$(foreach dir,$(MODULES),-I $(dir))
LIB_OPTS=$(foreach lib,$(OCAML_LIBRARIES),-lib $(lib))
NATIVE_LIB_OPTS=$(foreach lib, $(NATIVE_LIBRARIES),-cclib -l -cclib $(lib))
EXTRA_INCLUDE_OPTS=$(foreach dir, $(EXTRA_INCLUDE_PATHS),-ccopt -I -ccopt $(dir))
EXTRA_LIB_OPTS=$(foreach dir, $(EXTRA_LIB_PATHS),-cclib -L -cclib $(dir))
FRAMEWORK_OPTS=$(foreach framework, $(FRAMEWORKS),-cclib -framework -cclib $(framework))
LINKER_FLAGS=$(NATIVE_OBJECT_FILES) $(NATIVE_LIB_OPTS) $(EXTRA_LIB_OPTS) $(FRAMEWORK_OPTS) $(SECTCREATE)
all: build-flowlib-archive build-flow copy-flow-files
clean:
ocamlbuild -clean
rm -rf bin
rm -f hack/utils/get_build_id.gen.c
build-flow: build-flow-native-deps build-flowlib-archive
ocamlbuild -no-links $(INCLUDE_OPTS) $(LIB_OPTS) -lflags "$(LINKER_FLAGS)" src/flow.native
build-flow-native-deps: build-flow-stubs
ocamlbuild -cflags "$(EXTRA_INCLUDE_OPTS)" $(NATIVE_OBJECT_FILES)
build-flow-stubs:
echo 'const char* const BuildInfo_kRevision = "${SHA}";' > hack/utils/get_build_id.gen.c
build-flowlib-archive:
mkdir -p bin
tar czf bin/flowlib.tar.gz lib
copy-flow-files: build-flow $(FILES_TO_COPY)
mkdir -p bin
cp -r examples bin/examples
ifeq ($(OS), Linux)
objcopy --add-section flowlib=bin/flowlib.tar.gz _build/src/flow.native bin/flow
else
cp _build/src/flow.native bin/flow
endif
test: build-flow copy-flow-files
./runtests.sh bin/flow