# --- Compiler and Flags ---
CC       := gcc
CXX      := g++

# Optional flags — enable on the command line:
#   make PROFILING=-pg      (enable profiling)
#   make VERBOSE_INCLUDES=-H (print include hierarchy)
PROFILING         :=
VERBOSE_INCLUDES  :=

CFLAGS   := -fPIC -Wall -g $(PROFILING) $(VERBOSE_INCLUDES)
CPPFLAGS := -fPIC -Wall -g $(PROFILING) $(VERBOSE_INCLUDES)

# Include and Library paths
INCLUDES += -I.
LIBDIRS  += -L../lib
LIBS     := -lexchost2dpr -lftd2 -lftd3 -ldl -lrt -lpthread

# Source and Object files
C_SRCS += \
    deviceio.c \
    exc4000.c \
    console_utils.c

OBJS += \
    deviceio.o \
    exc4000.o \
    console_utils.o

# Final target
all: libExc4000.a

libExc4000.a: $(OBJS)
	ar -r libExc4000.a $(OBJS)

# Compile C
%.o: %.c
	$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) -c $< -o $@

# Compile C++
%.o: %.cpp
	$(CXX) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) -c $< -o $@

# Clean
clean:
	rm -f $(OBJS) libExc4000.a

clean%:
	$(MAKE) clean
