source: mainline/Makefile@ 2e2cefdb

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 2e2cefdb was 2e2cefdb, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 6 years ago

Put configuration in build directory instead of source root

  • Property mode set to 100644
File size: 5.3 KB
Line 
1#
2# Copyright (c) 2006 Martin Decky
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8#
9# - Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# - Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution.
14# - The name of the author may not be used to endorse or promote products
15# derived from this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27#
28
29# Just for this Makefile. Sub-makes will run in parallel if requested.
30.NOTPARALLEL:
31
32CCHECK = tools/sycek/ccheck
33CSCOPE = cscope
34FORMAT = clang-format
35CHECK = tools/check.sh
36CONFIG = $(abspath tools/config.py)
37MESON = meson
38
39BUILD_DIR=$(abspath build)
40
41CONFIG_RULES = HelenOS.config
42
43CONFIG_MAKEFILE = $(BUILD_DIR)/Makefile.config
44CONFIG_HEADER = $(BUILD_DIR)/config.h
45ERRNO_HEADER = abi/include/abi/errno.h
46ERRNO_INPUT = abi/include/abi/errno.in
47VERSION_FILE = version
48
49-include $(CONFIG_MAKEFILE)
50-include $(COMMON_MAKEFILE)
51
52# TODO: make meson reconfigure correctly when library build changes
53
54ifeq ($(CONFIG_BUILD_SHARED_LIBS),y)
55 MESON_ARGS = -Ddefault_library=shared
56else
57 MESON_ARGS = -Ddefault_library=static
58endif
59
60CROSS_PREFIX ?= /usr/local/cross
61CROSS_PATH = $(CROSS_PREFIX)/bin
62
63CROSS_TARGET ?= $(UARCH)
64
65ifeq ($(MACHINE),bmalta)
66 CROSS_TARGET = mips32eb
67endif
68
69.PHONY: all precheck cscope cscope_parts config_default config distclean clean check releasefile release meson space
70
71all: meson
72
73$(BUILD_DIR)/build.ninja: $(CONFIG_MAKEFILE) $(VERSION_FILE)
74 PATH="$(CROSS_PATH):$$PATH" meson . $(BUILD_DIR) --cross-file meson/cross/$(CROSS_TARGET) $(MESON_ARGS)
75
76meson: $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(ERRNO_HEADER) $(BUILD_DIR)/build.ninja
77 PATH="$(CROSS_PATH):$$PATH" ninja -C $(BUILD_DIR)
78
79test-xcw: meson
80ifeq ($(CONFIG_DEVEL_FILES),y)
81 export PATH=$$PATH:$(abspath tools/xcw/bin) && $(MAKE) -r -C tools/xcw/demo
82endif
83
84precheck: clean
85 $(MAKE) -r all PRECHECK=y
86
87cscope:
88 find abi kernel boot uspace -type f -regex '^.*\.[chsS]$$' | xargs $(CSCOPE) -b -k -u -f$(CSCOPE).out
89
90cscope_parts:
91 find abi -type f -regex '^.*\.[chsS]$$' | xargs $(CSCOPE) -b -k -u -f$(CSCOPE)_abi.out
92 find kernel -type f -regex '^.*\.[chsS]$$' | xargs $(CSCOPE) -b -k -u -f$(CSCOPE)_kernel.out
93 find boot -type f -regex '^.*\.[chsS]$$' | xargs $(CSCOPE) -b -k -u -f$(CSCOPE)_boot.out
94 find uspace -type f -regex '^.*\.[chsS]$$' | xargs $(CSCOPE) -b -k -u -f$(CSCOPE)_uspace.out
95
96format:
97 find abi kernel boot uspace -type f -regex '^.*\.[ch]$$' | xargs $(FORMAT) -i -sort-includes -style=file
98
99ccheck: $(CCHECK)
100 cd tools && ./build-ccheck.sh
101 tools/ccheck.sh
102
103ccheck-fix: $(CCHECK)
104 cd tools && ./build-ccheck.sh
105 tools/ccheck.sh --fix
106
107$(CCHECK):
108 cd tools && ./build-ccheck.sh
109
110space:
111 tools/srepl '[ \t]\+$$' ''
112
113doxy: $(BUILD_DIR)/build.ninja
114 ninja -C $(BUILD_DIR) doxygen
115
116# Pre-integration build check
117check: ccheck $(CHECK)
118ifdef JOBS
119 $(CHECK) -j $(JOBS)
120else
121 $(CHECK) -j $(shell nproc)
122endif
123
124# `sed` pulls a list of "compatibility-only" error codes from `errno.in`,
125# the following grep finds instances of those error codes in HelenOS code.
126check_errno:
127 @ ! cat abi/include/abi/errno.in | \
128 sed -n -e '1,/COMPAT_START/d' -e 's/__errno_entry(\([A-Z0-9]\+\).*/\\b\1\\b/p' | \
129 git grep -n -f - -- ':(exclude)abi' ':(exclude)uspace/lib/posix'
130
131# Build-time configuration
132
133config_default $(CONFIG_MAKEFILE) $(CONFIG_HEADER): $(CONFIG_RULES)
134 mkdir -p $(BUILD_DIR)
135ifeq ($(HANDS_OFF),y)
136 cd $(BUILD_DIR) && $(CONFIG) $(abspath $<) $(abspath defaults) hands-off $(PROFILE)
137else
138 cd $(BUILD_DIR) && $(CONFIG) $(abspath $<) $(abspath defaults) default $(PROFILE)
139endif
140
141config: $(CONFIG_RULES)
142 mkdir -p $(BUILD_DIR)
143 cd $(BUILD_DIR) && $(CONFIG) $(abspath $<) $(abspath defaults)
144
145random-config: $(CONFIG_RULES)
146 mkdir -p $(BUILD_DIR)
147 cd $(BUILD_DIR) && $(CONFIG) $(abspath $<) $(abspath defaults) random
148
149# Release files
150
151releasefile: all
152 $(MAKE) -r -C release releasefile
153
154release:
155 $(MAKE) -r -C release release
156
157# Cleaning
158
159distclean: clean
160 rm -f $(CSCOPE).out $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) tools/*.pyc tools/checkers/*.pyc release/HelenOS-*
161
162clean:
163 $(MAKE) -r -C tools/xcw/demo clean
164
165$(ERRNO_HEADER): $(ERRNO_INPUT)
166 echo '/* Generated file. Edit errno.in instead. */' > $@.new
167 sed 's/__errno_entry(\([^,]*\),\([^,]*\),.*/#define \1 __errno_t(\2)/' < $< >> $@.new
168 mv $@.new $@
169
170-include Makefile.local
Note: See TracBrowser for help on using the repository browser.