mkmakefile 866 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0
  3. # Generates a small Makefile used in the root of the output
  4. # directory, to allow make to be started from there.
  5. # The Makefile also allow for more convinient build of external modules
  6. # Usage
  7. # $1 - Kernel src directory
  8. # Only overwrite automatically generated Makefiles
  9. # (so we do not overwrite kernel Makefile)
  10. if test -e Makefile && ! grep -q Automatically Makefile
  11. then
  12. exit 0
  13. fi
  14. if [ "${quiet}" != "silent_" ]; then
  15. echo " GEN Makefile"
  16. fi
  17. cat << EOF > Makefile
  18. # Automatically generated by $0: don't edit
  19. ifeq ("\$(origin V)", "command line")
  20. VERBOSE := \$(V)
  21. endif
  22. ifneq (\$(VERBOSE),1)
  23. Q := @
  24. endif
  25. MAKEFLAGS += --no-print-directory
  26. .PHONY: __sub-make \$(MAKECMDGOALS)
  27. __sub-make:
  28. \$(Q)\$(MAKE) -C $1 O=\$(CURDIR) \$(MAKECMDGOALS)
  29. \$(filter-out __sub-make, \$(MAKECMDGOALS)): __sub-make
  30. @:
  31. EOF