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.


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