OILS / build / portable-rules.mk View on Github | oilshell.org

96 lines, 76 significant
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.
13REPO_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
75PY27 := 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