#=========================================================
# Generic Makefile
#
# Produces an executable with the same name as the
# current directory.
#=========================================================

CC := gcc

TARGET := $(notdir $(CURDIR))

CPPFLAGS := -I. -I../include
CFLAGS   := -Wall -Wextra -std=c11 -MMD -MP
LDFLAGS  := -L../lib

LDLIBS   := -lviebcopy -lvtape -laws_tape -lebcdic_utils -lvdasd -lvpds -lmvs_datetime -lmvs_utils -lmvs_types
#LDLIBS   :=-laws_tape
#LDLIBS   :=-laws_tape -lm -lpthread

LDLIBS  ?=

# Uncomment if needed
# LDLIBS += -laws_tape

SRCS := $(wildcard *.c)
OBJS := $(SRCS:.c=.o)
DEPS := $(SRCS:.c=.d)

all: $(TARGET)

$(TARGET): $(OBJS)
	$(CC) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $@

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

clean:
	rm -f $(OBJS) $(DEPS) $(TARGET)

# Applications have no installed build artifacts inside the source tree beyond
# the files removed by clean; keep a uniform top-level distclean contract.
distclean: clean

-include $(DEPS)

.PHONY: all clean distclean
