mkmakefile 896 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. # Only overwrite automatically generated Makefiles
  12. # (so we do not overwrite kernel Makefile)
  13. if test -e $2/Makefile && ! grep -q Automatically $2/Makefile
  14. then
  15. exit 0
  16. fi
  17. echo " GEN $2/Makefile"
  18. cat << EOF > $2/Makefile
  19. # Automatically generated by $0: don't edit
  20. VERSION = $3
  21. PATCHLEVEL = $4
  22. KERNELSRC := $1
  23. KERNELOUTPUT := $2
  24. MAKEFLAGS += --no-print-directory
  25. .PHONY: all \$(MAKECMDGOALS)
  26. all := \$(filter-out all Makefile,\$(MAKECMDGOALS))
  27. all:
  28. \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$(all)
  29. Makefile:;
  30. \$(all) %/: all
  31. @:
  32. EOF