| 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 |
|
|---|
| 32 | CCHECK = tools/sycek/ccheck
|
|---|
| 33 | CSCOPE = cscope
|
|---|
| 34 | FORMAT = clang-format
|
|---|
| 35 | CHECK = tools/check.sh
|
|---|
| 36 | CONFIG = $(abspath tools/config.py)
|
|---|
| 37 | MESON = meson
|
|---|
| 38 |
|
|---|
| 39 | BUILD_DIR=$(abspath build)
|
|---|
| 40 |
|
|---|
| 41 | CONFIG_RULES = HelenOS.config
|
|---|
| 42 |
|
|---|
| 43 | CONFIG_MAKEFILE = $(BUILD_DIR)/Makefile.config
|
|---|
| 44 | CONFIG_HEADER = $(BUILD_DIR)/config.h
|
|---|
| 45 | ERRNO_HEADER = abi/include/abi/errno.h
|
|---|
| 46 | ERRNO_INPUT = abi/include/abi/errno.in
|
|---|
| 47 | VERSION_FILE = version
|
|---|
| 48 |
|
|---|
| 49 | -include $(CONFIG_MAKEFILE)
|
|---|
| 50 | -include $(COMMON_MAKEFILE)
|
|---|
| 51 |
|
|---|
| 52 | CROSS_TARGET ?= $(UARCH)
|
|---|
| 53 |
|
|---|
| 54 | ifeq ($(MACHINE),bmalta)
|
|---|
| 55 | CROSS_TARGET = mips32eb
|
|---|
| 56 | endif
|
|---|
| 57 |
|
|---|
| 58 | .PHONY: all precheck cscope cscope_parts config_default config distclean clean check releasefile release meson space
|
|---|
| 59 |
|
|---|
| 60 | all: meson
|
|---|
| 61 |
|
|---|
| 62 | $(BUILD_DIR)/build.ninja: $(CONFIG_MAKEFILE) $(VERSION_FILE)
|
|---|
| 63 | meson . $(BUILD_DIR) --cross-file meson/cross/$(CROSS_TARGET)
|
|---|
| 64 |
|
|---|
| 65 | meson: $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(ERRNO_HEADER) $(BUILD_DIR)/build.ninja
|
|---|
| 66 | ninja -C $(BUILD_DIR)
|
|---|
| 67 |
|
|---|
| 68 | test-xcw: meson
|
|---|
| 69 | ifeq ($(CONFIG_DEVEL_FILES),y)
|
|---|
| 70 | export PATH=$$PATH:$(abspath tools/xcw/bin) && $(MAKE) -r -C tools/xcw/demo
|
|---|
| 71 | endif
|
|---|
| 72 |
|
|---|
| 73 | precheck: clean
|
|---|
| 74 | $(MAKE) -r all PRECHECK=y
|
|---|
| 75 |
|
|---|
| 76 | cscope:
|
|---|
| 77 | find abi kernel boot uspace -type f -regex '^.*\.[chsS]$$' | xargs $(CSCOPE) -b -k -u -f$(CSCOPE).out
|
|---|
| 78 |
|
|---|
| 79 | cscope_parts:
|
|---|
| 80 | find abi -type f -regex '^.*\.[chsS]$$' | xargs $(CSCOPE) -b -k -u -f$(CSCOPE)_abi.out
|
|---|
| 81 | find kernel -type f -regex '^.*\.[chsS]$$' | xargs $(CSCOPE) -b -k -u -f$(CSCOPE)_kernel.out
|
|---|
| 82 | find boot -type f -regex '^.*\.[chsS]$$' | xargs $(CSCOPE) -b -k -u -f$(CSCOPE)_boot.out
|
|---|
| 83 | find uspace -type f -regex '^.*\.[chsS]$$' | xargs $(CSCOPE) -b -k -u -f$(CSCOPE)_uspace.out
|
|---|
| 84 |
|
|---|
| 85 | format:
|
|---|
| 86 | find abi kernel boot uspace -type f -regex '^.*\.[ch]$$' | xargs $(FORMAT) -i -sort-includes -style=file
|
|---|
| 87 |
|
|---|
| 88 | ccheck: $(CCHECK)
|
|---|
| 89 | cd tools && ./build-ccheck.sh
|
|---|
| 90 | tools/ccheck.sh
|
|---|
| 91 |
|
|---|
| 92 | ccheck-fix: $(CCHECK)
|
|---|
| 93 | cd tools && ./build-ccheck.sh
|
|---|
| 94 | tools/ccheck.sh --fix
|
|---|
| 95 |
|
|---|
| 96 | $(CCHECK):
|
|---|
| 97 | cd tools && ./build-ccheck.sh
|
|---|
| 98 |
|
|---|
| 99 | space:
|
|---|
| 100 | tools/srepl '[ \t]\+$$' ''
|
|---|
| 101 |
|
|---|
| 102 | doxy: $(BUILD_DIR)/build.ninja
|
|---|
| 103 | ninja -C $(BUILD_DIR) doxygen
|
|---|
| 104 |
|
|---|
| 105 | # Pre-integration build check
|
|---|
| 106 | check: ccheck $(CHECK)
|
|---|
| 107 | ifdef JOBS
|
|---|
| 108 | $(CHECK) -j $(JOBS)
|
|---|
| 109 | else
|
|---|
| 110 | $(CHECK) -j $(shell nproc)
|
|---|
| 111 | endif
|
|---|
| 112 |
|
|---|
| 113 | # `sed` pulls a list of "compatibility-only" error codes from `errno.in`,
|
|---|
| 114 | # the following grep finds instances of those error codes in HelenOS code.
|
|---|
| 115 | check_errno:
|
|---|
| 116 | @ ! cat abi/include/abi/errno.in | \
|
|---|
| 117 | sed -n -e '1,/COMPAT_START/d' -e 's/__errno_entry(\([A-Z0-9]\+\).*/\\b\1\\b/p' | \
|
|---|
| 118 | git grep -n -f - -- ':(exclude)abi' ':(exclude)uspace/lib/posix'
|
|---|
| 119 |
|
|---|
| 120 | # Build-time configuration
|
|---|
| 121 |
|
|---|
| 122 | config_default $(CONFIG_MAKEFILE) $(CONFIG_HEADER): $(CONFIG_RULES)
|
|---|
| 123 | mkdir -p $(BUILD_DIR)
|
|---|
| 124 | ifeq ($(HANDS_OFF),y)
|
|---|
| 125 | cd $(BUILD_DIR) && $(CONFIG) $(abspath $<) $(abspath defaults) hands-off $(PROFILE)
|
|---|
| 126 | else
|
|---|
| 127 | cd $(BUILD_DIR) && $(CONFIG) $(abspath $<) $(abspath defaults) default $(PROFILE)
|
|---|
| 128 | endif
|
|---|
| 129 |
|
|---|
| 130 | config: $(CONFIG_RULES)
|
|---|
| 131 | mkdir -p $(BUILD_DIR)
|
|---|
| 132 | cd $(BUILD_DIR) && $(CONFIG) $(abspath $<) $(abspath defaults)
|
|---|
| 133 |
|
|---|
| 134 | random-config: $(CONFIG_RULES)
|
|---|
| 135 | mkdir -p $(BUILD_DIR)
|
|---|
| 136 | cd $(BUILD_DIR) && $(CONFIG) $(abspath $<) $(abspath defaults) random
|
|---|
| 137 |
|
|---|
| 138 | # Release files
|
|---|
| 139 |
|
|---|
| 140 | releasefile: all
|
|---|
| 141 | $(MAKE) -r -C release releasefile
|
|---|
| 142 |
|
|---|
| 143 | release:
|
|---|
| 144 | $(MAKE) -r -C release release
|
|---|
| 145 |
|
|---|
| 146 | # Cleaning
|
|---|
| 147 |
|
|---|
| 148 | distclean: clean
|
|---|
| 149 | rm -f $(CSCOPE).out $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) tools/*.pyc tools/checkers/*.pyc release/HelenOS-*
|
|---|
| 150 |
|
|---|
| 151 | clean:
|
|---|
| 152 | $(MAKE) -r -C tools/xcw/demo clean
|
|---|
| 153 |
|
|---|
| 154 | $(ERRNO_HEADER): $(ERRNO_INPUT)
|
|---|
| 155 | echo '/* Generated file. Edit errno.in instead. */' > $@.new
|
|---|
| 156 | sed 's/__errno_entry(\([^,]*\),\([^,]*\),.*/#define \1 __errno_t(\2)/' < $< >> $@.new
|
|---|
| 157 | mv $@.new $@
|
|---|
| 158 |
|
|---|
| 159 | -include Makefile.local
|
|---|