cc_binary {
	name: "gps_test",
	vendor: true,
	srcs: [
		"android/gps_test.c"
	],
	shared_libs: [
		"libutils",
		"liblog",
		"libcutils"
	],
	static_libs: [
		"libgps_static"
	],
	cflags: [
		"-Wno-unused-variable",
		"-Wno-unused-parameter",
		"-Wno-missing-field-initializers",
	]
}

cc_binary {
	name: "gpsd",
	vendor: true,
	required: ["gpsd_wrapper"],
	generated_headers: [
		"gpsd_config_h",
		"gpsd_packet_names_h"
	],
	srcs: [
		"dbusexport.c",
		"gpsd.c",
		"shmexport.c",
		"timehint.c"
	],
	static_libs: [
		"libgpsd",
		"libgps_static",
	],
	cflags: [
		"-Wno-unused-variable",
		"-Wno-unused-parameter",
		"-Wno-missing-field-initializers",
	]
}

cc_binary {
	name: "gpsd_wrapper",
	vendor: true,
	init_rc: ["android/gpsd.rc"],
	srcs: ["android/gpsd_wrapper.c"],
	shared_libs: [
		"liblog",
		"libcutils"
	]
}

cc_library_shared {
	name: "libgps",
	vendor: true,
	export_include_dirs: ["."],
	generated_headers: [
		"gpsd_config_h",
		"gpsd_packet_names_h"
	],
	generated_sources: ["gps_maskdump_c"],
	srcs: [
		"bits.c",
		"gpsdclient.c",
		"gpsutils.c",
		"hex.c",
		"json.c",
		"libgps_core.c",
		"libgps_dbus.c",
		"libgps_json.c",
		"libgps_shm.c",
		"libgps_sock.c",
		"netlib.c",
		"os_compat.c",
		"rtcm2_json.c",
		"rtcm3_json.c",
		"shared_json.c"
	],
	cflags: [
		"-Wno-unused-variable",
		"-Wno-unused-parameter",
		"-Wno-missing-field-initializers",
	],
}

cc_library_static {
        name: "libgps_static",
        vendor: true,
        export_include_dirs: ["."],
	generated_headers: [
		"gpsd_config_h",
		"gpsd_packet_names_h"
	],
	generated_sources: ["gps_maskdump_c"],
        srcs: [
                "bits.c",
                "gpsdclient.c",
                "gpsutils.c",
                "hex.c",
                "json.c",
                "libgps_core.c",
                "libgps_dbus.c",
                "libgps_json.c",
                "libgps_shm.c",
                "libgps_sock.c",
                "netlib.c",
                "os_compat.c",
                "rtcm2_json.c",
                "rtcm3_json.c",
                "shared_json.c"
        ],
        cflags: [
                "-Wno-unused-variable",
                "-Wno-unused-parameter",
                "-Wno-missing-field-initializers",
        ],
}

genrule {
	name: "gpsd_packet_names_h",
	cmd: "rm -f $(out); sed -e '/^ *\\([A-Z][A-Z0-9_]*\\)," +
		"/s//   \"\\1\",/' < $(in) > $(out)",
	srcs: ["packet_states.h"],
	out: ["packet_names.h"]
}

genrule {
	name: "gpsd_config_h",
	cmd: "cat $(in)/android/gpsd_config.in > $(out);" +
		"grep \"^gpsd_version\" $(in)/SConstruct | " +
		"cut -d\\= -f2 | sed -e 's/^/#define VERSION/'" +
		">> $(out); " +
		"grep \"^gpsd_version\" $(in)/SConstruct | " +
		"cut -d\\= -f2 | sed -e 's/^/#define RELEASE/'" +
		">> $(out)",
	srcs: [""],
	out: ["gpsd_config.h"]
}

python_binary_host {
	name: "maskaudit",
	main: "maskaudit.py",
	srcs: ["maskaudit.py"]
}

genrule {
	name: "gps_maskdump_c",
	tools: ["maskaudit"],
	cmd: "$(location maskaudit) -c $(in) > $(out)",
	out: ["gps_maskdump.c"],
	srcs: [""]
}

cc_library_static {
        name: "libgpsd",
        vendor: true,
        export_include_dirs: ["."],
        generated_headers: [
                "gpsd_config_h",
                "gpsd_packet_names_h"
        ],
        srcs: [
               "bsd_base64.c",
               "crc24q.c",
               "driver_ais.c",
               "driver_evermore.c",
               "driver_garmin.c",
               "driver_garmin_txt.c",
               "driver_geostar.c",
               "driver_greis.c",
               "driver_greis_checksum.c",
               "driver_italk.c",
               "driver_navcom.c",
               "driver_nmea0183.c",
               "driver_nmea2000.c",
               "driver_oncore.c",
               "driver_rtcm2.c",
               "driver_rtcm3.c",
               "drivers.c",
               "driver_sirf.c",
               "driver_skytraq.c",
               "driver_superstar2.c",
               "driver_tsip.c",
               "driver_ubx.c",
               "driver_zodiac.c",
               "geoid.c",
               "gpsd_json.c",
               "isgps.c",
               "libgpsd_core.c",
               "matrix.c",
               "net_dgpsip.c",
               "net_gnss_dispatch.c",
               "net_ntrip.c",
               "ntpshmread.c",
               "ntpshmwrite.c",
               "packet.c",
               "ppsthread.c",
               "pseudoais.c",
               "pseudonmea.c",
               "serial.c",
               "subframe.c",
               "timebase.c",
               "timespec_str.c"
        ],
        cflags: [
                "-Wno-unused-variable",
                "-Wno-unused-parameter",
                "-Wno-missing-field-initializers",
                "-Wno-uninitialized"
        ],
}
