mkmakefile 794 B

123456789101112131415161718192021222324252627282930313233343536373839
  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 convinient build of external modules
  5. # Usage
  6. # $1 - Kernel src directory
  7. # $2 - Output directory
  8. # $3 - version
  9. # $4 - patchlevel
  10. test ! -r $2/Makefile -o -O $2/Makefile || exit 0
  11. echo " GEN $2/Makefile"
  12. cat << EOF > $2/Makefile
  13. # Automatically generated by $0: don't edit
  14. VERSION = $3
  15. PATCHLEVEL = $4
  16. KERNELSRC := $1
  17. KERNELOUTPUT := $2
  18. MAKEFLAGS += --no-print-directory
  19. .PHONY: all \$(MAKECMDGOALS)
  20. all:
  21. \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT)
  22. Makefile:;
  23. \$(filter-out all Makefile,\$(MAKECMDGOALS)):
  24. \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$@
  25. %/:
  26. \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$@
  27. EOF