# VTI Instruments, Inc. (Ametek Instruments)
# Copyright 2014
#
# Makefile to build the EX1629 example

# general compilation and linker variables
EX1629_EXAMPLE_DIR = $(strip $(shell pwd) )
EX1629_EXAMPLE = ex1629example

CFLAGS  += -I../driver/shared -I../driver/scpilib -I../driver/libex1629 -I../driver/pnpclient
LDLIBS  += -lm
LIBPATH  = ../driver/pnpclient
LIBNAME  = ex1629client

EXAMPLE_CSRC = \
	example.c \

EXAMPLE_OBJS = $(patsubst %.c,%.o, $(EXAMPLE_CSRC))
EXAMPLE_HDRS = 

all: $(EX1629_EXAMPLE)

$(EXAMPLE_OBJS): %.o: %.c  $(EXAMPLE_HDRS) Makefile
	@test -s $(LIBPATH)/lib$(LIBNAME).so || { echo "Shared library (lib$(LIBNAME).so) required to build the example doesn't exist! Exiting..."; exit 1; }
	$(CC) $(CFLAGS) -c $< -o $*.o

$(EX1629_EXAMPLE): $(EXAMPLE_OBJS)
	$(CC) $(CFLAGS) $(LDFLAGS) $(EXAMPLE_OBJS) -o $@  $(LDLIBS) -L$(LIBPATH) -l$(LIBNAME) -lpthread

clean:
	rm -f *.o *.gdb
	rm -f $(EX1629_EXAMPLE)
