summaryrefslogtreecommitdiff
path: root/makefile
diff options
context:
space:
mode:
Diffstat (limited to 'makefile')
-rw-r--r--makefile43
1 files changed, 34 insertions, 9 deletions
diff --git a/makefile b/makefile
index 19d61f2d..07f101f1 100644
--- a/makefile
+++ b/makefile
@@ -42,7 +42,13 @@ ifeq ($(CCACHE),1)
CC := ccache $(CC)
endif
-export CC LD AR STRIP CROSS_COMPILE ARCH
+ifndef O
+ O := $(srctree)/dist
+else
+ O := $(srctree)/$(O)
+endif
+
+export CC LD AR STRIP CROSS_COMPILE ARCH O
ifeq ($(V),1)
Q :=
@@ -120,25 +126,29 @@ PHONY :=
export Q srctree MAKEFLAGS KCONFIG_CONFIG \
KBUILD_CFLAGS KBUILD_ASFLAGS KBUILD_LDFLAGS
+PHONY += install
all: compile_commands.json
$(Q)$(MAKE) -f scripts/makefile.build obj=$(obj)
+PHONY += install
+install: all
+ $(Q)$(MAKE) -f scripts/makefile.build obj=$(obj) install
+ mkdir -p $(O)/usr
+ cp -r $(srctree)/include $(O)/usr/
+ rm -rf $(O)/usr/include/arch $(O)/usr/include/generated ${O}/usr/include/config
+
+PHONY += clean
clean:
$(Q)$(MAKE) -f scripts/makefile.build obj=$(obj) clean
$(Q)rm -f $(srctree)/include/config/auto.conf
$(Q)rm -f $(srctree)/include/generated/autoconf.h
+ $(Q)rm -rf $(srctree)/dist
+PHONY += distclean
distclean: clean
$(Q)$(MAKE) -C scripts/kconfig clean
$(Q)rm -f compile_commands.json
-info:
- echo "CC: $(CC)"
- echo "ARCH: $(ARCH)"
- echo "CFLAGS: $(KBUILD_CFLAGS)"
- echo "LDFLAGS: $(KBUILD_LDFLAGS)"
- echo "ASFLAGS: $(KBUILD_ASFLAGS)"
-
$(KCONFIG_CONFIG):
@echo >&2 '***'
@echo >&2 '*** Configuration file "$@" not found!'
@@ -148,13 +158,26 @@ $(KCONFIG_CONFIG):
@echo >&2 '***'
@false
+PHONY += help
+help:
+ @echo "Available make targets:"
+ @echo " all - Build the project (default)"
+ @echo " install - Install the built files"
+ @echo " clean - Clean build files"
+ @echo " distclean - Clean all generated files"
+ @echo " menuconfig - Launch the menu-based configuration tool"
+ @echo " include-what-you-use - Run include-what-you-use on the source files"
+ @echo " clang-tidy - Run clang-tidy on the source files"
+ @echo " clang-format - Format source files using clang-format"
+
compile_commands.json:
$(Q)bear -- $(MAKE) -f scripts/makefile.build obj=$(obj) all
PHONY += menuconfig
menuconfig:
- $(Q)$(MAKE) -f scripts/kconfig/makefile menuconfig
+ $(Q)$(MAKE) -C $(srctree)/scripts/kconfig menuconfig
+PHONY += include-what-you-use
include-what-you-use: compile_commands.json
$(Q)iwyu_tool.py -p. -j4 -- -Xiwyu --update_comments -Xiwyu --transitive_includes_only -Xiwyu --no_internal_mappings | \
fix_includes.py --comments \
@@ -163,10 +186,12 @@ include-what-you-use: compile_commands.json
--update_comments \
--reorder
+PHONY += clang-tidy
clang-tidy: compile_commands.json
$(Q)clang-tidy -header-filter=.* -p=. -fix -fix-errors $(shell find . -name '*.c' -o -name '*.h' | grep -v './scripts/\|dtoa\|linux\|arch\|bits\|libm') \
--export-fixes=clang-tidy-fixes.yaml
+PHONY += clang-format
clang-format:
$(Q)clang-format -i $(shell find . -name '*.c' -o -name '*.h' | grep -v './scripts/')