SRCDIR ?= $(dir $(lastword $(MAKEFILE_LIST)))

LOCAL_PATH = $(shell pwd)
SRCDIR += -I$(LOCAL_PATH)/../sprd_fts_inc

CFLAGS ?= -O2 -g
CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common \
	  -Werror-implicit-function-declaration -Wsign-compare

OBJS = cmd2355.o wlnpi.o test.o

ALL = iwnpi

CFLAGS += -DCONFIG_LIBNL30
NLLIBNAME = libnl-3.0

LIBS += $(shell pkg-config --libs $(NLLIBNAME)) -lnl-genl-3
CFLAGS += $(shell pkg-config --cflags $(NLLIBNAME))

ifeq ($(V),1)
Q=
NQ=true
else
Q=@
NQ=echo
endif

all: $(ALL)

%.o: %.c
	@$(NQ) ' CC  ' $@
	$(CC) -I$(SRCDIR) $(CFLAGS) -c -o $@ $<

ifeq ($(IW_ANDROID_BUILD),)
iwnpi:	$(OBJS)
	@$(NQ) ' CC  ' iwnpi
	$(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o iwnpi
endif

clean:
	rm -f *.o
	rm -f iwnpi