GNUmakefile.in 6.66 KB
Newer Older
Leigh Stoller's avatar
Leigh Stoller committed
1
#
2
# Copyright (c) 2000-2016, 2018 University 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/>.
# 
# }}}
Leigh Stoller's avatar
Leigh Stoller committed
22
#
23 24
SRCDIR		= @srcdir@
TESTBED_SRCDIR	= @top_srcdir@
25 26
OBJDIR		= @top_builddir@
SUBDIR		= $(subst $(TESTBED_SRCDIR)/,,$(SRCDIR))
27 28 29

include $(OBJDIR)/Makeconf

30 31
PUBSUBFLAGS     = -I/usr/local/include
PUBSUBMTFLAGS   = -I/usr/local/include
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
PUBSUBLIB       = /usr/local/lib/libpubsub.a
#PUBSUBLIB       = /home/stoller/pubsub/libpubsub.a
SSLTEST        := $(shell nm $(PUBSUBLIB) | grep -q ps_client_sslinit; echo $$?)
ifeq ($(SSLTEST),0)
PUBSUBLIBS      = -L/usr/local/lib -lpubsub
PUBSUBLIBS_R    = -L/usr/local/lib -lpubsub_r
#PUBSUBLIBS      = -rpath /home/stoller/pubsub/.libs/ \
#			/home/stoller/pubsub/.libs/libpubsub.so
#PUBSUBLIBS_R    = -rpath /home/stoller/pubsub/.libs/ \
#			/home/stoller/pubsub/.libs/libpubsub_r.so
PUBSUBLIBS     += -lssl -lcrypto -lcrypt
PUBSUBLIBS_R   += -lssl -lcrypto -lcrypt
CFLAGS         += -DWITHSSL
else
PUBSUBLIBS     += -L/usr/local/lib -lpubsub -lcrypt
PUBSUBLIBS_R   += -L/usr/local/lib -lpubsub_r -lcrypt
endif
49 50 51 52 53 54

ifeq ($(ELVIN_COMPAT),1)
PUBSUBFLAGS    += -DELVIN_COMPAT
PUBSUBMTFLAGS  += -DELVIN_COMPAT
endif

55
SYSTEM	       := $(shell uname -s)
56 57
ARCH	       := $(shell uname -m)

58 59 60
# For the swig-*wrappers targets
SWIG		= swig2.0

61 62 63 64 65 66
# We should be able to use va_copy everywhere, but be conservative
SWIGCFLAGS	=
ifeq ($(ARCH),amd64)
SWIGCFLAGS     += -DHAVE_VA_COPY
endif

67 68
LIBS		= libevent.a
SWIGLIBS        =
69
# Re-entrant, multi-threaded version on FreeBSD and Linux, not on Windows.
70
ifneq ($(SYSTEM),CYGWIN_NT-5.1)
71
LIBS           += libevent_r.a
72 73 74
SWIGLIBS       += event.so
SWIGLIBS       += _tbevent.so
endif
75
PROGRAMS	= $(LIBS) $(SWIGLIBS)
76 77

all:		$(PROGRAMS)
78 79 80

include $(TESTBED_SRCDIR)/GNUmakerules

81 82 83
# We need to know what version of perl for headers below; use silly script.
PERLVERS	:= $(shell $(SRCDIR)/perlvers.pl)

