// Copyright 2017 The Android Open Source Project

// Library used to export files from this directory to other programs in this
// project.
cc_library {
    name: "libext2_misc",
    host_supported: true,

    srcs: [
        "create_inode.c",
    ],
    cflags: ["-W", "-Wall", "-Wno-macro-redefined"],
    shared_libs: [
        "libext2_quota",
        "libext2fs",
    ],
    system_shared_libs: ["libc"],
    export_include_dirs: ["."],
}

//########################################################################
// Build mke2fs

cc_binary {
    name: "mke2fs",
    host_supported: true,

    srcs: [
        "mke2fs.c",
        "util.c",
        "mk_hugefiles.c",
        "default_profile.c",
        "create_inode.c",
    ],
    cflags: ["-W", "-Wall", "-Wno-macro-redefined"],
    shared_libs: [
        "libext2fs",
        "libext2_blkid",
        "libext2_uuid",
        "libext2_quota",
        "libext2_com_err",
        "libext2_e2p",
    ],
    system_shared_libs: ["libc"],
    include_dirs: ["external/e2fsprogs/e2fsck"],
}

//##########################################################################
// Build tune2fs

cc_defaults {
    name: "tune2fs-defaults",
    srcs: [
        "tune2fs.c",
        "util.c",
    ],
    cflags: [
        "-W",
        "-Wall",
        "-DNO_RECOVERY",
        "-Wno-macro-redefined",
    ],
    include_dirs: ["external/e2fsprogs/e2fsck"],
}

tune2fs_libs = [
    "libext2_com_err",
    "libext2_blkid",
    "libext2_quota",
    "libext2_uuid",
    "libext2_e2p",
    "libext2fs",
]

cc_binary {
    name: "tune2fs",
    host_supported: true,
    defaults: ["tune2fs-defaults"],

    shared_libs: tune2fs_libs,
    system_shared_libs: ["libc"],
}

cc_binary {
    name: "tune2fs_static",
    static_executable: true,
    defaults: ["tune2fs-defaults"],

    static_libs: tune2fs_libs,
}

cc_library_static {
    name: "libtune2fs",
    defaults: ["tune2fs-defaults"],

    cflags: ["-DBUILD_AS_LIB"],
    static_libs: tune2fs_libs,
}

//########################################################################
// Build badblocks

cc_binary {
    name: "badblocks",
    host_supported: true,

    srcs: ["badblocks.c"],
    cflags: ["-W", "-Wall", "-Wno-macro-redefined"],
    shared_libs: [
        "libext2fs",
        "libext2_com_err",
        "libext2_uuid",
        "libext2_blkid",
        "libext2_e2p",
    ],
    system_shared_libs: ["libc"],
}

//########################################################################
// Build chattr

cc_binary {
    name: "chattr",
    host_supported: true,

    srcs: ["chattr.c"],
    cflags: ["-W", "-Wall", "-Wno-macro-redefined"],
    shared_libs: [
        "libext2_com_err",
        "libext2_e2p",
    ],
    system_shared_libs: ["libc"],
}

//########################################################################
// Build lsattr

cc_defaults {
    name: "lsattr-defaults",
    srcs: ["lsattr.c"],
    cflags: ["-W", "-Wall", "-Wno-macro-redefined"],
}

lsattr_libs = [
    "libext2_com_err",
    "libext2_e2p",
]

cc_binary {
    name: "lsattr",
    host_supported: true,
    defaults: ["lsattr-defaults"],

    shared_libs: lsattr_libs,
    system_shared_libs: ["libc"],
}

cc_binary {
    name: "lsattr_static",
    static_executable: true,
    defaults: ["lsattr-defaults"],

    static_libs: lsattr_libs,
}

//########################################################################
// Build blkid

cc_binary {
    name: "blkid",

    srcs: ["blkid.c"],
    cflags: ["-W", "-Wall", "-Wno-macro-redefined"],
    shared_libs: [
        "libext2fs",
        "libext2_blkid",
        "libext2_com_err",
        "libext2_e2p",
    ],
    system_shared_libs: ["libc"],
}

//########################################################################
// Build e4crypt

cc_binary {
    name: "e4crypt",
    host_supported: true,

    srcs: ["e4crypt.c"],
    cflags: ["-W", "-Wall", "-Wno-macro-redefined"],
    shared_libs: [
        "libext2fs",
        "libext2_uuid",
    ],
    system_shared_libs: ["libc"],

    target: {
        darwin: {
            enabled: false,
        },
    },
}

//##########################################################################
// Build e2image

cc_binary {
    name: "e2image",
    host_supported: true,

    srcs: ["e2image.c"],
    cflags: ["-W", "-Wall", "-Wno-macro-redefined"],
    shared_libs: [
        "libext2fs",
        "libext2_blkid",
        "libext2_com_err",
        "libext2_quota",
    ],
    system_shared_libs: ["libc"],
}
