Skip to content

Commit

Permalink
Force recompile if datadir or compiler flags change
Browse files Browse the repository at this point in the history
  • Loading branch information
tihirvon committed Nov 5, 2010
1 parent cda3b32 commit 0c6e448
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,19 @@ ifdef WERROR
BASIC_CFLAGS += $(call cc-option,-Werror -Wno-error=shadow -Wno-error=unused-variable)
endif

BASIC_CFLAGS += -DDATADIR=\"$(datadir)\"
BASIC_CFLAGS += -DDEBUG=$(DEBUG)

$(OBJECTS): .CFLAGS

buffer.o editor.o parse-command.o: .datadir
buffer.o editor.o parse-command.o: BASIC_CFLAGS += -DDATADIR=\"$(datadir)\"

.CFLAGS: FORCE
@./update-option "$(CC) $(CFLAGS) $(BASIC_CFLAGS)" $@

.datadir: FORCE
@./update-option "$(datadir)" $@

editor: $(OBJECTS)
$(call cmd,ld,)

Expand All @@ -163,7 +173,7 @@ install: all
$(INSTALL) -m644 $(syntax) $(DESTDIR)$(datadir)/editor/syntax

clean:
rm -f *.o editor
rm -f *.o editor .CFLAGS .datadir

distclean: clean
rm -f tags
Expand All @@ -178,4 +188,4 @@ TARBALL = $(RELEASE).tar.gz
dist:
git archive --format=tar --prefix=$(RELEASE)/ $(REV) | gzip -c -9 > $(TARBALL)

.PHONY: all clean distclean install tags dist
.PHONY: all clean distclean install tags dist FORCE
11 changes: 11 additions & 0 deletions update-option
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

value="$1"
file="$2"

current=$(cat "$file" 2>/dev/null)
if test "$current" != "$value"
then
echo " UPDATE $file"
echo "$value" > "$file"
fi

0 comments on commit 0c6e448

Please sign in to comment.