# Here we demonstrate variable substitution

OBJS = main.o blah.o \
	 bar.o
CC = gcc
AR = ar
RANLIB = ranlib # we might want to make this ar -s on some systems
RM = rm

.PHONY: all clean
all: main libblah.a

main: $(OBJS)
	$(CC) -o main $(OBJS)

$(OBJS): blah.h
#all the objects are dependent on blah.h.  No action is specified.

# Make knows how to do this, but we'll write a static pattern rule anyway.
$(OBJS): %.o: %.c
	$(CC) -c $< -o $@

libblah.a: $(OBJS)
	$(AR) -r libblah.a $(OBJS)
	$(RANLIB) libblah.a

clean:
	-$(RM) -f $(OBJS) main libblah.a core *~
