include ../../config.mk

INCLUDE+=-I.. -I.

PROGS=test test_pci

TEST_NGMP=-qngmp
ifeq ($(strip $(CPU)),ngmp)
	TEST_NGMP+=-DTEST_NGMP
	PROGS+=test_pci_rtr
endif

override CONFIG_DEPS=config*.c

all: $(PROGS)

clean:
	rm -f *.o core test test_pci test_pci_rtr > /dev/null

mmu_setup.o: mmu_setup.c
	$(CC) $(CFLAGS) -c $< -o $@

grspw_router_lib.o: ../grspw_router_lib.c ../grspw_router_lib.h
	$(CC) $(CFLAGS) -c $< -o $@

spwrouter_custom_config.o: spwrouter_custom_config.c
	$(CC) $(CFLAGS) -c $< -o $@

grspw_pkt_lib.o: ../grspw_pkt_lib.c ../grspw_pkt_lib.h
	$(CC) $(CFLAGS) -c $< -o $@

spwlib.o: spwlib.c spwlib.h
	$(CC) $(CFLAGS) -c $< -o $@

test: test.c spwlib.o spwrouter_custom_config.o grspw_router_lib.o $(if $(TEST_NGMP),mmu_setup.o) grspw_pkt_lib.o $(CONFIG_DEPS)
	$(CC) $(CFLAGS) $(TEST_NGMP) $< -o $@ spwlib.o spwrouter_custom_config.o grspw_router_lib.o $(if $(TEST_NGMP),mmu_setup.o) grspw_pkt_lib.o

test_pci: test_pci.c spwlib.o spwrouter_custom_config.o grspw_router_lib.o $(if $(TEST_NGMP),mmu_setup.o) grspw_pkt_lib.o $(CONFIG_DEPS)
	$(CC) $(CFLAGS) $(TEST_NGMP) $< -o $@ spwlib.o spwrouter_custom_config.o grspw_router_lib.o $(if $(TEST_NGMP),mmu_setup.o) grspw_pkt_lib.o

test_pci_rtr: test_pci_rtr.c spwlib.o spwrouter_custom_config.o grspw_router_lib.o $(if $(TEST_NGMP),mmu_setup.o) grspw_pkt_lib.o $(CONFIG_DEPS)
	$(CC) $(CFLAGS) $(TEST_NGMP) $< -o $@ spwlib.o spwrouter_custom_config.o grspw_router_lib.o $(if $(TEST_NGMP),mmu_setup.o) grspw_pkt_lib.o

