forked from ProgrammerAndHacker/0bt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
76 lines (60 loc) · 2.35 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
# -*- Mode: makefile; indent-tabs-mode: t -*-
#
# This file is part of 0bt. For more info see COPYING.
#
# Define V=1 for a more verbose build.
#
# Define DEBUG=1 for compilation in debug mode.
#
# Define DISK_IMAGE = name.img to change default name of a disk image.
#
# Define DISK_SIZE = 1G to set an image size. Default is 4G.
#
# Define USE_FAT32_FS to load kernel from FAT32 partition
include Makefile.common
.PHONY: $(HELP) $(CLEAN) $(TOOLS) $(CLEAN_IMAGE) $(CLEAN_ALL) \
$(BUILD_INITRD) $(CLEAN_INITRD)
.DEFAULT_GOAL: $(DEFAULT)
VERSION = "0.0.1"
IMG_MAKEFILE=--makefile=mk/Makefile.img
$(DEFAULT): $(BUILD_BOOTLOADER)
$(BUILD_IMAGE):
@$(MAKE) $(MAKE_FLAGS) $(IMG_MAKEFILE) TOPDIR=$(shell pwd)
@$(MAKE) $(MAKE_FLAGS) $(IMG_MAKEFILE) TOPDIR=$(shell pwd) $(CREATE_DISK_PARTITIONS)
@$(MAKE) $(MAKE_FLAGS) $(IMG_MAKEFILE) TOPDIR=$(shell pwd) $(FORMAT_FAT_IMAGE)
$(BUILD_BOOTLOADER):
@$(MAKE) $(MAKE_FLAGS) -C src/ TOPDIR=$(shell pwd)
$(TOOLS):
@$(MAKE) $(MAKE_FLAGS) -C tools TOPDIR=$(shell pwd) VERSION=$(VERSION)
# TODO this should be made by the 0bt-install util in future
$(INSTALL):
$(DD) if=src/$(ARCH)/$(STAGE0) of=$(DISK_IMAGE) conv=notrunc bs=446 count=1
$(DD) if=src/$(ARCH)/$(STAGE1) of=$(DISK_IMAGE) conv=notrunc count=3 seek=1 ibs=512
$(RUN):
qemu-system-x86_64 -vga std -drive format=raw,file=$(DISK_IMAGE)
$(BUILD_INITRD):
@echo " GEN initrd"
@$(MAKE) $(MAKE_FLAGS) -C initrd TOPDIR=$(shell pwd)
$(CLEAN):
@$(MAKE) $(MAKE_FLAGS) -C src/ TOPDIR=$(shell pwd) $@
$(CLEAN_DISK):
@$(MAKE) $(MAKE_FLAGS) $(IMG_MAKEFILE) TOPDIR=$(shell pwd) $(CLEAN)
$(CLEAN_INITRD):
@$(MAKE) $(MAKE_FLAGS) -C initrd TOPDIR=$(shell pwd) $@
$(CLEAN_ALL): $(CLEAN) $(CLEAN_DISK) $(CLEAN_INITRD)
$(HELP):
@echo "Common build targets:"
@echo " * build-boot - build source code (will be runned by default)"
@echo " * image - Create an empty disk.img image."
@echo " * initrd - Build initrd image."
@echo " * run - Run image with installed bootloader in qemu."
@echo " * tools - build 0bt utils from 0bt/tools directory."
@echo
@echo 'Cleaning targets:'
@echo ' * clean - Remove executables, object files and so on.'
@echo ' * clean_image - Remove *.img files.'
@echo ' * clean_initrd - Remove initrd.img and related files.'
@echo ' * clean_all - Both clean and clean_image.'
@echo
@echo "Miscellaneous targets:"
@echo ' * help - Print this output.'