
#########################################################################
#
#  $Id: Makefile 1.3 2025/11/18 15:45:42Z martin.burnicki REL_M $
#
#  Description:
#    Makefile for mbgclock driver to support Meinberg bus level
#    devices under FreeBSD.
#
# -----------------------------------------------------------------------
#  $Log: Makefile $
#  Revision 1.3  2025/11/18 15:45:42Z  martin.burnicki
#  Improved conditional debug builds.
#  Revision 1.2.1.5  2020/10/15 14:27:26Z  martin
#  Also remove dependency files on clean.
#  Revision 1.2.1.4  2018/06/13 16:02:33  martin
#  Support different conditional debug builds.
#  Revision 1.2.1.3  2018/04/12 15:35:56  martin
#  Use BSD kernel build system, support debug build.
#  Revision 1.2.1.2  2018/01/25 15:43:14  martin
#  Control several debug and build options from the make command line.
#  Revision 1.2.1.1  2018/01/24 16:53:18  martin
#  Added missing source files.
#  Revision 1.2  2017/07/06 09:13:50  martin
#  Updated paths, module list, and compiler flags.
#  Revision 1.1  2011/01/26 13:56:32  martin
#  Initial skeleton based on FreeBSD's mypci.c sample program by Murray Stokely.
#
#########################################################################

KMOD = mbgclock

MBGLIB = ../mbglib
MBGLIB_COMMON = $(MBGLIB)/common
MBGLIB_BSD = $(MBGLIB)/bsd

.PATH: $(MBGLIB_COMMON) $(MBGLIB_BSD)

CFLAGS += -I..
CFLAGS += -I$(MBGLIB_COMMON)
CFLAGS += -I$(MBGLIB_BSD)

SRCS =  mbgclock_main.c
SRCS += pcpsdrvr.c
SRCS += mbgioctl.c
SRCS += mbgerror.c
SRCS += mbgddmsg.c
SRCS += identdec.c
SRCS += rsrc_bsd.c


# Handle driver-specific debug options.
# Global debug options are handled in the
# top-level makefile.

.ifdef DEBUG_FULL
  REPORT_IO_ERRORS ?= $(DEBUG_FULL)
  REPORT_CFG ?= $(DEBUG_FULL)
  REPORT_CFG_DETAILS ?= $(DEBUG_FULL)
  DEBUG_RSRC ?= $(DEBUG_FULL)
  DEBUG_SERNUM ?= $(DEBUG_FULL)
  DEBUG_ACCESS_TIMING ?= $(DEBUG_FULL)
  DEBUG_IO_TIMING ?= $(DEBUG_FULL)
  DEBUG_IO ?= $(DEBUG_FULL)
  DEBUG_USB_IO ?= $(DEBUG_FULL)
  DEBUG_DRVR ?= $(DEBUG_FULL)
  DEBUG_DEV_INIT ?= $(DEBUG_FULL)
  DEBUG_IOCTL ?= $(DEBUG_FULL)
.endif

.ifdef FORCE_IO_ACCESS
  CFLAGS += -DFORCE_IO_ACCESS=$(FORCE_IO_ACCESS)
.endif

.ifdef FORCE_MM16_ACCESS
  CFLAGS += -DFORCE_MM16_ACCESS=$(FORCE_MM16_ACCESS)
.endif

.ifdef REPORT_IO_ERRORS
  CFLAGS += -DREPORT_IO_ERRORS=$(REPORT_IO_ERRORS)
.endif

.ifdef REPORT_CFG
  CFLAGS += -DREPORT_CFG=$(REPORT_CFG)
.endif

.ifdef REPORT_CFG_DETAILS
  CFLAGS += -DREPORT_CFG_DETAILS=$(REPORT_CFG_DETAILS)
  SRCS += str_ext_sys_info.c
.endif

.ifdef DEBUG_RSRC
  CFLAGS += -DDEBUG_RSRC=$(DEBUG_RSRC)
.endif

.ifdef DEBUG_SERNUM
  CFLAGS += -DDEBUG_SERNUM=$(DEBUG_SERNUM)
.endif

.ifdef DEBUG_ACCESS_TIMING
  CFLAGS += -DDEBUG_ACCESS_TIMING=$(DEBUG_ACCESS_TIMING)
  MUST_DEBUG_DRVR = 1
.endif

.ifdef DEBUG_IO_TIMING
  CFLAGS += -DDEBUG_IO_TIMING=$(DEBUG_IO_TIMING)
  MUST_DEBUG_DRVR = 1
.endif

.ifdef DEBUG_IO
  CFLAGS += -DDEBUG_IO=$(DEBUG_IO)
  MUST_DEBUG_DRVR = 1
.endif

.ifdef DEBUG_USB_IO
  CFLAGS += -DDEBUG_USB_IO=$(DEBUG_USB_IO)
  MUST_DEBUG_DRVR = 1
.endif

.ifdef DEBUG_DRVR
  CFLAGS += -DDEBUG_DRVR=$(DEBUG_IO)
  MUST_DEBUG_DRVR = 1
.endif

.ifdef DEBUG_DEV_INIT
  CFLAGS += -DDEBUG_DEV_INIT=$(DEBUG_DEV_INIT)
  MUST_DEBUG_DRVR = 1
.endif

.ifdef DEBUG_IOCTL
  CFLAGS += -DDEBUG_IOCTL=$(DEBUG_IOCTL)
  MUST_DEBUG_DRVR = 1
.endif

.ifdef USE_MM_IO
  CFLAGS += -D_PCPS_USE_MM_IO=$(USE_MM_IO)
.endif

.ifdef TEST_MM_ACCESS_TIME
  CFLAGS += -DTEST_MM_ACCESS_TIME=$(TEST_MM_ACCESS_TIME)
.endif

.ifdef PNP
  CFLAGS += -D_PCPS_USE_PCI_PNP=$(PNP)
.endif

# System source files.
SRCS += device_if.h bus_if.h pci_if.h

BASEDIR := ..
include $(BASEDIR)/Makefile
