|
| 1 | +const std = @import("std"); |
| 2 | + |
| 3 | +pub fn build(b: *std.Build) void { |
| 4 | + const target = b.standardTargetOptions(.{}); |
| 5 | + const optimize = b.standardOptimizeOption(.{}); |
| 6 | + const linkage = b.option(std.builtin.LinkMode, "linkage", "Library linkage type") orelse .static; |
| 7 | + |
| 8 | + const upstream = b.dependency("upstream", .{}); |
| 9 | + const src = upstream.path(""); |
| 10 | + |
| 11 | + const os = target.result.os.tag; |
| 12 | + const arch = target.result.cpu.arch; |
| 13 | + |
| 14 | + const mod = b.createModule(.{ .target = target, .optimize = optimize, .link_libc = true }); |
| 15 | + mod.addIncludePath(src.path(b, "include")); |
| 16 | + mod.addCSourceFiles(.{ .root = src, .files = sources, .flags = &((if (os != .windows) .{ |
| 17 | + "-fvisibility=hidden", |
| 18 | + "-DHAVE_FUNC_ATTRIBUTE_VISIBILITY=1", |
| 19 | + "-DHAVE_GMTIME_R=1", |
| 20 | + } else .{ "", "", "" }) ++ |
| 21 | + .{ "-DHasTHREADS=1", "-DHAVE_TIMESPEC_GET=1" } ++ |
| 22 | + .{if (arch.endian() == .big) "-DWORDS_BIGENDIAN=1" else ""} ++ |
| 23 | + .{if (arch != .x86_64 and arch != .x86) "-DCMS_DONT_USE_SSE2=1" else ""}) }); |
| 24 | + |
| 25 | + const lib = b.addLibrary(.{ .name = "lcms2", .root_module = mod, .linkage = linkage }); |
| 26 | + inline for (.{ "lcms2.h", "lcms2_plugin.h" }) |h| lib.installHeader(src.path(b, "include/" ++ h), h); |
| 27 | + b.installArtifact(lib); |
| 28 | +} |
| 29 | + |
| 30 | +const sources: []const []const u8 = &.{ |
| 31 | + "src/cmsalpha.c", "src/cmscam02.c", "src/cmscgats.c", "src/cmscnvrt.c", |
| 32 | + "src/cmserr.c", "src/cmsgamma.c", "src/cmsgmt.c", "src/cmshalf.c", |
| 33 | + "src/cmsintrp.c", "src/cmsio0.c", "src/cmsio1.c", "src/cmslut.c", |
| 34 | + "src/cmsmd5.c", "src/cmsmtrx.c", "src/cmsnamed.c", "src/cmsopt.c", |
| 35 | + "src/cmspack.c", "src/cmspcs.c", "src/cmsplugin.c", "src/cmsps2.c", |
| 36 | + "src/cmssamp.c", "src/cmssm.c", "src/cmstypes.c", "src/cmsvirt.c", |
| 37 | + "src/cmswtpnt.c", "src/cmsxform.c", |
| 38 | +}; |
0 commit comments