xref: /aosp_15_r20/external/pciutils/Android.bp (revision c2e0c6b56a71da9abe8df5c8348fb3eb5c2c9251)
1package {
2    default_applicable_licenses: ["external_pciutils_license"],
3}
4
5license {
6    name: "external_pciutils_license",
7    visibility: [":__subpackages__"],
8    license_kinds: [
9        "SPDX-license-identifier-GPL-2.0",
10    ],
11    license_text: [
12        "COPYING",
13        "LICENSE",
14    ],
15}
16
17cc_genrule {
18    name: "libpci_config",
19    out: ["config.h"],
20    srcs: ["Makefile"],
21    host_supported: true,
22    vendor_available: true,
23    cmd: "echo >$(out) '#define PCI_CONFIG_H'\n" +
24        "echo >>$(out) \"#define PCI_ARCH_`echo $${CC_ARCH} | tr '[a-z]' '[A-Z]'`\"\n" +
25        "echo >>$(out) '#define PCI_OS_LINUX'\n" +
26        "echo >>$(out) '#define PCI_HAVE_PM_LINUX_SYSFS'\n" +
27        "echo >>$(out) '#define PCI_HAVE_PM_LINUX_PROC'\n" +
28        "echo >>$(out) '#define PCI_HAVE_PM_MMIO_CONF'\n" +
29        "echo >>$(out) '#define PCI_HAVE_PM_ECAM'\n" +
30        "echo >>$(out) '#define PCI_HAVE_LINUX_BYTEORDER_H'\n" +
31        "echo >>$(out) '#define PCI_PATH_PROC_BUS_PCI \"/proc/bus/pci\"'\n" +
32        "echo >>$(out) '#define PCI_PATH_SYS_BUS_PCI \"/sys/bus/pci\"'\n" +
33        "echo >>$(out) '#define PCI_PATH_DEVMEM_DEVICE \"/dev/mem\"'\n" +
34        "echo >>$(out) '#define PCI_PATH_ACPI_MCFG \"/sys/firmware/acpi/tables/MCFG\"'\n" +
35        "echo >>$(out) '#define PCI_PATH_EFI_SYSTAB \"/sys/firmware/efi/systab\"'\n" +
36        "( [ \"$${CC_ARCH}\" == 'x86_64' ] && echo >>$(out) '#define PCI_HAVE_PM_INTEL_CONF' )\n" +
37        "echo >>$(out) '#define PCI_HAVE_64BIT_ADDRESS'\n" +
38        "echo >>$(out) '#define PCI_HAVE_PM_DUMP'\n" +
39        "echo >>$(out) '#define PCI_COMPRESSED_IDS'\n" + // ZLib
40        "echo >>$(out) '#define PCI_IDS \"pci.ids.gz\"'\n" +
41        "echo >>$(out) '#define PCI_PATH_IDS_DIR \"\"'\n" +
42        "echo >>$(out) '#define PCI_USE_LIBKMOD'\n" +
43        "echo >>$(out) \"#define PCILIB_VERSION \\\"`sed -nE 's/^VERSION=(\\S*)/\\1/p' $(in)`\\\"\"",
44}
45
46cc_genrule {
47    name: "libpci_includes",
48    host_supported: true,
49    vendor_available: true,
50    srcs: [
51        ":libpci_config",
52        "lib/header.h",
53        "lib/pci.h",
54        "lib/types.h",
55    ],
56    out: [
57        "pciutils/config.h",
58        "pciutils/header.h",
59        "pciutils/pci.h",
60        "pciutils/types.h",
61    ],
62    cmd: "mkdir -p $(genDir)/pciutils && cp $(in) $(genDir)/pciutils/",
63}
64
65cc_library_static {
66    name: "libpci",
67    host_supported: true,
68    vendor_available: true,
69    visibility: ["//external/flashrom"],
70
71    cflags: [
72        "-O2",
73        "-Wall",
74        "-W",
75        "-Wno-parentheses",
76        "-Wstrict-prototypes",
77        "-Wmissing-prototypes",
78    ],
79
80    srcs: [
81        "lib/init.c",
82        "lib/access.c",
83        "lib/generic.c",
84        "lib/dump.c",
85        "lib/names.c",
86        "lib/filter.c",
87        "lib/names-hash.c",
88        "lib/names-parse.c",
89        "lib/names-net.c",
90        "lib/names-cache.c",
91        "lib/names-hwdb.c",
92        "lib/params.c",
93        "lib/caps.c",
94        "lib/sysfs.c",
95        "lib/proc.c",
96        "lib/mmio-ports.c",
97        "lib/ecam.c",
98        "lib/physmem-posix.c",
99    ],
100
101    arch: {
102        x86: {
103            srcs: ["lib/i386-ports.c"],
104        },
105        x86_64: {
106            srcs: ["lib/i386-ports.c"],
107        },
108    },
109
110    generated_headers: [
111        "libpci_config",
112        "libpci_includes",
113    ],
114
115    export_generated_headers: ["libpci_includes"],
116
117    static_libs: [
118        "libkmod",
119        "libz",
120    ],
121}
122