blob: 857a2ea40de33e965f72fee688fd45306c6dcb78 [file] [log] [blame]
# Copyright 2021 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/cpp/library_headers.gni")
if (is_fuchsia || is_linux) {
target(default_library_type, "libpcap") {
output_name = "pcap"
sources = [
"src/bpf_dump.c",
"src/bpf_filter.c",
"src/bpf_image.c",
"src/etherent.c",
"src/fad-getad.c",
"src/fmtutils.c",
"src/gencode.c",
"src/grammar.c",
"src/nametoaddr.c",
"src/optimize.c",
"src/pcap-common.c",
"src/pcap-usb-linux-common.c",
"src/pcap-util.c",
"src/pcap.c",
"src/savefile.c",
"src/scanner.c",
"src/sf-pcap.c",
"src/sf-pcapng.c",
]
defines = [
"HAVE_CONFIG_H",
"BUILDING_PCAP",
"pcap_EXPORTS",
]
include_dirs = [
# For config.h.
"$target_gen_dir",
]
if (is_fuchsia) {
sources += [
# To build for the null-platform, use `src/pcap-null.c` instead of
# `pcap-fuchsia.{c,cc}`.
"pcap-fuchsia.c",
"pcap-fuchsia.cc",
]
include_dirs += [ "." ]
}
if (is_linux) {
sources += [
"src/missing/strlcat.c",
"src/missing/strlcpy.c",
"src/pcap-linux.c",
]
defines += [ "_GNU_SOURCE" ]
}
configs += [ ":suppress_warnings" ]
public_deps = [ ":headers" ]
deps = [
":copy_config",
"//sdk/lib/fit",
]
}
}
copy("copy_config") {
if (is_fuchsia) {
sources = [ "config.h.fuchsia" ]
}
if (is_linux) {
sources = [ "config.h.linux" ]
}
outputs = [ "$target_gen_dir/config.h" ]
}
library_headers("headers") {
headers = [
"pcap/bpf.h",
"pcap/can_socketcan.h",
"pcap/compiler-tests.h",
"pcap/dlt.h",
"pcap/funcattrs.h",
"pcap/ipnet.h",
"pcap/namedb.h",
"pcap/nflog.h",
"pcap/pcap.h",
"pcap/pcap-inttypes.h",
"pcap/sll.h",
"pcap/socket.h",
"pcap/usb.h",
"pcap/vlan.h",
]
include_dir = "./src"
}
config("suppress_warnings") {
visibility = [ ":*" ]
cflags = [
"-Wno-implicit-fallthrough",
"-Wno-int-conversion",
"-Wno-unused-but-set-variable",
]
if (is_linux) {
cflags += [
"-Wno-macro-redefined",
"-Wno-implicit-int-conversion",
]
}
}