GNUmakefile.in 4.23 KB
Newer Older
1
#
2
# Copyright (c) 2000-2011 , 2012University of Utah and the Flux Group.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
22
#
23 24
SRCDIR		= @srcdir@
TESTBED_SRCDIR	= @top_srcdir@
25
EVENTSYS	= @EVENTSYS@
26 27
OBJDIR		= ..
SUBDIR		= tmcd
28
SYSTEM	       := $(shell $(TESTBED_SRCDIR)/utils/osstuff.sh -o)
29

30
include $(OBJDIR)/Makeconf
31

32
all:	server
33
server: tmcd-meta tmcd tmcd.restart
34

35
# For VPATH.
36 37
MOSTLY_SRCDIRS = ${TESTBED_LIBSRCDIR}/libtb ${TESTBED_SRCDIR}/pxe \
		 ${TESTBED_LIBSRCDIR}/tmcd
38

39
include $(TESTBED_SRCDIR)/GNUmakerules
40

41
CFLAGS	+= -O -g -Wall -DUDP \
Leigh B. Stoller's avatar
Leigh B. Stoller committed
42
		-I${OBJDIR} -I/usr/local/include \
43 44
		-I${TESTBED_LIBSRCDIR}/libtb -I${TESTBED_SRCDIR}/pxe \
		-I${TESTBED_LIBSRCDIR}/tmcd \
45
		-L/usr/local/lib
46
TMLIBS	 = ${TESTBED_LIBOBJDIR}/libtb/libtb.a
Leigh B. Stoller's avatar
Leigh B. Stoller committed
47
BOOTINFO = ${OBJDIR}/pxe/bootinfo.o ${OBJDIR}/pxe/bootinfo_mysql.o
48
LDFLAGS += $(LDSTATIC)
49 50 51 52

#
# For SSL enabled tmcd/tmcc
#
53 54
CFLAGS	+= -DETCDIR='"$(INSTALL_ETCDIR)"'
SSLFLAGS = -DWITHSSL 
55
TMLIBS	+= -lssl -lcrypto
56
NOTPMLIB = ${TESTBED_LIBOBJDIR}/tmcd/libtmcd.a
57

58
ifeq ($(SYSTEM),Linux)
59 60
ifneq ($(LDSTATIC),)
NOKERB := $(shell nm /usr/lib/libssl.a | grep -q krb; echo $$?)
61
else
62 63 64 65 66 67 68
NOKERB := 1
endif
ifeq ($(NOKERB),0)
CFLAGS   += `/usr/kerberos/bin/krb5-config --cflags`
TMLIBS   += `/usr/kerberos/bin/krb5-config --libs krb5`
ifneq ($(wildcard /usr/lib/libkrb5support.a),)
TMLIBS     += -lkrb5support
69
endif
70
endif
71
TMLIBS  += -ldl
72 73
endif

74
ifeq ($(EVENTSYS),1)
75 76
	TMCDCFLAGS  = -I$(TESTBED_LIBSRCDIR)/event -DEVENTSYS
	TMCDLIBS    = ${TESTBED_LIBOBJDIR}/event/libevent.a
77
	ELVINFLAGS  = -lm -L/usr/local/lib -lpubsub 
78
endif
79 80 81

tmcd-meta:
	easy_install mysql-connector
82

83
tmcd: tmcd.c ${TMCDLIBS} tmcd.h version.o $(BOOTINFO) $(NOTPMLIB)
84
	$(CC) $(CFLAGS) $(SSLFLAGS) $(TMCDCFLAGS) -o tmcd $< \
85
		version.o $(NOTPMLIB) $(BOOTINFO) \
86 87
		$(LFLAGS) -L/usr/local/lib/mysql -lmysqlclient \
		$(ELVINFLAGS) $(TMCDLDFLAGS) $(TMCDLIBS) $(TMLIBS) 
88

89 90
mod_tmcd.so: libtmcd.o
	apxs -c mod_tmcd.c -L/usr/local/lib/mysqlclient -lmysqlclient \
91 92
		-L /usr/local/lib -lxml2 \
		$(ELVINFLAGS) $(TMCDLDFLAGS) $(TMCDLIBS) $(NOTPMLIB) $(TMLIBS) $<
93

94 95
newtmcd: newtmcd.c libtmcd.o ${TMCDLIBS} tmcd.h version.o \
	$(NOTPMLIB) $(BOOTINFO)
96
	$(CC) $(CFLAGS) $(SSLFLAGS) $(TMCDCFLAGS) -o tmcd $< \
97
		libtmcd.o version.o $(NOTPMLIB) $(BOOTINFO) \
98 99 100
		$(LFLAGS) -L/usr/local/lib/mysql -lmysqlclient  -lxml2 \
		$(ELVINFLAGS) $(TMCDLDFLAGS) $(TMCDLIBS) $(TMLIBS) 

101
libtmcd.o: libtmcd.c ${TMCDLIBS} tmcd.h version.o $(BOOTINFO)
102
	$(CC) $(CFLAGS) -I/usr/local/include/libxml2 $(SSLFLAGS) \
103
		$(TMCDCFLAGS) -c -o libtmcd.o $< 
104

105
libtmcd.so: libtmcd.o ${TMCDLIBS} tmcd.h $(BOOTINFO)
106
	$(LD) -shared $^ -L/usr/local/lib/mysql -lxml2 -lmysqlclient \
107
		$(TMCDLIBS) $(ELVINFLAGS) $(TESTBED_LIBOBJDIR)/libtb/libtb.a \
108 109
		-o $@

110 111 112
version.c: tmcd.c
	echo >$@ "char build_info[] = \"Built `date +%d-%b-%Y` by `id -nu`@`hostname | sed 's/\..*//'`:`pwd`\";"

113 114
install:	all

115
install:	$(INSTALL_SBINDIR)/tmcd \
116
		$(INSTALL_SBINDIR)/tmcd.restart
117

118 119 120 121
control-install:
boss-install: install
subboss-install:
client-install:
122

123 124 125 126 127
$(INSTALL_BINDIR)/tmcd/%: %
	@echo "Installing $<"
	-mkdir -p $(INSTALL_BINDIR)/tmcd
	$(INSTALL_PROGRAM) $< $@

128 129 130 131 132 133
# XXX using ${OBJDIR}/pxe/% didn't seem to work
${OBJDIR}/pxe/bootinfo.o:
	cd ${OBJDIR}/pxe && gmake bootinfo.o
${OBJDIR}/pxe/bootinfo_mysql.o:
	cd ${OBJDIR}/pxe && gmake bootinfo_mysql.o

134 135 136 137
#
# Here so that the event system libraries, and libraries they depend upon,
# can get made.
#
138 139 140 141 142 143
${TESTBED_LIBOBJDIR}/event/%:
	cd ${TESTBED_LIBOBJDIR}/event && gmake $<
${TESTBED_LIBOBJDIR}/libtb/%:
	cd ${TESTBED_LIBOBJDIR}/tbdb && gmake $<
${TESTBED_LIBOBJDIR}/tmcd/%:
	cd ${TESTBED_LIBOBJDIR}/tmcd && gmake $<
144

Leigh B Stoller's avatar
Leigh B Stoller committed
145
clean:
146
	rm -f *.o core tmcd *-debug version.c