172 lines
5.2 KiB
Zig
172 lines
5.2 KiB
Zig
const std = @import("std");
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
const target = b.standardTargetOptions(.{});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
const upstream = b.dependency("alsa-lib", .{});
|
|
|
|
// Create config header matching autotools output
|
|
const config = b.addConfigHeader(.{
|
|
.style = .blank,
|
|
.include_path = "config.h",
|
|
}, .{
|
|
.PACKAGE_NAME = "alsa-lib",
|
|
.VERSION = "1.2.14",
|
|
.HAVE_USELOCALE = 1,
|
|
.HAVE_EACCESS = 1,
|
|
.HAVE_ENDIAN_H = 1,
|
|
.HAVE_SYS_SHM_H = 1,
|
|
.HAVE_MALLOC_H = 1,
|
|
.HAVE_LFS = 1,
|
|
.HAVE_LIBDL = 1,
|
|
.PIC = 1,
|
|
.BUILD_PCM = "1",
|
|
.BUILD_MIXER = "1",
|
|
.BUILD_HWDEP = "1",
|
|
.ALSA_DEVICE_DIRECTORY = "/dev/snd/",
|
|
.ALSA_CONFIG_DIR = "/usr/share/alsa",
|
|
.ALSA_PLUGIN_DIR = "/usr/lib/alsa-lib",
|
|
.SND_MAX_CARDS = 32,
|
|
.__SYMBOL_PREFIX = "",
|
|
._GNU_SOURCE = 1,
|
|
.HAVE_GNU_LD = 1,
|
|
.HAVE_ELF = 1,
|
|
.HAVE_ASM_PREVIOUS_DIRECTIVE = 1,
|
|
});
|
|
|
|
// Create version.h
|
|
const version_h = b.addWriteFiles();
|
|
_ = version_h.add("version.h",
|
|
\\/*
|
|
\\ * version.h
|
|
\\ */
|
|
\\
|
|
\\#define SND_LIB_MAJOR 1 /**< major number of library version */
|
|
\\#define SND_LIB_MINOR 2 /**< minor number of library version */
|
|
\\#define SND_LIB_SUBMINOR 14 /**< subminor number of library version */
|
|
\\#define SND_LIB_EXTRAVER 1000000 /**< extra version number, used mainly for betas */
|
|
\\/** library version */
|
|
\\#define SND_LIB_VER(maj, min, sub) (((maj)<<16)|((min)<<8)|(sub))
|
|
\\#define SND_LIB_VERSION SND_LIB_VER(SND_LIB_MAJOR, SND_LIB_MINOR, SND_LIB_SUBMINOR)
|
|
\\/** library version (string) */
|
|
\\#define SND_LIB_VERSION_STR "1.2.14"
|
|
\\
|
|
);
|
|
|
|
// Generate asoundlib.h
|
|
const asoundlib_h = b.addWriteFiles();
|
|
_ = asoundlib_h.add("asoundlib.h",
|
|
\\/*
|
|
\\ * ALSA library - main header file
|
|
\\ */
|
|
\\
|
|
\\#ifndef __ALSA_ASOUNDLIB_H
|
|
\\#define __ALSA_ASOUNDLIB_H
|
|
\\
|
|
\\#include <stdio.h>
|
|
\\#include <stdlib.h>
|
|
\\#include <string.h>
|
|
\\#include <fcntl.h>
|
|
\\#include <assert.h>
|
|
\\#include <endian.h>
|
|
\\#include <sys/poll.h>
|
|
\\#include <errno.h>
|
|
\\#include <stdint.h>
|
|
\\#include <sys/types.h>
|
|
\\#include <unistd.h>
|
|
\\
|
|
\\#include <alsa/asoundef.h>
|
|
\\#include <alsa/version.h>
|
|
\\#include <alsa/global.h>
|
|
\\#include <alsa/input.h>
|
|
\\#include <alsa/output.h>
|
|
\\#include <alsa/error.h>
|
|
\\#include <alsa/conf.h>
|
|
\\#include <alsa/control.h>
|
|
\\#include <alsa/pcm.h>
|
|
\\
|
|
\\#endif /* __ALSA_ASOUNDLIB_H */
|
|
\\
|
|
);
|
|
|
|
const lib = b.addLibrary(.{
|
|
.name = "asound",
|
|
.linkage = .static,
|
|
.root_module = b.createModule(.{
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.link_libc = true,
|
|
}),
|
|
});
|
|
|
|
lib.addConfigHeader(config);
|
|
lib.addIncludePath(upstream.path("include"));
|
|
lib.addIncludePath(version_h.getDirectory());
|
|
lib.addIncludePath(asoundlib_h.getDirectory());
|
|
|
|
// Create alsa as symlink for the include directory. Not sure why upstream
|
|
// does this, but since we're not using their scripts, we need to do that
|
|
// as well
|
|
const create_symlink = b.addSystemCommand(&.{ "sh", "-c", "rm -f alsa; ln -sf . alsa" });
|
|
create_symlink.setCwd(upstream.path("include"));
|
|
lib.step.dependOn(&create_symlink.step);
|
|
|
|
lib.addCSourceFiles(.{
|
|
.root = upstream.path(""),
|
|
.files = &.{
|
|
"src/conf.c",
|
|
"src/confeval.c",
|
|
"src/confmisc.c",
|
|
"src/input.c",
|
|
"src/output.c",
|
|
"src/async.c",
|
|
"src/error.c",
|
|
"src/dlmisc.c",
|
|
"src/socket.c",
|
|
"src/shmarea.c",
|
|
"src/userfile.c",
|
|
"src/names.c",
|
|
"src/control/control.c",
|
|
"src/control/control_hw.c",
|
|
"src/control/cards.c",
|
|
"src/control/namehint.c",
|
|
"src/control/hcontrol.c",
|
|
"src/control/tlv.c",
|
|
"src/control/setup.c",
|
|
"src/control/ctlparse.c",
|
|
"src/control/eld.c",
|
|
"src/pcm/pcm.c",
|
|
"src/pcm/pcm_hw.c",
|
|
"src/pcm/pcm_params.c",
|
|
"src/pcm/pcm_misc.c",
|
|
"src/pcm/pcm_mmap.c",
|
|
"src/pcm/mask.c",
|
|
"src/pcm/interval.c",
|
|
},
|
|
.flags = &.{
|
|
"-D_GNU_SOURCE",
|
|
"-DALSA_LIBRARY_BUILD",
|
|
},
|
|
});
|
|
|
|
lib.installHeadersDirectory(upstream.path("include"), "alsa", .{
|
|
.include_extensions = &.{
|
|
"asoundef.h",
|
|
"version.h",
|
|
"global.h",
|
|
"input.h",
|
|
"output.h",
|
|
"error.h",
|
|
"conf.h",
|
|
"control.h",
|
|
"pcm.h",
|
|
},
|
|
});
|
|
|
|
// Install generated asoundlib.h and version.h
|
|
lib.installHeader(asoundlib_h.getDirectory().path(b, "asoundlib.h"), "alsa/asoundlib.h");
|
|
lib.installHeader(version_h.getDirectory().path(b, "version.h"), "alsa/version.h");
|
|
|
|
b.installArtifact(lib);
|
|
}
|