-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
149 lines (123 loc) · 4.2 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
###################################################################################
## Module Name: Makefile ##
## Project: AurixOS ##
## ##
## Copyright (c) 2024-2025 Jozef Nagy ##
## ##
## This source is subject to the MIT License. ##
## See License.txt in the root of this repository. ##
## All other rights reserved. ##
## ##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ##
## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ##
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ##
## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ##
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ##
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ##
## SOFTWARE. ##
###################################################################################
.DEFAULT_GOAL := all
##
# Build configuration
#
export ARCH ?= x86_64
export PLATFORM ?= generic-pc
export BUILD_TYPE ?= debug
export ROOT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
export BUILD_DIR ?= $(ROOT_DIR)/build
export SYSROOT_DIR ?= $(ROOT_DIR)/sysroot
export RELEASE_DIR ?= $(ROOT_DIR)/release
NOUEFI ?= n
##
# Image generation and running
#
LIVECD := $(RELEASE_DIR)/aurix-$(GITREV)-livecd_$(ARCH)-$(PLATFORM).iso
LIVEHDD := $(RELEASE_DIR)/aurix-$(GITREV)-livehdd_$(ARCH)-$(PLATFORM).img
LIVESD := $(RELEASE_DIR)/aurix-$(GITREV)-livesd_$(ARCH)-$(PLATFORM).img
QEMU_FLAGS := -m 2G -smp 4 -serial stdio
##
# General info
#
export CODENAME := "Matterhorn"
export VERSION := "0.1"
export GITREV := $(shell git rev-parse --short HEAD)
export DEFINES := AURIX_CODENAME=$(CODENAME) \
AURIX_VERSION=$(VERSION) \
AURIX_GITREV=$(GITREV) \
BUILD_TYPE=$(BUILD_TYPE)
ifeq ($(BUILD_TYPE),debug)
DEFINES += BUILD_DEBUG
else
DEFINES += BUILD_RELEASE
endif
##
# Recipes
#
.PHONY: all
all: boot kernel
@:
.PHONY: boot
boot:
@printf ">>> Building bootloader...\n"
ifneq (,$(filter $(ARCH),i686 x86_64))
@$(MAKE) -C boot PLATFORM=pc-bios
else
@$(MAKE) -C boot
endif
ifneq (,$(filter $(ARCH),i686 x86_64 arm32 aarch64))
ifeq ($(NOUEFI),n)
@$(MAKE) -C boot PLATFORM=uefi
endif
endif
.PHONY: kernel
kernel:
@printf ">>> Building kernel...\n"
@$(MAKE) -C kernel
.PHONY: install
install: boot kernel
@printf ">>> Building sysroot...\n"
@mkdir -p $(SYSROOT_DIR)
ifneq (,$(filter $(ARCH),i686 x86_64))
@$(MAKE) -C boot install PLATFORM=pc-bios
else
@$(MAKE) -C boot install
endif
ifneq (,$(filter $(ARCH),i686 x86_64 arm32 aarch64))
ifeq ($(NOUEFI),n)
@$(MAKE) -C boot install PLATFORM=uefi
endif
endif
@$(MAKE) -C kernel install
ovmf:
@printf ">>> Downloading OVMF images...\n"
@utils/download-ovmf.sh
.PHONY: livecd
livecd: install
@printf ">>> Generating Live CD..."
@mkdir -p $(RELEASE_DIR)
@utils/arch/$(ARCH)/generate-iso.sh $(LIVECD)
.PHONY: livehdd
livehdd: install
@printf ">>> Generating Live HDD..."
@mkdir -p $(RELEASE_DIR)
@utils/arch/$(ARCH)/generate-hdd.sh $(LIVEHDD)
.PHONY: livesd
livesd: install
@$(error SD Card Generation is not supported yet!)
@printf ">>> Generating Live SD Card..."
@mkdir -p $(RELEASE_DIR)
@utils/arch/$(ARCH)/generate-sd.sh $(LIVESD)
.PHONY: run
run: livecd
@printf ">>> Running QEMU...\n"
@qemu-system-$(ARCH) $(QEMU_FLAGS) $(QEMU_MACHINE_FLAGS) -cdrom $(LIVECD)
.PHONY: run-uefi
run-uefi: livecd ovmf
@printf ">>> Running QEMU (UEFI)...\n"
@qemu-system-$(ARCH) $(QEMU_FLAGS) $(QEMU_MACHINE_FLAGS) -bios ovmf/ovmf-$(ARCH).fd -cdrom $(LIVECD)
.PHONY: clean
clean:
@rm -rf $(BUILD_DIR) $(SYSROOT_DIR)
.PHONY: distclean
distclean:
@rm -rf $(BUILD_DIR) $(SYSROOT_DIR) $(RELEASE_DIR) ovmf/