84
#CFLAGS += -DDEBUG
85
CFLAGS += -O2 -g -I. -Wall
86 87
SCFLAGS = $(CFLAGS) $(PUBSUBFLAGS)
TCFLAGS = $(CFLAGS) $(PUBSUBMTFLAGS)
88
# Special CFLAGS w/o warnings, for SWIG-generated code
89
CFLAGS_NOWARN += -O2 -g -I. $(PUBSUBFLAGS)
90
ifeq ($(SYSTEM),Linux)
91 92
PCORE  = -I$(shell find /usr/lib/perl5/$(PERLVERS) | grep CORE\$$$") \
	`perl -e 'use Config; print $$Config{ccflags};'`
93
PYCORE = -I@PYTHON_INCLUDE@
94
else
95 96 97

# If $PERLVERS is null, then we are running the old 5.005 version under
# FreeBSD 4.X
98
ifeq ($(strip $(PERLVERS)),)
99
PCORE  = -I/usr/libdata/perl/5.00503/mach/CORE
100 101
else
PCORE  = -I/usr/local/lib/perl5/$(PERLVERS)/mach/CORE
102
endif
103
PYCORE = -I@PYTHON_INCLUDE@
104
endif
105

106 107 108 109 110 111
# PERL_POLLUTE gets us sv_undef on newer versions of perl
PCORE += -DPERL_POLLUTE 

# This is needed when trying to compile code generated by swig 1.3
# PCORE += `perl -e 'use Config; print $$Config{ccflags}'`

112
OBJS	= event.o util.o
113
POBJS	= event_r.o util.o
114 115 116 117 118

libevent.a:	$(OBJS)
	$(AR) crv $@ $(OBJS)
	$(RANLIB) $@

119 120 121 122
libevent_r.a:	$(POBJS)
	$(AR) crv $@ $(POBJS)
	$(RANLIB) $@

123
$(OBJS):	event.h
124 125 126
$(POBJS):	event.h

event_r.o:	event.c
127 128 129 130
	$(CC) $(TCFLAGS) -DTHREADED -c -o event_r.o $<

event.o:	event.c
	$(CC) $(SCFLAGS) -c -o event.o $<
131 132
event.So:	event.c
	$(CC) -fpic -DPIC $(SCFLAGS) -c -o event.So $<
133 134
util.o:		util.c
	$(CC) $(SCFLAGS) -c -o util.o $<
135 136
util.So:	util.c
	$(CC) -fpic -DPIC $(SCFLAGS) -c -o util.So $<
137

138 139 140
#
# These three targets are for the perl binding to the event system
# 
141 142

#
143
# SWIG has some horribly annoying behavior and bugs that we have to work
144 145 146 147 148
# around, so we normally check the SWIG-generated code into CVS. This is a
# maintainer target for regenerating the SWIG wrappers - see README for full
# instructions
#
swig-wrappers:	event.i	event.c event.pm.tail
149
	$(SWIG) -exportall -perl5 -shadow -I$(SRCDIR) $(SRCDIR)/event.i
150
	cat $(SRCDIR)/event.pm.tail >> $(SRCDIR)/event.pm
151 152

event_wrap.o:	$(SRCDIR)/event_wrap.c
153 154 155
	$(CC) -c $(SWIGCFLAGS) $(CFLAGS_NOWARN) $(PCORE) $<
event_wrap.So:	$(SRCDIR)/event_wrap.c
	$(CC) -fpic -DPIC -c $(SWIGCFLAGS) $(CFLAGS_NOWARN) $(PCORE) -o event_wrap.So $<
156

157 158 159 160
#
# Note: The python version of the wrappers do not seem to be afflicted by the
# same problems as the perl one.
#
161
swig-pywrappers: event.i event.h event.c tbevent.py.tail
162
	$(SWIG) -python -I$(SRCDIR) -o $(SRCDIR)/event_wrap_py.c -module tbevent \
163 164 165 166
		$(SRCDIR)/event.i
	cat $(SRCDIR)/tbevent.py.tail >> $(SRCDIR)/tbevent.py
	touch $@

167
# $(SRCDIR)/event_wrap_py.c: swig-pywrappers
168

Timothy Stack's avatar
Timothy Stack committed
169
event_wrap_py.o: $(SRCDIR)/event_wrap_py.c event.h
170 171 172
	$(CC) -c $(SWIGCFLAGS) $(CFLAGS_NOWARN) $(PYCORE) $<
event_wrap_py.So: $(SRCDIR)/event_wrap_py.c event.h
	$(CC) -fpic -DPIC -c $(SWIGCFLAGS) $(CFLAGS_NOWARN) $(PYCORE) -o event_wrap_py.So $<
173

174
event.so:	event.So event_wrap.So util.So
175
	ld -shared $^ $(PUBSUBLIB) -lcrypto -o event.so
Leigh Stoller's avatar
Leigh Stoller committed
176

177
_tbevent.so:	event.So event_wrap_py.So util.So
178
	ld -shared $^ $(PUBSUBLIB) -lcrypto -o $@
179 180

LIB_STUFF       = event.pm event.so tbevent.py _tbevent.so
181

182
install: $(LIBS) $(addprefix $(INSTALL_LIBDIR)/, $(LIB_STUFF)) \
183
	$(addprefix $(INSTALL_DIR)/opsdir/lib/, $(LIB_STUFF))
184

185
control-install:	$(LIBS) $(addprefix $(INSTALL_LIBDIR)/, $(LIB_STUFF))
186
fs-install:
187

188
#
189 190 191 192 193
# Right now we don't bother with the dynamic libs for a couple of reasons:
# * clients are either statically linked or, even if dynamically linked,
#   they are statically linked with the event code
# * SWIG stubs don't build everywhere.  For instance the perl stubs (event.so)
#   won't build on Fedora.
194 195 196
#
client: $(LIBS)
client-install: client # client-libinstall
197
client-libinstall: client-pylibinstall client-pllibinstall
198
subboss-install: client client-libinstall
199

200 201 202
#
# XXX Fix the python install location.
#
203 204 205 206
client-pylibinstall: _tbevent.so
	$(INSTALL_PROGRAM) $(SRCDIR)/tbevent.py $(DESTDIR)$(CLIENT_BINDIR)/tbevent.py
	$(INSTALL_PROGRAM) _tbevent.so $(DESTDIR)$(CLIENT_BINDIR)/_tbevent.so

207
client-pllibinstall: event.so
208 209 210
	$(INSTALL_PROGRAM) $(SRCDIR)/event.pm $(DESTDIR)$(CLIENT_BINDIR)/event.pm
	$(INSTALL_PROGRAM) event.so $(DESTDIR)$(CLIENT_BINDIR)/event.so

211
clean:
212
	/bin/rm -f *.o libevent.a libevent_r.a *.So *.so *.py
213

Mike Hibler's avatar
Mike Hibler committed
214 215 216
distclean:
	/bin/rm -f event.pm event_wrap.c event_wrap_py.c tbevent.py

217 218 219 220
$(INSTALL_DIR)/opsdir/lib/%: %
	@echo "Installing $<"
	-mkdir -p $(INSTALL_DIR)/opsdir/lib
	$(INSTALL) $< $@