* as/z80/Makefile: fix permanent rebuild of z80
[fw/sdcc] / as / z80 / Makefile
index 9ea2069dd37dc09aeee5d8908d502cb311ae271f..9a914813ac4dfd35b4933c00700fde834cb0bedd 100644 (file)
@@ -22,7 +22,7 @@ CFLAGS        += -I$(SLIB)
 
 LDFLAGS += -lm $(EXTRALIBS)
 
-all:   $(OBJDIR) dep $(BINS)
+all:   dep $(BINS)
 
 dep: Makefile.dep
 
@@ -31,17 +31,24 @@ Makefile.dep: $(SRC) *.h
 
 include Makefile.dep
 
-$(OBJDIR):
+# We need a '.stamp'-file in $(OBJDIR), because the time stamp
+# of $(OBJDIR) itself is always updated, when a file in $(OBJDIR)
+# is updated. A rule like
+#      $(OBJDIR)/anyfile: $(OBJDIR)
+# will always force a remake (at least on Linux ext2).
+
+$(OBJDIR)/.stamp:
        mkdir -p $(OBJDIR)
+       touch $(OBJDIR)/.stamp
 
 $(BINS): $(OBJS) $(SLIBOBJS)
        $(CC) -o $(BINS) $(OBJS) $(SLIBOBJS) $(LDFLAGS)
 
 
-$(OBJDIR)/%.o: %.c
+$(OBJDIR)/%.o: %.c $(OBJDIR)/.stamp
        $(CC) -c $(CFLAGS) -o $@ $<
 
-$(OBJDIR)/%.o: $(SLIB)/%.c
+$(OBJDIR)/%.o: $(SLIB)/%.c $(OBJDIR)/.stamp
        $(CC) -c $(CFLAGS) -o $@ $<
 
 _as-z80: