aboutsummaryrefslogtreecommitdiff
path: root/src/patch/Makefile
blob: 544e979f36a05938c6d1f9a3859ef4f80482c7ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# 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)