1 # Makefile for GeekOS kernel, userspace, and tools
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>
9 # Based on GeekOS Makefile:
10 # Copyright (c) 2004,2005 David H. Hovemeyer <daveho@cs.umd.edu>
14 # This is free software. You are permitted to use,
15 # redistribute, and modify it as specified in the file "COPYING".
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
23 # Cygwin (http://cygwin.com) may be used to build GeekOS.
24 # Make sure that gcc, binutils, nasm, and perl are installed.
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.
34 # ----------------------------------------------------------------------
36 # Various options specifying how GeekOS should be built,
37 # what source files to build, which user programs to build,
38 # etc. This is generally the only section of the makefile
39 # that will need to be modified.
40 # ----------------------------------------------------------------------
42 PALACIOS_BUILD_DIR := $(PROJECT_ROOT)/palacios/build
43 KITTEN_TOP_DIR := $(PROJECT_ROOT)/kitten
44 GEEKOS_BUILD_DIR := $(PROJECT_ROOT)/geekos/build
45 GUEST_ISO_DIR := /opt/vmm-tools/isos
47 # List of targets to build by default.
48 # These targets encompass everything needed to boot
50 ALL_TARGETS := palacios geekos
52 QEMU := /usr/local/qemu/bin/qemu-system-x86_64
56 #when -DNDEBUG is set the kassert functions are disabled
59 # DEBUG=1 means VMM_DEBUG, VMM_INFO, and VMM_TRACE are enabled
60 # as are SERIAL_PRINT_DEBUG
62 DEBUG_SECTIONS := DEBUG=1
65 DEBUG_SECTIONS:= $(DEBUG_SECTIONS) DEBUG_ALL=1
68 ifeq ($(DEBUG_SHADOW_PAGING),1)
69 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_SHADOW_PAGING=1
71 ifeq ($(DEBUG_SHADOW_PAGING),0)
72 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_SHADOW_PAGING=0
76 ifeq ($(DEBUG_CTRL_REGS),1)
77 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_CTRL_REGS=1
79 ifeq ($(DEBUG_CTRL_REGS),0)
80 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_CTRL_REGS=0
84 ifeq ($(DEBUG_INTERRUPTS),1)
85 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_INTERRUPTS=1
87 ifeq ($(DEBUG_INTERRUPTS),0)
88 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_INTERRUPTS=0
93 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_IO=1
96 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_IO=0
100 ifeq ($(DEBUG_KEYBOARD),1)
101 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_KEYBOARD=1
103 ifeq ($(DEBUG_KEYBOARD),0)
104 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_KEYBOARD=0
108 ifeq ($(DEBUG_PIC),1)
109 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_PIC=1
111 ifeq ($(DEBUG_PIC),0)
112 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_PIC=0
116 ifeq ($(DEBUG_PIT),1)
117 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_PIT=1
119 ifeq ($(DEBUG_PIT),0)
120 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_PIT=0
124 ifeq ($(DEBUG_NVRAM),1)
125 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_NVRAM=1
127 ifeq ($(DEBUG_NVRAM),0)
128 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_NVRAM=0
132 ifeq ($(DEBUG_GENERIC),1)
133 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_GENERIC=1
135 ifeq ($(DEBUG_GENERIC),0)
136 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_GENERIC=0
140 ifeq ($(DEBUG_EMULATOR),1)
141 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_EMULATOR=1
143 ifeq ($(DEBUG_EMULATOR),0)
144 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_EMULATOR=0
148 ifeq ($(DEBUG_RAMDISK),1)
149 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_RAMDISK=1
151 ifeq ($(DEBUG_RAMDISK),0)
152 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_RAMDISK=0
156 ifeq ($(DEBUG_XED),1)
157 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_XED=1
159 ifeq ($(DEBUG_XED),0)
160 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_XED=0
164 ifeq ($(DEBUG_HALT),1)
165 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_HALT=1
167 ifeq ($(DEBUG_HALT),0)
168 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_HALT=0
172 ifeq ($(DEBUG_DEV_MGR),1)
173 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_DEV_MGR=1
175 ifeq ($(DEBUG_DEV_MGR),0)
176 DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_DEV_MGR=0
181 # ----------------------------------------------------------------------
183 # Specifies files to be built
184 # ----------------------------------------------------------------------
186 # Default target - see definition of ALL_TARGETS in Configuration section
191 (cd $(PALACIOS_BUILD_DIR) && make ARCH=64 $(DEBUG_SECTIONS))
194 (cd $(PALACIOS_BUILD_DIR) && make $(DEBUG_SECTIONS))
198 (cd $(PALACIOS_BUILD_DIR) && make $(DEBUG_SECTIONS) world)
201 (cd $(PALACIOS_BUILD_DIR) && make ARCH=64 $(DEBUG_SECTIONS) world)
204 (cd $(PALACIOS_BUILD_DIR) && make LEAN_AND_MEAN=1 world)
207 cp $(PALACIOS_BUILD_DIR)/libv3vee.a $(KITTEN_TOP_DIR)/palacios/
208 cp $(PALACIOS_BUILD_DIR)/../lib/xed/libxed32e.a $(KITTEN_TOP_DIR)/palacios/
209 cp $(PALACIOS_BUILD_DIR)/vm_kernel $(KITTEN_TOP_DIR)/palacios/
210 (cd $(KITTEN_TOP_DIR) && make)
212 kitten-full: palacios-full64
213 (cd $(KITTEN_TOP_DIR) && make clean)
214 cp $(PALACIOS_BUILD_DIR)/libv3vee.a $(KITTEN_TOP_DIR)/palacios/
215 cp $(PALACIOS_BUILD_DIR)/../lib/xed/libxed32e.a $(KITTEN_TOP_DIR)/palacios/
216 cp $(PALACIOS_BUILD_DIR)/vm_kernel $(KITTEN_TOP_DIR)/palacios/
217 (cd $(KITTEN_TOP_DIR) && make)
221 cp $(PALACIOS_BUILD_DIR)/libv3vee.a $(GEEKOS_BUILD_DIR)/palacios/
222 cp $(PALACIOS_BUILD_DIR)/../lib/xed/libxed.a $(GEEKOS_BUILD_DIR)/palacios/
223 cp $(PALACIOS_BUILD_DIR)/vm_kernel $(GEEKOS_BUILD_DIR)/palacios/
224 (cd $(GEEKOS_BUILD_DIR) && make)
227 geekos-full: palacios-full32
228 cp $(PALACIOS_BUILD_DIR)/libv3vee.a $(GEEKOS_BUILD_DIR)/palacios/
229 cp $(PALACIOS_BUILD_DIR)/../lib/xed/libxed.a $(GEEKOS_BUILD_DIR)/palacios/
230 cp $(PALACIOS_BUILD_DIR)/vm_kernel $(GEEKOS_BUILD_DIR)/palacios/
231 (cd $(GEEKOS_BUILD_DIR) && make clean && make)
234 world: geekos-full kitten-full
236 lean-and-mean: palacios-lean geekos-full
240 # make ready to boot over PXE
242 cp $(GEEKOS_BUILD_DIR)/vmm.img /tftpboot/vmm.img
245 $(QEMU) -m 1024 -serial file:serial.out -cdrom $(GUEST_ISO_DIR)/puppy.iso -fda $(GEEKOS_BUILD_DIR)/vmm.img
248 cp $(GEEKOS_BUILD_DIR)/vmm.img iso/vmm.img
249 mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o test.iso iso
258 # Clean build directories of generated files
260 for d in $(GEEKOS_BUILD_DIR) $(PALACIOS_BUILD_DIR); do \
261 (cd $$d && make clean); \