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.


move vnet code outside of palacios core directory
[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 CFLAGS          :=  -fno-stack-protector -Wall -Werror  -mno-red-zone -fno-common 
302
303
304
305 #-ffreestanding
306
307
308 LDFLAGS         := --whole-archive 
309
310 ifeq ($(call cc-option-yn, -fgnu89-inline),y)
311 CFLAGS          += -fgnu89-inline
312 endif
313
314 AFLAGS          := 
315
316 # Read KERNELRELEASE from .kernelrelease (if it exists)
317 #KERNELRELEASE = $(shell cat .kernelrelease 2> /dev/null)
318 #KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
319
320 export  VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION \
321         ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \
322         CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \
323         HOSTCXX HOSTCXXFLAGS CHECK
324
325 export CPPFLAGS NOSTDINC_FLAGS V3_INCLUDE OBJCOPYFLAGS LDFLAGS
326 export CFLAGS CFLAGS_KERNEL 
327 export AFLAGS AFLAGS_KERNEL
328
329 # When compiling out-of-tree modules, put MODVERDIR in the module
330 # tree rather than in the kernel tree. The kernel tree might
331 # even be read-only.
332 export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions
333
334 # Files to ignore in find ... statements
335
336 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
337 export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc --exclude .hg --exclude .git
338
339 # ===========================================================================
340 # Rules shared between *config targets and build targets
341
342 # Basic helpers built in scripts/
343 PHONY += scripts_basic
344 scripts_basic:
345         $(Q)$(MAKE) $(build)=scripts/basic
346
347 # To avoid any implicit rule to kick in, define an empty command.
348 scripts/basic/%: scripts_basic ;
349
350 PHONY += outputmakefile
351 # outputmakefile generates a Makefile in the output directory, if using a
352 # separate output directory. This allows convenient use of make in the
353 # output directory.
354 outputmakefile:
355 ifneq ($(KBUILD_SRC),)
356         $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \
357             $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
358 endif
359
360 # To make sure we do not include .config for any of the *config targets
361 # catch them early, and hand them over to scripts/kconfig/Makefile
362 # It is allowed to specify more targets when calling make, including
363 # mixing *config targets and build targets.
364 # For example 'make oldconfig all'. 
365 # Detect when mixed targets is specified, and make a second invocation
366 # of make so .config is not included in this case either (for *config).
367
368 no-dot-config-targets := clean mrproper distclean \
369                          cscope TAGS tags help %docs check%
370
371 config-targets := 0
372 mixed-targets  := 0
373 dot-config     := 1
374
375 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
376         ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
377                 dot-config := 0
378         endif
379 endif
380
381 ifeq ($(KBUILD_EXTMOD),)
382         ifneq ($(filter config %config,$(MAKECMDGOALS)),)
383                 config-targets := 1
384                 ifneq ($(filter-out config %config,$(MAKECMDGOALS)),)
385                         mixed-targets := 1
386                 endif
387         endif
388 endif
389
390 ifeq ($(mixed-targets),1)
391 # ===========================================================================
392 # We're called with mixed targets (*config and build targets).
393 # Handle them one by one.
394
395 %:: FORCE
396         $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@
397
398 else
399 ifeq ($(config-targets),1)
400 # ===========================================================================
401 # *config targets only - make sure prerequisites are updated, and descend
402 # in scripts/kconfig to make the *config target
403
404 # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.
405 # KBUILD_DEFCONFIG may point out an alternative default configuration
406 # used for 'make defconfig'
407 include $(srctree)/Makefile.$(ARCH)
408 export KBUILD_DEFCONFIG
409
410 config %config: scripts_basic outputmakefile FORCE
411         $(Q)mkdir -p palacios/include/config
412         $(Q)$(MAKE) $(build)=scripts/kconfig $@
413 #       $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease
414
415 else
416 # ===========================================================================
417 # Build targets only - this includes Palacios arch specific targets, clean
418 # targets and others. In general all targets except *config targets.
419
420
421 # Additional helpers built in scripts/
422 # Carefully list dependencies so we do not try to build scripts twice
423 # in parrallel
424 PHONY += scripts
425 scripts: scripts_basic palacios/include/config/MARKER
426         $(Q)$(MAKE) $(build)=$(@)
427
428 scripts_basic: palacios/include/autoconf.h
429
430 # Objects we will link into palacios / subdirs we need to visit
431 #drivers-y      := drivers/
432 #net-y          := net/
433 #core-y         := usr/
434 core-y          := palacios/src/palacios/
435 libs-y          := palacios/lib/$(ARCH)/
436 devices-y       := palacios/src/devices/
437 interfaces-y    := palacios/src/interfaces/
438 extensions-y    := palacios/src/extensions/
439 vnet-y          := palacios/src/vnet/
440 modules-y       := modules/
441
442
443
444 ifeq ($(dot-config),1)
445 # In this section, we need .config
446
447 # Read in dependencies to all Kconfig* files, make sure to run
448 # oldconfig if changes are detected.
449 -include .kconfig.d
450
451 include .config
452
453 # If .config needs to be updated, it will be done via the dependency
454 # that autoconf has on .config.
455 # To avoid any implicit rule to kick in, define an empty command
456 .config .kconfig.d: ;
457
458 # If .config is newer than palacios/include/autoconf.h, someone tinkered
459 # with it and forgot to run make oldconfig.
460 # If kconfig.d is missing then we are probarly in a cleaned tree so
461 # we execute the config step to be sure to catch updated Kconfig files
462 palacios/include/autoconf.h: .kconfig.d .config
463         $(Q)mkdir -p palacios/include/config
464         $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
465 else
466 # Dummy target needed, because used as prerequisite
467 palacios/include/autoconf.h: ;
468 endif
469
470
471 ifdef V3_CONFIG_LINUX
472 DEFAULT_EXTRA_TARGETS=linux_module
473 else
474 DEFAULT_EXTRA_TARGETS=
475 endif
476
477 # The all: target is the default when no target is given on the
478 # command line.
479 # This allow a user to issue only 'make' to build a kernel including modules
480 # Defaults palacios but it is usually overriden in the arch makefile
481 all: palacios $(DEFAULT_EXTRA_TARGETS)
482
483
484 ifdef V3_CONFIG_LINUX
485 CFLAGS          += -mcmodel=kernel 
486 else
487 CFLAGS          += -fPIC
488 endif
489
490 ifdef V3_CONFIG_FRAME_POINTER
491 CFLAGS          += -fno-omit-frame-pointer $(call cc-option,-fno-optimize-sibling-calls,)
492 else
493 CFLAGS          += -fomit-frame-pointer
494 endif
495
496
497 ifdef V3_CONFIG_UNWIND_INFO
498 CFLAGS          += -fasynchronous-unwind-tables
499 endif
500
501 ifdef V3_CONFIG_DEBUG_INFO
502 CFLAGS          += -g
503 else 
504 CFLAGS          += -O
505 endif
506
507
508 include $(srctree)/Makefile.$(ARCH)
509
510 # arch Makefile may override CC so keep this after arch Makefile is included
511 NOSTDINC_FLAGS +=
512
513
514 # disable pointer signedness warnings in gcc 4.0
515 CFLAGS += $(call cc-option,-Wno-pointer-sign,)
516
517 # Default kernel image to build when no specific target is given.
518 # KBUILD_IMAGE may be overruled on the commandline or
519 # set in the environment
520 # Also any assignments in /Makefile.$(ARCH) take precedence over
521 # this default value
522 export KBUILD_IMAGE ?= palacios
523
524 #
525 # INSTALL_PATH specifies where to place the updated kernel and system map
526 # images. Default is /boot, but you can set it to other values
527 export  INSTALL_PATH ?= /build
528
529
530
531
532
533 palacios-dirs   := $(patsubst %/,%,$(filter %/,  \
534                      $(core-y) $(devices-y) $(interfaces-y) $(extensions-y) $(vnet-y) $(libs-y)) $(modules-y))
535
536
537
538 #palacios-alldirs       := $(sort $(palacios-dirs) $(patsubst %/,%,$(filter %/, \
539 #                    $(core-n) $(core-) $(devices-n) $(devices-) \
540 #                    $(libs-n)    $(libs-))))
541
542
543 palacios-cleandirs := $(sort $(palacios-dirs) $(patsubst %/,%,$(filter %/, \
544                         $(core-n) $(core-) $(devices-n) $(devices-) \
545                         $(interfaces-n) $(interfaces-) $(extensions-n) $(extensions-) $(vnet-n) $(vnet-) $(modules-n) $(modules-))))
546
547
548
549 core-y          := $(patsubst %/, %/built-in.o, $(core-y))
550 devices-y       := $(patsubst %/, %/built-in.o, $(devices-y))
551 interfaces-y    := $(patsubst %/, %/built-in.o, $(interfaces-y))
552 extensions-y    := $(patsubst %/, %/built-in.o, $(extensions-y))
553 libs-y          := $(patsubst %/, %/built-in.o, $(libs-y))
554 vnet-y          := $(patsubst %/, %/built-in.o, $(vnet-y))
555 modules-y       := $(patsubst %/, %/built-in.o, $(modules-y))
556 #lnxmod-y        := $(patsubst %/, %/built-in.o, $(lnxmod-y))
557
558 #core-y         := $(patsubst %/, %/lib.a, $(core-y))
559 #devices-y      := $(patsubst %/, %/lib.a, $(devices-y))
560
561 # $(patsubst %/, %/built-in.o, $(libs-y))
562
563
564 # Build palacios
565 # ---------------------------------------------------------------------------
566 # Palacios is build from the objects selected by $(palacios-init) and
567 # $(palacios). Most are built-in.o files from top-level directories
568 # in the kernel tree, others are specified in Makefile.
569 # Ordering when linking is important, and $(palacios-init) must be first.
570 #
571 # palacios
572 #   ^
573 #   |
574 #   +--< $(palacios)
575 #   |    +--< devices/built-in.o  + more
576 #
577
578
579
580 palacios := $(core-y) $(devices-y) $(interfaces-y) $(extensions-y) $(vnet-y) $(libs-y) $(modules-y)
581
582
583 # Rule to link palacios - also used during CONFIG_CONFIGKALLSYMS
584 # May be overridden by /Makefile.$(ARCH)
585 quiet_cmd_palacios__ ?= AR $@ 
586       cmd_palacios__ ?= $(AR) rcs $@ $^
587
588
589
590 # Generate new palacios version
591 quiet_cmd_palacios_version = GEN     .version
592       cmd_palacios_version = set -e;                       \
593         if [ ! -r .version ]; then                      \
594           rm -f .version;                               \
595           echo 1 >.version;                             \
596         else                                            \
597           mv .version .old_version;                     \
598           expr 0$$(cat .old_version) + 1 >.version;     \
599         fi;                                     
600
601
602 # Link of palacios
603 # If CONFIG_KALLSYMS is set .version is already updated
604 # Generate System.map and verify that the content is consistent
605 # Use + in front of the palacios_version rule to silent warning with make -j2
606 # First command is ':' to allow us to use + in front of the rule
607 define rule_palacios__
608         :
609         $(call cmd,palacios__)
610         $(Q)echo 'cmd_$@ := $(cmd_palacios__)' > $(@D)/.$(@F).cmd
611
612
613 endef
614
615
616 # palacios image - including updated kernel symbols
617 libv3vee.a: $(palacios)
618         $(call if_changed_rule,palacios__)
619
620 palacios: libv3vee.a
621
622
623
624
625 linux_module/v3vee.ko: linux_module/*.c linux_module/*.h libv3vee.a
626         cd linux_module/ && make
627         cp linux_module/v3vee.ko v3vee.ko
628
629
630 linux_module: linux_module/v3vee.ko 
631
632
633
634 palacios.asm: palacios
635         $(OBJDUMP) --disassemble $< > $@
636
637 # The actual objects are generated when descending, 
638 # make sure no implicit rule kicks in
639 $(sort  $(palacios)) : $(palacios-dirs) ;
640
641 # Handle descending into subdirectories listed in $(palacios-dirs)
642 # Preset locale variables to speed up the build process. Limit locale
643 # tweaks to this spot to avoid wrong language settings when running
644 # make menuconfig etc.
645 # Error messages still appears in the original language
646
647 PHONY += $(palacios-dirs)
648 $(palacios-dirs): prepare scripts
649         $(Q)$(MAKE) $(build)=$@
650
651
652
653
654
655 # Things we need to do before we recursively start building the kernel
656 # or the modules are listed in "prepare".
657 # A multi level approach is used. prepareN is processed before prepareN-1.
658 # archprepare is used in arch Makefiles and when processed arch symlink,
659 # version.h and scripts_basic is processed / created.
660
661 # Listed in dependency order
662 PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
663
664 # prepare-all is deprecated, use prepare as valid replacement
665 PHONY += prepare-all
666
667 # prepare3 is used to check if we are building in a separate output directory,
668 # and if so do:
669 # 1) Check that make has not been executed in the kernel src $(srctree)
670 prepare3: 
671 ifneq ($(KBUILD_SRC),)
672         @echo '  Using $(srctree) as source for kernel'
673         $(Q)if [ -f $(srctree)/.config ]; then \
674                 echo "  $(srctree) is not clean, please run 'make mrproper'";\
675                 echo "  in the '$(srctree)' directory.";\
676                 /bin/false; \
677         fi;
678 endif
679
680 # prepare2 creates a makefile if using a separate output directory
681 prepare2: prepare3 outputmakefile
682
683 prepare1: prepare2 palacios/include/config/MARKER
684
685 archprepare: prepare1 scripts_basic
686
687 prepare0: archprepare FORCE
688         $(Q)$(MAKE) $(build)=.
689
690 # All the preparing..
691 prepare prepare-all: prepare0
692
693
694
695 palacios/include/config/MARKER: scripts/basic/split-include palacios/include/autoconf.h
696         @echo '  SPLIT   palacios/include/autoconf.h -> palacios/include/config/*'
697         @scripts/basic/split-include palacios/include/autoconf.h palacios/include/config
698         @touch $@
699
700
701
702 # ---------------------------------------------------------------------------
703
704 PHONY += depend dep
705 depend dep:
706         @echo '*** Warning: make $@ is unnecessary now.'
707
708
709
710 ###
711 # Cleaning is done on three levels.
712 # make clean     Delete most generated files
713 #                Leave enough to build external modules
714 # make mrproper  Delete the current configuration, and all generated files
715 # make distclean Remove editor backup files, patch leftover files and the like
716
717 # Directories & files removed with 'make clean'
718 CLEAN_DIRS  += $(MODVERDIR)
719 CLEAN_FILES +=   v3vee.asm \
720                  .tmp_version .tmp_palacios*
721
722 # Directories & files removed with 'make mrproper'
723 MRPROPER_DIRS  += palacios/include/config 
724 MRPROPER_FILES += .config .config.old  .version .old_version \
725                   palacios/include/autoconf.h  \
726                   tags TAGS cscope*
727
728
729 #               \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
730
731
732 # clean - Delete most, but leave enough to build external modules
733 #
734 clean: rm-dirs  := $(CLEAN_DIRS)
735 clean: rm-files := $(CLEAN_FILES)
736 clean-dirs      := $(addprefix _clean_,$(srctree) $(palacios-cleandirs))
737
738 PHONY += $(clean-dirs) clean archclean
739 $(clean-dirs):
740         $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
741
742
743 clean: archclean $(clean-dirs)
744         $(call cmd,rmdirs)
745         $(call cmd,rmfiles)
746         @find . $(RCS_FIND_IGNORE) \
747                 \( -name 'lib' \) -prune -o \
748                 \( -name '*.[oas]' -o -name '.*.cmd' \
749                 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' -o -name '*.ko' \) \
750                 -type f -print | xargs rm -f
751
752 # mrproper - Delete all generated files, including .config
753 #
754 mrproper: rm-dirs  := $(wildcard $(MRPROPER_DIRS))
755 mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
756 #mrproper-dirs      := $(addprefix _mrproper_,Documentation/DocBook scripts)
757 mrproper-dirs      := $(addprefix _mrproper_, scripts)
758
759 PHONY += $(mrproper-dirs) mrproper archmrproper
760 $(mrproper-dirs):
761         $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
762
763 mrproper: clean archmrproper $(mrproper-dirs)
764         $(call cmd,rmdirs)
765         $(call cmd,rmfiles)
766
767 # distclean
768 #
769 PHONY += distclean
770
771 distclean: mrproper
772         @find $(srctree) $(RCS_FIND_IGNORE) \
773                 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
774                 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
775                 -o -name '.*.rej' -o -size 0 \
776                 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
777                 -type f -print | xargs rm -f
778
779
780 # Packaging of the kernel to various formats
781 # ---------------------------------------------------------------------------
782 # rpm target kept for backward compatibility
783 package-dir     := $(srctree)/scripts/package
784
785 %pkg: FORCE
786         $(Q)$(MAKE) $(build)=$(package-dir) $@
787 rpm: FORCE
788         $(Q)$(MAKE) $(build)=$(package-dir) $@
789
790
791 # Brief documentation of the typical targets used
792 # ---------------------------------------------------------------------------
793
794
795 help:
796         @echo  'Cleaning targets:'
797         @echo  '  clean           - remove most generated files but keep the config'
798         @echo  '  mrproper        - remove all generated files + config + various backup files'
799         @echo  ''
800         @echo  'Configuration targets:'
801         @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
802         @echo  ''
803         @echo  'Other generic targets:'
804         @echo  '  all             - Build all targets marked with [*]'
805         @echo  '* palacios        - Build the palacios VMM'
806         @echo  '  dir/            - Build all files in dir and below'
807         @echo  '  dir/file.[ois]  - Build specified target only'
808         @echo  '  dir/file.ko     - Build module including final link'
809         @echo  '  rpm             - Build a kernel as an RPM package'
810         @echo  '  tags/TAGS       - Generate tags file for editors'
811         @echo  '  cscope          - Generate cscope index'
812         @echo  ''
813         @echo  'Kernel packaging:'
814         @$(MAKE) $(build)=$(package-dir) help
815         @echo  ''
816         @echo  'Documentation targets:'
817         @$(MAKE) -f $(srctree)/Documentation/DocBook/Makefile dochelp
818         @echo  ''
819         @echo  'Architecture specific targets ($(ARCH)):'
820         @$(if $(archhelp),$(archhelp),\
821                 echo '  No architecture specific help defined for $(ARCH)')
822         @echo  ''
823         @echo  '  make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
824         @echo  '  make O=dir [targets] Locate all output files in "dir", including .config'
825         @echo  '  make C=1   [targets] Check all c source with $$CHECK (sparse)'
826         @echo  '  make C=2   [targets] Force check of all c source with $$CHECK (sparse)'
827         @echo  ''
828         @echo  'Execute "make" or "make all" to build all targets marked with [*] '
829         @echo  'For further info see the ./README file'
830
831
832 # Documentation targets
833 # ---------------------------------------------------------------------------
834 %docs: scripts_basic FORCE
835         $(Q)$(MAKE) $(build)=Documentation/DocBook $@
836
837
838 # Generate tags for editors
839 # ---------------------------------------------------------------------------
840
841 #We want __srctree to totally vanish out when KBUILD_OUTPUT is not set
842 #(which is the most common case IMHO) to avoid unneeded clutter in the big tags file.
843 #Adding $(srctree) adds about 20M on i386 to the size of the output file!
844
845 ifeq ($(src),$(obj))
846 __srctree =
847 else
848 __srctree = $(srctree)/
849 endif
850
851 ifeq ($(ALLSOURCE_ARCHS),)
852 ifeq ($(ARCH),um)
853 ALLINCLUDE_ARCHS := $(ARCH) $(SUBARCH)
854 else
855 ALLINCLUDE_ARCHS := $(ARCH)
856 endif
857 else
858 #Allow user to specify only ALLSOURCE_PATHS on the command line, keeping existing behaviour.
859 ALLINCLUDE_ARCHS := $(ALLSOURCE_ARCHS)
860 endif
861
862 ALLSOURCE_ARCHS := $(ARCH)
863
864 define all-sources
865         ( find $(__srctree)palacios $(RCS_FIND_IGNORE) \
866                \( -name lib \) -prune -o \
867                -name '*.[chS]' -print; )
868 endef
869
870 quiet_cmd_cscope-file = FILELST cscope.files
871       cmd_cscope-file = (echo \-k; echo \-q; $(all-sources)) > cscope.files
872
873 quiet_cmd_cscope = MAKE    cscope.out
874       cmd_cscope = cscope -b
875
876 cscope: FORCE
877         $(call cmd,cscope-file)
878         $(call cmd,cscope)
879
880 quiet_cmd_TAGS = MAKE   $@
881 define cmd_TAGS
882         rm -f $@; \
883         ETAGSF=`etags --version | grep -i exuberant >/dev/null &&     \
884                 echo "-I __initdata,__exitdata,__acquires,__releases  \
885                       -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL              \
886                       --extra=+f --c-kinds=+px"`;                     \
887                 $(all-sources) | xargs etags $$ETAGSF -a
888 endef
889
890 TAGS: FORCE
891         $(call cmd,TAGS)
892
893
894 quiet_cmd_tags = MAKE   $@
895 define cmd_tags
896         rm -f $@; \
897         CTAGSF=`ctags --version | grep -i exuberant >/dev/null &&     \
898                 echo "-I __initdata,__exitdata,__acquires,__releases  \
899                       -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL              \
900                       --extra=+f --c-kinds=+px"`;                     \
901                 $(all-sources) | xargs ctags $$CTAGSF -a
902 endef
903
904 tags: FORCE
905         $(call cmd,tags)
906
907
908 # Scripts to check various things for consistency
909 # ---------------------------------------------------------------------------
910
911 endif #ifeq ($(config-targets),1)
912 endif #ifeq ($(mixed-targets),1)
913
914
915
916
917 # Single targets
918 # ---------------------------------------------------------------------------
919 # Single targets are compatible with:
920 # - build whith mixed source and output
921 # - build with separate output dir 'make O=...'
922 # - external modules
923 #
924 #  target-dir => where to store outputfile
925 #  build-dir  => directory in kernel source tree to use
926
927 build-dir  = $(patsubst %/,%,$(dir $@))
928 target-dir = $(dir $@)
929
930
931 %.s: %.c prepare scripts FORCE
932         $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
933 %.i: %.c prepare scripts FORCE
934         $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
935 %.o: %.c prepare scripts FORCE
936         $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
937 %.lst: %.c prepare scripts FORCE
938         $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
939 %.s: %.S prepare scripts FORCE
940         $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
941 %.o: %.S prepare scripts FORCE
942         $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
943
944 # Modules
945 / %/: prepare scripts FORCE
946         $(Q)$(MAKE) KBUILD_MODULES=$(if $(V3_CONFIG_MODULES),1) \
947         $(build)=$(build-dir)
948 %.ko: prepare scripts FORCE
949         $(Q)$(MAKE) KBUILD_MODULES=$(if $(V3_CONFIG_MODULES),1)   \
950         $(build)=$(build-dir) $(@:.ko=.o)
951         $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
952
953 # FIXME Should go into a make.lib or something 
954 # ===========================================================================
955
956 quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN   $(wildcard $(rm-dirs)))
957       cmd_rmdirs = rm -rf $(rm-dirs)
958
959 quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN   $(wildcard $(rm-files)))
960       cmd_rmfiles = rm -f $(rm-files)
961
962
963 a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) \
964           $(NOSTDINC_FLAGS) $(CPPFLAGS) \
965           $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
966
967 quiet_cmd_as_o_S = AS      $@
968 cmd_as_o_S       = $(CC) $(a_flags) -c -o $@ $<
969
970 # read all saved command lines
971
972 targets := $(wildcard $(sort $(targets)))
973 cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
974
975 ifneq ($(cmd_files),)
976   $(cmd_files): ;       # Do not try to update included dependency files
977   include $(cmd_files)
978 endif
979
980 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
981 # Usage:
982 # $(Q)$(MAKE) $(clean)=dir
983 clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
984
985 endif   # skip-makefile
986
987 # Force the O variable for user and init_task (not set by kbuild?)
988 user init_task: O:=$(if $O,$O,$(objtree))
989 # Build Palacios user-space libraries and example programs
990 user: FORCE
991         if [ ! -d $O/$@ ]; then mkdir $O/$@; fi
992         $(MAKE) \
993                 -C $(src)/$@ \
994                 O=$O/$@ \
995                 src=$(src)/$@ \
996                 all
997
998
999
1000 PHONY += FORCE
1001 FORCE:
1002
1003
1004 # Declare the contents of the .PHONY variable as phony.  We keep that
1005 # information in a variable se we can use it in if_changed and friends.
1006 .PHONY: $(PHONY)