mkmakefile 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/sh
  2. # Generates a small Makefile used in the root of the output
  3. # directory, to allow make to be started from there.
  4. # The Makefile also allow for more convenient build of external modules
  5. # Usage
  6. # $1 - Kernel src directory
  7. # $2 - Output directory
  8. test ! -r $2/Makefile -o -O $2/Makefile || exit 0
  9. # Only overwrite automatically generated Makefiles
  10. # (so we do not overwrite buildroot Makefile)
  11. if test -e $2/Makefile && ! grep -q Automatically $2/Makefile
  12. then
  13. exit 0
  14. fi
  15. if [ "${quiet}" != "silent_" ]; then
  16. echo " GEN $2/Makefile"
  17. fi
  18. cat << EOF > $2/Makefile
  19. # Automatically generated by $0: don't edit
  20. lastword = \$(word \$(words \$(1)),\$(1))
  21. makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST)))
  22. MAKEARGS := -C $1
  23. MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$(patsubst %/,%,\$(makedir))
  24. MAKEFLAGS += --no-print-directory
  25. .PHONY: all \$(MAKECMDGOALS)
  26. all := \$(filter-out all Makefile,\$(MAKECMDGOALS))
  27. all:
  28. \$(MAKE) \$(MAKEARGS) \$(all)
  29. Makefile:;
  30. \$(all): all
  31. @:
  32. %/: all
  33. @:
  34. EOF