-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·97 lines (97 loc) · 4.33 KB
/
Makefile
File metadata and controls
executable file
·97 lines (97 loc) · 4.33 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
#*******************************************************************************
# ___ public
# ¦OUX¦ GNU “make”
# ¦/C+¦ OUX/C+ OS
# --- kernel
# makefile
# ©overcq on ‟Gentoo Linux 23.0” “x86_64” 2025‒5‒2 K
#*******************************************************************************
CC := clang
CFLAGS := -Os
#===============================================================================
H_make_I_block_root = $(if $(filter 0,$(shell id -u)),$(error root user not allowed. Run make as user first.))
#===============================================================================
all: build
build: kernel
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.PHONY: all build mostlyclean clean install-qemu install-vmware install-usb
.SECONDARY: $(patsubst %.S,%.o,interrupt.S) \
I_compile_S_0.h \
$(patsubst %.cx,I_compile_S_0_%.h,$(wildcard *.cx)) \
$(patsubst %.cx,I_compile_S_0_%.c,$(wildcard *.cx))
#===============================================================================
kernel: I_compile_S_0.h \
$(patsubst %.S,%.o,interrupt.S) \
$(patsubst %.cx,I_compile_S_0_%.h,$(wildcard *.cx)) \
simple.h \
$(patsubst %.cx,I_compile_S_0_%.c,$(wildcard *.cx)) \
main.ld \
Makefile
$(CC) $(CFLAGS) -std=gnu23 -march=native -mno-sse -mno-red-zone -fno-zero-initialized-in-bss -ffreestanding -fno-stack-protector -fwrapv -Wall -Wextra -Wno-address-of-packed-member -Wno-dangling-else -Wno-incompatible-pointer-types-discards-qualifiers -Wno-missing-braces -Wno-parentheses -Wno-sign-compare -Wno-switch -include stdarg.h -include I_compile_S_0.h -nostdlib -shared -s -Wl,-T,main.ld -o $@.elf $(filter %.o,$^) $(filter %.c,$^)
rm -f $@; elf2oux $@.elf
rm $@.elf
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I_compile_S_0.h: \
I_compile_N_c_to_h.sh \
$(wildcard *.cx)
$(H_make_I_block_root)
{ echo '#include "I_compile_S_machine.h"' ;\
echo '#include "I_compile_S_language.h"' ;\
./I_compile_N_c_to_h.sh -f $(patsubst %.cx,%,$(filter %.cx,$^)) ;\
for header in $(patsubst %.cx,I_compile_S_0_%.h,$(filter-out main.cx,$(filter %.cx,$^))); do \
echo "#include \"$${header}\"" ;\
done ;\
echo '#include "I_compile_S_0_main.h"' ;\
echo '#include "simple.h"' ;\
} > $@
I_compile_S_0_%.h: %.cx \
I_compile_N_c_to_h.sh
$(H_make_I_block_root)
{ ./I_compile_N_c_to_h.sh -h1 $< \
&& ./I_compile_N_c_to_h.sh -h2 $< \
&& ./I_compile_N_c_to_h.sh -h3 $< ;\
} > $@
I_compile_S_0_%.c: %.cx \
I_compile_N_c_to_h.sh
$(H_make_I_block_root)
./I_compile_N_c_to_h.sh -c $< > $@
%.o: %.S
$(CC) -c -o $@ $<
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mostlyclean: $(wildcard *.cx)
rm -f I_compile_S_0.h $(patsubst %.cx,I_compile_S_0_%.h,$^) $(patsubst %.cx,I_compile_S_0_%.c,$^) *.o
clean: mostlyclean
rm -f kernel
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
install-qemu:
ocq_mnt=/mnt/oth; \
mkdir -p $$ocq_mnt \
&& loopdev=$$( losetup -LPf --show ../boot/UEFI/disk.img ) \
&& trap 'losetup -d $$loopdev' EXIT \
&& install/a.out kernel $${loopdev}p2
install-vmware:
ocq_mnt=/mnt/oth; \
mkdir -p $$ocq_mnt \
&& trap 'vmware-mount -d $$ocq_mnt' EXIT \
&& vmware-mount -f /mnt/hgfs/kernel\ UEFI/kernel\ UEFI.vmdk $$ocq_mnt \
&& trap 'vmware-mount -d $$ocq_mnt' EXIT \
&& loopdev=$$( losetup -LPf --show $$ocq_mnt/flat ) \
&& trap 'losetup -d $$loopdev && vmware-mount -d $$ocq_mnt' EXIT \
&& install/a.out kernel $${loopdev}p2
install-virtualbox:
ocq_mnt=/mnt/oth; \
mkdir -p $$ocq_mnt \
&& trap '$(VMWARE_DIR)/bin/vmware-mount -d $$ocq_mnt' EXIT \
&& $(VMWARE_DIR)/bin/vmware-mount -f ~inc/.VirtualBox/Machines/boot\ UEFI/boot\ UEFI.vmdk $$ocq_mnt \
&& trap '$(VMWARE_DIR)/bin/vmware-mount -d $$ocq_mnt' EXIT \
&& loopdev=$$( losetup -LPf --show $$ocq_mnt/flat ) \
&& trap 'losetup -d $$loopdev && $(VMWARE_DIR)/bin/vmware-mount -d $$ocq_mnt' EXIT \
&& install/a.out kernel $${loopdev}p2
#-------------------------------------------------------------------------------
install-usb:
ocq_usb_dev=/dev/sdb; \
ocq_usb_mnt=/mnt/usb; \
loopdev=$$( losetup -Lf --show $${ocq_usb_dev}2 ); \
trap 'losetup -d $$loopdev' EXIT \
&& install/a.out kernel $$loopdev
#*******************************************************************************