-include ../../common.mk

# Makefile - pwrfip test (2 stations)
COMMON_INC_DIR ?= ../../include

ifeq ($(SYS_NAME), windows)
	MACHINE = $(SYS_ARCH)
	CC = $(MACHINE)-w64-mingw32-gcc
else
	MACHINE = $(SYS_ARCH)
	ifeq ($(MACHINE), aarch64)
		CC = aarch64-linux-gnu-gcc
	else ifeq ($(MACHINE), arm)
		CC = arm-linux-gnueabi-gcc
	else ifeq ($(MACHINE), i386)
		CC = i686-linux-gnu-gcc
	else
		CC = x86_64-linux-gnu-gcc
	endif
	XTRA_LDLIBS = -Wl,-Bdynamic -lpthread -lm
endif

PWRFIP_INC_DIR = ../../lib/$(MACHINE)/static

CFLAGS = -g -Wall -I. -I$(PWRFIP_INC_DIR) -I$(COMMON_INC_DIR)
CFLAGS += -DPWRFIP_API_STATIC

LDLIBS += -Wl,-Bstatic -L$(PWRFIP_INC_DIR)
LDLIBS += -lpowerfip
LDLIBS += $(XTRA_LDLIBS)

EXEC := pwrfip_2sta
LOBJS := common.o
LOBJS += dev.o
LOBJS += sta.o
LOBJS += main.o

all: $(EXEC)

$(EXEC): $(LOBJS)
	$(CC) $(CFLAGS) $(LOBJS) $(LDLIBS) -o $@

clean:
	rm -f *.[o,so,a] $(EXEC)
