[e16e036a] | 1 | #
|
---|
| 2 | # Copyright (C) 2005 Martin Decky
|
---|
| 3 | # All rights reserved.
|
---|
| 4 | #
|
---|
| 5 | # Redistribution and use in source and binary forms, with or without
|
---|
| 6 | # modification, are permitted provided that the following conditions
|
---|
| 7 | # are met:
|
---|
| 8 | #
|
---|
| 9 | # - Redistributions of source code must retain the above copyright
|
---|
| 10 | # notice, this list of conditions and the following disclaimer.
|
---|
| 11 | # - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | # notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | # documentation and/or other materials provided with the distribution.
|
---|
| 14 | # - The name of the author may not be used to endorse or promote products
|
---|
| 15 | # derived from this software without specific prior written permission.
|
---|
| 16 | #
|
---|
| 17 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | #
|
---|
| 28 |
|
---|
| 29 | ## Kernel release
|
---|
| 30 | #
|
---|
| 31 |
|
---|
| 32 | VERSION = 0
|
---|
| 33 | PATCHLEVEL = 1
|
---|
| 34 | SUBLEVEL = 0
|
---|
| 35 | EXTRAVERSION =
|
---|
| 36 | NAME = Dawn
|
---|
| 37 | RELEASE = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
|
---|
| 38 |
|
---|
[9371c30] | 39 | ## Include configuration
|
---|
[e16e036a] | 40 | #
|
---|
| 41 |
|
---|
[839470f] | 42 | -include Makefile.config
|
---|
[e16e036a] | 43 |
|
---|
| 44 | ## Common compiler flags
|
---|
| 45 | #
|
---|
| 46 |
|
---|
[6d9c49a] | 47 | DEFS = -D$(ARCH) -DARCH=\"$(ARCH)\" -DRELEASE=\"$(RELEASE)\" "-DNAME=\"$(NAME)\"" -DKERNEL
|
---|
[2cf5634] | 48 | CFLAGS = -fno-builtin -fomit-frame-pointer -Wall -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -nostdlib -nostdinc -Igeneric/include/
|
---|
[e16e036a] | 49 | LFLAGS = -M
|
---|
[ba22dcb] | 50 | AFLAGS =
|
---|
| 51 |
|
---|
[940cac0] | 52 | ifdef REVISION
|
---|
| 53 | DEFS += "-DREVISION=\"$(REVISION)\""
|
---|
| 54 | endif
|
---|
| 55 |
|
---|
| 56 | ifdef TIMESTAMP
|
---|
| 57 | DEFS += "-DTIMESTAMP=\"$(TIMESTAMP)\""
|
---|
[ba22dcb] | 58 | endif
|
---|
[e16e036a] | 59 |
|
---|
| 60 | ## Setup kernel configuration
|
---|
| 61 | #
|
---|
| 62 |
|
---|
[839470f] | 63 | -include arch/$(ARCH)/Makefile.inc
|
---|
| 64 | -include genarch/Makefile.inc
|
---|
[c9ed176] | 65 |
|
---|
[b183865e] | 66 | ifeq ($(CONFIG_DEBUG),y)
|
---|
| 67 | DEFS += -DCONFIG_DEBUG
|
---|
[e16e036a] | 68 | endif
|
---|
| 69 | ifeq ($(CONFIG_DEBUG_SPINLOCK),y)
|
---|
[5f85c91] | 70 | DEFS += -DCONFIG_DEBUG_SPINLOCK
|
---|
[e16e036a] | 71 | endif
|
---|
[4e49572] | 72 | ifeq ($(CONFIG_DEBUG_AS_WATCHPOINT),y)
|
---|
| 73 | DEFS += -DCONFIG_DEBUG_AS_WATCHPOINT
|
---|
| 74 | endif
|
---|
[944b15c] | 75 | ifeq ($(CONFIG_FPU_LAZY),y)
|
---|
| 76 | DEFS += -DCONFIG_FPU_LAZY
|
---|
| 77 | endif
|
---|
[8d25b44] | 78 | ifeq ($(CONFIG_DEBUG_ALLREGS),y)
|
---|
| 79 | DEFS += -DCONFIG_DEBUG_ALLREGS
|
---|
| 80 | endif
|
---|
[68091bd] | 81 | ifeq ($(CONFIG_VHPT),y)
|
---|
| 82 | DEFS += -DCONFIG_VHPT
|
---|
| 83 | endif
|
---|
[e16e036a] | 84 |
|
---|
| 85 | ## Toolchain configuration
|
---|
| 86 | #
|
---|
| 87 |
|
---|
| 88 | ifeq ($(COMPILER),native)
|
---|
| 89 | CC = gcc
|
---|
| 90 | AS = as
|
---|
| 91 | LD = ld
|
---|
| 92 | OBJCOPY = objcopy
|
---|
| 93 | OBJDUMP = objdump
|
---|
| 94 | else
|
---|
| 95 | CC = $(TOOLCHAIN_DIR)/$(TARGET)-gcc
|
---|
| 96 | AS = $(TOOLCHAIN_DIR)/$(TARGET)-as
|
---|
| 97 | LD = $(TOOLCHAIN_DIR)/$(TARGET)-ld
|
---|
| 98 | OBJCOPY = $(TOOLCHAIN_DIR)/$(TARGET)-objcopy
|
---|
| 99 | OBJDUMP = $(TOOLCHAIN_DIR)/$(TARGET)-objdump
|
---|
| 100 | endif
|
---|
| 101 |
|
---|
| 102 | ## Generic kernel sources
|
---|
| 103 | #
|
---|
| 104 |
|
---|
| 105 | GENERIC_SOURCES = \
|
---|
[97a7eff] | 106 | generic/src/adt/bitmap.c \
|
---|
[018d957e] | 107 | generic/src/adt/btree.c \
|
---|
[c585827] | 108 | generic/src/adt/hash_table.c \
|
---|
[5c9a08b] | 109 | generic/src/adt/list.c \
|
---|
[2677758] | 110 | generic/src/console/chardev.c \
|
---|
| 111 | generic/src/console/console.c \
|
---|
[f4338d2] | 112 | generic/src/console/kconsole.c \
|
---|
[442d0ae] | 113 | generic/src/console/cmd.c \
|
---|
[e16e036a] | 114 | generic/src/cpu/cpu.c \
|
---|
[9a8d91b] | 115 | generic/src/ddi/ddi.c \
|
---|
[973be64e] | 116 | generic/src/interrupt/interrupt.c \
|
---|
[169c408] | 117 | generic/src/main/main.c \
|
---|
| 118 | generic/src/main/kinit.c \
|
---|
| 119 | generic/src/main/uinit.c \
|
---|
[0132630] | 120 | generic/src/main/version.c \
|
---|
[169c408] | 121 | generic/src/proc/scheduler.c \
|
---|
| 122 | generic/src/proc/thread.c \
|
---|
| 123 | generic/src/proc/task.c \
|
---|
| 124 | generic/src/proc/the.c \
|
---|
[a59e81e] | 125 | generic/src/syscall/syscall.c \
|
---|
[169c408] | 126 | generic/src/mm/buddy.c \
|
---|
| 127 | generic/src/mm/frame.c \
|
---|
| 128 | generic/src/mm/page.c \
|
---|
| 129 | generic/src/mm/tlb.c \
|
---|
[20d50a1] | 130 | generic/src/mm/as.c \
|
---|
[4e147a6] | 131 | generic/src/mm/slab.c \
|
---|
[169c408] | 132 | generic/src/lib/func.c \
|
---|
| 133 | generic/src/lib/memstr.c \
|
---|
| 134 | generic/src/lib/sort.c \
|
---|
[de6b301] | 135 | generic/src/lib/elf.c \
|
---|
[169c408] | 136 | generic/src/debug/print.c \
|
---|
| 137 | generic/src/debug/symtab.c \
|
---|
| 138 | generic/src/time/clock.c \
|
---|
| 139 | generic/src/time/timeout.c \
|
---|
| 140 | generic/src/time/delay.c \
|
---|
| 141 | generic/src/preempt/preemption.c \
|
---|
| 142 | generic/src/synch/spinlock.c \
|
---|
| 143 | generic/src/synch/condvar.c \
|
---|
| 144 | generic/src/synch/rwlock.c \
|
---|
| 145 | generic/src/synch/mutex.c \
|
---|
| 146 | generic/src/synch/semaphore.c \
|
---|
| 147 | generic/src/synch/waitq.c \
|
---|
[9aa72b4] | 148 | generic/src/synch/futex.c \
|
---|
[6d9c49a] | 149 | generic/src/smp/ipi.c \
|
---|
[e74cb73] | 150 | generic/src/ipc/ipc.c \
|
---|
[4e49572] | 151 | generic/src/ipc/sysipc.c \
|
---|
[1077d91] | 152 | generic/src/ipc/ipcrsc.c \
|
---|
| 153 | generic/src/security/cap.c
|
---|
[bbf5657] | 154 |
|
---|
[36a140b] | 155 | ## Test sources
|
---|
| 156 | #
|
---|
| 157 |
|
---|
| 158 | ifneq ($(CONFIG_TEST),)
|
---|
| 159 | DEFS += -DCONFIG_TEST
|
---|
| 160 | GENERIC_SOURCES += test/$(CONFIG_TEST)/test.c
|
---|
| 161 | endif
|
---|
| 162 |
|
---|
[e16e036a] | 163 | GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
|
---|
| 164 | ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES)))
|
---|
| 165 | GENARCH_OBJECTS := $(addsuffix .o,$(basename $(GENARCH_SOURCES)))
|
---|
[c9ed176] | 166 |
|
---|
[b629483] | 167 | .PHONY: all build config distclean clean archlinks depend disasm
|
---|
[c9ed176] | 168 |
|
---|
[839470f] | 169 | all:
|
---|
[f8973c00] | 170 | tools/config.py default $(NARCH)
|
---|
| 171 | ifdef NARCH
|
---|
| 172 | ifneq ($(ARCH), $(NARCH))
|
---|
| 173 | $(MAKE) -C . clean
|
---|
| 174 | endif
|
---|
| 175 | endif
|
---|
[940cac0] | 176 | $(MAKE) -C . build
|
---|
[839470f] | 177 |
|
---|
[b629483] | 178 | build: kernel.bin disasm
|
---|
[839470f] | 179 |
|
---|
| 180 | config:
|
---|
[208189f] | 181 | -rm Makefile.depend
|
---|
[839470f] | 182 | tools/config.py
|
---|
[c9ed176] | 183 |
|
---|
| 184 | -include Makefile.depend
|
---|
| 185 |
|
---|
[839470f] | 186 | distclean: clean
|
---|
| 187 | -rm Makefile.config
|
---|
| 188 |
|
---|
[e16e036a] | 189 | clean:
|
---|
[fcfac420] | 190 | -rm -f kernel.bin kernel.raw kernel.map kernel.map.pre kernel.objdump kernel.disasm generic/src/debug/real_map.bin Makefile.depend* generic/include/arch generic/include/genarch arch/$(ARCH)/_link.ld
|
---|
[839470f] | 191 | find generic/src/ arch/*/src/ genarch/src/ test/ -name '*.o' -follow -exec rm \{\} \;
|
---|
| 192 | for arch in arch/*; do \
|
---|
| 193 | [ -e $$arch/_link.ld ] && rm $$arch/_link.ld 2>/dev/null;\
|
---|
| 194 | done;exit 0
|
---|
[c9ed176] | 195 |
|
---|
[839470f] | 196 | archlinks:
|
---|
[e16e036a] | 197 | ln -sfn ../../arch/$(ARCH)/include/ generic/include/arch
|
---|
| 198 | ln -sfn ../../genarch/include/ generic/include/genarch
|
---|
[c9ed176] | 199 |
|
---|
[6095342] | 200 | depend: archlinks
|
---|
[d6e8529] | 201 | -makedepend $(DEFS) $(CFLAGS) -f - $(ARCH_SOURCES) $(GENARCH_SOURCES) $(GENERIC_SOURCES) > Makefile.depend 2> /dev/null
|
---|
[c9ed176] | 202 |
|
---|
[e16e036a] | 203 | arch/$(ARCH)/_link.ld: arch/$(ARCH)/_link.ld.in
|
---|
[d1f8a87] | 204 | $(CC) $(DEFS) $(CFLAGS) -D__ASM__ -E -x c $< | grep -v "^\#" > $@
|
---|
[c9ed176] | 205 |
|
---|
[e16e036a] | 206 | generic/src/debug/real_map.bin: depend arch/$(ARCH)/_link.ld $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS)
|
---|
[169c408] | 207 | $(OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) --prefix-sections=symtab Makefile generic/src/debug/empty_map.o
|
---|
[e16e036a] | 208 | $(LD) -T arch/$(ARCH)/_link.ld $(LFLAGS) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) generic/src/debug/empty_map.o -o $@ -Map kernel.map.pre
|
---|
| 209 | $(OBJDUMP) -t $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) > kernel.objdump
|
---|
[169c408] | 210 | tools/genmap.py kernel.map.pre kernel.objdump generic/src/debug/real_map.bin
|
---|
[3550c393] | 211 | # Do it once again, this time to get correct even the symbols
|
---|
| 212 | # on architectures, that have bss after symtab
|
---|
| 213 | $(OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) --prefix-sections=symtab generic/src/debug/real_map.bin generic/src/debug/sizeok_map.o
|
---|
| 214 | $(LD) -T arch/$(ARCH)/_link.ld $(LFLAGS) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) generic/src/debug/sizeok_map.o -o $@ -Map kernel.map.pre
|
---|
| 215 | $(OBJDUMP) -t $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) > kernel.objdump
|
---|
| 216 | tools/genmap.py kernel.map.pre kernel.objdump generic/src/debug/real_map.bin
|
---|
[c9ed176] | 217 |
|
---|
[169c408] | 218 | generic/src/debug/real_map.o: generic/src/debug/real_map.bin
|
---|
[c9ed176] | 219 | $(OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) --prefix-sections=symtab $< $@
|
---|
| 220 |
|
---|
[6e259d5] | 221 | kernel.raw: depend arch/$(ARCH)/_link.ld $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) generic/src/debug/real_map.o
|
---|
[e16e036a] | 222 | $(LD) -T arch/$(ARCH)/_link.ld $(LFLAGS) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) generic/src/debug/real_map.o -o $@ -Map kernel.map
|
---|
[c9ed176] | 223 |
|
---|
[6e259d5] | 224 | kernel.bin: kernel.raw
|
---|
| 225 | $(OBJCOPY) -O $(BFD) kernel.raw kernel.bin
|
---|
| 226 |
|
---|
[2ccd275] | 227 | disasm: kernel.raw
|
---|
| 228 | $(OBJDUMP) -d kernel.raw > kernel.disasm
|
---|
| 229 |
|
---|
[c9ed176] | 230 | %.o: %.S
|
---|
[6a78e84] | 231 | $(CC) $(DEFS) $(CFLAGS) -D__ASM__ -c $< -o $@
|
---|
[c9ed176] | 232 |
|
---|
| 233 | %.o: %.s
|
---|
[6bc4dbd] | 234 | $(AS) $(AFLAGS) $< -o $@
|
---|
[c9ed176] | 235 |
|
---|
| 236 | %.o: %.c
|
---|
[6bc4dbd] | 237 | $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
|
---|