objects := osl.o util.o rbtree.o sha1.o
fsck_objects := fsck.o osl.o util.o rbtree.o sha1.o oslfsck.lsg.o
+deps := $(sort $(objects:.o=.d) $(fsck_objects:.o=.d))
headers := osl.h
executables := oslfsck
man_pages := oslfsck.1
all: $(realname) $(executables) $(man_pages)
shared: $(realname)
-Makefile.deps: $(wildcard *.c *.h)
- $(CC) -MM -MG *.c > $@
-osl.c fsck.c:
-
--include Makefile.deps
-
+ifeq ($(findstring clean, $(MAKECMDGOALS)),)
+-include $(deps)
+endif
%.o: %.c Makefile errtab.h
- $(CC) -c $(CPPFLAGS) $(CFLAGS) $(LIBCFLAGS) $<
+ $(CC) $(CPPFLAGS) -c -MMD -MF $(*F).d -MT $@ $(CFLAGS) $(LIBCFLAGS) $<
+fsck.o: oslfsck.lsg.h
oslfsck: $(fsck_objects)
$(CC) -o $@ $(fsck_objects) -llopsub
echo '#endif /* _OSL_H */' >> $@
clean:
rm -f *.o $(realname) osl.h osl_errors.h errtab.h \
- oslfsck *.a *.ga *.sym *.lsg.*
+ oslfsck *.a *.ga *.sym *.lsg.* *.d
distclean: clean
rm -f web/index.html web/oslfsck.1.html web/osl.png