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.


cleaned up Palacios Makefile
[palacios.git] / palacios / build / Makefile
1 #  Northwestern University 
2 # (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
3 # (c) 2008, Peter Dinda <pdinda@northwestern.edu> 
4 # (c) 2008, Lei Xia <lxia@northwestern.edu>
5 # (c) 2008, The V3VEE Project <http://www.v3vee.org> 
6
7 PROJECT_ROOT := ..
8 VPATH := $(PROJECT_ROOT)/src
9
10 #when -DNDEBUG is set the kassert functions are disabled
11 #JRLDEBUG=-DNDEBUG
12
13 # DEBUG=1 means VMM_DEBUG, VMM_INFO, and VMM_TRACE are enabled
14 # as are SERIAL_PRINT_DEBUG
15
16
17 ifeq ($(LEAN_AND_MEAN),1) 
18 DEBUG := 0
19 DEBUG_SECTIONS :=
20 else
21 DEBUG := 1
22 DEBUG_SECTIONS := 
23 endif
24
25
26 ifeq ($(DEBUG_ALL),1)
27   DEBUG_SECTIONS:= $(DEBUG_SECTIONS) -DDEBUG_SHADOW_PAGING -DDEBUG_NESTED_PAGING -DDEBUG_CTRL_REGS -DDEBUG_INTERRUPTS -DDEBUG_KEYBOARD -DDEBUG_PIC -DDEBUG_PIT -DDEBUG_NVRAM -DDEBUG_EMULATOR  -DDEBUG_XED -DDEBUG_HALT -DDEBUG_DEV_MGR
28 # -DDEBUG_IO -DDEBUG_GENERIC -DDEBUG_IDE
29 endif
30
31
32 ifeq ($(DEBUG_SHADOW_PAGING),1)
33 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_SHADOW_PAGING
34 else 
35 ifeq ($(DEBUG_SHADOW_PAGING),0) 
36 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_SHADOW_PAGING
37 endif
38
39 endif
40 ifeq ($(DEBUG_NESTED_PAGING),1)
41 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_NESTED_PAGING
42 else 
43 ifeq ($(DEBUG_NESTED_PAGING),0) 
44 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_NESTED_PAGING
45 endif
46 endif
47
48 ifeq ($(DEBUG_CTRL_REGS),1)
49 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_CTRL_REGS
50 else 
51 ifeq ($(DEBUG_CTRL_REGS),0) 
52 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_CTRL_REGS
53 endif
54 endif
55
56 ifeq ($(DEBUG_INTERRUPTS),1)
57 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_INTERRUPTS
58 else 
59 ifeq ($(DEBUG_INTERRUPTS),0) 
60 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_INTERRUPTS
61 endif
62 endif
63
64 ifeq ($(DEBUG_IO),1)
65 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_IO
66 else 
67 ifeq ($(DEBUG_IO),0) 
68 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_IO
69 endif
70 endif
71
72 ifeq ($(DEBUG_KEYBOARD),1)
73 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_KEYBOARD
74 else 
75 ifeq ($(DEBUG_KEYBOARD),0) 
76 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_KEYBOARD
77 endif
78 endif
79
80 ifeq ($(DEBUG_PIC),1)
81 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_PIC
82 else 
83 ifeq ($(DEBUG_PIC),0) 
84 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_PIC
85 endif
86 endif
87
88 ifeq ($(DEBUG_PIT),1)
89 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_PIT
90 else 
91 ifeq ($(DEBUG_PIT),0) 
92 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_PIT
93 endif
94 endif
95
96 ifeq ($(DEBUG_NVRAM),1)
97 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_NVRAM
98 else 
99 ifeq ($(DEBUG_NVRAM),0) 
100 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_NVRAM
101 endif
102 endif
103
104 ifeq ($(DEBUG_GENERIC),1)
105 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_GENERIC
106 else 
107 ifeq ($(DEBUG_GENERIC),0) 
108 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_GENERIC
109 endif
110 endif
111
112 ifeq ($(DEBUG_EMULATOR),1)
113 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_EMULATOR
114 else 
115 ifeq ($(DEBUG_EMULATOR),0) 
116 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_EMULATOR
117 endif
118 endif
119
120 ifeq ($(DEBUG_IDE),1)
121 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_IDE
122 else 
123 ifeq ($(DEBUG_IDE),0) 
124 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_IDE
125 endif
126 endif
127
128 ifeq ($(DEBUG_XED),1)
129 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_XED
130 else 
131 ifeq ($(DEBUG_XED),0) 
132 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_XED
133 endif
134 endif
135
136 ifeq ($(DEBUG_HALT),1)
137 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_HALT
138 else 
139 ifeq ($(DEBUG_HALT),0) 
140 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_HALT
141 endif
142 endif
143
144 ifeq ($(DEBUG_APIC),1)
145 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_APIC
146 else 
147 ifeq ($(DEBUG_APIC),0) 
148 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_APIC
149 endif
150 endif
151
152 ifeq ($(DEBUG_PCI),1)
153 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_PCI
154 else 
155 ifeq ($(DEBUG_PCI),0) 
156 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_PCI
157 endif
158 endif
159
160 ifeq ($(DEBUG_DEV_MGR),1)
161 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_DEV_MGR
162 else 
163 ifeq ($(DEBUG_DEV_MGR),0)
164 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_DEV_MGR
165 endif
166 endif
167
168
169 ifeq ($(DEBUG),1)
170   JRLDEBUG=  -DVMM_DEBUG -DVMM_INFO -DVMM_TRACE $(DEBUG_SECTIONS)
171 else
172
173 endif
174
175
176 ifeq ($(INSTRUMENT_VMM),1)
177   EXTRA_C_OPTS:= -DINSTRUMENT_VMM
178   INSTRUMENT_OPT := -finstrument-functions
179   OBJ_FILES := palacios/vmm_instrument.o
180 else
181   INSTRUMENT_OPT := 
182 endif
183
184 CFLAGS = -fno-stack-protector
185
186
187 # Compile targets
188
189 ALL_TARGETS := vmm force_payload
190
191 # Compilation Objects
192
193
194 VMM_OBJS := \
195         palacios/vm_guest.o \
196         palacios/svm.o \
197         palacios/svm_handler.o \
198         palacios/vmm.o \
199         palacios/vmm_util.o \
200         palacios/vmm_ctrl_regs.o \
201         palacios/vmcb.o \
202         palacios/vmm_mem.o \
203         palacios/vmm_paging.o \
204         palacios/vmm_io.o \
205         palacios/vmm_debug.o \
206         palacios/svm_io.o \
207         palacios/vmm_intr.o \
208         palacios/vmm_excp.o \
209         palacios/vmm_time.o \
210         palacios/vmm_shadow_paging.o \
211         palacios/vm_guest_mem.o \
212         palacios/vm_dev.o \
213         palacios/vmm_dev_mgr.o \
214         palacios/vmm_decoder.o \
215         palacios/svm_halt.o \
216         palacios/svm_pause.o \
217         palacios/svm_wbinvd.o \
218         palacios/vmm_config.o \
219         palacios/vmm_hashtable.o \
220         palacios/vmm_string.o \
221         palacios/vmm_emulator.o \
222         palacios/vmm_queue.o \
223         palacios/vmm_host_events.o \
224         palacios/svm_lowlevel.o \
225         palacios/vmm_msr.o \
226         palacios/svm_msr.o \
227         palacios/vmm_socket.o \
228         palacios/vmm_xed.o \
229         palacios/vmm_rbtree.o \
230         palacios/vmm_profiler.o \
231         palacios/vmm_direct_paging.o \
232         palacios/vmm_ringbuffer.o \
233         palacios/vmm_hypercall.o \
234         $(OBJ_FILES)
235
236 #               vmx.c vmcs_gen.c vmcs.c
237
238 # Extra C flags for the VMM objects
239 $(VMM_OBJS) :: EXTRA_CFLAGS = \
240         $(JRLDEBUG) $(CFLAGS)\
241
242
243
244 XED_OBJS := \
245         xed/v3-xed-compat.o \
246         xed/v3-udiv-compat.o \
247
248 $(XED_OBJS) :: EXTRA_CFLAGS = \
249         $(JRLDEBUG) $(CFLAGS)\
250
251 DEVICES_OBJS := \
252         devices/generic.o \
253         devices/keyboard.o \
254         devices/nvram.o \
255         devices/timer.o \
256         devices/simple_pic.o \
257         devices/8259a.o \
258         devices/8254.o \
259         devices/serial.o \
260         devices/bochs_debug.o \
261         devices/os_debug.o \
262         devices/apic.o  \
263         devices/io_apic.o \
264         devices/pci.o \
265         devices/para_net.o \
266         devices/ide.o \
267         devices/ram_cd.o \
268         devices/ram_hd.o \
269         devices/i440fx.o \
270         devices/piix3.o \
271
272 #       devices/ne2k.o  \
273 #       devices/vnic.o \
274
275 $(DEVICES_OBJS) :: EXTRA_CFLAGS = \
276         $(JRLDEBUG) $(CFLAGS)\
277
278
279
280 # ----------------------------------------------------------------------
281 # Tools -
282 #   This section defines programs that are used to build GeekOS.
283 # ----------------------------------------------------------------------
284
285 ifeq ($(ARCH),64)
286 V3_ARCH := __V3_64BIT__
287 else 
288 V3_ARCH := __V3_32BIT__
289 endif
290
291
292 ifeq ($(CRAY_XT),1)
293 EXTRA_C_OPTS := $(EXTRA_C_OPTS) -DCRAY_XT
294 endif
295
296
297 # Uncomment if cross compiling
298 #TARGET_CC_PREFIX :=  $(PROJECT_ROOT)/../devtools/i386/bin/i386-elf-
299 #TARGET_CC_PREFIX :=  i386-elf-
300
301 ifeq ($(ARCH),64)
302 TARGET_CC := $(TARGET_CC_PREFIX)gcc -m64
303 else 
304 TARGET_CC := $(TARGET_CC_PREFIX)gcc -m32
305 endif
306
307
308 # Target linker.  GNU ld is probably to only one that will work.
309 TARGET_LD := $(TARGET_CC_PREFIX)ld -melf_i386
310
311 # Target archiver
312 TARGET_AR := $(TARGET_CC_PREFIX)ar
313
314 # Target ranlib
315 TARGET_RANLIB := $(TARGET_CC_PREFIX)ranlib
316
317 # Target nm
318 TARGET_NM := $(TARGET_CC_PREFIX)nm
319
320 # Target objcopy
321 TARGET_OBJCOPY := $(TARGET_CC_PREFIX)objcopy
322
323 CPP := cpp
324
325
326 ifeq ($(ARCH),64)
327 AS = as --64
328 else 
329 AS = as --32
330 endif
331
332
333 # Tool to build PFAT filesystem images.
334 BUILDFAT := tools/builtFat.exe
335
336 # Perl5 or later
337 PERL := perl
338
339 # Pad a file so its size is a multiple of some unit (i.e., sector size)
340 PAD := $(PERL) $(PROJECT_ROOT)/scripts/pad
341
342 # Create a file filled with zeroes.
343 ZEROFILE := $(PERL) $(PROJECT_ROOT)/scripts/zerofile
344
345 # Calculate size of file in sectors
346 NUMSECS := $(PERL) $(PROJECT_ROOT)/scripts/numsecs
347
348
349 FD_SECTORS_PER_TRACK := $(PERL) $(PROJECT_ROOT)/scripts/numsecs_per_track
350
351
352 # ----------------------------------------------------------------------
353 # Definitions -
354 #   Options passed to the tools.
355 # ----------------------------------------------------------------------
356
357 # Flags used for all C source files
358
359 CC_GENERAL_OPTS = \
360         -O \
361         -Wall \
362         -g \
363         -D__V3VEE__ \
364         -D$(V3_ARCH) \
365         $(EXTRA_C_OPTS) \
366         $(VMM_FLAGS) \
367         -I$(PROJECT_ROOT)/include \
368         -Werror \
369         -fPIC \
370         -mno-red-zone \
371         -Wp,-MD,$(@D)/.$(@F).d \
372         -Wp,-MT,$@ \
373
374 #-fPIC \
375 #-fvisibility=hidden
376
377
378 # Flags passed to objcopy program (strip unnecessary sections from kernel.exe)
379 OBJCOPY_FLAGS := -R .dynamic -R .note -R .comment
380
381 # ----------------------------------------------------------------------
382 # Rules -
383 #   Describes how to compile the source files.
384 # ----------------------------------------------------------------------
385
386 # Compilation of kernel C source files
387 # Usage:
388 #       $(call build,TAG,commandline)
389 #
390 # If V=1 on the command line or the environment, then the actual
391 # command executed will be echoed to the terminal.  Otherwise
392 # only the tag and the output file will be printed to make
393 # any warnings stand out from the compile messages.
394 #
395 build = \
396         @if [ -z "$V" ]; then \
397                 echo '    [$1]  $@'; \
398                 $2; \
399         else \
400                 echo '$2'; \
401                 $2; \
402         fi
403
404
405
406 CC_COMPILE = \
407         $(call build,CC,$(TARGET_CC) \
408                 $(CC_GENERAL_OPTS) \
409                 $(EXTRA_CFLAGS) \
410                 -c \
411                 $< \
412                 -o $@ \
413                 $(INSTRUMENT_OPT) \
414         )
415
416 AS_COMPILE = \
417         $(call build,AS,$(TARGET_CC) \
418                 $(CC_GENERAL_OPTS) \
419                 $(EXTRA_CFLAGS) \
420                 -c \
421                 $< \
422                 -o $@ \
423                 $(INSTRUMENT_OPT) \
424         )
425
426
427 %.o: %.c
428         $(CC_COMPILE)
429 %.o: %.S
430         $(AS_COMPILE)
431 %.o: %.s
432         $(AS_COMPILE)
433
434
435 # ----------------------------------------------------------------------
436 # Targets -
437 #   Specifies files to be built
438 # ----------------------------------------------------------------------
439
440 # Default target - see definition of ALL_TARGETS in Configuration section
441 all : $(ALL_TARGETS)
442
443 rombios_link:
444         ln -s -f ../src/vmboot/rombios/BIOS-bochs-latest rombios
445
446 vgabios_link:
447         ln -s -f ../src/vmboot/vgabios/VGABIOS-lgpl-latest.bin vgabios
448
449
450 force_payload: rombios_link vgabios_link
451         ../scripts/make_payload.pl payload_layout.txt vm_kernel
452
453 inter1: force_payload
454         -make clean
455
456 world: inter1 vmm
457
458 vmm: palacios/vmm.lib 
459
460
461 # Loadable (flat) kernel image.
462 palacios/vmm.bin : palacios/vmm.lib
463         $(TARGET_OBJCOPY) $(OBJCOPY_FLAGS) -S -O binary palacios/vmm.lib palacios/vmm.bin
464
465
466 # The kernel executable and symbol map.
467 palacios/vmm.lib: libv3vee.a
468 libv3vee.a: \
469         $(VMM_OBJS) \
470         $(DEVICES_OBJS) \
471         $(XED_OBJS) \
472
473         $(call build,AR,$(TARGET_AR) rcs $@ $^)
474
475 force:
476
477
478
479
480
481 # Clean build directories of generated files
482 clean :
483         for d in palacios devices xed; do \
484                 (cd $$d && rm -f * .*.d); \
485         done
486
487
488 # Include all of the generated dependency files if they exist
489 -include */.*.o.d