Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


More Linux 3.19+ kernel compatability fixes
[palacios.git] / Makefile
1 VERSION = 1
2 PATCHLEVEL = 1
3 SUBLEVEL = 0
4 EXTRAVERSION = Palacios
5 NAME=Palacios
6
7
8 # *DOCUMENTATION*
9 # To see a list of typical targets execute "make help"
10 # More info can be located in ./README
11 # Comments in this file are targeted only to the developer, do not
12 # expect to learn how to build the kernel reading this file.
13
14 # Do not print "Entering directory ..."
15 MAKEFLAGS += --no-print-directory
16
17 # We are using a recursive build, so we need to do a little thinking
18 # to get the ordering right.
19 #
20 # Most importantly: sub-Makefiles should only ever modify files in
21 # their own directory. If in some directory we have a dependency on
22 # a file in another dir (which doesn't happen often, but it's often
23 # unavoidable when linking the built-in.o targets which finally
24 # turn into palacios), we will call a sub make in that other dir, and
25 # after that we are sure that everything which is in that other dir
26 # is now up to date.
27 #
28 # The only cases where we need to modify files which have global
29 # effects are thus separated out and done before the recursive
30 # descending is started. They are now explicitly listed as the
31 # prepare rule.
32
33 # To put more focus on warnings, be less verbose as default
34 # Use 'make V=1' to see the full commands
35
36 ifdef V
37   ifeq ("$(origin V)", "command line")
38     KBUILD_VERBOSE = $(V)
39   endif
40 endif
41 ifndef KBUILD_VERBOSE
42   KBUILD_VERBOSE = 0
43 endif
44
45 # Call sparse as part of compilation of C files
46 # Use 'make C=1' to enable sparse checking
47
48 ifdef C
49   ifeq ("$(origin C)", "command line")
50     KBUILD_CHECKSRC = $(C)
51   endif
52 endif
53 ifndef KBUILD_CHECKSRC
54   KBUILD_CHECKSRC = 0
55 endif
56
57 # Use make M=dir to specify directory of external module to build
58 # Old syntax make ... SUBDIRS=$PWD is still supported
59 # Setting the environment variable KBUILD_EXTMOD take precedence
60 ifdef SUBDIRS
61   KBUILD_EXTMOD ?= $(SUBDIRS)
62 endif
63 ifdef M
64   ifeq ("$(origin M)", "command line")
65     KBUILD_EXTMOD := $(M)
66   endif
67 endif
68
69
70 # kbuild supports saving output files in a separate directory.
71 # To locate output files in a separate directory two syntaxes are supported.
72 # In both cases the working directory must be the root of the kernel src.
73 # 1) O=
74 # Use "make O=dir/to/store/output/files/"
75
76 # 2) Set KBUILD_OUTPUT
77 # Set the environment variable KBUILD_OUTPUT to point to the directory
78 # where the output files shall be placed.
79 # export KBUILD_OUTPUT=dir/to/store/output/files/
80 # make
81 #
82 # The O= assignment takes precedence over the KBUILD_OUTPUT environment
83 # variable.
84
85
86 # KBUILD_SRC is set on invocation of make in OBJ directory
87 # KBUILD_SRC is not intended to be used by the regular user (for now)
88 ifeq ($(KBUILD_SRC),)
89
90 # OK, Make called in directory where kernel src resides
91 # Do we want to locate output files in a separate directory?
92 ifdef O
93   ifeq ("$(origin O)", "command line")
94     KBUILD_OUTPUT := $(O)
95   endif
96 endif
97
98 # That's our default target when none is given on the command line
99 PHONY := _all
100 _all:
101
102 ifneq ($(KBUILD_OUTPUT),)
103 # Invoke a second make in the output directory, passing relevant variables
104 # check that the output directory actually exists
105 saved-output := $(KBUILD_OUTPUT)
106 KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
107 $(if $(KBUILD_OUTPUT),, \
108      $(error output directory "$(saved-output)" does not exist))
109
110 PHONY += $(MAKECMDGOALS)
111
112 $(filter-out _all,$(MAKECMDGOALS)) _all:
113         $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
114         KBUILD_SRC=$(CURDIR) \
115         KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile $@
116
117 # Leave processing to above invocation of make
118 skip-makefile := 1
119 endif # ifneq ($(KBUILD_OUTPUT),)
120 endif # ifeq ($(KBUILD_SRC),)
121
122 # We process the rest of the Makefile if this is the final invocation of make
123 ifeq ($(skip-makefile),)
124
125 # If building an external module we do not care about the all: rule
126 # but instead _all depend on modules
127 PHONY += all
128
129 _all: all
130
131
132 srctree         := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
133 TOPDIR          := $(srctree)
134 # FIXME - TOPDIR is obsolete, use srctree/objtree
135 objtree         := $(CURDIR)
136 src             := $(srctree)
137 obj             := $(objtree)
138
139 VPATH           := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
140
141 export srctree objtree VPATH TOPDIR
142
143
144 # SUBARCH tells the usermode build what the underlying arch is.  That is set
145 # first, and if a usermode build is happening, the "ARCH=um" on the command
146 # line overrides the setting of ARCH below.  If a native build is happening,
147 # then ARCH is assigned, getting whatever value it gets normally, and 
148 # SUBARCH is subsequently ignored.
149
150 SUBARCH := $(shell uname -m | sed -e s/i.86/i386/  )
151
152 # Cross compiling and selecting different set of gcc/bin-utils
153 # ---------------------------------------------------------------------------
154 #
155 # When performing cross compilation for other architectures ARCH shall be set
156 # to the target architecture. (See arch/* for the possibilities).
157 # ARCH can be set during invocation of make:
158 # make ARCH=ia64
159 # Another way is to have ARCH set in the environment.
160 # The default ARCH is the host where make is executed.
161
162 # CROSS_COMPILE specify the prefix used for all executables used
163 # during compilation. Only gcc and related bin-utils executables
164 # are prefixed with $(CROSS_COMPILE).
165 # CROSS_COMPILE can be set on the command line
166 # make CROSS_COMPILE=ia64-linux-
167 # Alternatively CROSS_COMPILE can be set in the environment.
168 # Default value for CROSS_COMPILE is not to prefix executables
169 # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
170
171 ARCH            ?= $(SUBARCH)
172 CROSS_COMPILE   ?=
173
174 # Architecture as present in compile.h
175 UTS_MACHINE := $(ARCH)
176
177 # SHELL used by kbuild
178 CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
179           else if [ -x /bin/bash ]; then echo /bin/bash; \
180           else echo sh; fi ; fi)
181
182 HOSTCC          = gcc
183 HOSTCXX         = g++
184 HOSTCFLAGS      = -Wall -Wstrict-prototypes  -fomit-frame-pointer \
185                         -Wno-unused -Wno-format-security -U_FORTIFY_SOURCE
186 HOSTCXXFLAGS    = -O
187
188 #       Decide whether to build built-in, modular, or both.
189 #       Normally, just do built-in.
190
191 KBUILD_MODULES :=
192 KBUILD_BUILTIN := 1
193
194 #       If we have only "make modules", don't compile built-in objects.
195 #       When we're building modules with modversions, we need to consider
196 #       the built-in objects during the descend as well, in order to
197 #       make sure the checksums are uptodate before we record them.
198
199 ifeq ($(MAKECMDGOALS),modules)
200   KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1)
201 endif
202
203 #       If we have "make <whatever> modules", compile modules
204 #       in addition to whatever we do anyway.
205 #       Just "make" or "make all" shall build modules as well
206
207 ifneq ($(filter all _all modules,$(MAKECMDGOALS)),)
208   KBUILD_MODULES := 1
209 endif
210
211 ifeq ($(MAKECMDGOALS),)
212   KBUILD_MODULES := 1
213 endif
214
215 export KBUILD_MODULES KBUILD_BUILTIN
216 export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD
217
218 # Beautify output
219 # ---------------------------------------------------------------------------
220 #
221 # Normally, we echo the whole command before executing it. By making
222 # that echo $($(quiet)$(cmd)), we now have the possibility to set
223 # $(quiet) to choose other forms of output instead, e.g.
224 #
225 #         quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
226 #         cmd_cc_o_c       = $(CC) $(c_flags) -c -o $@ $<
227 #
228 # If $(quiet) is empty, the whole command will be printed.
229 # If it is set to "quiet_", only the short version will be printed. 
230 # If it is set to "silent_", nothing wil be printed at all, since
231 # the variable $(silent_cmd_cc_o_c) doesn't exist.
232 #
233 # A simple variant is to prefix commands with $(Q) - that's useful
234 # for commands that shall be hidden in non-verbose mode.
235 #
236 #       $(Q)ln $@ :<
237 #
238 # If KBUILD_VERBOSE equals 0 then the above command will be hidden.
239 # If KBUILD_VERBOSE equals 1 then the above command is displayed.
240
241 ifeq ($(KBUILD_VERBOSE),1)
242   quiet =
243   Q =
244 else
245   quiet=quiet_
246   Q = @
247 endif
248
249 # If the user is running make -s (silent mode), suppress echoing of
250 # commands
251
252 ifneq ($(findstring s,$(MAKEFLAGS)),)
253   quiet=silent_
254 endif
255
256 export quiet Q KBUILD_VERBOSE
257
258
259 # Look for make include files relative to root of kernel src
260 MAKEFLAGS += --include-dir=$(srctree)
261
262 # We need some generic definitions
263 include  $(srctree)/scripts/Kbuild.include
264
265 # For maximum performance (+ possibly random breakage, uncomment
266 # the following)
267
268 #MAKEFLAGS += -rR
269
270 # Make variables (CC, etc...)
271
272 AS              = $(CROSS_COMPILE)as
273 LD              = $(CROSS_COMPILE)ld
274 CC              = $(CROSS_COMPILE)gcc
275 CPP             = $(CC) -E
276 AR              = $(CROSS_COMPILE)ar
277 NM              = $(CROSS_COMPILE)nm
278 STRIP           = $(CROSS_COMPILE)strip
279 OBJCOPY         = $(CROSS_COMPILE)objcopy
280 OBJDUMP         = $(CROSS_COMPILE)objdump
281 AWK             = awk
282 GENKSYMS        = scripts/genksyms/genksyms
283 DEPMOD          = /sbin/depmod
284 KALLSYMS        = scripts/kallsyms
285 PERL            = perl
286 CHECK           = sparse
287
288
289 CFLAGS_KERNEL   =
290 AFLAGS_KERNEL   =
291
292
293 # Use V3_INCLUDE when you must reference the include/ directory.
294 # Needed to be compatible with the O= option
295 V3_INCLUDE      := -Ipalacios/include \
296                    $(if $(KBUILD_SRC),-I$(srctree)/palacios/include) \
297                    -include palacios/include/autoconf.h
298
299 CPPFLAGS        := $(V3_INCLUDE) -D__V3VEE__
300
301 #
302 # We want no-strict-aliasing here whether or not the target kernel
303 # has it configued.  See Linus's rant about gcc's "if the standard
304 # says we can do anything, we will do the wrong thing" behavior with
305 # regard to this option
306 #
307 CFLAGS          :=  -fno-stack-protector -Wall -Werror  -mno-red-zone -fno-common \
308                     -fno-strict-aliasing -ffreestanding \
309                     $(call cc-option, -Wno-unused-but-set-variable,)
310
311
312
313 #-ffreestanding
314
315
316 LDFLAGS         := --whole-archive 
317
318 ifeq ($(call cc-option-yn, -fgnu89-inline),y)
319 CFLAGS          += -fgnu89-inline
320 endif
321
322 AFLAGS          := 
323
324 # Read KERNELRELEASE from .kernelrelease (if it exists)
325 #KERNELRELEASE = $(shell cat .kernelrelease 2> /dev/null)
326 #KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
327
328 export  VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION \
329         ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \
330         CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \
331         HOSTCXX HOSTCXXFLAGS CHECK
332
333 export CPPFLAGS NOSTDINC_FLAGS V3_INCLUDE OBJCOPYFLAGS LDFLAGS
334 export CFLAGS CFLAGS_KERNEL 
335 export AFLAGS AFLAGS_KERNEL
336
337 # When compiling out-of-tree modules, put MODVERDIR in the module
338 # tree rather than in the kernel tree. The kernel tree might
339 # even be read-only.
340 export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions
341
342 # Files to ignore in find ... statements
343
344 RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg -o -name .git \) -prune -o
345 export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc --exclude .hg --exclude .git
346
347 # ===========================================================================
348 # Rules shared between *config targets and build targets
349
350 # Basic helpers built in scripts/
351 PHONY += scripts_basic
352 scripts_basic:
353         $(Q)$(MAKE) $(build)=scripts/basic
354
355 # To avoid any implicit rule to kick in, define an empty command.
356 scripts/basic/%: scripts_basic ;
357
358 PHONY += outputmakefile
359 # outputmakefile generates a Makefile in the output directory, if using a
360 # separate output directory. This allows convenient use of make in the
361 # output directory.
362 outputmakefile:
363 ifneq ($(KBUILD_SRC),)
364         $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \
365             $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
366 endif
367
368 # To make sure we do not include .config for any of the *config targets
369 # catch them early, and hand them over to scripts/kconfig/Makefile
370 # It is allowed to specify more targets when calling make, including
371 # mixing *config targets and build targets.
372 # For example 'make oldconfig all'. 
373 # Detect when mixed targets is specified, and make a second invocation
374 # of make so .config is not included in this case either (for *config).
375
376 no-dot-config-targets := clean mrproper distclean \
377                          cscope TAGS tags help %docs check%
378
379 config-targets := 0
380 mixed-targets  := 0
381 dot-config     := 1
382
383 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
384         ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
385                 dot-config := 0
386         endif
387 endif
388
389 ifeq ($(KBUILD_EXTMOD),)
390         ifneq ($(filter %config,$(MAKECMDGOALS)),)
391                 config-targets := 1
392                 ifneq ($(filter-out %config,$(MAKECMDGOALS)),)
393                         mixed-targets := 1
394                 endif
395         endif
396 endif
397
398 ifeq ($(mixed-targets),1)
399 # ===========================================================================
400 # We're called with mixed targets (*config and build targets).
401 # Handle them one by one.
402
403 %:: FORCE
404         $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@
405
406 else
407 ifeq ($(config-targets),1)
408 # ===========================================================================
409 # *config targets only - make sure prerequisites are updated, and descend
410 # in scripts/kconfig to make the *config target
411
412 # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.
413 # KBUILD_DEFCONFIG may point out an alternative default configuration
414 # used for 'make defconfig'
415 include $(srctree)/Makefile.$(ARCH)
416 export KBUILD_DEFCONFIG
417
418 %config: scripts_basic outputmakefile FORCE
419         $(Q)mkdir -p palacios/include/config
420         $(Q)$(MAKE) $(build)=scripts/kconfig $@
421 #       $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease
422
423 else
424 # ===========================================================================
425 # Build targets only - this includes Palacios arch specific targets, clean
426 # targets and others. In general all targets except *config targets.
427
428
429 # Additional helpers built in scripts/
430 # Carefully list dependencies so we do not try to build scripts twice
431 # in parrallel
432 PHONY += scripts
433 scripts: scripts_basic palacios/include/config/MARKER
434         $(Q)$(MAKE) $(build)=$(@)
435
436 scripts_basic: palacios/include/autoconf.h
437
438 # Objects we will link into palacios / subdirs we need to visit
439 #drivers-y      := drivers/
440 #net-y          := net/
441 #core-y         := usr/
442 core-y          := palacios/src/palacios/
443 libs-y          := palacios/lib/$(ARCH)/
444 devices-y       := palacios/src/devices/
445 interfaces-y    := palacios/src/interfaces/
446 extensions-y    := palacios/src/extensions/
447 vnet-y          := palacios/src/vnet/
448 gears-y         := palacios/src/gears/
449 modules-y       := modules/
450
451
452
453 ifeq ($(dot-config),1)
454 # In this section, we need .config
455
456 # Read in dependencies to all Kconfig* files, make sure to run
457 # oldconfig if changes are detected.
458 -include .kconfig.d
459
460 include .config
461
462 # If .config needs to be updated, it will be done via the dependency
463 # that autoconf has on .config.
464 # To avoid any implicit rule to kick in, define an empty command
465 .config .kconfig.d: ;
466
467 # If .config is newer than palacios/include/autoconf.h, someone tinkered
468 # with it and forgot to run make oldconfig.
469 # If kconfig.d is missing then we are probarly in a cleaned tree so
470 # we execute the config step to be sure to catch updated Kconfig files
471 palacios/include/autoconf.h: .kconfig.d .config
472         $(Q)mkdir -p palacios/include/config
473         $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
474 else
475 # Dummy target needed, because used as prerequisite
476 palacios/include/autoconf.h: ;
477 endif
478
479
480 ifdef V3_CONFIG_LINUX
481 DEFAULT_EXTRA_TARGETS=linux_module
482 else
483 ifdef V3_CONFIG_NAUTILUS
484 DEFAULT_EXTRA_TARGETS=nautilus
485 else
486 DEFAULT_EXTRA_TARGETS=
487 endif
488 endif
489
490 # The all: target is the default when no target is given on the
491 # command line.
492 # This allow a user to issue only 'make' to build a kernel including modules
493 # Defaults palacios but it is usually overriden in the arch makefile
494 all: palacios $(DEFAULT_EXTRA_TARGETS)
495
496
497 ifdef V3_CONFIG_LINUX
498 CFLAGS          += -mcmodel=kernel 
499 else
500 ifdef V3_CONFIG_NAUTILUS
501 CFLAGS          += -O2 \
502                    -fno-omit-frame-pointer \
503                    -ffreestanding \
504                    -fno-stack-protector \
505                    -fno-strict-aliasing \
506                    -mno-red-zone \
507                    -mcmodel=large 
508 LDFLAGS         += -z max-page-size=0x1000
509 else
510 CFLAGS          += -fPIC
511 endif
512 endif
513
514 ifdef V3_CONFIG_FRAME_POINTER
515 CFLAGS          += -fno-omit-frame-pointer $(call cc-option,-fno-optimize-sibling-calls,)
516 else
517 CFLAGS          += -fomit-frame-pointer
518 endif
519
520
521 ifdef V3_CONFIG_UNWIND_INFO
522 CFLAGS          += -fasynchronous-unwind-tables
523 endif
524
525 ifdef V3_CONFIG_DEBUG_INFO
526 CFLAGS          += -g
527 endif
528
529
530 include $(srctree)/Makefile.$(ARCH)
531
532 # arch Makefile may override CC so keep this after arch Makefile is included
533 NOSTDINC_FLAGS +=
534
535
536 # disable pointer signedness warnings in gcc 4.0
537 CFLAGS += $(call cc-option,-Wno-pointer-sign,)
538
539 CFLAGS += -O2
540
541 # Default kernel image to build when no specific target is given.
542 # KBUILD_IMAGE may be overruled on the commandline or
543 # set in the environment
544 # Also any assignments in /Makefile.$(ARCH) take precedence over
545 # this default value
546 export KBUILD_IMAGE ?= palacios
547
548 #
549 # INSTALL_PATH specifies where to place the updated kernel and system map
550 # images. Default is /boot, but you can set it to other values
551 export  INSTALL_PATH ?= /build
552
553
554
555
556
557 palacios-dirs   := $(patsubst %/,%,$(filter %/,  \
558                      $(core-y) $(devices-y) $(interfaces-y) $(extensions-y) $(vnet-y) $(gears-y) $(libs-y)) $(modules-y))
559
560
561
562 #palacios-alldirs       := $(sort $(palacios-dirs) $(patsubst %/,%,$(filter %/, \
563 #                    $(core-n) $(core-) $(devices-n) $(devices-) \
564 #                    $(libs-n)    $(libs-))))
565
566
567 palacios-cleandirs := $(sort $(palacios-dirs) $(patsubst %/,%,$(filter %/, \
568                         $(core-n) $(core-) $(devices-n) $(devices-) \
569                         $(interfaces-n) $(interfaces-) $(extensions-n) $(extensions-) $(vnet-n) $(vnet-) $(gears-n) $(gears-) $(modules-n) $(modules-))))
570
571
572
573 core-y          := $(patsubst %/, %/built-in.o, $(core-y))
574 devices-y       := $(patsubst %/, %/built-in.o, $(devices-y))
575 interfaces-y    := $(patsubst %/, %/built-in.o, $(interfaces-y))
576 extensions-y    := $(patsubst %/, %/built-in.o, $(extensions-y))
577 libs-y          := $(patsubst %/, %/built-in.o, $(libs-y))
578 vnet-y          := $(patsubst %/, %/built-in.o, $(vnet-y))
579 gears-y         := $(patsubst %/, %/built-in.o, $(gears-y))
580 modules-y       := $(patsubst %/, %/built-in.o, $(modules-y))
581 #lnxmod-y        := $(patsubst %/, %/built-in.o, $(lnxmod-y))
582
583 #core-y         := $(patsubst %/, %/lib.a, $(core-y))
584 #devices-y      := $(patsubst %/, %/lib.a, $(devices-y))
585
586 # $(patsubst %/, %/built-in.o, $(libs-y))
587
588
589 # Build palacios
590 # ---------------------------------------------------------------------------
591 # Palacios is build from the objects selected by $(palacios-init) and
592 # $(palacios). Most are built-in.o files from top-level directories
593 # in the kernel tree, others are specified in Makefile.
594 # Ordering when linking is important, and $(palacios-init) must be first.
595 #
596 # palacios
597 #   ^
598 #   |
599 #   +--< $(palacios)
600 #   |    +--< devices/built-in.o  + more
601 #
602
603
604
605 palacios := $(core-y) $(devices-y) $(interfaces-y) $(extensions-y) $(vnet-y) $(gears-y) $(libs-y) $(modules-y)
606
607
608 # Rule to link palacios - also used during CONFIG_CONFIGKALLSYMS
609 # May be overridden by /Makefile.$(ARCH)
610 quiet_cmd_palacios__ ?= AR $@ 
611       cmd_palacios__ ?= $(AR) rcs $@ $^
612
613
614
615 # Generate new palacios version
616 quiet_cmd_palacios_version = GEN     .version
617       cmd_palacios_version = set -e;                       \
618         if [ ! -r .version ]; then                      \
619           rm -f .version;                               \
620           echo 1 >.version;                             \
621         else                                            \
622           mv .version .old_version;                     \
623           expr 0$$(cat .old_version) + 1 >.version;     \
624         fi;                                     
625
626
627 # Link of palacios
628 # If CONFIG_KALLSYMS is set .version is already updated
629 # Generate System.map and verify that the content is consistent
630 # Use + in front of the palacios_version rule to silent warning with make -j2
631 # First command is ':' to allow us to use + in front of the rule
632 define rule_palacios__
633         :
634         $(call cmd,palacios__)
635         $(Q)echo 'cmd_$@ := $(cmd_palacios__)' > $(@D)/.$(@F).cmd
636
637
638 endef
639
640
641 # palacios image - including updated kernel symbols
642 libv3vee.a: $(palacios)
643         $(call if_changed_rule,palacios__)
644
645 palacios: libv3vee.a
646
647
648
649
650 linux_module/v3vee.ko: linux_module/*.c linux_module/*.h libv3vee.a
651         cd linux_module/ && make -j 8
652         cp linux_module/v3vee.ko v3vee.ko
653
654 .PHONY: linux_module
655 linux_module: linux_module/v3vee.ko 
656
657 nautilus/libnautilus.a: nautilus/*.c nautilus/*.h libv3vee.a
658         cd nautilus/ && make 
659         cp nautilus/libnautilus.a .
660
661 .PHONY: nautilus
662 nautilus: nautilus/libnautilus.a
663
664
665 palacios.asm: palacios
666         $(OBJDUMP) --disassemble $< > $@
667
668 # The actual objects are generated when descending, 
669 # make sure no implicit rule kicks in
670 $(sort  $(palacios)) : $(palacios-dirs) ;
671
672 # Handle descending into subdirectories listed in $(palacios-dirs)
673 # Preset locale variables to speed up the build process. Limit locale
674 # tweaks to this spot to avoid wrong language settings when running
675 # make menuconfig etc.
676 # Error messages still appears in the original language
677
678 PHONY += $(palacios-dirs)
679 $(palacios-dirs): prepare scripts
680         $(Q)$(MAKE) $(build)=$@
681
682
683
684
685
686 # Things we need to do before we recursively start building the kernel
687 # or the modules are listed in "prepare".
688 # A multi level approach is used. prepareN is processed before prepareN-1.
689 # archprepare is used in arch Makefiles and when processed arch symlink,
690 # version.h and scripts_basic is processed / created.
691
692 # Listed in dependency order
693 PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
694
695 # prepare-all is deprecated, use prepare as valid replacement
696 PHONY += prepare-all
697
698 # prepare3 is used to check if we are building in a separate output directory,
699 # and if so do:
700 # 1) Check that make has not been executed in the kernel src $(srctree)
701 prepare3: 
702 ifneq ($(KBUILD_SRC),)
703         @echo '  Using $(srctree) as source for kernel'
704         $(Q)if [ -f $(srctree)/.config ]; then \
705                 echo "  $(srctree) is not clean, please run 'make mrproper'";\
706                 echo "  in the '$(srctree)' directory.";\
707                 /bin/false; \
708         fi;
709 endif
710
711 # prepare2 creates a makefile if using a separate output directory
712 prepare2: prepare3 outputmakefile
713
714 prepare1: prepare2 palacios/include/config/MARKER
715
716 archprepare: prepare1 scripts_basic
717
718 prepare0: archprepare FORCE
719         $(Q)$(MAKE) $(build)=.
720
721 # All the preparing..
722 prepare prepare-all: prepare0
723
724
725
726 palacios/include/config/MARKER: scripts/basic/split-include palacios/include/autoconf.h
727         @echo '  SPLIT   palacios/include/autoconf.h -> palacios/include/config/*'
728         @scripts/basic/split-include palacios/include/autoconf.h palacios/include/config
729         @touch $@
730
731
732
733 # ---------------------------------------------------------------------------
734
735 PHONY += depend dep
736 depend dep:
737         @echo '*** Warning: make $@ is unnecessary now.'
738
739
740
741 ###
742 # Cleaning is done on three levels.
743 # make clean     Delete most generated files
744 #                Leave enough to build external modules
745 # make mrproper  Delete the current configuration, and all generated files
746 # make distclean Remove editor backup files, patch leftover files and the like
747
748 # Directories & files removed with 'make clean'
749 CLEAN_DIRS  += $(MODVERDIR)
750 CLEAN_FILES +=   v3vee.asm \
751                  .tmp_version .tmp_palacios*
752
753 # Directories & files removed with 'make mrproper'
754 MRPROPER_DIRS  += palacios/include/config 
755 MRPROPER_FILES += .config .config.old  .version .old_version \
756                   palacios/include/autoconf.h  \
757                   tags TAGS cscope*
758
759
760 #               \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
761
762
763 # clean - Delete most, but leave enough to build external modules
764 #
765 clean: rm-dirs  := $(CLEAN_DIRS)
766 clean: rm-files := $(CLEAN_FILES)
767 clean-dirs      := $(addprefix _clean_,$(srctree) $(palacios-cleandirs))
768
769 PHONY += $(clean-dirs) clean archclean
770 $(clean-dirs):
771         $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
772
773
774 clean: archclean $(clean-dirs)
775         $(call cmd,rmdirs)
776         $(call cmd,rmfiles)
777         @find . $(RCS_FIND_IGNORE) \
778                 \( -name 'lib' \) -prune -o \
779                 \( -name '*.[oas]' -o -name '.*.cmd' \
780                 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' -o -name '*.ko' \) \
781                 -type f -print | xargs rm -f
782
783 # mrproper - Delete all generated files, including .config
784 #
785 mrproper: rm-dirs  := $(wildcard $(MRPROPER_DIRS))
786 mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
787 #mrproper-dirs      := $(addprefix _mrproper_,Documentation/DocBook scripts)
788 mrproper-dirs      := $(addprefix _mrproper_, scripts)
789
790 PHONY += $(mrproper-dirs) mrproper archmrproper
791 $(mrproper-dirs):
792         $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
793
794 mrproper: clean archmrproper $(mrproper-dirs)
795         $(call cmd,rmdirs)
796         $(call cmd,rmfiles)
797
798 # distclean
799 #
800 PHONY += distclean
801
802 distclean: mrproper
803         @find $(srctree) $(RCS_FIND_IGNORE) \
804                 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
805                 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
806                 -o -name '.*.rej' -o -size 0 \
807                 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
808                 -type f -print | xargs rm -f
809
810
811 # Packaging of the kernel to various formats
812 # ---------------------------------------------------------------------------
813 # rpm target kept for backward compatibility
814 package-dir     := $(srctree)/scripts/package
815
816 %pkg: FORCE
817         $(Q)$(MAKE) $(build)=$(package-dir) $@
818 rpm: FORCE
819         $(Q)$(MAKE) $(build)=$(package-dir) $@
820
821
822 # Brief documentation of the typical targets used
823 # ---------------------------------------------------------------------------
824
825
826 help:
827         @echo  'Cleaning targets:'
828         @echo  '  clean           - remove most generated files but keep the config'
829         @echo  '  mrproper        - remove all generated files + config + various backup files'
830         @echo  ''
831         @echo  'Configuration targets:'
832         @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
833         @echo  ''
834         @echo  'Other generic targets:'
835         @echo  '  all             - Build all targets marked with [*]'
836         @echo  '* palacios        - Build the palacios VMM'
837         @echo  '  dir/            - Build all files in dir and below'
838         @echo  '  dir/file.[ois]  - Build specified target only'
839         @echo  '  dir/file.ko     - Build module including final link'
840         @echo  '  rpm             - Build a kernel as an RPM package'
841         @echo  '  tags/TAGS       - Generate tags file for editors'
842         @echo  '  cscope          - Generate cscope index'
843         @echo  ''
844         @echo  'Kernel packaging:'
845         @$(MAKE) $(build)=$(package-dir) help
846         @echo  ''
847         @echo  'Documentation targets:'
848         @$(MAKE) -f $(srctree)/Documentation/DocBook/Makefile dochelp
849         @echo  ''
850         @echo  'Architecture specific targets ($(ARCH)):'
851         @$(if $(archhelp),$(archhelp),\
852                 echo '  No architecture specific help defined for $(ARCH)')
853         @echo  ''
854         @echo  '  make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
855         @echo  '  make O=dir [targets] Locate all output files in "dir", including .config'
856         @echo  '  make C=1   [targets] Check all c source with $$CHECK (sparse)'
857         @echo  '  make C=2   [targets] Force check of all c source with $$CHECK (sparse)'
858         @echo  ''
859         @echo  'Execute "make" or "make all" to build all targets marked with [*] '
860         @echo  'For further info see the ./README file'
861
862
863 # Documentation targets
864 # ---------------------------------------------------------------------------
865 %docs: scripts_basic FORCE
866         $(Q)$(MAKE) $(build)=Documentation/DocBook $@
867
868
869 # Generate tags for editors
870 # ---------------------------------------------------------------------------
871
872 #We want __srctree to totally vanish out when KBUILD_OUTPUT is not set
873 #(which is the most common case IMHO) to avoid unneeded clutter in the big tags file.
874 #Adding $(srctree) adds about 20M on i386 to the size of the output file!
875
876 ifeq ($(src),$(obj))
877 __srctree =
878 else
879 __srctree = $(srctree)/
880 endif
881
882 ifeq ($(ALLSOURCE_ARCHS),)
883 ifeq ($(ARCH),um)
884 ALLINCLUDE_ARCHS := $(ARCH) $(SUBARCH)
885 else
886 ALLINCLUDE_ARCHS := $(ARCH)
887 endif
888 else
889 #Allow user to specify only ALLSOURCE_PATHS on the command line, keeping existing behaviour.
890 ALLINCLUDE_ARCHS := $(ALLSOURCE_ARCHS)
891 endif
892
893 ALLSOURCE_ARCHS := $(ARCH)
894
895 define all-sources
896         ( find $(__srctree)palacios $(RCS_FIND_IGNORE) \
897                \( -name lib \) -prune -o \
898                -name '*.[chS]' -print; )
899 endef
900
901 quiet_cmd_cscope-file = FILELST cscope.files
902       cmd_cscope-file = (echo \-k; echo \-q; $(all-sources)) > cscope.files
903
904 quiet_cmd_cscope = MAKE    cscope.out
905       cmd_cscope = cscope -b
906
907 cscope: FORCE
908         $(call cmd,cscope-file)
909         $(call cmd,cscope)
910
911 quiet_cmd_TAGS = MAKE   $@
912 define cmd_TAGS
913         rm -f $@; \
914         ETAGSF=`etags --version | grep -i exuberant >/dev/null &&     \
915                 echo "-I __initdata,__exitdata,__acquires,__releases  \
916                       -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL              \
917                       --extra=+f --c-kinds=+px"`;                     \
918                 $(all-sources) | xargs etags $$ETAGSF -a
919 endef
920
921 TAGS: FORCE
922         $(call cmd,TAGS)
923
924
925 quiet_cmd_tags = MAKE   $@
926 define cmd_tags
927         rm -f $@; \
928         CTAGSF=`ctags --version | grep -i exuberant >/dev/null &&     \
929                 echo "-I __initdata,__exitdata,__acquires,__releases  \
930                       -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL              \
931                       --extra=+f --c-kinds=+px"`;                     \
932                 $(all-sources) | xargs ctags $$CTAGSF -a
933 endef
934
935 tags: FORCE
936         $(call cmd,tags)
937
938
939 # Scripts to check various things for consistency
940 # ---------------------------------------------------------------------------
941
942 endif #ifeq ($(config-targets),1)
943 endif #ifeq ($(mixed-targets),1)
944
945
946
947
948 # Single targets
949 # ---------------------------------------------------------------------------
950 # Single targets are compatible with:
951 # - build whith mixed source and output
952 # - build with separate output dir 'make O=...'
953 # - external modules
954 #
955 #  target-dir => where to store outputfile
956 #  build-dir  => directory in kernel source tree to use
957
958 build-dir  = $(patsubst %/,%,$(dir $@))
959 target-dir = $(dir $@)
960
961
962 %.s: %.c prepare scripts FORCE
963         $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
964 %.i: %.c prepare scripts FORCE
965         $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
966 %.o: %.c prepare scripts FORCE
967         $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
968 %.lst: %.c prepare scripts FORCE
969         $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
970 %.s: %.S prepare scripts FORCE
971         $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
972 %.o: %.S prepare scripts FORCE
973         $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
974
975 # Modules
976 %/: prepare scripts FORCE
977         $(Q)$(MAKE) KBUILD_MODULES=$(if $(V3_CONFIG_MODULES),1) \
978         $(build)=$(build-dir)
979 %.ko: prepare scripts FORCE
980         $(Q)$(MAKE) KBUILD_MODULES=$(if $(V3_CONFIG_MODULES),1)   \
981         $(build)=$(build-dir) $(@:.ko=.o)
982         $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
983
984 # FIXME Should go into a make.lib or something 
985 # ===========================================================================
986
987 quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN   $(wildcard $(rm-dirs)))
988       cmd_rmdirs = rm -rf $(rm-dirs)
989
990 quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN   $(wildcard $(rm-files)))
991       cmd_rmfiles = rm -f $(rm-files)
992
993
994 a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) \
995           $(NOSTDINC_FLAGS) $(CPPFLAGS) \
996           $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
997
998 quiet_cmd_as_o_S = AS      $@
999 cmd_as_o_S       = $(CC) $(a_flags) -c -o $@ $<
1000
1001 # read all saved command lines
1002
1003 targets := $(wildcard $(sort $(targets)))
1004 cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
1005
1006 ifneq ($(cmd_files),)
1007   $(cmd_files): ;       # Do not try to update included dependency files
1008   include $(cmd_files)
1009 endif
1010
1011 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
1012 # Usage:
1013 # $(Q)$(MAKE) $(clean)=dir
1014 clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
1015
1016 endif   # skip-makefile
1017
1018 # Force the O variable for user and init_task (not set by kbuild?)
1019 user init_task: O:=$(if $O,$O,$(objtree))
1020 # Build Palacios user-space libraries and example programs
1021 user: FORCE
1022         if [ ! -d $O/$@ ]; then mkdir $O/$@; fi
1023         $(MAKE) \
1024                 -C $(src)/$@ \
1025                 O=$O/$@ \
1026                 src=$(src)/$@ \
1027                 all
1028
1029
1030
1031 PHONY += FORCE
1032 FORCE:
1033
1034
1035 # Declare the contents of the .PHONY variable as phony.  We keep that
1036 # information in a variable se we can use it in if_changed and friends.
1037 .PHONY: $(PHONY)