This repository was archived by the owner on Apr 7, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathMakefile.rules
More file actions
143 lines (102 loc) · 3.65 KB
/
Copy pathMakefile.rules
File metadata and controls
143 lines (102 loc) · 3.65 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
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
# KallistiOS ##version##
#
# Makefile.rules
# Copyright (c) 2000, 2001 Megan Potter
# Copyright (c) 2024 Eric Fradella
# Copyright (C) 2024 Ruslan Rostovtsev
#
# Global KallistiOS Makefile include
# Default build archs
KOS_BUILD_SUBARCHS ?= naomi pristine
# Build rules
ifndef KOS_DEPDIR
%.o: %.c
kos-cc $(CFLAGS) $(CPPFLAGS) -c $< -o $@
%.o: %.cc
kos-c++ $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
%.o: %.cpp
kos-c++ $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
%.o: %.m
kos-cc $(CFLAGS) $(CPPFLAGS) -c $< -o $@
%.o: %.mm
kos-c++ $(CFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
else
%.o: %.c
kos-cc $(CFLAGS) $(CPPFLAGS) -c $< -o $@ -MD -MF $(KOS_DEPDIR)/$(patsubst %.c,%.md,$(subst /,__,$(subst ..,,$<)))
%.o: %.cc
kos-c++ $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ -MD -MF $(KOS_DEPDIR)/$(patsubst %.c,%.md,$(subst /,__,$(subst ..,,$<)))
%.o: %.cpp
kos-c++ $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ -MD -MF $(KOS_DEPDIR)/$(patsubst %.c,%.md,$(subst /,__,$(subst ..,,$<)))
%.o: %.m
kos-cc $(CFLAGS) $(CPPFLAGS) -c $< -o $@ -MD -MF $(KOS_DEPDIR)/$(patsubst %.m,%.md,$(subst /,__,$(subst ..,,$<)))
%.o: %.mm
kos-c++ $(CFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ -MD -MF $(KOS_DEPDIR)/$(patsubst %.mm,%.md,$(subst /,__,$(subst ..,,$<)))
-include $(wildcard $(KOS_DEPDIR)/*.md)
endif
.PHONY: all_naomi all_pristine
all_naomi: $(if $(filter $(KOS_BUILD_SUBARCHS),naomi),all)
all_pristine: $(if $(filter $(KOS_BUILD_SUBARCHS),pristine),all)
%.o: %.s
kos-as $< -o $@
%.o: %.S
kos-cc -c $< -o $@
%.bin: %.elf
kos-objcopy -O binary $< $@
subdirs: $(patsubst %, _dir_%, $(SUBDIRS))
$(patsubst %, _dir_%, $(SUBDIRS)):
$(MAKE) -C $(patsubst _dir_%, %, $@)
clean_subdirs: $(patsubst %, _clean_dir_%, $(SUBDIRS))
$(patsubst %, _clean_dir_%, $(SUBDIRS)):
-$(MAKE) -C $(patsubst _clean_dir_%, %, $@) clean
distclean_subdirs: $(patsubst %, _distclean_dir_%, $(SUBDIRS))
$(patsubst %, _distclean_dir_%, $(SUBDIRS)):
-$(MAKE) -C $(patsubst _distclean_dir_%, %, $@) distclean
# Define KOS_ROMDISK_DIR in your Makefile if you want these two handy rules.
ifdef KOS_ROMDISK_DIR
romdisk.img:
$(KOS_GENROMFS) -f romdisk.img -d $(KOS_ROMDISK_DIR) -v -x .keepme -x .DS_Store -x Thumbs.db
romdisk.o: romdisk.img
$(KOS_BASE)/utils/bin2c/bin2c romdisk.img romdisk_tmp.c romdisk
$(KOS_CC) $(KOS_CFLAGS) -o romdisk_tmp.o -c romdisk_tmp.c
$(KOS_CC) -o romdisk.o -r romdisk_tmp.o $(KOS_LIB_PATHS) -Wl,--whole-archive -lromdiskbase
rm romdisk_tmp.c romdisk_tmp.o
endif
# Add the application name to the binary
ifdef KOS_APP_NAME
OBJS += app_name.o
app_name.bin:
@printf "%s\0" "$(KOS_APP_NAME)" > app_name.bin
app_name.o: app_name.bin
$(KOS_BASE)/utils/bin2c/bin2c app_name.bin app_name_tmp.c app_name
$(KOS_CC) $(KOS_CFLAGS) -c app_name_tmp.c -o app_name_tmp.o
$(KOS_CC) -o app_name.o -r app_name_tmp.o $(KOS_LIB_PATHS)
rm app_name.bin app_name_tmp.c app_name_tmp.o
endif
define KOS_GCCVER_MIN_CHECK
$(shell \
awk 'BEGIN { \
split("$(1)", min, "."); \
split("$(KOS_GCCVER)", cur, "."); \
if (cur[1] > min[1] || \
(cur[1] == min[1] && cur[2] > min[2]) || \
(cur[1] == min[1] && cur[2] == min[2] && cur[3] >= min[3])) { \
print 1; \
} else { \
print 0; \
} \
}')
endef
define KOS_GCCVER_MIN_WARNING
@echo "Skipping $(TARGET) build as current GCC version ($(KOS_GCCVER)) is less than $(KOS_GCCVER_MIN)."
endef
ifdef EXPORTS_FILE
OBJS += exports.o
exports.o: exports.c
exports.c: $(EXPORTS_FILE)
$(KOS_BASE)/utils/genexports/genexports.sh $(EXPORTS_FILE) exports.c $(EXPORTS_SYMBOL)
exports_stubs.o: exports_stubs.c
exports_stubs.c: $(EXPORTS_FILE)
$(KOS_BASE)/utils/genexports/genexportstubs.sh $(EXPORTS_FILE) exports_stubs.c
$(TARGET_LIB): exports_stubs.o
$(KOS_AR) rcs $(TARGET_LIB) exports_stubs.o
endif