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.


Merge branch 'lwip_dev' into devel
[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_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
151 #DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DTEST_NE2K
152
153 ifeq ($(DEBUG),1)
154   JRLDEBUG= -DSERIAL_PRINT_DEBUG=1 -DSERIAL_PRINT_DEBUG_LEVEL=10 -DSERIAL_PRINT=1 -DVMM_DEBUG=1 -DVMM_INFO=1 -DVMM_TRACE=1 $(DEBUG_SECTIONS)
155
156 else
157   JRLDEBUG= -DSERIAL_PRINT_DEBUG=0 -DSERIAL_PRINT_DEBUG_LEVEL=999999 -DSERIAL_PRINT=0 -DVMM_DEBUG=0 -DVMM_INFO=0 -DVMM_TRACE=0
158 endif
159
160
161 #
162 # DECODER is the decoder that will be used 
163 # currently we only support xed
164 #
165 DECODER=XED
166
167 DECODER_FLAGS=
168 DECODER_SRCS=
169 DECODER_LIBS=
170
171 ifeq ($(DECODER),XED)
172 DECODER_SRCS := vmm_xed.c
173 DECODER_FLAGS :=  -L../lib/xed
174 DECODER_LIBS := $(PROJECT_ROOT)/lib/xed/libxed.a
175 else
176 # This is an error
177 endif
178
179
180
181
182
183
184 #
185 # This is wrong for current cygwin - no changes needed
186 #
187 # Figure out if we're compiling with cygwin, http://cygwin.com
188 #
189
190 #SYSTEM_NAME := $(shell uname -s)
191 #ifeq ($(findstring CYGWIN,$(SYSTEM_NAME)),CYGWIN)
192 #SYM_PFX            := _
193 #EXTRA_C_OPTS       := -DNEED_UNDERSCORE -DGNU_WIN32
194 #EXTRA_NASM_OPTS    := -DNEED_UNDERSCORE
195 #NON_ELF_SYSTEM     := yes
196 #EXTRA_CC_USER_OPTS := -Dmain=geekos_main
197 #endif
198
199
200
201
202 # ----------------------------------------------------------------------
203 # Configuration -
204 #   Various options specifying how GeekOS should be built,
205 #   what source files to build, which user programs to build,
206 #   etc.  This is generally the only section of the makefile
207 #   that will need to be modified.
208 # ----------------------------------------------------------------------
209
210 # List of targets to build by default.
211 # These targets encompass everything needed to boot
212 # and run GeekOS.
213 ALL_TARGETS := vmm vm_kernel
214
215
216
217
218
219
220 VMM_ASM_SRCS :=  svm_lowlevel.asm vmm_lowlevel.asm\
221 #                       vmx_lowlevel.asm
222
223 VMM_ASM_OBJS := $(VMM_ASM_SRCS:%.asm=palacios/%.o)
224
225
226 VMM_C_SRCS :=   vm_guest.c \
227                 svm.c svm_handler.c vmm.c vmm_util.c vmm_ctrl_regs.c \
228                 vmcb.c vmm_mem.c vmm_paging.c vmm_io.c vmm_debug.c svm_io.c \
229                 vmm_intr.c vmm_time.c \
230                 vmm_shadow_paging.c vm_guest_mem.c  \
231                 vm_dev.c vmm_dev_mgr.c vmm_decoder.c \
232                 svm_halt.c svm_pause.c svm_wbinvd.c \
233                 vmm_config.c vmm_hashtable.c \
234                 vmm_string.c vmm_emulator.c vmm_queue.c\
235                  $(DECODER_SRCS)
236 #               vmx.c vmcs_gen.c vmcs.c
237
238 VMM_C_OBJS := $(VMM_C_SRCS:%.c=palacios/%.o)
239
240 VMM_OBJS := $(VMM_C_OBJS) $(VMM_ASM_OBJS)
241
242
243
244 XED_C_SRCS := v3-xed-compat.c
245
246 XED_C_OBJS := $(XED_C_SRCS:%.c=xed/%.o)
247
248 XED_GAS_SRCS := v3-udiv-compat.s
249
250 XED_GAS_OBJS := $(XED_GAS_SRCS:%.s=xed/%.o)
251
252 XED_OBJS := $(XED_C_OBJS) $(XED_GAS_OBJS)
253
254
255
256 DEVICE_C_SRCS := generic.c keyboard.c nvram.c timer.c simple_pic.c 8259a.c 8254.c serial.c ramdisk.c cdrom.c
257
258 DEVICE_C_OBJS := $(DEVICE_C_SRCS:%.c=devices/%.o)
259
260 DEVICE_OBJS := $(DEVICE_C_OBJS)
261
262 V3LIBS := $(DECODER_LIBS)
263
264
265
266
267
268 # ----------------------------------------------------------------------
269 # Tools -
270 #   This section defines programs that are used to build GeekOS.
271 # ----------------------------------------------------------------------
272
273 # Uncomment if cross compiling
274 TARGET_CC_PREFIX :=  $(PROJECT_ROOT)/../devtools/i386/bin/i386-elf-
275 #TARGET_CC_PREFIX :=  i386-elf-
276
277 # Target C compiler.  gcc 2.95.2 or later should work.
278 TARGET_CC := $(TARGET_CC_PREFIX)gcc
279 #TARGET_CC := $(TARGET_CC_PREFIX)gcc34 -m32
280
281
282 # Target linker.  GNU ld is probably to only one that will work.
283 TARGET_LD := $(TARGET_CC_PREFIX)ld -melf_i386
284
285 # Target archiver
286 TARGET_AR := $(TARGET_CC_PREFIX)ar
287
288 # Target ranlib
289 TARGET_RANLIB := $(TARGET_CC_PREFIX)ranlib
290
291 # Target nm
292 TARGET_NM := $(TARGET_CC_PREFIX)nm
293
294 # Target objcopy
295 TARGET_OBJCOPY := $(TARGET_CC_PREFIX)objcopy
296
297 # Nasm (http://nasm.sourceforge.net)
298 NASM := $(PROJECT_ROOT)/../devtools/bin/nasm
299 #NASM := /opt/vmm-tools/bin/nasm
300
301 AS = as --32
302
303 # Tool to build PFAT filesystem images.
304 BUILDFAT := tools/builtFat.exe
305
306 # Perl5 or later
307 PERL := perl
308
309 # Pad a file so its size is a multiple of some unit (i.e., sector size)
310 PAD := $(PERL) $(PROJECT_ROOT)/scripts/pad
311
312 # Create a file filled with zeroes.
313 ZEROFILE := $(PERL) $(PROJECT_ROOT)/scripts/zerofile
314
315 # Calculate size of file in sectors
316 NUMSECS := $(PERL) $(PROJECT_ROOT)/scripts/numsecs
317
318
319 FD_SECTORS_PER_TRACK := $(PERL) $(PROJECT_ROOT)/scripts/numsecs_per_track
320
321
322 # ----------------------------------------------------------------------
323 # Definitions -
324 #   Options passed to the tools.
325 # ----------------------------------------------------------------------
326
327 # Flags used for all C source files
328 GENERAL_OPTS := -O -Wall $(EXTRA_C_OPTS) $(VMM_FLAGS) -fPIC #-fvisibility=hidden
329 CC_GENERAL_OPTS := $(GENERAL_OPTS) -Werror 
330
331 # Flags used for VMM C source files
332 CC_VMM_OPTS := -g -I$(PROJECT_ROOT)/include -D__V3VEE__ -D__V3_32BIT__ $(DECODER_FLAGS) $(JRLDEBUG)
333
334 # Flags used for VMM C ASM files
335 NASM_VMM_OPTS := -I$(PROJECT_ROOT)/src/palacios/ -f elf $(EXTRA_NASM_OPTS)
336
337
338
339
340
341 # Flags passed to objcopy program (strip unnecessary sections from kernel.exe)
342 OBJCOPY_FLAGS := -R .dynamic -R .note -R .comment
343
344 # ----------------------------------------------------------------------
345 # Rules -
346 #   Describes how to compile the source files.
347 # ----------------------------------------------------------------------
348
349
350
351 palacios/%.o : palacios/%.c
352         $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_VMM_OPTS) $< -o palacios/$*.o
353
354 palacios/%.o : palacios/%.asm
355         $(NASM) $(NASM_VMM_OPTS) $< -o palacios/$*.o
356
357 devices/%.o : devices/%.c
358         $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_VMM_OPTS) $< -o devices/$*.o
359
360 devices/%.o : devices/%.asm
361         $(NASM) $(NASM_VMM_OPTS) $< -o devices/$*.o
362
363
364 xed/%.o : xed/%.c
365         $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_VMM_OPTS) $< -o xed/$*.o
366
367 xed/%.o : xed/%.s
368         $(AS) $< -o xed/$*.o
369
370
371 # ----------------------------------------------------------------------
372 # Targets -
373 #   Specifies files to be built
374 # ----------------------------------------------------------------------
375
376 # Default target - see definition of ALL_TARGETS in Configuration section
377 all : $(ALL_TARGETS)
378
379
380 #geekos/vmx_lowlevel.o: $(PROJECT_ROOT)/src/geekos/vmx_lowlevel.asm
381 #       $(NASM) -O99 \
382 #       -f elf \
383 #               -I$(PROJECT_ROOT)/src/geekos/ \
384 #               $(PROJECT_ROOT)/src/geekos/vmx_lowlevel.asm \
385 #       -o $@
386
387
388 #geekos/test: geekos/test.o geekos/vmcs.o geekos/vmx_lowlevel.o 
389 #       $(CC) geekos/test.o geekos/vmcs.o geekos/vmx_lowlevel.o  -o geekos/test
390
391
392
393 rombios_link:
394         ln -s -f ../src/vmboot/rombios/BIOS-bochs-latest rombios
395
396 vgabios_link:
397         ln -s -f ../src/vmboot/vgabios/VGABIOS-lgpl-latest.bin vgabios
398
399 force_lwip:
400         (cd ../src/lwip/build; make clean; make)
401
402 force_rombios: rombios_link
403         (cd ../src/vmboot/rombios; make clean; make)
404
405 force_vgabios: vgabios_link
406         (cd ../src/vmboot/vgabios; make clean; make)
407
408 force_payload: force_rombios force_vgabios
409         ../scripts/make_payload.pl payload_layout.txt vm_kernel
410
411 inter1: force_payload force_lwip
412         -make clean
413
414 world: inter1 vmm
415
416 vmm: palacios/vmm.lib 
417
418
419
420
421 # Loadable (flat) kernel image.
422 palacios/vmm.bin : palacios/vmm.lib
423         $(TARGET_OBJCOPY) $(OBJCOPY_FLAGS) -S -O binary palacios/vmm.lib palacios/vmm.bin
424
425
426 # The kernel executable and symbol map.
427 palacios/vmm.lib: $(VMM_OBJS) $(DEVICE_OBJS) $(XED_OBJS) vm_kernel
428 #       $(TARGET_LD) -o palacios/vmm.lib  \
429 #               $(DECODER_FLAGS) \
430 #                $(VMM_OBJS) $(DEVICE_OBJS) $(XED_OBJS) $(V3LIBS) -b binary vm_kernel
431 #       $(TARGET_NM) palacios/vmm.lib > palacios/vmm.syms
432         $(TARGET_AR) rcs libv3vee.a  \
433                  $(VMM_OBJS) $(DEVICE_OBJS) $(XED_OBJS)
434
435
436
437 force:
438
439
440
441
442
443 # Clean build directories of generated files
444 clean :
445         for d in palacios devices; do \
446                 (cd $$d && rm -f *); \
447         done
448
449
450 # Build header file dependencies, so source files are recompiled when
451 # header files they depend on are modified.
452 depend : $(GENERATED_LIBC_SRCS)
453
454         $(TARGET_CC) -M $(CC_GENERAL_OPTS) $(CC_KERNEL_OPTS) \
455                 $(VMM_C_SRCS:%.c=$(PROJECT_ROOT)/src/palacios/%.c) \
456                 | $(PERL) -n -e 's,^(\S),palacios/$$1,;print' \
457                 >> depend.mak
458         $(TARGET_CC) -M $(CC_GENERAL_OPTS) $(CC_KERNEL_OPTS) \
459                 $(DEVICE_C_SRCS:%.c=$(PROJECT_ROOT)/src/devices/%.c) \
460                 | $(PERL) -n -e 's,^(\S),devices/$$1,;print' \
461                 >> depend.mak
462
463 # By default, there are no header file dependencies.
464 depend.mak :
465         touch $@
466
467 include depend.mak