| [3654684] | 1 | #
 | 
|---|
| [df4ed85] | 2 | # Copyright (c) 2006 Martin Decky
 | 
|---|
| [41f7564] | 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 | 
 | 
|---|
| [218e50c] | 29 | CSCOPE = cscope
 | 
|---|
| [b1efe3e] | 30 | FORMAT = clang-format
 | 
|---|
| [4e9aaf5] | 31 | 
 | 
|---|
| [3529fbf0] | 32 | ERRNO_HEADER = abi/include/abi/errno.h
 | 
|---|
 | 33 | ERRNO_INPUT = abi/include/abi/errno.in
 | 
|---|
| [feab36ae] | 34 | 
 | 
|---|
| [05d97eef] | 35 | .PHONY: nothing cscope cscope_parts format ccheck ccheck-fix space check_errno
 | 
|---|
| [a5c468e] | 36 | 
 | 
|---|
| [05d97eef] | 37 | nothing:
 | 
|---|
| [656437a0] | 38 | 
 | 
|---|
 | 39 | cscope:
 | 
|---|
| [6eda732] | 40 |         find abi kernel boot uspace -type f -regex '^.*\.[chsS]$$' | xargs $(CSCOPE) -b -k -u -f$(CSCOPE).out
 | 
|---|
| [656437a0] | 41 | 
 | 
|---|
| [efb94a77] | 42 | cscope_parts:
 | 
|---|
| [6eda732] | 43 |         find abi -type f -regex '^.*\.[chsS]$$' | xargs $(CSCOPE) -b -k -u -f$(CSCOPE)_abi.out
 | 
|---|
 | 44 |         find kernel -type f -regex '^.*\.[chsS]$$' | xargs $(CSCOPE) -b -k -u -f$(CSCOPE)_kernel.out
 | 
|---|
 | 45 |         find boot -type f -regex '^.*\.[chsS]$$' | xargs $(CSCOPE) -b -k -u -f$(CSCOPE)_boot.out
 | 
|---|
 | 46 |         find uspace -type f -regex '^.*\.[chsS]$$' | xargs $(CSCOPE) -b -k -u -f$(CSCOPE)_uspace.out
 | 
|---|
| [efb94a77] | 47 | 
 | 
|---|
| [b1efe3e] | 48 | format:
 | 
|---|
 | 49 |         find abi kernel boot uspace -type f -regex '^.*\.[ch]$$' | xargs $(FORMAT) -i -sort-includes -style=file
 | 
|---|
 | 50 | 
 | 
|---|
| [be9702e0] | 51 | ccheck:
 | 
|---|
| [a4eb3ba2] | 52 |         cd tools && ./build-ccheck.sh
 | 
|---|
| [db3089d] | 53 |         tools/ccheck.sh
 | 
|---|
 | 54 | 
 | 
|---|
| [be9702e0] | 55 | ccheck-fix:
 | 
|---|
| [a4eb3ba2] | 56 |         cd tools && ./build-ccheck.sh
 | 
|---|
| [e347396] | 57 |         tools/ccheck.sh --fix
 | 
|---|
 | 58 | 
 | 
|---|
| [34e1206] | 59 | space:
 | 
|---|
 | 60 |         tools/srepl '[ \t]\+$$' ''
 | 
|---|
 | 61 | 
 | 
|---|
| [3c7702c0] | 62 | # `sed` pulls a list of "compatibility-only" error codes from `errno.in`,
 | 
|---|
 | 63 | # the following grep finds instances of those error codes in HelenOS code.
 | 
|---|
 | 64 | check_errno:
 | 
|---|
 | 65 |         @ ! cat abi/include/abi/errno.in | \
 | 
|---|
 | 66 |         sed -n -e '1,/COMPAT_START/d' -e 's/__errno_entry(\([A-Z0-9]\+\).*/\\b\1\\b/p' | \
 | 
|---|
 | 67 |         git grep -n -f - -- ':(exclude)abi' ':(exclude)uspace/lib/posix'
 | 
|---|
 | 68 | 
 | 
|---|
| [3529fbf0] | 69 | $(ERRNO_HEADER): $(ERRNO_INPUT)
 | 
|---|
 | 70 |         echo '/* Generated file. Edit errno.in instead. */' > $@.new
 | 
|---|
| [10de842] | 71 |         sed 's/__errno_entry(\([^,]*\),\([^,]*\),.*/#define \1 __errno_t(\2)/' < $< >> $@.new
 | 
|---|
| [3529fbf0] | 72 |         mv $@.new $@
 | 
|---|