Blame view

scripts/mkmakefile 1.17 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
9
10
  #!/bin/sh
  # Generates a small Makefile used in the root of the output
  # directory, to allow make to be started from there.
  # The Makefile also allow for more convinient build of external modules
  
  # Usage
  # $1 - Kernel src directory
  # $2 - Output directory
  # $3 - version
  # $4 - patchlevel
fd5f0cd6b   Jan Beulich   kbuild: Do not ov...
11
  test ! -r $2/Makefile -o -O $2/Makefile || exit 0
18c32dac7   Sam Ravnborg   kbuild: fix build...
12
13
  # Only overwrite automatically generated Makefiles
  # (so we do not overwrite kernel Makefile)
971edcfc8   Guillaume Chazarain   kbuild: re-enable...
14
  if test -e $2/Makefile && ! grep -q Automatically $2/Makefile
18c32dac7   Sam Ravnborg   kbuild: fix build...
15
16
17
  then
  	exit 0
  fi
d2301249e   Sam Ravnborg   kbuild: teach mkm...
18
19
20
  if [ "${quiet}" != "silent_" ]; then
  	echo "  GEN     $2/Makefile"
  fi
fd5f0cd6b   Jan Beulich   kbuild: Do not ov...
21
22
  
  cat << EOF > $2/Makefile
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
23
24
25
26
  # Automatically generated by $0: don't edit
  
  VERSION = $3
  PATCHLEVEL = $4
1d3b3bfab   Jan Beulich   kbuild: scripts/m...
27
28
  lastword = \$(word \$(words \$(1)),\$(1))
  makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST)))
0ff35771f   Peter Foley   kbuild: silence g...
29
30
31
32
33
34
  ifeq ("\$(origin V)", "command line")
  VERBOSE := \$(V)
  endif
  ifneq (\$(VERBOSE),1)
  Q := @
  endif
1d3b3bfab   Jan Beulich   kbuild: scripts/m...
35
36
  MAKEARGS := -C $1
  MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$(patsubst %/,%,\$(makedir))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
37
38
  
  MAKEFLAGS += --no-print-directory
96678281b   Jan Beulich   kbuild: fix mkmak...
39
  .PHONY: all \$(MAKECMDGOALS)
0b35786d7   Milton Miller   kbuild: call make...
40
  all	:= \$(filter-out all Makefile,\$(MAKECMDGOALS))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
41
  all:
0ff35771f   Peter Foley   kbuild: silence g...
42
  	\$(Q)\$(MAKE) \$(MAKEARGS) \$(all)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
43

96678281b   Jan Beulich   kbuild: fix mkmak...
44
  Makefile:;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
45

3c955b407   Jan Beulich   fixes for using m...
46
  \$(all): all
0b35786d7   Milton Miller   kbuild: call make...
47
  	@:
1d3b3bfab   Jan Beulich   kbuild: scripts/m...
48

3c955b407   Jan Beulich   fixes for using m...
49
50
  %/: all
  	@:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
51
  EOF