# Makefile for the "bagsimple" program that uses the "bag" module.
#
# CS 50, Fall 2022

CC = gcc
CFLAGS = -Wall -pedantic -std=c11 -ggdb
PROG = bagsimple
OBJS = bagsimple.o bag.o readlinep.o
LIBS =
TESTFILE = names.txt

.PHONY: clean test

# executable depends on object files
$(PROG): $(OBJS)
    $(CC) $(CFLAGS) $(OBJS) $(LIBS) -o $(PROG)

# object files dependency of header files
bagsimple.o: bag.h readlinep.h
bag.o: bag.h
readlinep.o: readlinep.h

# a test case
test: $(PROG)
    @echo “running a test with file $(TESTFILE)”
    @./$(PROG) < $(TESTFILE)

clean:
    rm -f $(PROG)
    rm -f *~* .o
    rm -rf *.dSYM