-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
114 lines (96 loc) · 3.37 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#########################################################################
# Copyright (c) 2012 Ákos Kovács - Akosix operating system
# http://akoskovacs.github.com/Akosix
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
#########################################################################
CC = gcc
AS = gcc
CAT = cat
LD = ld
RM = rm
SH = bash
QEMU = qemu-system-i386
PERL = perl
VERBOSE_BUILD = false
CFLAGS := -std=c99 -Wall -O3 -march=i586 -nostdinc -fno-builtin -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -Wall -Wextra -Werror -ffreestanding -Wno-unused -m32 -ggdb
ASFLAGS := -Wall -Wextra -Werror -m32 -ggdb -I .
LDFLAGS := -nostartfiles -nodefaultlibs -nostdlib -static -T linker.ld
INCLUDES := -I include -I lib/include -I .
TMP_TARGET := .tmp_akosix.bin
TARGET := akosix.bin
MAPFILE := kernel.map
ISO := akosix.iso
DIST := dist/
VERSION = 0.1-alpha
export KERNELVERSION := $(VERSION)
OBJECTS := kmain.o panic.o console.o lib/string.o lib/kprintf.o boot/pgsetup.o boot/boot.o boot/multiboot.o mm/pmm.o mm/vmm.o mm/memory.o mm/kmalloc.o devices/input/ps2_kbd.o
KSYM_OBJ := ksymbol.o
KSYM_SRC := ksymbol.c
ifeq ($(VERBOSE_BUILD),true)
COMP=$(CC) $(CFLAGS) $(INCLUDES) -c -o $*.o $*.c
else
COMP=@$(CC) $(CFLAGS) $(INCLUDES) -c -o $*.o $*.c
endif
all: $(TARGET)
kconfig:
@export CC=$(CC)
@export CFLAGS=$(CC)
@export LD=$(LD)
@make -C build/kconfig/
menuconfig: .config
conf: .config
config: .config
.config: kconfig
@build/kconfig/mconf Kconfig
@$(PERL) scripts/genconf.pl
@echo "Now, you can simply run 'make' to build Akosix"
%.o : %.c config.h
@echo "CC $*.c"
$(COMP)
%.o : %.S config.h
@echo "AS $*.S"
@$(AS) $(ASFLAGS) -c -o $*.o $*.S
$(TMP_TARGET): $(OBJECTS)
@echo "LINK $@"
@$(LD) $(LDFLAGS) -o $@ $^
iso: $(TARGET)
@echo "Creating $(ISO) with GRUB..."
@$(SH) scripts/make_iso.sh
qemu: $(TARGET)
@$(QEMU) -kernel $(TARGET)
qemu-iso: iso
@$(QEMU) -cdrom $(ISO)
bochs: iso
@$(SH) scripts/run_bochs.sh
$(TARGET): $(OBJECTS) $(TMP_TARGET) config.h
@echo "GENKSYMS $(TMP_TARGET)"
@$(PERL) scripts/genksyms.pl $(TMP_TARGET) $(KSYM_SRC)
@echo "CC $(KSYM_SRC)"
@$(CC) $(CFLAGS) $(INCLUDES) -c $(KSYM_SRC)
@echo "LINK $(TARGET)"
@$(LD) $(LDFLAGS) -o $(TARGET) -ggdb $(OBJECTS) $(KSYM_OBJ) -Map $(MAPFILE)
help:
@echo "make - Build and link the whole kernel"
@echo "make iso - Build an iso image"
@echo "make qemu - Test the kernel in qemu"
@echo "make qemu-iso - Test the ISO image in qemu"
@echo "make bochs - Test the kernel in bochs"
@echo "make config - Start the configuration utility"
@echo "make clean - Clean the working directory"
.PHONY: clean
clean:
$(RM) -rf $(OBJECTS) $(TARGET) $(TMP_TARGET) $(MAPFILE) $(ISO) $(DIST)
.PHONY: kconfig_clean
kconfig_clean:
make clean -C build/kconfig/