Skip to content

Commit

Permalink
add default m4 path as a build option
Browse files Browse the repository at this point in the history
  • Loading branch information
leroycep committed Dec 10, 2024
1 parent 5f2697d commit 2776128
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ pub fn build(b: *std.Build) void {
// set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{});

// TODO: depend on an M4 implementation through build.zig.zon?
const m4_path = b.option([]const u8, "M4", "set the path to the default M4 binary") orelse "/bin/m4";

const flex = b.dependency("flex-generated-src", .{});

const exe = b.addExecutable(.{
Expand All @@ -27,7 +30,8 @@ pub fn build(b: *std.Build) void {
exe.root_module.addCMacro("HAVE_ASSERT_H", "");
exe.root_module.addCMacro("HAVE_LIMITS_H", "");
exe.root_module.addCMacro("HAVE_NETINET_IN_H", "");
exe.root_module.addCMacro("M4", "\"m4\""); // path to default m4 binary

exe.root_module.addCMacro("M4", b.fmt("\"{}\"", .{std.zig.fmtEscapes(m4_path)})); // path to default m4 binary

exe.root_module.addIncludePath(flex.path("src"));
exe.root_module.addCSourceFile(.{ .file = flex.path("src/buf.c") });
Expand Down

0 comments on commit 2776128

Please sign in to comment.