aboutsummaryrefslogtreecommitdiff
path: root/src/jtutil/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'src/jtutil/Makefile')
-rw-r--r--src/jtutil/Makefile95
1 files changed, 95 insertions, 0 deletions
diff --git a/src/jtutil/Makefile b/src/jtutil/Makefile
new file mode 100644
index 0000000..32f2384
--- /dev/null
+++ b/src/jtutil/Makefile
@@ -0,0 +1,95 @@
+# Makefile for my utility library (g++ + GNU make version)
+# $Id: Makefile,v 1.1 2001-06-15 11:21:34 jthorn Exp $
+#
+# Arguments:
+# JT_GXX_FLAGS = (env in) My standard flags for g++(1).
+# JT_LINTXX_FLAGS = (env in) My standard flags for lint++(1).
+# LIB = (env in) My personal library directory.
+# LIMBO = (env in) My personal "limbo" directory (for saving
+# old copies of libraries in).
+#
+# Targets:
+# lib ==> lib-g lib-O
+# lib-g ==> (re)build the library compiled with -g
+# and symlink the "public" library to the -g one
+# lib-O ==> (re)build the library compiled with -O9
+# and symlink the "public" library to the -O one
+# test ==> build test programs with -g
+# lint ==> lint++ all the C files
+# clean ==> delete object files, test drivers
+# superclean ==> delete object files, test drivers, !library!
+#
+# Bugs:
+# - Dependencies on *.hh are omitted.
+# - All *.cc files (except test*) are assumed to go into the library.
+#
+
+###############################################################################
+
+CXX := g++
+LINTXX := lint++
+
+# default -- often overridden from command-line args
+CXXFLAGS :=
+
+CXXFLAGS-g := $(JT_GXX_FLAGS) $(CXXFLAGS) -g
+CXXFLAGS-O := $(JT_GXX_FLAGS) $(CXXFLAGS) -g -O9 -DNDEBUG
+LINTXXFLAGS := $(JT_LINTXX_FLAGS)
+
+LIBDIR := $(LIB)
+LIBUTILXX := libutil++.a
+LIBUTILXX-g := libutil++-g.a
+LIBUTILXX-O := libutil++-O.a
+
+# ... note '%' = wildcard character for filter() and filter-out()
+LIB_CCFILES := $(filter-out test%, $(wildcard *.cc))
+TEST_CCFILES := $(wildcard test*.cc)
+TEST_BINARIES := $(TEST_CCFILES:.cc=)
+
+###############################################################################
+
+.PHONY : lib
+lib : lib-g lib-O
+
+.PHONY : lib-g
+lib-g : $(LIBDIR)/$(LIBUTILXX-g)
+$(LIBDIR)/$(LIBUTILXX-g) :: $(LIB_CCFILES)
+ $(CXX) -c $(CXXFLAGS-g) $?
+ ar rv $@ $(?:.cc=.o)
+ ranlib $@
+ rm $(?:.cc=.o)
+$(LIBDIR)/$(LIBUTILXX-g) ::
+ cd $(LIBDIR) && rm -f $(LIBUTILXX) && ln -s $(LIBUTILXX-g) $(LIBUTILXX)
+
+.PHONY : lib-O
+lib-O : $(LIBDIR)/$(LIBUTILXX-O)
+$(LIBDIR)/$(LIBUTILXX-O) :: $(LIB_CCFILES)
+ $(CXX) -c $(CXXFLAGS-O) $?
+ ar rv $@ $(?:.cc=.o)
+ ranlib $@
+ rm $(?:.cc=.o)
+$(LIBDIR)/$(LIBUTILXX-O) ::
+ cd $(LIBDIR) && rm -f $(LIBUTILXX) && ln -s $(LIBUTILXX-O) $(LIBUTILXX)
+
+###############################################################################
+
+.PHONY : test
+test : $(TEST_BINARIES)
+$(TEST_BINARIES): %: %.cc
+ $(CXX) $(CXXFLAGS-g) -o $@ $? -lutil++-g -lutil-g -lm
+
+.PHONY : lint
+lint :
+ $(LINTXX) $(LINTXXFLAGS) $(LIB_CCFILES) $(TEST_CCFILES)
+
+.PHONY : clean
+clean :
+ -rm -f *.o $(TEST_BINARIES)
+
+.PHONY : superclean
+superclean : clean
+ -rm -f $(LIBDIR)/$(LIBUTILXX)
+ -test -f $(LIBDIR)/$(LIBUTILXX-g) \
+ && mv $(LIBDIR)/$(LIBUTILXX-g) $(LIMBO)
+ -test -f $(LIBDIR)/$(LIBUTILXX-O) \
+ && mv $(LIBDIR)/$(LIBUTILXX-O) $(LIMBO)