CC      ?= gcc
CFLAGS  := -Wall -Wextra -I../include

# tools/ is not part of the customer release; skip it when absent.
TOOLS   := $(wildcard tools/Makefile)

all: fw_update list_cards guide can_utility
	$(if $(TOOLS),$(MAKE) -C tools)

fw_update: fw_update.c ../include/ixcm_api_cm100.h ../lib/libixcm.so
	$(CC) $(CFLAGS) -o $@ $< -L../lib -lixcm -Wl,-rpath,'$$ORIGIN/../lib'

list_cards: list_cards.c ../include/ixcm_driver.h
	$(CC) $(CFLAGS) -o $@ $<

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

can_utility: can_utility.c can_utility_shared.h ../include/ixcm_api_cm100.h ../lib/libixcm.so
	$(CC) $(CFLAGS) -o $@ $< -L../lib -lixcm -Wl,-rpath,'$$ORIGIN/../lib'

clean:
	rm -f fw_update list_cards guide can_utility
	$(if $(TOOLS),$(MAKE) -C tools clean)
