--- /dev/null
+# Copyright (c) 2008, Sandia National Laboratories
+
+#
+# The build rules are modelled on the Linux style less-verbose
+# build by default, but with full details if V=1 flag is
+# set in the environment or on the build line.
+#
+# Typical usage:
+# $(call build,FOO,$filename,\
+# foo -flags $filename \
+# )
+#
+build = \
+ @if [ "$(V)" != 1 ]; then \
+ echo ' $1'; \
+ else \
+ echo "$2"; \
+ fi; \
+ $2
+
+#
+# Generate a library .a file from a list of object files.
+# For consistency of symbol ordering, we do not use ar to do any
+# updates of the library, but instead remove the old one and
+# re-generate it from all of its input object files.
+#
+# Typical usage:
+# $(call buildlib,libfoo.a,$(FILES))
+#
+buildlib = \
+ $(call build,AR $1,\
+ $(RM) $1; \
+ $(AR) crs $1 $2; \
+ )
+
+buildprog = \
+ $(call build,LD $1,\
+ $(RM) $1; \
+ $(CC) -static -o $1 $2; \
+ )
+
+#
+# Build the .o files from the sources.
+#
+%.o: %.c
+ $(call build,CC $@,$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<)
+
+all: $(PROGS-y) $(LIBS-y)
+
+clean: FORCE
+ $(call build,CLEAN $(PROGS-y) $(LIBS-y) $(OBJS-y), \
+ $(RM) $(PROGS-y) $(LIBS-y) $(OBJS-y); \
+ )
+
+FORCE: