@@ -116,21 +116,12 @@ BUILT_BIN := $(BUILD_DIR)/out
116
116
IRIX_BASE ?= ido
117
117
IRIX_USR_DIR ?= $(IRIX_BASE ) /$(VERSION ) /usr
118
118
119
- # -- Location of the irix tool chain error messages
120
- ERR_STRS := $(BUILT_BIN ) /err.english.cc
121
- LIBS := $(foreach lib,$(IDO_LIBS ) ,$(BUILT_BIN ) /$(lib ) )
119
+ # -- IRIX toolchain error messages and libraries for linking
120
+ RUNTIME_DEPS := $(BUILT_BIN ) /err.english.cc $(foreach lib,$(IDO_LIBS ) ,$(BUILT_BIN ) /$(lib ) )
122
121
123
122
RECOMP_ELF := $(BUILD_BASE ) /recomp.elf
124
- LIBC_IMPL := libc_impl
125
- VERSION_INFO := version_info
126
123
127
124
TARGET_BINARIES := $(foreach binary,$(IDO_TC ) ,$(BUILT_BIN ) /$(binary ) )
128
- # NCC is filtered out since it isn't an actual program, but a symlink to cc
129
- O_FILES := $(foreach binary,$(filter-out NCC, $(IDO_TC ) ) ,$(BUILD_DIR ) /$(binary ) .o)
130
- C_FILES := $(O_FILES:.o=.c )
131
-
132
- # Automatic dependency files
133
- DEP_FILES := $(O_FILES:.o=.d )
134
125
135
126
# create build directories
136
127
$(shell mkdir -p $(BUILT_BIN))
@@ -152,14 +143,20 @@ ifeq ($(DETECTED_OS),linux)
152
143
$(RECOMP_ELF ) : LDFLAGS += -Wl,-export-dynamic
153
144
endif
154
145
155
- CFLAGS += -DPACKAGE_VERSION="\" $( PACKAGE_VERSION ) \"" -DDATETIME="\" $( DATETIME ) \""
146
+ LIBC_WARNINGS := $( WARNINGS ) -Wno-unused-parameter -Wno-deprecated-declarations
156
147
157
- % /$(LIBC_IMPL ) .o : WARNINGS += -Wno-unused-parameter -Wno-deprecated-declarations
158
- % /$(LIBC_IMPL ) _53.o : WARNINGS += -Wno-unused-parameter -Wno-deprecated-declarations
148
+ LIBC_IMPLS := libc_impl_53 libc_impl_71
149
+ LIBC_IMPL := libc_impl_$(subst .,,$(VERSION ) )
150
+
151
+ % /libc_impl_53.o : CFLAGS += -DIDO53
152
+ % /libc_impl_71.o : CFLAGS += -DIDO71
153
+
154
+ # edgcpfe 7.1 uses libc 5.3
155
+ % /7.1/out/edgcpfe :: LIBC_IMPL := libc_impl_53
159
156
160
157
# ### Main Targets ###
161
158
162
- all : $(TARGET_BINARIES ) $(ERR_STRS ) $( LIBS )
159
+ all : $(TARGET_BINARIES ) $(RUNTIME_DEPS )
163
160
164
161
# Build the recompiler binary on a separate step.
165
162
# Currently this is needed to avoid Windows and Linux ARM CIs from dying.
@@ -174,10 +171,10 @@ distclean:
174
171
$(RM ) -r $(BUILD_BASE )
175
172
$(MAKE ) -C $(RABBITIZER ) distclean
176
173
177
- c_files : $( C_FILES )
178
-
174
+ # Build only the C files (dependencies set below )
175
+ c_files :
179
176
180
- .PHONY : all clean distclean setup
177
+ .PHONY : all setup clean distclean c_files
181
178
.DEFAULT_GOAL := all
182
179
# Prevent removing intermediate files
183
180
.SECONDARY :
@@ -221,116 +218,72 @@ $(BUILT_BIN)/%.so.1: $(IRIX_USR_DIR)/lib/%.so.1
221
218
cp $^ $@
222
219
223
220
224
- ifeq ($(TARGET ) ,universal)
225
- MACOS_FAT_TARGETS ?= arm64-apple-macos11 x86_64-apple-macos10.14
226
-
227
- FAT_FOLDERS := $(foreach target,$(MACOS_FAT_TARGETS ) ,$(BUILD_DIR ) /$(target ) )
228
-
229
- # create build directories
230
- $(shell mkdir -p $(FAT_FOLDERS))
231
-
232
- # TODO: simplify
233
- FAT_BINARIES := $(foreach binary,$(IDO_TC ) ,$(BUILT_BIN ) /arm64-apple-macos11/$(binary ) ) \
234
- $(foreach binary,$(IDO_TC ) ,$(BUILT_BIN ) /x86_64-apple-macos10.14/$(binary ) )
235
-
236
- # ## Fat ###
237
-
238
- $(BUILT_BIN ) /% : $(BUILD_DIR ) /arm64-apple-macos11/% $(BUILD_DIR ) /x86_64-apple-macos10.14/% | $(ERR_STRS )
239
- lipo -create -output $@ $^
240
-
241
-
242
- # ## Built programs ###
243
-
244
- $(BUILD_DIR ) /arm64-apple-macos11/% : $(BUILD_DIR ) /arm64-apple-macos11/% .o $(BUILD_DIR ) /arm64-apple-macos11/$(LIBC_IMPL ) .o $(BUILD_DIR ) /arm64-apple-macos11/$(VERSION_INFO ) .o | $(ERR_STRS )
245
- $(CC ) $(CSTD ) $(OPTFLAGS ) $(CFLAGS ) -target arm64-apple-macos11 -o $@ $^ $(LDFLAGS )
246
- $(STRIP ) $@
247
-
248
- $(BUILD_DIR ) /x86_64-apple-macos10.14/% : $(BUILD_DIR ) /x86_64-apple-macos10.14/% .o $(BUILD_DIR ) /x86_64-apple-macos10.14/$(LIBC_IMPL ) .o $(BUILD_DIR ) /x86_64-apple-macos10.14/$(VERSION_INFO ) .o | $(ERR_STRS )
249
- $(CC ) $(CSTD ) $(OPTFLAGS ) $(CFLAGS ) -target x86_64-apple-macos10.14 -o $@ $^ $(LDFLAGS )
250
- $(STRIP ) $@
251
-
252
221
# NCC 7.1 is just a renamed cc
253
- $(BUILD_BASE ) /7.1/arm64-apple-macos11/NCC : $(BUILD_BASE ) /7.1/arm64-apple-macos11/cc
254
- cp $^ $@
255
-
256
- $(BUILD_BASE ) /7.1/x86_64-apple-macos10.14/NCC : $(BUILD_BASE ) /7.1/x86_64-apple-macos10.14/cc
222
+ $(BUILD_BASE ) /7.1/out/NCC : $(BUILD_BASE ) /7.1/out/cc
257
223
cp $^ $@
258
224
259
- $(BUILD_DIR ) /arm64-apple-macos11/edgcpfe : $(BUILD_DIR ) /arm64-apple-macos11/edgcpfe.o $(BUILD_DIR ) /arm64-apple-macos11/$(LIBC_IMPL ) _53.o $(BUILD_DIR ) /arm64-apple-macos11/$(VERSION_INFO ) .o | $(ERR_STRS )
260
- $(CC ) $(CSTD ) $(OPTFLAGS ) $(CFLAGS ) -target arm64-apple-macos11 -o $@ $^ $(LDFLAGS )
261
- $(STRIP ) $@
262
225
263
- $(BUILD_DIR ) /x86_64-apple-macos10.14/edgcpfe : $(BUILD_DIR ) /x86_64-apple-macos10.14/edgcpfe.o $(BUILD_DIR ) /x86_64-apple-macos10.14/$(LIBC_IMPL ) _53.o $(BUILD_DIR ) /x86_64-apple-macos10.14/$(VERSION_INFO ) .o | $(ERR_STRS )
264
- $(CC ) $(CSTD ) $(OPTFLAGS ) $(CFLAGS ) -target x86_64-apple-macos10.14 -o $@ $^ $(LDFLAGS )
265
- $(STRIP ) $@
226
+ # Template to compile libc_impl and output binaries
227
+ # $(1): target name (or "default" if it's the only target)
228
+ # $(2): target flags
229
+ define compile_template
266
230
231
+ ifeq ($(1 ) ,default)
232
+ TARGET_DIR-$(1) := $(BUILD_DIR )
233
+ else
234
+ TARGET_DIR-$(1) := $(BUILD_DIR ) /$(1 )
235
+ endif
267
236
268
- # ## Intermediary steps ###
269
-
270
- $(BUILD_DIR ) /arm64-apple-macos11/% .o : $(BUILD_DIR ) /% .c
271
- $(CC ) -c $(CSTD ) $(OPTFLAGS ) $(CFLAGS ) -target arm64-apple-macos11 -o $@ $<
272
-
273
- $(BUILD_DIR ) /x86_64-apple-macos10.14/% .o : $(BUILD_DIR ) /% .c
274
- $(CC ) -c $(CSTD ) $(OPTFLAGS ) $(CFLAGS ) -target x86_64-apple-macos10.14 -o $@ $<
275
-
276
-
277
- $(BUILD_DIR ) /arm64-apple-macos11/$(LIBC_IMPL ) .o : $(LIBC_IMPL ) .c
278
- $(CC ) -c $(CSTD ) $(OPTFLAGS ) $(CFLAGS ) -D$(IDO_VERSION ) $(WARNINGS ) -target arm64-apple-macos11 -o $@ $<
279
-
280
- $(BUILD_DIR ) /x86_64-apple-macos10.14/$(LIBC_IMPL ) .o : $(LIBC_IMPL ) .c
281
- $(CC ) -c $(CSTD ) $(OPTFLAGS ) $(CFLAGS ) -D$(IDO_VERSION ) $(WARNINGS ) -target x86_64-apple-macos10.14 -o $@ $<
282
-
283
- $(BUILD_DIR ) /arm64-apple-macos11/$(LIBC_IMPL ) _53.o : $(LIBC_IMPL ) .c
284
- $(CC ) -c $(CSTD ) $(OPTFLAGS ) $(CFLAGS ) -DIDO53 $(WARNINGS ) -target arm64-apple-macos11 -o $@ $<
285
-
286
- $(BUILD_DIR ) /x86_64-apple-macos10.14/$(LIBC_IMPL ) _53.o : $(LIBC_IMPL ) .c
287
- $(CC ) -c $(CSTD ) $(OPTFLAGS ) $(CFLAGS ) -DIDO53 $(WARNINGS ) -target x86_64-apple-macos10.14 -o $@ $<
288
-
289
- # $(VERSION_INFO).o is set to depend on every other .o file to ensure the version information is always up to date
290
- $(BUILD_DIR ) /arm64-apple-macos11/$(VERSION_INFO ) .o : $(VERSION_INFO ) .c $(O_FILES ) $(BUILD_DIR ) /arm64-apple-macos11/$(LIBC_IMPL ) .o
291
- $(CC ) -c $(CSTD ) $(OPTFLAGS ) $(CFLAGS ) -D$(IDO_VERSION ) $(WARNINGS ) -target arm64-apple-macos11 -o $@ $<
237
+ TARGET_BIN-$(1 ) := $$(TARGET_DIR-$(1 ) ) /out
238
+ TARGET_FLAGS-$(1 ) := $(2 )
292
239
293
- $(BUILD_DIR ) /x86_64-apple-macos10.14/$(VERSION_INFO ) .o : $(VERSION_INFO ) .c $(O_FILES ) $(BUILD_DIR ) /x86_64-apple-macos10.14/$(LIBC_IMPL ) .o
294
- $(CC ) -c $(CSTD ) $(OPTFLAGS ) $(CFLAGS ) -D$(IDO_VERSION ) $(WARNINGS ) -target x86_64-apple-macos10.14 -o $@ $<
240
+ # NCC is filtered out since it isn't an actual program, but a symlink to cc
241
+ LIBC_IMPL_O_FILES-$(1 ) := $(foreach libc_impl,$(LIBC_IMPLS ) ,$$(TARGET_DIR-$(1 ) ) /$(libc_impl ) .o)
242
+ PROGRAM_O_FILES-$(1 ) := $(foreach binary,$(filter-out NCC,$(IDO_TC ) ) ,$$(TARGET_DIR-$(1 ) ) /$(binary ) .o)
243
+ PROGRAM_C_FILES-$(1 ) := $$(PROGRAM_O_FILES-$(1 ) :.o=.c )
244
+ O_FILES-$(1 ) := $$(LIBC_IMPL_O_FILES-$(1 ) ) $$(PROGRAM_O_FILES-$(1 ) )
295
245
296
- else
297
- # ## Built programs ###
246
+ # create build directories
247
+ $$( shell mkdir -p $$( TARGET_BIN- $( 1 ) ) )
298
248
299
- $(BUILT_BIN ) /% : $(BUILD_DIR ) /% .o $(BUILD_DIR ) /$(LIBC_IMPL ) .o $(BUILD_DIR ) /$(VERSION_INFO ) .o | $(ERR_STRS )
300
- $(CC ) $(CSTD ) $(OPTFLAGS ) $(CFLAGS ) -o $@ $^ $(LDFLAGS )
301
- $(STRIP ) $@
249
+ c_files: $$(PROGRAM_C_FILES-$(1 ) )
302
250
303
- # NCC 7.1 is just a renamed cc
304
- $( BUILD_BASE ) /7.1/out/NCC : $( BUILD_BASE ) /7.1/out/cc
305
- cp $^ $@
251
+ $$( TARGET_BIN- $( 1 ) ) /%: $$( TARGET_DIR- $( 1 ) ) /%.o $$( TARGET_DIR- $( 1 ) ) /version_info.o $$( LIBC_IMPL_O_FILES- $( 1 ) ) | $$( RUNTIME_DEPS )
252
+ $$( CC ) $$( CSTD ) $$( OPTFLAGS ) $$( CFLAGS ) $$( TARGET_FLAGS- $( 1 ) ) -o $$@ $$< $$( TARGET_DIR- $( 1 ) ) /version_info.o $$( TARGET_DIR- $( 1 ) ) / $$( LIBC_IMPL ) .o $$( LDFLAGS )
253
+ $$( STRIP ) $ $@
306
254
307
- # edgcpfe 7.1 uses libc 5.3, so we need to hack a way to link a libc_impl file with the 5.3 stuff
308
- $(BUILT_BIN ) /edgcpfe : $(BUILD_DIR ) /edgcpfe.o $(BUILD_DIR ) /$(LIBC_IMPL ) _53.o $(BUILD_DIR ) /$(VERSION_INFO ) .o | $(ERR_STRS )
309
- $(CC ) $(CSTD ) $(OPTFLAGS ) $(CFLAGS ) -o $@ $^ $(LDFLAGS )
310
- $(STRIP ) $@
255
+ $$(TARGET_DIR-$(1 ) ) /%.o: $$(BUILD_DIR ) /%.c
256
+ $$(CC ) -c $$(CSTD ) $$(OPTFLAGS ) $$(CFLAGS ) $$(TARGET_FLAGS-$(1 ) ) -o $$@ $$<
311
257
258
+ $$(TARGET_DIR-$(1 ) ) /libc_impl_%.o: libc_impl.c
259
+ $$(CC ) -c $$(CSTD ) $$(OPTFLAGS ) $$(CFLAGS ) $$(LIBC_WARNINGS ) $$(TARGET_FLAGS-$(1 ) ) -o $$@ $$<
312
260
313
- # ## Intermediary steps ###
261
+ # Rebuild version info if the recomp binary or libc_impl are updated
262
+ $$(TARGET_DIR-$(1 ) ) /version_info.o: version_info.c $$(RECOMP_ELF ) $$(LIBC_IMPL_O_FILES-$(1 ) )
263
+ $$(CC ) -c $$(CSTD ) $$(OPTFLAGS ) $$(CFLAGS ) -D$$(IDO_VERSION ) -DPACKAGE_VERSION="\"$$(PACKAGE_VERSION ) \"" -DDATETIME="\"$$(DATETIME ) \"" $$(TARGET_FLAGS-$(1 ) ) -o $$@ $$<
314
264
315
- $( BUILD_DIR ) / % .o : $( BUILD_DIR ) / % .c
316
- $( CC ) -c $( CSTD ) $( OPTFLAGS ) $( CFLAGS ) -o $@ $<
265
+ # Automatic dependency files
266
+ -include $$( O_FILES- $( 1 ) :.o=.d )
317
267
268
+ endef
318
269
319
- $(BUILD_DIR ) /$(LIBC_IMPL ) .o : $(LIBC_IMPL ) .c
320
- $(CC ) -c $(CSTD ) $(OPTFLAGS ) $(CFLAGS ) -D$(IDO_VERSION ) $(WARNINGS ) -o $@ $<
321
270
322
- $(BUILD_DIR ) /$(LIBC_IMPL ) _53.o : $(LIBC_IMPL ) .c
323
- $(CC ) -c $(CSTD ) $(OPTFLAGS ) $(CFLAGS ) -DIDO53 $(WARNINGS ) -o $@ $<
271
+ ifeq ($(TARGET ) ,universal)
272
+ # Build universal binaries on macOS
273
+ $(eval $(call compile_template,arm64-apple-macos11,-target arm64-apple-macos11))
274
+ $(eval $(call compile_template,x86_64-apple-macos10.14,-target x86_64-apple-macos10.14))
324
275
325
- # $(VERSION_INFO).o is set to depend on every other .o file to ensure the version information is always up to date
326
- $(BUILD_DIR ) /$(VERSION_INFO ) .o : $(VERSION_INFO ) .c $(O_FILES ) $(BUILD_DIR ) /$(LIBC_IMPL ) .o $(BUILD_DIR ) /$(LIBC_IMPL ) _53.o
327
- $(CC ) -c $(CSTD ) $(OPTFLAGS ) $(CFLAGS ) -D$(IDO_VERSION ) $(WARNINGS ) -o $@ $<
276
+ $(BUILT_BIN ) /% : $(BUILD_DIR ) /arm64-apple-macos11/out/% $(BUILD_DIR ) /x86_64-apple-macos10.14/out/%
277
+ lipo -create -output $@ $^
278
+ else
279
+ # Normal build
280
+ $(eval $(call compile_template,default,))
328
281
endif
329
282
330
- # Remove built-in rules, to improve performance
331
- MAKEFLAGS += --no-builtin-rules
332
283
333
- -include $(DEP_FILES )
284
+ # Remove built-in rules
285
+ MAKEFLAGS += --no-builtin-rules
286
+ .SUFFIXES :
334
287
335
288
# --- Debugging
336
289
# run `make print-VARIABLE` to debug that variable
0 commit comments