1
- # Nuke built-in rules and variables.
2
- MAKEFLAGS += -rR
1
+ # Nuke built-in rules.
3
2
.SUFFIXES :
4
3
5
4
# This is the name that our final executable will have.
@@ -64,7 +63,7 @@ CFLAGS := -g -O2 -pipe
64
63
CPPFLAGS :=
65
64
66
65
# User controllable nasm flags.
67
- NASMFLAGS := -F dwarf - g
66
+ NASMFLAGS := -g
68
67
69
68
# User controllable linker flags. We set none by default.
70
69
LDFLAGS :=
@@ -104,14 +103,15 @@ override CFLAGS += \
104
103
-fno-stack-protector \
105
104
-fno-stack-check \
106
105
-fshort-wchar \
106
+ -fno-lto \
107
107
-fPIE \
108
108
-ffunction-sections \
109
109
-fdata-sections
110
110
111
111
# Internal C preprocessor flags that should not be changed by the user.
112
112
override CPPFLAGS := \
113
113
-I src \
114
- -I nyu-efi /inc \
114
+ -I picoefi /inc \
115
115
-I uACPI/include \
116
116
-DUACPI_OVERRIDE_CONFIG \
117
117
-DBUILD_VERSION=\"$(BUILD_VERSION ) \" \
@@ -121,7 +121,8 @@ override CPPFLAGS := \
121
121
-MP
122
122
123
123
# Internal nasm flags that should not be changed by the user.
124
- override NASMFLAGS += \
124
+ override NASMFLAGS := \
125
+ $(patsubst -g,-g -F dwarf,$(NASMFLAGS ) ) \
125
126
-Wall
126
127
127
128
# Architecture specific internal flags.
@@ -170,25 +171,23 @@ override LDFLAGS += \
170
171
-z text \
171
172
-z max-page-size=0x1000 \
172
173
--gc-sections \
173
- -T nyu-efi/$(ARCH ) /link_script.lds
174
-
175
- # Use "find" to glob all *.c, *.S, and *.asm{32,64} files in the tree and obtain the
176
- # object and header dependency file names.
177
- override SRCFILES := $(shell find -L src cc-runtime/src nyu-efi/$(ARCH ) uACPI/source -type f 2>/dev/null | LC_ALL=C sort)
174
+ -T picoefi/$(ARCH ) /link_script.lds
175
+
176
+ # Use "find" to glob all *.c, *.S, and *.asm files in the tree
177
+ # (except the src/arch/* directories, as those are gonna be added
178
+ # in the next step).
179
+ override SRCFILES := $(shell find -L src cc-runtime/src picoefi/$(ARCH ) uACPI/source -type f -not -path 'src/arch/* ' 2>/dev/null | LC_ALL=C sort)
180
+ # Add architecture specific files, if they exist.
181
+ override SRCFILES += $(shell find -L src/arch/$(ARCH ) -type f 2>/dev/null | LC_ALL=C sort)
182
+ # Obtain the object and header dependencies file names.
178
183
override CFILES := $(filter % .c,$(SRCFILES ) )
179
184
override ASFILES := $(filter % .S,$(SRCFILES ) )
180
- ifeq ($(ARCH ) ,ia32)
181
- override NASMFILES := $(filter % .asm32,$(SRCFILES ) )
182
- endif
183
- ifeq ($(ARCH ) ,x86_64)
184
- override NASMFILES := $(filter % .asm64,$(SRCFILES ) )
185
+ ifneq ($(filter $(ARCH ) ,ia32 x86_64) ,)
186
+ override NASMFILES := $(filter % .asm,$(SRCFILES ) )
185
187
endif
186
188
override OBJ := $(addprefix obj-$(ARCH ) /,$(CFILES:.c=.c.o ) $(ASFILES:.S=.S.o ) )
187
- ifeq ($(ARCH ) ,ia32)
188
- override OBJ += $(addprefix obj-$(ARCH ) /,$(NASMFILES :.asm32=.asm32.o))
189
- endif
190
- ifeq ($(ARCH ) ,x86_64)
191
- override OBJ += $(addprefix obj-$(ARCH ) /,$(NASMFILES :.asm64=.asm64.o))
189
+ ifneq ($(filter $(ARCH ) ,ia32 x86_64) ,)
190
+ override OBJ += $(addprefix obj-$(ARCH ) /,$(NASMFILES :.asm=.asm.o))
192
191
endif
193
192
override HEADER_DEPS := $(addprefix obj-$(ARCH ) /,$(CFILES:.c=.c.d ) $(ASFILES:.S=.S.d ) )
194
193
@@ -210,36 +209,29 @@ obj-$(ARCH)/src/printf.c.o: override CPPFLAGS += \
210
209
211
210
# Rule to convert the final ELF executable to a .EFI PE executable.
212
211
bin-$(ARCH ) /$(OUTPUT ) .efi : bin-$(ARCH ) /$(OUTPUT ) GNUmakefile
213
- mkdir -p " $$ (dirname $@ )"
212
+ mkdir -p " $( dir $@ ) "
214
213
$(OBJCOPY ) -O binary $< $@
215
214
dd if=/dev/zero of=$@ bs=4096 count=0 seek=$$(( ($$(wc -c < $@ ) + 4095 ) / 4096 )) 2> /dev/null
216
215
217
216
# Link rules for the final executable.
218
- bin-$(ARCH ) /$(OUTPUT ) : GNUmakefile nyu-efi /$(ARCH ) /link_script.lds $(OBJ )
219
- mkdir -p " $$ (dirname $@ )"
220
- $(LD ) $(OBJ ) $(LDFLAGS ) -o $@
217
+ bin-$(ARCH ) /$(OUTPUT ) : GNUmakefile picoefi /$(ARCH ) /link_script.lds $(OBJ )
218
+ mkdir -p " $( dir $@ ) "
219
+ $(LD ) $(LDFLAGS ) $(OBJ ) -o $@
221
220
222
221
# Compilation rules for *.c files.
223
222
obj-$(ARCH ) /% .c.o : % .c GNUmakefile
224
- mkdir -p " $$ (dirname $@ )"
223
+ mkdir -p " $( dir $@ ) "
225
224
$(CC ) $(CFLAGS ) $(CPPFLAGS ) -c $< -o $@
226
225
227
226
# Compilation rules for *.S files.
228
227
obj-$(ARCH ) /% .S.o : % .S GNUmakefile
229
- mkdir -p " $$ (dirname $@ )"
228
+ mkdir -p " $( dir $@ ) "
230
229
$(CC ) $(CFLAGS ) $(CPPFLAGS ) -c $< -o $@
231
230
232
- ifeq ($(ARCH ) ,ia32)
233
- # Compilation rules for *.asm32 (nasm) files.
234
- obj-$(ARCH ) /% .asm32.o : % .asm32 GNUmakefile
235
- mkdir -p " $$ (dirname $@ )"
236
- nasm $(NASMFLAGS ) $< -o $@
237
- endif
238
-
239
- ifeq ($(ARCH ) ,x86_64)
240
- # Compilation rules for *.asm64 (nasm) files.
241
- obj-$(ARCH ) /% .asm64.o : % .asm64 GNUmakefile
242
- mkdir -p " $$ (dirname $@ )"
231
+ ifneq ($(filter $(ARCH ) ,ia32 x86_64) ,)
232
+ # Compilation rules for *.asm (nasm) files.
233
+ obj-$(ARCH ) /% .asm.o : % .asm GNUmakefile
234
+ mkdir -p " $( dir $@ ) "
243
235
nasm $(NASMFLAGS ) $< -o $@
244
236
endif
245
237
0 commit comments