<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>.gitignore</filename>
    </added>
    <added>
      <filename>gen-deps.sh</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,27 +1,38 @@
 
+# Function to expand a wildcard pattern recursively.
+rwildcard=$(strip $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2)$(filter $(subst *,%,$2),$d)))
+
 .PHONY: all clean
 CC=gcc
 CXX=g++
 CFLAGS=-std=c99
 INCLUDE=-Idescriptor -Isrc -Itests -I.
 CPPFLAGS=-O3 -fomit-frame-pointer -Wall -Wextra -g -DNDEBUG $(INCLUDE)
-OBJ=src/upb_parse.o src/upb_table.o src/upb_msg.o src/upb_enum.o src/upb_context.o \
-    src/upb_string.o src/upb_text.o src/upb_serialize.o descriptor/descriptor.o
-SRC=src/*.c src/*.h descriptor/*.c descriptor/*.h tests/*.c tests/*.h tools/*.c
-ALL=$(OBJ) src/libupb.a tests/test_table tests/tests tools/upbc benchmark/benchmark
+
+ALL=deps $(OBJ) src/libupb.a tests/test_table tests/tests tools/upbc
 all: $(ALL)
 clean:
-	rm -f $(ALL) benchmark/google_messages.proto.pb benchmark/google_messages.pb.*
-
-test: tests/tests
-	./tests/tests
+	rm -f $(call rwildcard,,*.o) $(ALL) benchmark/google_messages.proto.pb benchmark/google_messages.pb.* benchmark/b_*
 
+# The core library (src/libupb.a)
+OBJ=src/upb_parse.o src/upb_table.o src/upb_msg.o src/upb_enum.o src/upb_context.o \
+    src/upb_string.o src/upb_text.o src/upb_serialize.o descriptor/descriptor.o
+SRC=$(call rwildcard,,*.c)
+HEADERS=$(call rwildcard,,*.h)
 src/libupb.a: $(OBJ)
 	ar rcs src/libupb.a $(OBJ)
+
+# Tests
+test: tests/tests
+	./tests/tests
 tests/test_table: src/libupb.a
 tests/tests: src/libupb.a
+
+# Tools
 tools/upbc: src/libupb.a
-benchmark/benchmark: src/libupb.a benchmark/google_messages.pb.h benchmark/google_messages.pb.o benchmark/benchmark.o
-	$(CXX) $(CPPFLAGS) -o benchmark/benchmark benchmark/google_messages.pb.o benchmark/benchmark.cc src/libupb.a -lm -lprotobuf -lpthread
-benchmark/google_messages.pb.cc benchmark/google_messages.pb.h benchmark/google_messages.pb: benchmark/google_messages.proto
-	protoc benchmark/google_messages.proto --cpp_out=. -obenchmark/google_messages.proto.pb
+
+# Benchmarks
+
+-include deps
+deps: $(SRC) $(HEADERS) gen-deps.sh Makefile
+	./gen-deps.sh $(SRC)</diff>
      <filename>Makefile</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>f03c8bd7dddb17f51e6baeacd68e4c0172411e82</id>
    </parent>
  </parents>
  <author>
    <name>Joshua Haberman</name>
    <email>joshua@reverberate.org</email>
  </author>
  <url>http://github.com/haberman/upb/commit/2aaea5390a841e2682a318746e90aebbe8a955b9</url>
  <id>2aaea5390a841e2682a318746e90aebbe8a955b9</id>
  <committed-date>2009-08-04T17:51:17-07:00</committed-date>
  <authored-date>2009-08-04T17:51:17-07:00</authored-date>
  <message>Makefile is much improved (&quot;make deps&quot; works again, etc).</message>
  <tree>7fb416aafcf8d84d2d3b73344b4b68f21f3d01f5</tree>
  <committer>
    <name>Joshua Haberman</name>
    <email>joshua@reverberate.org</email>
  </committer>
</commit>
