1 | # portable-rules.mk: These are done on the dev machine.
|
2 | #
|
3 | # Non-portable rules involves C compilers, and must be done on the target
|
4 | # machine.
|
5 |
|
6 | # The root of this repo, e.g. ~/git/oil, should be our PYTHONPATH for
|
7 | # detecting dependencies.
|
8 | #
|
9 | # From this link:
|
10 | # https://stackoverflow.com/questions/322936/common-gnu-makefile-directory-path
|
11 | # Except we're using 'firstword' instead of 'lastword', because
|
12 | # _build/oil/ovm.d is the last one.
|
13 | REPO_ROOT := $(abspath $(dir $(firstword $(MAKEFILE_LIST))))
|
14 |
|
15 | #
|
16 | # App-independent rules.
|
17 | #
|
18 |
|
19 | # NOTES:
|
20 | # - Manually rm this file to generate a new build timestamp.
|
21 | # - This messes up reproducible builds.
|
22 | # - It's not marked .PHONY because that would mess up the end user build.
|
23 | # bytecode-*.zip should NOT be built by the user.
|
24 | _build/release-date.txt:
|
25 | $(STAMP_SH) write-release-date
|
26 |
|
27 | # The Makefiles generated by autoconf don't call configure, but Linux/toybox
|
28 | # config system does. This can be overridden.
|
29 | _build/detected-config.sh:
|
30 | ./configure
|
31 |
|
32 | # Needed by make-tar for gcc -M
|
33 | _build/detected-config.h:
|
34 | ./configure
|
35 |
|
36 | # What files correspond to each C module.
|
37 | # TODO:
|
38 | # - Where to put -l z? (Done in Modules/Setup.dist)
|
39 | _build/c-module-toc.txt: build/c_module_toc.py
|
40 | $(ACTIONS_SH) c-module-toc > $@
|
41 |
|
42 | #
|
43 | # App-Independent Pattern Rules.
|
44 | #
|
45 |
|
46 | # Regenerate dependencies. But only if we made the app dirs.
|
47 | _build/%/ovm.d: _build/%/app-deps-c.txt
|
48 | $(ACTIONS_SH) make-dotd $* $^ > $@
|
49 |
|
50 | # Source paths of all C modules the app depends on. For the tarball.
|
51 | # A trick: remove the first dep to form the lists. You can't just use $^
|
52 | # because './c_module_srcs.py' is rewritten to 'c_module_srcs.py'.
|
53 | _build/%/c-module-srcs.txt: \
|
54 | build/c_module_srcs.py _build/c-module-toc.txt _build/%/app-deps-c.txt
|
55 | build/c_module_srcs.py $(filter-out $<,$^) > $@
|
56 |
|
57 | _build/%/all-deps-c.txt: build/static-c-modules.txt _build/%/app-deps-c.txt
|
58 | $(ACTIONS_SH) join-modules $^ > $@
|
59 |
|
60 | _build/%/all-deps-py.txt: _build/%/py-to-compile.txt
|
61 | sort $^ | uniq > $@
|
62 |
|
63 | _build/opy/py27.grammar.marshal: opy/py27.grammar
|
64 | bin/opyc pgen2 $^ $@
|
65 |
|
66 | # NOTE: This should really depend on all the .py files.
|
67 | # I should make a _build/oil/py.d file and include it?
|
68 | # This depends on the grammar pickle because it's the first one that calls opy
|
69 | # compile.
|
70 | _build/%/opy-app-deps.txt: _build/opy/py27.grammar.marshal _build/%/all-deps-py.txt
|
71 | # exclude the pickle
|
72 | cat _build/$*/all-deps-py.txt | opy/build.sh compile-manifest _build/$*/bytecode-opy > $@
|
73 |
|
74 |
|
75 | PY27 := Python-2.7.13
|
76 |
|
77 | # Per-app extension module initialization.
|
78 | _build/%/module_init.c: $(PY27)/Modules/config.c.in _build/%/all-deps-c.txt
|
79 | # NOTE: Using xargs < input.txt style because it will fail if input.txt
|
80 | # doesn't exist! 'cat' errors will be swallowed.
|
81 | xargs $(ACTIONS_SH) gen-module-init < _build/$*/all-deps-c.txt > $@
|
82 |
|
83 |
|
84 | #
|
85 | # Tarballs
|
86 | #
|
87 | # Contain Makefile and associated shell scripts, discovered .c and .py deps,
|
88 | # app source.
|
89 |
|
90 | _release/%.tar: _build/%/$(BYTECODE_ZIP) \
|
91 | _build/%/module_init.c \
|
92 | _build/%/main_name.c \
|
93 | _build/%/c-module-srcs.txt \
|
94 | _build/detected-config.h
|
95 | $(COMPILE_SH) make-tar $* $(BYTECODE_ZIP) $@
|
96 |
|