diff --git a/makefile b/makefile index 0b27b12..cb9b6fb 100644 --- a/makefile +++ b/makefile @@ -3,22 +3,21 @@ CC=gcc CFLAGS=-Wall -g OBJS=text.o page.o line.o prompt.o +HEADERS=$(subst .o,.h,$(OBJS)) # text.h page.h ... LIBS=-lncurses text: $(OBJS) $(CC) $(CFLAGS) -o text $(OBJS) $(LIBS) -text.o: text.c text.h page.h line.h prompt.h +text.o: text.c $(HEADERS) $(CC) $(CFLAGS) -c text.c page.o: page.c page.h line.h $(CC) $(CFLAGS) -c page.c - -line.o: line.c line.h - $(CC) $(CFLAGS) -c line.c -prompt.o: prompt.c prompt.h - $(CC) $(CFLAGS) -c prompt.c +# '$<' expands to first prerequisite file +%.o: %.c %.h + $(CC) $(CFLAGS) -c $< -o $@ clean: rm -f $(OBJS) text