]> git.tuebingen.mpg.de Git - osl.git/blobdiff - Makefile
build: Don't insist on gcc.
[osl.git] / Makefile
index a4f5fadb1631f47c0b8a131e28553ed476186aa0..a9fad773a3e03669deedfe7749f4cdc99f503f93 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,14 +6,15 @@ bindir := $(PREFIX)/bin
 mandir := $(PREFIX)/man/man1
 
 objects := osl.o util.o rbtree.o sha1.o
-fsck_objects := fsck.fsck.o osl.fsck.o util.fsck.o rbtree.fsck.o sha1.fsck.o oslfsck.lsg.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
 
 INSTALL := install
 ifeq "$(origin CC)" "default"
-        CC := gcc
+        CC := cc
 endif
 MKDIR := mkdir -p
 RM := rm -f
@@ -29,6 +30,8 @@ z := 3
 VERSION := $(x).$(y).$(z)
 
 # common flags
+CPPFLAGS += -DOSL_VERSION='"$(VERSION)"'
+
 CFLAGS += -Wno-sign-compare -g -Wunused -Wundef -W
 CFLAGS += -Wredundant-decls
 CFLAGS += -Os
@@ -113,18 +116,13 @@ endif
 all: $(realname) $(executables) $(man_pages)
 shared: $(realname)
 
-Makefile.deps: $(wildcard *.c *.h)
-       $(CC) -MM -MG *.c > $@
-osl.c fsck.c:
-
--include Makefile.deps
-
-%.fsck.o: %.c Makefile osl.h errtab.h oslfsck.lsg.h
-       $(CC) -c -DOSL_VERSION='"$(VERSION)"' $(CPPFLAGS) $(CFLAGS) $< -o $@
-
+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
 
@@ -165,7 +163,7 @@ osl.h: osl.h.in osl_errors.h Makefile
        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