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.


added symbiotic virtio device
[palacios.git] / palacios / build / Makefile
1 # Makefile for GeekOS kernel, userspace, and tools
2 #
3 #  Northwestern University 
4 # (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
5 # (c) 2008, Peter Dinda <pdinda@northwestern.edu> 
6 # (c) 2008, Lei Xia <lxia@northwestern.edu>
7 # (c) 2008, The V3VEE Project <http://www.v3vee.org> 
8 #
9 # Based on GeekOS Makefile:
10 # Copyright (c) 2004,2005 David H. Hovemeyer <daveho@cs.umd.edu>
11 # $Revision: 1.71 $
12
13
14 # This is free software.  You are permitted to use,
15 # redistribute, and modify it as specified in the file "COPYING".
16
17 # Required software to build GeekOS:
18 # - GNU Make (http://www.gnu.org/software/make)
19 # - gcc 2.95.2 generating code for target (i386/ELF) and host platforms
20 # - Perl5, AWK (any version), egrep
21 #
22 # Cygwin (http://cygwin.com) may be used to build GeekOS.
23 # Make sure that gcc, binutils, nasm, and perl are installed.
24
25 # NOTES:
26 # - This makefile has been written carefully to work correctly
27 #   with the -j (parallel make) option.  I regularly use "make -j 2"
28 #   to speed the build process on 2 processor systems.
29
30
31 # Base address of kernel
32 #
33 # Note: at top of memory minus three pages (GDT/TSS/IDT) 
34 # minus maximum size
35 #
36 #
37 # Note that the code will initially load at 0x10000
38 #
39 # The setup code needs to copy it up to this address and jump there
40 #
41
42
43
44
45 PROJECT_ROOT := ..
46 VPATH := $(PROJECT_ROOT)/src
47
48 #when -DNDEBUG is set the kassert functions are disabled
49 #JRLDEBUG=-DNDEBUG
50
51 # DEBUG=1 means VMM_DEBUG, VMM_INFO, and VMM_TRACE are enabled
52 # as are SERIAL_PRINT_DEBUG
53
54
55 ifeq ($(LEAN_AND_MEAN),1) 
56 DEBUG := 0
57 DEBUG_SECTIONS :=
58 else
59 DEBUG := 1
60 DEBUG_SECTIONS := 
61 endif
62
63
64 ifeq ($(DEBUG_ALL),1)
65   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
66 # -DDEBUG_IO -DDEBUG_GENERIC -DDEBUG_IDE
67 endif
68
69
70 ifeq ($(DEBUG_SHADOW_PAGING),1)
71 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_SHADOW_PAGING
72 else 
73 ifeq ($(DEBUG_SHADOW_PAGING),0) 
74 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_SHADOW_PAGING
75 endif
76
77 endif
78 ifeq ($(DEBUG_NESTED_PAGING),1)
79 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_NESTED_PAGING
80 else 
81 ifeq ($(DEBUG_NESTED_PAGING),0) 
82 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_NESTED_PAGING
83 endif
84 endif
85
86 ifeq ($(DEBUG_CTRL_REGS),1)
87 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_CTRL_REGS
88 else 
89 ifeq ($(DEBUG_CTRL_REGS),0) 
90 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_CTRL_REGS
91 endif
92 endif
93
94 ifeq ($(DEBUG_INTERRUPTS),1)
95 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_INTERRUPTS
96 else 
97 ifeq ($(DEBUG_INTERRUPTS),0) 
98 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_INTERRUPTS
99 endif
100 endif
101
102 ifeq ($(DEBUG_IO),1)
103 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_IO
104 else 
105 ifeq ($(DEBUG_IO),0) 
106 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_IO
107 endif
108 endif
109
110 ifeq ($(DEBUG_KEYBOARD),1)
111 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_KEYBOARD
112 else 
113 ifeq ($(DEBUG_KEYBOARD),0) 
114 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_KEYBOARD
115 endif
116 endif
117
118 ifeq ($(DEBUG_PIC),1)
119 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_PIC
120 else 
121 ifeq ($(DEBUG_PIC),0) 
122 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_PIC
123 endif
124 endif
125
126 ifeq ($(DEBUG_PIT),1)
127 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_PIT
128 else 
129 ifeq ($(DEBUG_PIT),0) 
130 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_PIT
131 endif
132 endif
133
134 ifeq ($(DEBUG_NVRAM),1)
135 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_NVRAM
136 else 
137 ifeq ($(DEBUG_NVRAM),0) 
138 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_NVRAM
139 endif
140 endif
141
142 ifeq ($(DEBUG_GENERIC),1)
143 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_GENERIC
144 else 
145 ifeq ($(DEBUG_GENERIC),0) 
146 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_GENERIC
147 endif
148 endif
149
150 ifeq ($(DEBUG_EMULATOR),1)
151 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_EMULATOR
152 else 
153 ifeq ($(DEBUG_EMULATOR),0) 
154 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_EMULATOR
155 endif
156 endif
157
158 ifeq ($(DEBUG_IDE),1)
159 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_IDE
160 else 
161 ifeq ($(DEBUG_IDE),0) 
162 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_IDE
163 endif
164 endif
165
166 ifeq ($(DEBUG_XED),1)
167 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_XED
168 else 
169 ifeq ($(DEBUG_XED),0) 
170 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_XED
171 endif
172 endif
173
174 ifeq ($(DEBUG_HALT),1)
175 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_HALT
176 else 
177 ifeq ($(DEBUG_HALT),0) 
178 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_HALT
179 endif
180 endif
181
182 ifeq ($(DEBUG_APIC),1)
183 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_APIC
184 else 
185 ifeq ($(DEBUG_APIC),0) 
186 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_APIC
187 endif
188 endif
189
190 ifeq ($(DEBUG_PCI),1)
191 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_PCI
192 else 
193 ifeq ($(DEBUG_PCI),0) 
194 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_PCI
195 endif
196 endif
197
198 ifeq ($(DEBUG_DEV_MGR),1)
199 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_DEV_MGR
200 else 
201 ifeq ($(DEBUG_DEV_MGR),0)
202 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_DEV_MGR
203 endif
204 endif
205
206 ifeq ($(DEBUG_NE2K),1)
207 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_NE2K
208 else 
209 ifeq ($(DEBUG_NE2K),0)
210 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_NE2K
211 endif
212 endif
213
214 #DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DTEST_NE2K
215
216 ifeq ($(DEBUG),1)
217   JRLDEBUG=  -DVMM_DEBUG -DVMM_INFO -DVMM_TRACE $(DEBUG_SECTIONS)
218 else
219
220 endif
221
222
223
224
225
226
227 #
228 # This is wrong for current cygwin - no changes needed
229 #
230 # Figure out if we're compiling with cygwin, http://cygwin.com
231 #
232
233 #SYSTEM_NAME := $(shell uname -s)
234 #ifeq ($(findstring CYGWIN,$(SYSTEM_NAME)),CYGWIN)
235 #SYM_PFX            := _
236 #EXTRA_C_OPTS       := -DNEED_UNDERSCORE -DGNU_WIN32
237 #EXTRA_NASM_OPTS    := -DNEED_UNDERSCORE
238 #NON_ELF_SYSTEM     := yes
239 #EXTRA_CC_USER_OPTS := -Dmain=geekos_main
240 #endif
241
242
243
244 ifeq ($(INSTRUMENT_VMM),1)
245   EXTRA_C_OPTS:= -DINSTRUMENT_VMM
246   INSTRUMENT_OPT := -finstrument-functions
247   OBJ_FILES := palacios/vmm_instrument.o
248 else
249   INSTRUMENT_OPT := 
250 endif
251
252 CFLAGS = -fno-stack-protector
253
254
255 # ----------------------------------------------------------------------
256 # Configuration -
257 #   Various options specifying how GeekOS should be built,
258 #   what source files to build, which user programs to build,
259 #   etc.  This is generally the only section of the makefile
260 #   that will need to be modified.
261 # ----------------------------------------------------------------------
262
263 # List of targets to build by default.
264 # These targets encompass everything needed to boot
265 # and run GeekOS.
266 ALL_TARGETS := vmm force_payload
267
268
269 VMM_OBJS := \
270         palacios/vm_guest.o \
271         palacios/svm.o \
272         palacios/svm_handler.o \
273         palacios/vmm.o \
274         palacios/vmm_util.o \
275         palacios/vmm_ctrl_regs.o \
276         palacios/vmcb.o \
277         palacios/vmm_mem.o \
278         palacios/vmm_paging.o \
279         palacios/vmm_io.o \
280         palacios/vmm_debug.o \
281         palacios/svm_io.o \
282         palacios/vmm_intr.o \
283         palacios/vmm_excp.o \
284         palacios/vmm_time.o \
285         palacios/vmm_shadow_paging.o \
286         palacios/vm_guest_mem.o \
287         palacios/vmm_dev_mgr.o \
288         palacios/vmm_decoder.o \
289         palacios/svm_halt.o \
290         palacios/svm_pause.o \
291         palacios/svm_wbinvd.o \
292         palacios/vmm_config.o \
293         palacios/vmm_hashtable.o \
294         palacios/vmm_string.o \
295         palacios/vmm_emulator.o \
296         palacios/vmm_sprintf.o \
297         palacios/vmm_queue.o \
298         palacios/vmm_host_events.o \
299         palacios/svm_lowlevel.o \
300         palacios/vmm_msr.o \
301         palacios/svm_msr.o \
302         palacios/vmm_socket.o \
303         palacios/vmm_xed.o \
304         palacios/vmm_rbtree.o \
305         palacios/vmm_profiler.o \
306         palacios/vmm_direct_paging.o \
307         palacios/vmm_ringbuffer.o \
308         palacios/vmm_hypercall.o \
309         palacios/vmm_lock.o \
310         palacios/vmx.o \
311         palacios/vmcs.o \
312         palacios/vmx_handler.o \
313         palacios/vmx_lowlevel.o \
314         palacios/vmxassist.o \
315         palacios/vmx_io.o \
316         palacios/vmx_msr.o \
317         $(OBJ_FILES)
318
319
320 # Extra C flags for the VMM objects
321 $(VMM_OBJS) :: EXTRA_CFLAGS = \
322         $(JRLDEBUG) $(CFLAGS) -DVMXASSIST_PATH="\"../build/vmxassist\"" \
323
324
325
326 XED_OBJS := \
327         xed/v3-xed-compat.o \
328         xed/v3-udiv-compat.o \
329
330 $(XED_OBJS) :: EXTRA_CFLAGS = \
331         $(JRLDEBUG) $(CFLAGS)\
332
333 DEVICES_OBJS := \
334         devices/generic.o \
335         devices/keyboard.o \
336         devices/nvram.o \
337         devices/timer.o \
338         devices/simple_pic.o \
339         devices/8259a.o \
340         devices/8254.o \
341         devices/serial.o \
342         devices/bochs_debug.o \
343         devices/os_debug.o \
344         devices/apic.o  \
345         devices/io_apic.o \
346         devices/pci.o \
347         devices/para_net.o \
348         devices/ide.o \
349         devices/ram_cd.o \
350         devices/ram_hd.o \
351         devices/i440fx.o \
352         devices/piix3.o \
353         devices/net_cd.o \
354         devices/net_hd.o \
355         devices/lnx_virtio_blk.o \
356         devices/lnx_virtio_balloon.o \
357         devices/lnx_virtio_sym.o \
358         devices/sym_swap.o \
359
360 #       devices/ne2k.o  \
361 #       devices/cdrom.o \
362 #       devices/ramdisk.o \
363 #       devices/vnic.o \
364
365 $(DEVICES_OBJS) :: EXTRA_CFLAGS = \
366         $(JRLDEBUG) $(CFLAGS)\
367
368
369
370 # ----------------------------------------------------------------------
371 # Tools -
372 #   This section defines programs that are used to build GeekOS.
373 # ----------------------------------------------------------------------
374
375 ifeq ($(ARCH),64)
376 V3_ARCH := __V3_64BIT__
377 else 
378 V3_ARCH := __V3_32BIT__
379 endif
380
381
382 ifeq ($(CRAY_XT),1)
383 EXTRA_C_OPTS := $(EXTRA_C_OPTS) -DCRAY_XT
384 endif
385
386
387 # Uncomment if cross compiling
388 #TARGET_CC_PREFIX :=  $(PROJECT_ROOT)/../devtools/i386/bin/i386-elf-
389 #TARGET_CC_PREFIX :=  i386-elf-
390
391 # Target C compiler.  gcc 2.95.2 or later should work.
392 ifeq ($(ARCH),64)
393 TARGET_CC := $(TARGET_CC_PREFIX)gcc -m64
394 else 
395 TARGET_CC := $(TARGET_CC_PREFIX)gcc -m32
396 endif
397 #TARGET_CC := $(TARGET_CC_PREFIX)gcc34 -m32
398
399
400 # Target linker.  GNU ld is probably to only one that will work.
401 TARGET_LD := $(TARGET_CC_PREFIX)ld -melf_i386
402
403 # Target archiver
404 TARGET_AR := $(TARGET_CC_PREFIX)ar
405
406 # Target ranlib
407 TARGET_RANLIB := $(TARGET_CC_PREFIX)ranlib
408
409 # Target nm
410 TARGET_NM := $(TARGET_CC_PREFIX)nm
411
412 # Target objcopy
413 TARGET_OBJCOPY := $(TARGET_CC_PREFIX)objcopy
414
415 # Nasm (http://nasm.sourceforge.net)
416 NASM := $(PROJECT_ROOT)/../devtools/bin/nasm
417 #NASM := /opt/vmm-tools/bin/nasm
418
419 CPP := cpp
420
421
422 ifeq ($(ARCH),64)
423 AS = as --64
424 else 
425 AS = as --32
426 endif
427
428
429 # Tool to build PFAT filesystem images.
430 BUILDFAT := tools/builtFat.exe
431
432 # Perl5 or later
433 PERL := perl
434
435 # Pad a file so its size is a multiple of some unit (i.e., sector size)
436 PAD := $(PERL) $(PROJECT_ROOT)/scripts/pad
437
438 # Create a file filled with zeroes.
439 ZEROFILE := $(PERL) $(PROJECT_ROOT)/scripts/zerofile
440
441 # Calculate size of file in sectors
442 NUMSECS := $(PERL) $(PROJECT_ROOT)/scripts/numsecs
443
444
445 FD_SECTORS_PER_TRACK := $(PERL) $(PROJECT_ROOT)/scripts/numsecs_per_track
446
447
448 # ----------------------------------------------------------------------
449 # Definitions -
450 #   Options passed to the tools.
451 # ----------------------------------------------------------------------
452
453 # Flags used for all C source files
454
455 CC_GENERAL_OPTS = \
456         -O \
457         -Wall \
458         -g \
459         -D__V3VEE__ \
460         -D$(V3_ARCH) \
461         $(EXTRA_C_OPTS) \
462         $(VMM_FLAGS) \
463         -I$(PROJECT_ROOT)/include \
464         -Werror \
465         -fPIC \
466         -mno-red-zone \
467         -Wp,-MD,$(@D)/.$(@F).d \
468         -Wp,-MT,$@ \
469
470 #-fPIC \
471 #-fvisibility=hidden
472
473
474 # Flags passed to objcopy program (strip unnecessary sections from kernel.exe)
475 OBJCOPY_FLAGS := -R .dynamic -R .note -R .comment
476
477 # ----------------------------------------------------------------------
478 # Rules -
479 #   Describes how to compile the source files.
480 # ----------------------------------------------------------------------
481
482 # Compilation of kernel C source files
483 # Usage:
484 #       $(call build,TAG,commandline)
485 #
486 # If V=1 on the command line or the environment, then the actual
487 # command executed will be echoed to the terminal.  Otherwise
488 # only the tag and the output file will be printed to make
489 # any warnings stand out from the compile messages.
490 #
491 build = \
492         @if [ -z "$V" ]; then \
493                 echo '    [$1]  $@'; \
494                 $2; \
495         else \
496                 echo '$2'; \
497                 $2; \
498         fi
499
500
501
502 CC_COMPILE = \
503         $(call build,CC,$(TARGET_CC) \
504                 $(CC_GENERAL_OPTS) \
505                 $(EXTRA_CFLAGS) \
506                 -c \
507                 $< \
508                 -o $@ \
509                 $(INSTRUMENT_OPT) \
510         )
511
512 AS_COMPILE = \
513         $(call build,AS,$(TARGET_CC) \
514                 $(CC_GENERAL_OPTS) \
515                 $(EXTRA_CFLAGS) \
516                 -c \
517                 $< \
518                 -o $@ \
519                 $(INSTRUMENT_OPT) \
520         )
521
522
523 %.o: %.c
524         $(CC_COMPILE)
525 %.o: %.S
526         $(AS_COMPILE)
527 %.o: %.s
528         $(AS_COMPILE)
529
530
531 # ----------------------------------------------------------------------
532 # Targets -
533 #   Specifies files to be built
534 # ----------------------------------------------------------------------
535
536 # Default target - see definition of ALL_TARGETS in Configuration section
537 all : $(ALL_TARGETS)
538
539
540 #geekos/vmx_lowlevel.o: $(PROJECT_ROOT)/src/geekos/vmx_lowlevel.asm
541 #       $(NASM) -O99 \
542 #       -f elf \
543 #               -I$(PROJECT_ROOT)/src/geekos/ \
544 #               $(PROJECT_ROOT)/src/geekos/vmx_lowlevel.asm \
545 #       -o $@
546
547
548 #geekos/test: geekos/test.o geekos/vmcs.o geekos/vmx_lowlevel.o 
549 #       $(CC) geekos/test.o geekos/vmcs.o geekos/vmx_lowlevel.o  -o geekos/test
550
551
552
553 rombios_link:
554         ln -s -f ../src/vmboot/rombios/BIOS-bochs-latest rombios
555
556 vgabios_link:
557         ln -s -f ../src/vmboot/vgabios/VGABIOS-lgpl-latest.bin vgabios
558
559 vmxassist_link:
560         ln -s -f ../src/vmboot/vmxassist/vmxassist.bin vmxassist
561
562
563 force_payload: rombios_link vgabios_link vmxassist_link
564         ../scripts/make_payload.pl payload_layout.txt vm_kernel
565
566 inter1: force_payload
567         -make clean
568
569 world: inter1 vmm
570
571 vmm: palacios/vmm.lib 
572
573
574
575
576 # Loadable (flat) kernel image.
577 palacios/vmm.bin : palacios/vmm.lib
578         $(TARGET_OBJCOPY) $(OBJCOPY_FLAGS) -S -O binary palacios/vmm.lib palacios/vmm.bin
579
580
581 # The kernel executable and symbol map.
582 palacios/vmm.lib: libv3vee.a
583 libv3vee.a: \
584         $(VMM_OBJS) \
585         $(DEVICES_OBJS) \
586         $(XED_OBJS) \
587
588         $(call build,AR,$(TARGET_AR) rcs $@ $^)
589
590 force:
591
592
593
594
595
596 # Clean build directories of generated files
597 clean :
598         for d in palacios devices xed; do \
599                 (cd $$d && rm -f * .*.d); \
600         done
601         rm -f libv3vee.a
602
603
604 # Include all of the generated dependency files if they exist
605 -include */.*.o.d