-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
354 lines (296 loc) · 11.6 KB
/
Makefile
File metadata and controls
354 lines (296 loc) · 11.6 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
################################################################################
# amiga-base - Amiga Build Makefile (vbcc +aos68k)
#
# Usage:
# make - release build (no console, no memtrack)
# make CONSOLE=1 - enable console window + printf output
# make MEMTRACK=1 - enable memory leak detection
# make CONSOLE=1 MEMTRACK=1
# make AUTO=0 - disable VBCC auto startup/cleanup code
# make clean - remove build artefacts
# make help - show this help
#
# Customise:
# APP_NAME - displayed in window title and OOM dialogs
# PROJECT - output executable name
################################################################################
CONSOLE ?= 0
MEMTRACK ?= 0
AUTO ?= 1
RELEASE ?= 0
# Used for normal builds. Update manually or run "make refresh-version".
PINNED_BUILD_DATE ?= 18.03.2026
# ---------------------------------------------------------------------------
# Project identity - change these for each new project
# ---------------------------------------------------------------------------
APP_NAME = Retroplay WHD Downloader
PROJECT = whdfetch
# ---------------------------------------------------------------------------
# Directories
# ---------------------------------------------------------------------------
SRC_DIR = src
BUILD_DIR = build
OUT_DIR = $(BUILD_DIR)/amiga
BIN_DIR = Bin/Amiga
BIN = $(BIN_DIR)/$(PROJECT)
GENERATED_DIR = $(OUT_DIR)/generated
GENERATED_VERSION_H = $(GENERATED_DIR)/build_version.h
# ---------------------------------------------------------------------------
# Feature flags
# ---------------------------------------------------------------------------
ifeq ($(CONSOLE),1)
CONSOLE_FLAG = -DENABLE_CONSOLE
else
CONSOLE_FLAG =
endif
ifeq ($(MEMTRACK),1)
MEMTRACK_FLAG = -DDEBUG_MEMORY_TRACKING
else
MEMTRACK_FLAG =
endif
# ---------------------------------------------------------------------------
# Compiler settings (VBCC cross-compiler, AmigaOS 68000 target)
# ---------------------------------------------------------------------------
CC = vc
# NOTE: VBCC on Windows strips quotes from -D string values, so AMIGA_APP_NAME
# cannot be set via -D. Edit the #define in src/platform/platform.h instead.
# Set these to match your local installation paths
ROADSHOW_INC = C:/Amiga/Roadshow-SDK-1.8/netinclude
NDK_INC = C:/Amiga/AmigaIncludes
CFLAGS = +aos68k -c99 -cpu=68000 -O2 -size \
-I$(VBCC)/targets/m68k-amigaos/include \
-I$(SRC_DIR) \
-I$(GENERATED_DIR) \
-I$(NDK_INC) \
-I$(ROADSHOW_INC) \
-DPLATFORM_AMIGA=1 \
-D__AMIGA__ \
-DDEBUG \
$(CONSOLE_FLAG) \
$(MEMTRACK_FLAG)
LDFLAGS_BASE = +aos68k -cpu=68000 -O2 -size -final -lamiga
ifeq ($(AUTO),1)
LDFLAGS = $(LDFLAGS_BASE) -lauto
else
LDFLAGS = $(LDFLAGS_BASE)
endif
ifeq ($(RELEASE),1)
LINK_LDFLAGS = $(LDFLAGS) -s
else
LINK_LDFLAGS = $(LDFLAGS)
endif
# ---------------------------------------------------------------------------
# Source files
# ---------------------------------------------------------------------------
SRCS = \
$(SRC_DIR)/main.c \
$(SRC_DIR)/cli/cli_parser.c \
$(SRC_DIR)/config/app_constants.c \
$(SRC_DIR)/config/app_defaults.c \
$(SRC_DIR)/config/app_state.c \
$(SRC_DIR)/startup/startup.c \
$(SRC_DIR)/lifecycle/lifecycle.c \
$(SRC_DIR)/phases/html_phase.c \
$(SRC_DIR)/phases/dat_phase.c \
$(SRC_DIR)/phases/download_phase.c \
$(SRC_DIR)/ini_parser.c \
$(SRC_DIR)/icon_unsnapshot.c \
$(SRC_DIR)/utilities.c \
$(SRC_DIR)/gamefile_parser.c \
$(SRC_DIR)/tag_text.c \
$(SRC_DIR)/cli_utilities.c \
$(SRC_DIR)/linecounter.c \
$(SRC_DIR)/report/report.c \
$(SRC_DIR)/extract/extract.c \
$(SRC_DIR)/download/http_download.c \
$(SRC_DIR)/download/download_retry.c \
$(SRC_DIR)/download/download_lib.c \
$(SRC_DIR)/download/file_crc.c \
$(SRC_DIR)/download/timer_shared.c \
$(SRC_DIR)/download/display_message.c \
$(SRC_DIR)/log/log.c \
$(SRC_DIR)/platform/platform.c
# ---------------------------------------------------------------------------
# Object files
# ---------------------------------------------------------------------------
OBJS = \
$(OUT_DIR)/main.o \
$(OUT_DIR)/cli/cli_parser.o \
$(OUT_DIR)/config/app_constants.o \
$(OUT_DIR)/config/app_defaults.o \
$(OUT_DIR)/config/app_state.o \
$(OUT_DIR)/startup/startup.o \
$(OUT_DIR)/lifecycle/lifecycle.o \
$(OUT_DIR)/phases/html_phase.o \
$(OUT_DIR)/phases/dat_phase.o \
$(OUT_DIR)/phases/download_phase.o \
$(OUT_DIR)/ini_parser.o \
$(OUT_DIR)/icon_unsnapshot.o \
$(OUT_DIR)/utilities.o \
$(OUT_DIR)/gamefile_parser.o \
$(OUT_DIR)/tag_text.o \
$(OUT_DIR)/cli_utilities.o \
$(OUT_DIR)/linecounter.o \
$(OUT_DIR)/report/report.o \
$(OUT_DIR)/extract/extract.o \
$(OUT_DIR)/download/http_download.o \
$(OUT_DIR)/download/download_retry.o \
$(OUT_DIR)/download/download_lib.o \
$(OUT_DIR)/download/file_crc.o \
$(OUT_DIR)/download/timer_shared.o \
$(OUT_DIR)/download/display_message.o \
$(OUT_DIR)/log/log.o \
$(OUT_DIR)/platform/platform.o
# ---------------------------------------------------------------------------
# Targets
# ---------------------------------------------------------------------------
.PHONY: all clean help directories FORCE refresh-version release
all: directories $(BIN)
directories:
@if not exist "$(OUT_DIR)" mkdir "$(OUT_DIR)"
@if not exist "$(GENERATED_DIR)" mkdir "$(GENERATED_DIR)"
@if not exist "$(OUT_DIR)\log" mkdir "$(OUT_DIR)\log"
@if not exist "$(OUT_DIR)\cli" mkdir "$(OUT_DIR)\cli"
@if not exist "$(OUT_DIR)\config" mkdir "$(OUT_DIR)\config"
@if not exist "$(OUT_DIR)\startup" mkdir "$(OUT_DIR)\startup"
@if not exist "$(OUT_DIR)\lifecycle" mkdir "$(OUT_DIR)\lifecycle"
@if not exist "$(OUT_DIR)\phases" mkdir "$(OUT_DIR)\phases"
@if not exist "$(OUT_DIR)\platform" mkdir "$(OUT_DIR)\platform"
@if not exist "$(OUT_DIR)\extract" mkdir "$(OUT_DIR)\extract"
@if not exist "$(OUT_DIR)\report" mkdir "$(OUT_DIR)\report"
@if not exist "$(OUT_DIR)\download" mkdir "$(OUT_DIR)\download"
@if not exist "$(BIN_DIR)" mkdir "$(BIN_DIR)"
$(GENERATED_VERSION_H): | directories
@echo Generating pinned build version header: $@
@echo #ifndef BUILD_VERSION_H > $(GENERATED_VERSION_H)
@echo #define BUILD_VERSION_H >> $(GENERATED_VERSION_H)
@echo /* Auto-generated by Makefile. */ >> $(GENERATED_VERSION_H)
@echo /* Release builds and refresh-version overwrite this file. */ >> $(GENERATED_VERSION_H)
@echo /* Do not hand-edit; update PINNED_BUILD_DATE or run a version target. */ >> $(GENERATED_VERSION_H)
@echo #define APP_BUILD_DATE_DMY "$(PINNED_BUILD_DATE)" >> $(GENERATED_VERSION_H)
@echo #endif >> $(GENERATED_VERSION_H)
refresh-version: | directories
@echo Regenerating build version header with current date: $(GENERATED_VERSION_H)
@echo #ifndef BUILD_VERSION_H > $(GENERATED_VERSION_H)
@echo #define BUILD_VERSION_H >> $(GENERATED_VERSION_H)
@echo /* Auto-generated by Makefile. */ >> $(GENERATED_VERSION_H)
@echo /* Release builds and refresh-version overwrite this file. */ >> $(GENERATED_VERSION_H)
@echo /* Do not hand-edit; update PINNED_BUILD_DATE or run a version target. */ >> $(GENERATED_VERSION_H)
@for /f %%i in ('powershell -NoProfile -Command "Get-Date -Format dd.MM.yyyy"') do @echo #define APP_BUILD_DATE_DMY "%%i" >> $(GENERATED_VERSION_H)
@echo #endif >> $(GENERATED_VERSION_H)
release:
@echo Building release binary with fresh date metadata...
@$(MAKE) clean
@$(MAKE) RELEASE=1 CONSOLE=0 MEMTRACK=0 refresh-version all
# Link
$(BIN): $(OBJS)
@echo Linking: $(BIN)
$(CC) $(LINK_LDFLAGS) -o $@ $^
@echo Build complete: $(BIN)
# Compile rules
$(OUT_DIR)/main.o: $(SRC_DIR)/main.c $(GENERATED_VERSION_H)
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/cli/cli_parser.o: $(SRC_DIR)/cli/cli_parser.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/config/app_constants.o: $(SRC_DIR)/config/app_constants.c $(GENERATED_VERSION_H)
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/config/app_defaults.o: $(SRC_DIR)/config/app_defaults.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/config/app_state.o: $(SRC_DIR)/config/app_state.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/startup/startup.o: $(SRC_DIR)/startup/startup.c $(GENERATED_VERSION_H)
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/lifecycle/lifecycle.o: $(SRC_DIR)/lifecycle/lifecycle.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/phases/html_phase.o: $(SRC_DIR)/phases/html_phase.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/phases/dat_phase.o: $(SRC_DIR)/phases/dat_phase.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/phases/download_phase.o: $(SRC_DIR)/phases/download_phase.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/ini_parser.o: $(SRC_DIR)/ini_parser.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/icon_unsnapshot.o: $(SRC_DIR)/icon_unsnapshot.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/utilities.o: $(SRC_DIR)/utilities.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/gamefile_parser.o: $(SRC_DIR)/gamefile_parser.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/tag_text.o: $(SRC_DIR)/tag_text.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/cli_utilities.o: $(SRC_DIR)/cli_utilities.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/linecounter.o: $(SRC_DIR)/linecounter.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/report/report.o: $(SRC_DIR)/report/report.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/extract/extract.o: $(SRC_DIR)/extract/extract.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/download/http_download.o: $(SRC_DIR)/download/http_download.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/download/download_retry.o: $(SRC_DIR)/download/download_retry.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/download/download_lib.o: $(SRC_DIR)/download/download_lib.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/download/file_crc.o: $(SRC_DIR)/download/file_crc.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/download/timer_shared.o: $(SRC_DIR)/download/timer_shared.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/download/display_message.o: $(SRC_DIR)/download/display_message.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/log/log.o: $(SRC_DIR)/log/log.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
$(OUT_DIR)/platform/platform.o: $(SRC_DIR)/platform/platform.c
@echo Compiling: $<
$(CC) $(CFLAGS) -c $< -o $@
clean:
@echo Cleaning...
@if exist "$(OUT_DIR)" rmdir /S /Q "$(OUT_DIR)"
@echo Done.
FORCE:
help:
@echo amiga-base Build System
@echo =======================
@echo.
@echo make Build release (no console, no memtrack)
@echo make CONSOLE=1 Enable console window
@echo make MEMTRACK=1 Enable memory tracking
@echo make AUTO=0 Disable -lauto for shutdown diagnostics
@echo make refresh-version Regenerate build date header with current date
@echo make release Fresh-date release build with stripped symbols
@echo make clean Remove build artefacts
@echo.
@echo APP_NAME=$(APP_NAME) (edit src/platform/platform.h to change AMIGA_APP_NAME)
@echo PROJECT=$(PROJECT)
@echo PINNED_BUILD_DATE=$(PINNED_BUILD_DATE)
@echo BIN=$(BIN)
@echo CONSOLE=$(CONSOLE)
@echo MEMTRACK=$(MEMTRACK)
@echo AUTO=$(AUTO)
@echo RELEASE=$(RELEASE)