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.


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