# Makefile for AHFinderDirect src/util library # $Id: Makefile,v 1.2 2001-06-17 17:23:10 jthorn Exp $ # # This Makefile can be called either as part of a Cactus build # (in which case it expects the usual Cactus Makefile variables to be # set), or directly from the command line (in which case it provides # default values for some variables). # # Arguments: # SRCDIR = Directory where the source code lives. Default is . # if variable isn't set from command line or environment. # CC, CXX = C and C++ compilers. Defaults are gcc and g++ if # variables aren't set from command line or environment. # CC_FLAGS, CXX_FLAGS = C++ compiler flags. Defaults are # -I.. $(JT_GCC_FLAGS) -g # and # -I.. $(JT_GXX_FLAGS) -g # if variables aren't set from command line or # environment. # # Targets: # lib ==> build libahfutil.a in the current directory # from all source files except test* # test ==> build test programs # clean ==> delete object files, test drivers # superclean ==> delete object files, test drivers, !library! # # Bugs: # - Dependencies on *.hh are omitted. # ############################################################################### # # defaults if we're not called as part of a Cactus build # ifndef SRCDIR SRCDIR := . endif # these variables have defaults provided by Make itself, so instead of # "isn't set from command line or environment", we really just want # "has the default definition" ifeq ($(origin CC),default) CC := gcc endif ifeq ($(origin CXX),default) CXX := g++ endif ifndef CFLAGS CFLAGS := -I.. -L../libutil $(JT_GCC_FLAGS) -g endif ifndef CXXFLAGS CXXFLAGS := -I.. -L../libutil $(JT_GXX_FLAGS) -g endif ################################################################################ # note '%' = wildcard character for $(filter-out ...) # but '*' = wildcard character for shell used by $(wildcard ...) LIB := libahfutil.a LIB_CFILES := $(filter-out $(SRCDIR)/test%, $(wildcard $(SRCDIR)/*.c)) LIB_CCFILES := $(filter-out $(SRCDIR)/test%, $(wildcard $(SRCDIR)/*.cc)) LIB_OFILES := $(LIB_CFILES:.c=.o) $(LIB_CCFILES:.cc=.o) TEST_CCFILES := $(wildcard test*.cc) TEST_BINARIES := $(TEST_CCFILES:.cc=) ############################################################################### .PHONY : lib lib : $(LIB) $(LIB) : $(LIB_OFILES) ar -rv $@ $^ ranlib $@ $(LIB_CFILES:.c=.o) : %.o : %.c $(CC) $(CFLAGS) -c -o $@ $< $(LIB_CCFILES:.cc=.o) : %.o : %.cc $(CXX) $(CXXFLAGS) -c -o $@ $< .PHONY : test test : $(TEST_BINARIES) $(TEST_BINARIES): %: %.cc libahfutil.a ../libutil/libutil.a -lm $(CXX) $(CXXFLAGS) -o $@ $^ .PHONY : clean clean : -rm -f *.o $(TEST_BINARIES) .PHONY : superclean superclean : clean -rm -f $(LIB)