-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
78 lines (70 loc) · 2.34 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
CC=gcc
LD=ld
AS=nasm
BITS=32
OUTPUT := $(CURDIR)/bin
INCLUDE := -I $(CURDIR)/include/
AINCLUDE:= -I $(CURDIR)/include/foundation/inc
OUTPUT := $(CURDIR)/bin
CFLAGS := -m32 -c $(INCLUDE)
AFLAGS := -f elf32 $(AINCLUDE)
LFLAGS := -melf_i386 -r
# If the user wants to bind atlas to
# the kernel, they have to set the
# atlas build path
ATLAS := Atlas.o
# These folder contain the top level make
# files for that portion of the kernel.
# Each of these has a makefile in them, which
# may or may not point to other Makefiles in sub-
# directories.
maketree := $(CURDIR)/system/ $(CURDIR)/device/ $(CURDIR)/app/
# The make process for the kernel is started here,
# the default bit setting is 32, and for now there is
# no alternative. The kernel will reach through the
# directory's building the appropriate files, and alloting
# the correct include directory, bit build type, and other
# various aspect of the build process.
export CC
export LD
export AS
export BITS
export FINCLUDE
export AINCLUDE
export OUTPUT
export CFLAGS
export AFLAGS
export OUTPORT
export srctree
all: link
@echo "Building Image..."
$(LD) -melf_i386 -r -T ./script/liveimg.ld $(shell find $(OUTPUT)/ -name a.out) -o $(OUTPUT)/foundation.o
# Link the subfolders of the link tree into
# usable object files within the parent
# directory of OUTPUT.
link: build
@echo "Linking Files..."
@for folder in $(shell find $(OUTPUT) -type d); do echo $(LD) $(LFLAGS) $$folder/*.o -o $$folder/a.out; $(LD) $(LFLAGS) $$folder/*.o -o $$folder/a.out; done
# The object building file process,
# it iterates through the maketree list,
# running the makefiles within.
# This allows each section of the kernel and its
# subsections to build in specific ways.
build:
@mkdir -p $(OUTPUT)
# We have to build the start and main files
# as they are technically outside the recursive reach.
@for dir in $(maketree) ; do \
$(MAKE) -C $$dir -s ; \
done
bind-atlas: link
@mkdir -p $(OUTPUT)/images/
@echo "Binding Atlas..."
$(LD) -melf_i386 -r $(shell find $(OUTPUT)/ -name a.out) -o $(OUTPUT)/foundation.o
dd if=/dev/zero of=$(OUTPUT)/fluff.bin bs=1M count=10
$(LD) -melf_i386 -T ./script/atlas.ld $(ATLAS) $(OUTPUT)/foundation.o -o $(OUTPUT)/fbounda.o
cat $(OUTPUT)/fbounda.o $(OUTPUT)/fluff.bin > $(OUTPUT)/images/fnlive.img
clean:
@echo "Cleaning..."
@echo "Removing Bin Folder..."
@rm -rf ./bin