Skip to content

Commit be5d702

Browse files
build: support multi os/arch conf for libiconv
Signed-off-by: Francis Bouvier <[email protected]>
1 parent d1951b2 commit be5d702

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

Makefile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ install-netsurf: _install-netsurf
112112
install-netsurf: OPTCFLAGS := -DNDEBUG
113113

114114
BC_NS := $(BC)vendor/netsurf
115-
ICONV := $(BC)vendor/libiconv
115+
ICONV := $(BC)vendor/libiconv/out/$(OS)-$(ARCH)
116116
# TODO: add Linux iconv path (I guess it depends on the distro)
117117
# TODO: this way of linking libiconv is not ideal. We should have a more generic way
118118
# and stick to a specif version. Maybe build from source. Anyway not now.
@@ -169,15 +169,22 @@ test-netsurf:
169169
cd vendor/netsurf/libdom && \
170170
BUILDDIR=$(BC_NS)/build/libdom make test
171171

172-
install-libiconv:
173-
ifeq ("$(wildcard vendor/libiconv/lib/libiconv.a)","")
172+
download-libiconv:
173+
ifeq ("$(wildcard vendor/libiconv/libiconv-1.17)","")
174174
@mkdir -p vendor/libiconv
175175
@cd vendor/libiconv && \
176176
curl https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.17.tar.gz | tar -xvzf -
177+
endif
178+
179+
install-libiconv: download-libiconv clean-libiconv
177180
@cd vendor/libiconv/libiconv-1.17 && \
178-
./configure --prefix=$(BC)vendor/libiconv --enable-static && \
181+
./configure --prefix=$(ICONV) --enable-static && \
179182
make && make install
180-
endif
183+
184+
clean-libiconv:
185+
@cd vendor/libiconv/libiconv-1.17 && \
186+
make clean > /dev/null && cd .. && \
187+
rm -Rf lib && rm -Rf share && rm -Rf bin && rm -Rf include
181188

182189
install-zig-js-runtime-dev:
183190
@cd vendor/zig-js-runtime && \

build.zig

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,23 @@ fn moduleNetSurf(b: *std.Build, target: std.Build.ResolvedTarget) !*std.Build.Mo
170170
.root_source_file = b.path("src/netsurf/netsurf.zig"),
171171
.target = target,
172172
});
173+
174+
const os = target.result.os.tag;
175+
const arch = target.result.cpu.arch;
176+
173177
// iconv
174-
mod.addObjectFile(b.path("vendor/libiconv/lib/libiconv.a"));
175-
mod.addIncludePath(b.path("vendor/libiconv/include"));
178+
const libiconv_lib_path = try std.fmt.allocPrint(
179+
mod.owner.allocator,
180+
"vendor/libiconv/out/{s}-{s}/lib/libiconv.a",
181+
.{ @tagName(os), @tagName(arch) },
182+
);
183+
const libiconv_include_path = try std.fmt.allocPrint(
184+
mod.owner.allocator,
185+
"vendor/libiconv/out/{s}-{s}/lib/libiconv.a",
186+
.{ @tagName(os), @tagName(arch) },
187+
);
188+
mod.addObjectFile(b.path(libiconv_lib_path));
189+
mod.addIncludePath(b.path(libiconv_include_path));
176190

177191
// mimalloc
178192
mod.addImport("mimalloc", (try moduleMimalloc(b, target)));

0 commit comments

Comments
 (0)