forked from frida/frida
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.freebsd.mk
191 lines (159 loc) · 6.7 KB
/
Makefile.freebsd.mk
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
include config.mk
build_arch := $(shell releng/detect-arch.sh)
test_args := $(addprefix -p=,$(tests))
HELP_FUN = \
my (%help, @sections); \
while(<>) { \
if (/^([\w-]+)\s*:.*\#\#(?:@([\w-]+))?\s(.*)$$/) { \
$$section = $$2 // 'options'; \
push @sections, $$section unless exists $$help{$$section}; \
push @{$$help{$$section}}, [$$1, $$3]; \
} \
} \
$$target_color = "\033[32m"; \
$$variable_color = "\033[36m"; \
$$reset_color = "\033[0m"; \
print "\n"; \
print "\033[31mUsage:$${reset_color} make $${target_color}TARGET$${reset_color} [$${variable_color}VARIABLE$${reset_color}=value]\n\n"; \
print "Where $${target_color}TARGET$${reset_color} specifies one or more of:\n"; \
print "\n"; \
for (@sections) { \
print " /* $$_ */\n"; $$sep = " " x (30 - length $$_->[0]); \
printf(" $${target_color}%-30s$${reset_color} %s\n", $$_->[0], $$_->[1]) for @{$$help{$$_}}; \
print "\n"; \
} \
print "And optionally also $${variable_color}VARIABLE$${reset_color} values:\n"; \
print " $${variable_color}PYTHON$${reset_color} Absolute path of Python interpreter including version suffix\n"; \
print " $${variable_color}NODE$${reset_color} Absolute path of Node.js binary\n"; \
print "\n"; \
print "For example:\n"; \
print " \$$ make $${target_color}python $${variable_color}PYTHON$${reset_color}=/opt/python36-64/bin/python3.6\n"; \
print " \$$ make $${target_color}node $${variable_color}NODE$${reset_color}=/opt/node-freebsd-x86/bin/node\n"; \
print "\n";
help:
@LC_ALL=C perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)
include releng/frida.mk
distclean: clean-submodules
rm -rf build/
rm -rf deps/
clean: clean-submodules
rm -f build/*-clang*
rm -f build/*-pkg-config
rm -f build/*-stamp
rm -f build/*.rc
rm -f build/*.tar.bz2
rm -f build/*.txt
rm -f build/frida-version.h
rm -rf build/frida-*-*
rm -rf build/fs-*-*
rm -rf build/ft-*-*
rm -rf build/tmp-*-*
rm -rf build/fs-tmp-*-*
rm -rf build/ft-tmp-*-*
clean-submodules:
cd frida-gum && git clean -xfd
cd frida-core && git clean -xfd
cd frida-python && git clean -xfd
cd frida-node && git clean -xfd
cd frida-tools && git clean -xfd
gum: build/frida-freebsd-$(build_arch)/libdata/pkgconfig/frida-gum-1.0.pc ##@gum Build
build/frida-%/libdata/pkgconfig/frida-gum-1.0.pc: build/frida-env-%.rc build/.frida-gum-submodule-stamp
. build/frida-env-$*.rc; \
builddir=build/tmp-$*/frida-gum; \
if [ ! -f $$builddir/build.ninja ]; then \
$(call meson-setup,$*) \
--prefix $(FRIDA)/build/frida-$* \
$(frida_gum_flags) \
frida-gum $$builddir || exit 1; \
fi; \
$(MESON) install -C $$builddir || exit 1
@touch -c $@
check-gum: gum ##@gum Run tests
build/tmp-freebsd-$(build_arch)/frida-gum/tests/gum-tests $(test_args)
core: build/frida-freebsd-$(build_arch)/libdata/pkgconfig/frida-core-1.0.pc ##@core Build
build/tmp-%/frida-core/.frida-ninja-stamp: build/.frida-core-submodule-stamp build/frida-%/libdata/pkgconfig/frida-gum-1.0.pc
. build/frida-env-$*.rc; \
builddir=$(@D); \
if [ ! -f $$builddir/build.ninja ]; then \
$(call meson-setup,$*) \
--prefix $(FRIDA)/build/frida-$* \
$(frida_core_flags) \
frida-core $$builddir || exit 1; \
fi
@touch $@
build/frida-%/libdata/pkgconfig/frida-core-1.0.pc: build/tmp-%/frida-core/.frida-ninja-stamp
. build/frida-env-$*.rc && $(MESON) install -C build/tmp-$*/frida-core
@touch $@
check-core: core ##@core Run tests
build/tmp-freebsd-$(build_arch)/frida-core/tests/frida-tests $(test_args)
python: build/tmp-freebsd-$(build_arch)/frida-$(PYTHON_NAME)/.frida-stamp ##@python Build Python bindings
build/tmp-%/frida-$(PYTHON_NAME)/.frida-stamp: build/.frida-python-submodule-stamp build/frida-%/libdata/pkgconfig/frida-core-1.0.pc
. build/frida-env-$*.rc; \
builddir=$(@D); \
if [ ! -f $$builddir/build.ninja ]; then \
$(call meson-setup,$*) \
--prefix $(FRIDA)/build/frida-$* \
$(FRIDA_FLAGS_COMMON) \
-Dpython=$(PYTHON) \
frida-python $$builddir || exit 1; \
fi; \
$(MESON) install -C $$builddir || exit 1
@touch $@
check-python: build/tmp-freebsd-$(build_arch)/frida-$(PYTHON_NAME)/.frida-stamp ##@python Test Python bindings
export PYTHONPATH="$(shell pwd)/build/frida-freebsd-$(build_arch)/lib/$(PYTHON_NAME)/site-packages" \
&& cd frida-python \
&& ${PYTHON} -m unittest discover
node: build/frida-freebsd-$(build_arch)/lib/node_modules/frida build/.frida-node-submodule-stamp ##@node Build Node.js bindings
build/frida-%/lib/node_modules/frida: build/frida-%/libdata/pkgconfig/frida-core-1.0.pc build/.frida-node-submodule-stamp
@$(NPM) --version 1>/dev/null 2>&1 || (echo -e "\033[31mOops. It appears Node.js is not installed.\nCheck PATH or set NODE to the absolute path of your Node.js binary.\033[0m"; exit 1;)
export PATH=$(NODE_BIN_DIR):$$PATH FRIDA=$(FRIDA) \
&& cd frida-node \
&& rm -rf frida-0.0.0.tgz build node_modules \
&& $(NPM) install \
&& $(NPM) pack \
&& rm -rf ../$@/ ../[email protected]/ \
&& mkdir -p ../[email protected]/build/ \
&& tar -C ../[email protected]/ --strip-components 1 -x -f frida-0.0.0.tgz \
&& rm frida-0.0.0.tgz \
&& mv build/Release/frida_binding.node ../[email protected]/build/ \
&& rm -rf build \
&& mv node_modules ../[email protected]/ \
&& strip --strip-all ../[email protected]/build/frida_binding.node \
&& mv ../[email protected] ../$@
check-node: node ##@node Test Node.js bindings
export PATH=$(NODE_BIN_DIR):$$PATH FRIDA=$(FRIDA) \
&& cd frida-node \
&& git clean -xfd \
&& $(NPM) install \
&& $(NODE) \
--expose-gc \
../build/frida-freebsd-$(build_arch)/lib/node_modules/frida/node_modules/.bin/_mocha \
-r ts-node/register \
--timeout 60000 \
test/*.ts
tools: build/tmp-freebsd-$(build_arch)/frida-tools-$(PYTHON_NAME)/.frida-stamp ##@tools Build CLI tools
build/tmp-%/frida-tools-$(PYTHON_NAME)/.frida-stamp: build/.frida-tools-submodule-stamp build/tmp-%/frida-$(PYTHON_NAME)/.frida-stamp
. build/frida-env-$*.rc; \
builddir=$(@D); \
if [ ! -f $$builddir/build.ninja ]; then \
$(call meson-setup,$*) \
--prefix $(FRIDA)/build/frida-$* \
$(FRIDA_FLAGS_COMMON) \
-Dpython=$(PYTHON) \
frida-tools $$builddir || exit 1; \
fi; \
$(MESON) install -C $$builddir || exit 1
@touch $@
check-tools: build/tmp-freebsd-$(build_arch)/frida-tools-$(PYTHON_NAME)/.frida-stamp ##@tools Test CLI tools
export PYTHONPATH="$(shell pwd)/build/frida-freebsd-$(build_arch)/lib/$(PYTHON_NAME)/site-packages" \
&& cd frida-tools \
&& ${PYTHON} -m unittest discover
.PHONY: \
help \
distclean clean clean-submodules git-submodules git-submodule-stamps \
gum check-gum frida-gum-update-submodule-stamp \
core check-core frida-core-update-submodule-stamp \
python check-python frida-python-update-submodule-stamp \
node check-node frida-node-update-submodule-stamp \
tools check-tools frida-tools-update-submodule-stamp
.SECONDARY: