#$FreeBSD$

# Automatically enable multi-job make if it wasn't specified. To disable
# running in parallel, the caller may pass -j1.
.if !defined(.MAKE.JOBS)
.MAKE.JOBS != sysctl -n hw.ncpu
.endif

#Ensure that pass the maximum number of jobs to all recursive Make processes
MAKE += -j $(.MAKE.JOBS)

KMODDIR ?= /boot/kernel

THIS_FILE := $(.PARSEDIR)/$(.PARSEFILE)

.include <bsd.own.mk>
.include <bsd.compiler.mk>

.PATH: ${.CURDIR}

KMOD = if_iavf
SRCS != ls *.[ch]
SRCS += device_if.h bus_if.h pci_if.h

# kernel option files
SRCS += opt_inet.h opt_inet6.h opt_rss.h

LEGACY_ENABLE ?= 0

KERNVER != uname -K
NO_IFLIB != test $(KERNVER) -ge 1100110; echo $$?

.if $(NO_IFLIB)
  LEGACY_ENABLE = 1
.endif

.if $(LEGACY_ENABLE)
  CFLAGS += -DIAVF_NO_IFLIB
  SRCS := ${SRCS:N*iflib*}
.else
  CFLAGS += -DIFLIB
  SRCS += ifdi_if.h
  SRCS := ${SRCS:N*legacy*}
.endif

CFLAGS += -Wformat=2

DEBUG_FLAGS = -g3 -gdwarf-4

.if ${COMPILER_TYPE} == "clang"
.if ${COMPILER_VERSION} >= 60000
DEBUG_FLAGS += -fdebug-macro
.endif
.endif

clean:
	rm -f opt_*.h *_if.h setdef* *_StripErr
	rm -f *.o *.kld *.ko *.ko.* .depend.* *.profraw
	rm -f @ export_syms machine x86

.include <bsd.kmod.mk>

legacy:
	$(MAKE) -f $(THIS_FILE) LEGACY_ENABLE=1
