Back to home page

LXR

 
 

    


0001 #!/bin/sh
0002 # Generates a small Makefile used in the root of the output
0003 # directory, to allow make to be started from there.
0004 # The Makefile also allow for more convinient build of external modules
0005 
0006 # Usage
0007 # $1 - Kernel src directory
0008 # $2 - Output directory
0009 # $3 - version
0010 # $4 - patchlevel
0011 
0012 
0013 test ! -r $2/Makefile -o -O $2/Makefile || exit 0
0014 # Only overwrite automatically generated Makefiles
0015 # (so we do not overwrite kernel Makefile)
0016 if test -e $2/Makefile && ! grep -q Automatically $2/Makefile
0017 then
0018         exit 0
0019 fi
0020 if [ "${quiet}" != "silent_" ]; then
0021         echo "  GEN     $2/Makefile"
0022 fi
0023 
0024 cat << EOF > $2/Makefile
0025 # Automatically generated by $0: don't edit
0026 
0027 VERSION = $3
0028 PATCHLEVEL = $4
0029 
0030 lastword = \$(word \$(words \$(1)),\$(1))
0031 makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST)))
0032 
0033 ifeq ("\$(origin V)", "command line")
0034 VERBOSE := \$(V)
0035 endif
0036 ifneq (\$(VERBOSE),1)
0037 Q := @
0038 endif
0039 
0040 MAKEARGS := -C $1
0041 MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$(patsubst %/,%,\$(makedir))
0042 
0043 MAKEFLAGS += --no-print-directory
0044 
0045 .PHONY: __sub-make \$(MAKECMDGOALS)
0046 
0047 __sub-make:
0048         \$(Q)\$(MAKE) \$(MAKEARGS) \$(MAKECMDGOALS)
0049 
0050 \$(filter-out __sub-make, \$(MAKECMDGOALS)): __sub-make
0051         @:
0052 EOF