From: Brian Norris <banorris@uci.edu>
Date: Thu, 2 Aug 2012 23:36:29 +0000 (-0700)
Subject: Makefile: wire up test/ directory for compilation
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3e29290164634f0c3dad7599df512e3890c67f2d;p=cdsspec-compiler.git

Makefile: wire up test/ directory for compilation
---

diff --git a/Makefile b/Makefile
index 6a85ee8..c2d7072 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,9 @@ CPPFLAGS += -Iinclude -I.
 LDFLAGS=-ldl -lrt
 SHARED=-shared
 
-all: $(LIB_SO)
+TESTS=test
+
+all: $(LIB_SO) tests
 
 debug: CPPFLAGS += -DCONFIG_DEBUG
 debug: all
@@ -42,9 +44,13 @@ snapshot.o: mymemory.h snapshot.h snapshotimp.h snapshot.cc
 
 clean:
 	rm -f *.o *.so
+	$(MAKE) -C $(TESTS) clean
 
 mrclean: clean
 	rm -rf docs
 
 tags::
 	ctags -R
+
+tests:: $(LIB_SO)
+	$(MAKE) -C $(TESTS)
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 0000000..f7a01be
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,15 @@
+include ../common.mk
+
+CPPFLAGS += -I.. -I../include
+TESTS=userprog
+
+SRCS = $(wildcard *.c)
+OBJS = $(patsubst %.c,%.o,$(SRCS))
+
+all: $(OBJS)
+
+%.o: %.c
+	$(CC) -o $@ $< $(CPPFLAGS) -L.. -l$(LIB_NAME)
+
+clean::
+	rm -f *.o $(TESTS)