-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
145 lines (121 loc) · 5.27 KB
/
Makefile
File metadata and controls
145 lines (121 loc) · 5.27 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
# =============================================================================
# MICRO-BASIC 2.1 - Makefile
#
# Targets:
# make -> linux (default)
# make linux -> GCC/Linux
# make windows -> MinGW 32-bit cross (i686-w64-mingw32-gcc)
# make windows64 -> MinGW 64-bit cross (x86_64-w64-mingw32-gcc)
# make dos -> ia16-elf-gcc, normal model
# make dos-small -> ia16-elf-gcc, SMALL_TARGET (64KB conservative)
# make clean -> remove all built binaries
#
# Tuning overrides (any target):
# make linux NUM_VAR=52 CTL_DEPTH=12 SA_SIZE=32
# =============================================================================
# =============================================================================
# MICRO-BASIC 2.1 - Makefile
# =============================================================================
SRC = BASIC.c
CFLAGS = -std=c99 -Wall -Wextra -O2
BIN_DIR = bin
DIST_DIR = dist
# Optional tuning defines
ifdef NUM_VAR
CFLAGS += -DNUM_VAR=$(NUM_VAR)
endif
ifdef CTL_DEPTH
CFLAGS += -DCTL_DEPTH=$(CTL_DEPTH)
endif
ifdef SA_SIZE
CFLAGS += -DSA_SIZE=$(SA_SIZE)
endif
ifdef BUFFER_SIZE
CFLAGS += -DBUFFER_SIZE=$(BUFFER_SIZE)
endif
ifdef MAX_FILES
CFLAGS += -DMAX_FILES=$(MAX_FILES)
endif
# -----------------------------------------------------------------------------
.PHONY: all linux windows windows64 dos dos-small clean dirs package
all: linux
dirs:
mkdir -p $(BIN_DIR) $(DIST_DIR)
# -----------------------------------------------------------------------------
# Linux
# -----------------------------------------------------------------------------
linux: dirs $(SRC)
mkdir -p $(BIN_DIR)/linux
gcc $(CFLAGS) -o $(BIN_DIR)/linux/basic $(SRC) tinybeep.c -lasound
$(MAKE) package-linux
# -----------------------------------------------------------------------------
# Windows 32-bit
# -----------------------------------------------------------------------------
windows: dirs $(SRC)
mkdir -p $(BIN_DIR)/windows
i686-w64-mingw32-gcc $(CFLAGS) -o $(BIN_DIR)/windows/basic.exe $(SRC)
$(MAKE) package-windows
# -----------------------------------------------------------------------------
# Windows 64-bit
# -----------------------------------------------------------------------------
windows64: dirs $(SRC)
mkdir -p $(BIN_DIR)/windows64
x86_64-w64-mingw32-gcc $(CFLAGS) -o $(BIN_DIR)/windows64/basic.exe $(SRC)
$(MAKE) package-windows64
# -----------------------------------------------------------------------------
# DOS (normal)
# -----------------------------------------------------------------------------
dos: dirs $(SRC)
mkdir -p $(BIN_DIR)/dos
ia16-elf-gcc -mcmodel=small $(CFLAGS) -o $(BIN_DIR)/dos/basic.exe $(SRC) -li86
$(MAKE) package-dos
# -----------------------------------------------------------------------------
# DOS (SMALL_TARGET)
# -----------------------------------------------------------------------------
dos-small: dirs $(SRC)
mkdir -p $(BIN_DIR)/dos-small
ia16-elf-gcc -mcmodel=small $(CFLAGS) -DSMALL_TARGET -o $(BIN_DIR)/dos-small/basic.exe $(SRC) -li86
$(MAKE) package-dos-small
# -----------------------------------------------------------------------------
# Packaging rules
# -----------------------------------------------------------------------------
package-linux:
@echo "Packaging Linux build..."
@if [ -f README.md ]; then cp README.md $(BIN_DIR)/linux; fi
cd $(BIN_DIR)/linux && zip -q ../../$(DIST_DIR)/linux.zip basic README.md 2>/dev/null || \
cd $(BIN_DIR)/linux && zip -q ../../$(DIST_DIR)/linux.zip basic
package-windows:
@echo "Packaging Windows 32-bit build..."
@if [ -f README.md ]; then cp README.md $(BIN_DIR)/windows; fi
cd $(BIN_DIR)/windows && zip -q ../../$(DIST_DIR)/windows.zip basic.exe README.md 2>/dev/null || \
cd $(BIN_DIR)/windows && zip -q ../../$(DIST_DIR)/windows.zip basic.exe
package-windows64:
@echo "Packaging Windows 64-bit build..."
@if [ -f README.md ]; then cp README.md $(BIN_DIR)/windows64; fi
cd $(BIN_DIR)/windows64 && zip -q ../../$(DIST_DIR)/windows64.zip basic.exe README.md 2>/dev/null || \
cd $(BIN_DIR)/windows64 && zip -q ../../$(DIST_DIR)/windows64.zip basic.exe
package-dos:
@echo "Packaging DOS build..."
@if [ -f README.md ]; then cp README.md $(BIN_DIR)/dos; fi
cd $(BIN_DIR)/dos && zip -q ../../$(DIST_DIR)/dos.zip basic.exe README.md 2>/dev/null || \
cd $(BIN_DIR)/dos && zip -q ../../$(DIST_DIR)/dos.zip basic.exe
package-dos-small:
@echo "Packaging DOS SMALL_TARGET build..."
@if [ -f README.md ]; then cp README.md $(BIN_DIR)/dos-small; fi
cd $(BIN_DIR)/dos-small && zip -q ../../$(DIST_DIR)/dos-small.zip basic.exe README.md 2>/dev/null || \
cd $(BIN_DIR)/dos-small && zip -q ../../$(DIST_DIR)/dos-small.zip basic.exe
# -----------------------------------------------------------------------------
# Clean
# -----------------------------------------------------------------------------
clean:
rm -rf $(BIN_DIR) $(DIST_DIR)
# -----------------------------------------------------------------------------
# Meta‑targets
# -----------------------------------------------------------------------------
# Build everything
all: linux windows windows64 dos dos-small
# Package everything (assumes builds already exist)
package-all: package-linux package-windows package-windows64 package-dos package-dos-small
# Clean only binaries, keep dist packages
clean-bins:
rm -rf $(BIN_DIR)