-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
179 lines (161 loc) · 6.22 KB
/
Makefile
File metadata and controls
179 lines (161 loc) · 6.22 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
# Makefile for building FuseX third-party libraries on Windows (MSYS2 MinGW-w64).
# Run from MSYS2 "MinGW 64-bit" shell: cd 3rdparty && make
SCRIPT_DIR := $(CURDIR)
DIST_PREFIX := $(SCRIPT_DIR)/dist
export PKG_CONFIG_PATH := $(DIST_PREFIX)/lib/pkgconfig:$(PKG_CONFIG_PATH)
RED := \033[0;31m
GREEN := \033[0;32m
YELLOW := \033[1;33m
NC := \033[0m
# Optional audiofile: only the legacy `audiofile-patched/` tree (from zip), not the
# submodule path, so default Windows deps stay minimal and build with current GCC.
AUDIOFILE_SRC := $(shell if [ -d "audiofile-patched" ]; then echo "audiofile-patched"; else echo ""; fi)
.PHONY: all clean distclean libspectrum audiofile libxml2 mbedtls check-tools check-libspectrum extract-audiofile extract-libxml2 libspectrum-with-audiofile
# Default: libspectrum (+ optional libxml2 / mbedtls if present).
all: check-tools check-libspectrum dist-dirs libspectrum
@if [ -d "libxml2-2.9.12" ] || [ -f "libxml2-2.9.12.tar.gz" ]; then \
$(MAKE) libxml2; \
fi
@if [ -d "mbedtls/src" ] && [ -f "mbedtls/src/Makefile" ]; then \
$(MAKE) mbedtls; \
fi
@echo ""
@echo "$(GREEN)=== Library build complete! ===$(NC)"
@echo ""
@echo "Libraries installed to: $(DIST_PREFIX)"
@echo " - DLLs: $(DIST_PREFIX)/bin/"
@echo " - Headers: $(DIST_PREFIX)/include/"
@echo " - pkg-config: $(DIST_PREFIX)/lib/pkgconfig/"
@echo ""
@echo "Built libraries:"
@echo " ✓ libspectrum"
@if [ -n "$(AUDIOFILE_SRC)" ]; then echo " ✓ audiofile"; fi
@if [ -d "libxml2-2.9.12" ]; then echo " ✓ libxml2"; fi
@if [ -d "mbedtls/src" ] && [ -f "mbedtls/src/Makefile" ]; then echo " ✓ mbedtls"; fi
@echo ""
@echo "You can now run ./build_win32.sh from the repository root."
dist-dirs:
@mkdir -p $(DIST_PREFIX)/bin
@mkdir -p $(DIST_PREFIX)/lib/pkgconfig
@mkdir -p $(DIST_PREFIX)/include
@echo "$(GREEN)Using local dist prefix: $(DIST_PREFIX)$(NC)"
check-tools:
@echo "$(GREEN)Checking for required tools...$(NC)"
@for tool in gcc make pkg-config; do \
if ! command -v $$tool >/dev/null 2>&1; then \
echo "$(RED)Error: $$tool is not installed$(NC)"; \
echo "Install with: pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-make mingw-w64-x86_64-pkg-config"; \
exit 1; \
fi; \
echo " ✓ $$tool found"; \
done
check-libspectrum:
@echo ""
@echo "$(GREEN)Checking for libspectrum...$(NC)"
@if [ ! -d "libspectrum" ]; then \
echo "$(YELLOW)libspectrum submodule missing; initializing from repo root...$(NC)"; \
cd .. && git submodule update --init --recursive 3rdparty/libspectrum && cd 3rdparty; \
fi
extract-audiofile:
@if [ -f "audiofile-patched.zip" ] && [ ! -d "audiofile-patched" ]; then \
echo "$(GREEN)Extracting audiofile-patched.zip...$(NC)"; \
unzip -q audiofile-patched.zip; \
fi
extract-libxml2:
@if [ -f "libxml2-2.9.12.tar.gz" ] && [ ! -d "libxml2-2.9.12" ]; then \
echo "$(GREEN)Extracting libxml2...$(NC)"; \
tar -xzf libxml2-2.9.12.tar.gz; \
fi
libspectrum: dist-dirs check-libspectrum
@echo ""
@echo "$(GREEN)Building libspectrum (required)...$(NC)"
@cd libspectrum && \
if [ -f Makefile ]; then \
$(MAKE) distclean || true; \
fi && \
if [ ! -f configure ]; then \
./autogen.sh; \
fi && \
./configure --with-fake-glib --without-libaudiofile --without-libgcrypt \
--without-zlib --without-bzip2 --prefix="$(DIST_PREFIX)" && \
$(MAKE) && \
$(MAKE) install
audiofile: extract-audiofile
@afdir="$(AUDIOFILE_SRC)"; \
if test -z "$$afdir" && test -d audiofile-patched; then afdir=audiofile-patched; fi; \
if test -n "$$afdir"; then \
echo ""; \
echo "$(GREEN)Building audiofile (optional)...$(NC)"; \
cd "$$afdir" && \
if [ -f Makefile ]; then \
$(MAKE) distclean || true; \
fi && \
if [ ! -f configure ]; then \
./autogen.sh --disable-static --disable-flac --disable-docs --disable-examples; \
fi && \
./configure --disable-static --disable-flac --disable-docs --disable-examples --prefix="$(DIST_PREFIX)" && \
$(MAKE) && \
$(MAKE) install-strip; \
fi
libspectrum-with-audiofile: audiofile
@echo ""
@echo "$(GREEN)Rebuilding libspectrum with audiofile...$(NC)"
@cd libspectrum && \
$(MAKE) distclean || true && \
./autogen.sh && \
./configure --with-fake-glib --with-libaudiofile --without-libgcrypt \
--without-zlib --without-bzip2 --prefix="$(DIST_PREFIX)" && \
$(MAKE) && \
$(MAKE) install
libxml2: extract-libxml2
@if [ -d "libxml2-2.9.12" ]; then \
echo ""; \
echo "$(GREEN)Building libxml2 (optional)...$(NC)"; \
cd libxml2-2.9.12 && \
if [ -f Makefile ]; then \
$(MAKE) distclean || true; \
fi && \
./configure --disable-static --without-iconv --without-python --without-lzma --prefix="$(DIST_PREFIX)" && \
$(MAKE) && \
$(MAKE) install-strip; \
fi
mbedtls:
@if [ -d "mbedtls/src" ] && [ -f "mbedtls/src/Makefile" ]; then \
echo ""; \
echo "$(GREEN)Building mbedtls (optional)...$(NC)"; \
cd mbedtls/src && \
if [ -f library/Makefile ]; then \
$(MAKE) clean || true; \
fi && \
$(MAKE) WINDOWS=1 SHARED=1 no_test && \
mkdir -p "$(DIST_PREFIX)/include/mbedtls" && \
cp -rp include/mbedtls/* "$(DIST_PREFIX)/include/mbedtls/" && \
mkdir -p "$(DIST_PREFIX)/lib" && \
mkdir -p "$(DIST_PREFIX)/bin" && \
cd library && \
for lib in libmbedtls libmbedx509 libmbedcrypto; do \
if [ -f "$$lib.a" ]; then cp -f "$$lib.a" "$(DIST_PREFIX)/lib/" || true; fi; \
if [ -f "$$lib.dll.a" ]; then cp -f "$$lib.dll.a" "$(DIST_PREFIX)/lib/" || true; fi; \
if [ -f "$$lib.dll" ]; then cp -f "$$lib.dll" "$(DIST_PREFIX)/bin/" || true; fi; \
done; \
fi
clean:
@echo "$(YELLOW)Cleaning build artifacts...$(NC)"
@if [ -d "libspectrum" ] && [ -f "libspectrum/Makefile" ]; then \
cd libspectrum && $(MAKE) distclean || true; \
fi
@if [ -n "$(AUDIOFILE_SRC)" ] && [ -f "$(AUDIOFILE_SRC)/Makefile" ]; then \
cd "$(AUDIOFILE_SRC)" && $(MAKE) distclean || true; \
fi
@if [ -d "audiofile-patched" ] && [ -f "audiofile-patched/Makefile" ]; then \
cd audiofile-patched && $(MAKE) distclean || true; \
fi
@if [ -d "libxml2-2.9.12" ] && [ -f "libxml2-2.9.12/Makefile" ]; then \
cd libxml2-2.9.12 && $(MAKE) distclean || true; \
fi
@if [ -d "mbedtls/src" ] && [ -f "mbedtls/src/library/Makefile" ]; then \
cd mbedtls/src && $(MAKE) clean || true; \
fi
distclean: clean
@echo "$(YELLOW)Removing dist directory...$(NC)"
@rm -rf $(DIST_PREFIX)