# define secondary expansion to use $$@ at prerequisites
.SECONDEXPANSION:

# final target
TARGET = main_APG7400A_histogram main_APG7400A_list

WARNINGS := -Wall

# definition of command and option
CC = /usr/bin/gcc
CFLAGS += -I./ $(WARNINGS)
LIBS = -L./lib -lftd2xx -lpthread -ldl -lrt

# sub object files
SUB_OBJS := usbmca.o

# local header files
LOCAL_INCS := usbmca.h	\
			ftd2xx.h	\
			WinTypes.h	\
			sys_compatible.h

.PHONY: all
all: $(TARGET)


$(TARGET): $(SUB_OBJS) $$@.o
	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)

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


.PHONY: clean
clean:
	rm -f *.o $(TARGET)
