-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
98 lines (81 loc) · 2.83 KB
/
Makefile
File metadata and controls
98 lines (81 loc) · 2.83 KB
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
.PHONY: build install
all: build
DESTDIR:=/opt/CppOSEngine
HEADER_PATH:=/usr/include
src:=$(shell pwd)/src
INCLUDE_FOLDER=${src}/Kernel/include
CXX_COMPILER=g++
gccMAINcommandline+= \
-m32 \
-c
gccEXTRAcommandline+= \
-fno-stack-protector \
-fno-use-cxa-atexit \
-nostdlib \
-fno-builtin \
-fno-rtti \
-fno-exceptions \
-fno-leading-underscore \
-mno-red-zone \
-Wwrite-strings \
-Wno-unused-variable \
-pedantic \
-finline-functions \
-nostdinc \
-ffreestanding \
-Wno-unused-parameter \
-fno-permissive
Cobject := $(patsubst ${src}/Kernel/%.cpp, ${src}/Kernel/object/%.o, $(shell find ${src}/Kernel -name *.cpp))
asmobj := ${src}/Kernel/object/boot.o
$(Cobject): ${src}/Kernel/object/%.o : ${src}/Kernel/%.cpp
@if [ ! -d $(shell dirname $@) ]; then mkdir -p $(shell dirname $@); fi
${CXX_COMPILER} ${gccMAINcommandline} $< -o $@ -I${INCLUDE_FOLDER} ${gccEXTRAcommandline}
$(asmobj): ${src}/Kernel/object/%.o: ${src}/%.asm
@if [ ! -d $(shell dirname $@) ]; then mkdir -p $(shell dirname $@); fi
nasm -f elf32 $< -o $@
all: build install
build: $(asmobj) $(Cobject)
ar rv libCppOSEngine.a $(asmobj) $(Cobject)
install:
mkdir -p ${DESTDIR}
mkdir -p /usr/include/Kernel
find src/Kernel/include -type f -exec install -Dm 755 "{}" "/usr/include/Kernel" \;
@if [ -f ${DESTDIR}/linker.ld ]; then echo "removing linker.ld"; rm -rf ${DESTDIR}/linker.ld ; fi
@echo adding linker.ld...
@echo "ENTRY(start)" >> ${DESTDIR}/linker.ld
@echo "OUTPUT_FORMAT(elf32-i386)" >> ${DESTDIR}/linker.ld
@echo "OUTPUT_ARCH(i386:i386)" >> ${DESTDIR}/linker.ld
@echo "SECTIONS" >> ${DESTDIR}/linker.ld
@echo "{" >> ${DESTDIR}/linker.ld
@echo " . = 0x0100000;" >> ${DESTDIR}/linker.ld
@echo " .text :" >> ${DESTDIR}/linker.ld
@echo " {" >> ${DESTDIR}/linker.ld
@echo " KEEP(*(.multiboot))" >> ${DESTDIR}/linker.ld
@echo " *(.text*)" >> ${DESTDIR}/linker.ld
@echo " *(.rodata)" >> ${DESTDIR}/linker.ld
@echo " }" >> ${DESTDIR}/linker.ld
@echo " .data :" >> ${DESTDIR}/linker.ld
@echo " {" >> ${DESTDIR}/linker.ld
@echo " start_ctors = .; ">> ${DESTDIR}/linker.ld
@echo " KEEP(*( .init_array ));" >> ${DESTDIR}/linker.ld
@echo " KEEP(*(SORT_BY_INIT_PRIORITY( .init_array.* )));" >> ${DESTDIR}/linker.ld
@echo " end_ctors = .;" >> ${DESTDIR}/linker.ld
@echo " *(.data)" >> ${DESTDIR}/linker.ld
@echo " }" >> ${DESTDIR}/linker.ld
@echo " .bss : ">> ${DESTDIR}/linker.ld
@echo " {" >> ${DESTDIR}/linker.ld
@echo " *(COMMON)" >> ${DESTDIR}/linker.ld
@echo " *(.bss)" >> ${DESTDIR}/linker.ld
@echo " }" >> ${DESTDIR}/linker.ld
@echo " /DISCARD/ : { *(.fini_array*) *(.comment) }" >> ${DESTDIR}/linker.ld
@echo " }" >> ${DESTDIR}/linker.ld
test:
@make -f tests/Makefile
uninstall:
@echo Removing all...
@rm -rvf /usr/include/Kernel
@rm -rvf /opt/CppOSEngine
clean:
@echo Cleaning...
@rm -rvf ${src}/Kernel/object
@rm -rvf ./libCppOSEngine.a