# # Copyright (c) 2000-2016, 2018 University of Utah and the Flux Group. # # {{{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 . # # }}} # SRCDIR = @srcdir@ TESTBED_SRCDIR = @top_srcdir@ OBJDIR = @top_builddir@ SUBDIR = $(subst $(TESTBED_SRCDIR)/,,$(SRCDIR)) include $(OBJDIR)/Makeconf PUBSUBFLAGS = -I/usr/local/include PUBSUBMTFLAGS = -I/usr/local/include 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 ifeq ($(ELVIN_COMPAT),1) PUBSUBFLAGS += -DELVIN_COMPAT PUBSUBMTFLAGS += -DELVIN_COMPAT endif SYSTEM := $(shell uname -s) ARCH := $(shell uname -m) # For the swig-*wrappers targets SWIG = swig2.0 # We should be able to use va_copy everywhere, but be conservative SWIGCFLAGS = ifeq ($(ARCH),amd64) SWIGCFLAGS += -DHAVE_VA_COPY endif LIBS = libevent.a SWIGLIBS = # Re-entrant, multi-threaded version on FreeBSD and Linux, not on Windows. ifneq ($(SYSTEM),CYGWIN_NT-5.1) LIBS += libevent_r.a SWIGLIBS += event.so SWIGLIBS += _tbevent.so endif PROGRAMS = $(LIBS) $(SWIGLIBS) all: $(PROGRAMS) include $(TESTBED_SRCDIR)/GNUmakerules # We need to know what version of perl for headers below; use silly script. PERLVERS := $(shell $(SRCDIR)/perlvers.pl) #CFLAGS += -DDEBUG CFLAGS += -O2 -g -I. -Wall SCFLAGS = $(CFLAGS) $(PUBSUBFLAGS) TCFLAGS = $(CFLAGS) $(PUBSUBMTFLAGS) # Special CFLAGS w/o warnings, for SWIG-generated code CFLAGS_NOWARN += -O2 -g -I. $(PUBSUBFLAGS) ifeq ($(SYSTEM),Linux) PCORE = -I$(shell find /usr/lib/perl5/$(PERLVERS) | grep CORE\$$$") \ `perl -e 'use Config; print $$Config{ccflags};'` PYCORE = -I@PYTHON_INCLUDE@ else # If $PERLVERS is null, then we are running the old 5.005 version under # FreeBSD 4.X ifeq ($(strip $(PERLVERS)),) PCORE = -I/usr/libdata/perl/5.00503/mach/CORE else PCORE = -I/usr/local/lib/perl5/$(PERLVERS)/mach/CORE endif PYCORE = -I@PYTHON_INCLUDE@ endif # 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}'` OBJS = event.o util.o POBJS = event_r.o util.o libevent.a: $(OBJS) $(AR) crv $@ $(OBJS) $(RANLIB) $@ libevent_r.a: $(POBJS) $(AR) crv $@ $(POBJS) $(RANLIB) $@ $(OBJS): event.h $(POBJS): event.h event_r.o: event.c $(CC) $(TCFLAGS) -DTHREADED -c -o event_r.o $< event.o: event.c $(CC) $(SCFLAGS) -c -o event.o $< event.So: event.c $(CC) -fpic -DPIC $(SCFLAGS) -c -o event.So $< util.o: util.c $(CC) $(SCFLAGS) -c -o util.o $< util.So: util.c $(CC) -fpic -DPIC $(SCFLAGS) -c -o util.So $< # # These three targets are for the perl binding to the event system # # # SWIG has some horribly annoying behavior and bugs that we have to work # 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 $(SWIG) -exportall -perl5 -shadow -I$(SRCDIR) $(SRCDIR)/event.i cat $(SRCDIR)/event.pm.tail >> $(SRCDIR)/event.pm event_wrap.o: $(SRCDIR)/event_wrap.c $(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 $< # # Note: The python version of the wrappers do not seem to be afflicted by the # same problems as the perl one. # swig-pywrappers: event.i event.h event.c tbevent.py.tail $(SWIG) -python -I$(SRCDIR) -o $(SRCDIR)/event_wrap_py.c -module tbevent \ $(SRCDIR)/event.i cat $(SRCDIR)/tbevent.py.tail >> $(SRCDIR)/tbevent.py touch $@ # $(SRCDIR)/event_wrap_py.c: swig-pywrappers event_wrap_py.o: $(SRCDIR)/event_wrap_py.c event.h $(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 $< event.so: event.So event_wrap.So util.So ld -shared $^ $(PUBSUBLIB) -lcrypto -o event.so _tbevent.so: event.So event_wrap_py.So util.So ld -shared $^ $(PUBSUBLIB) -lcrypto -o $@ LIB_STUFF = event.pm event.so tbevent.py _tbevent.so install: $(LIBS) $(addprefix $(INSTALL_LIBDIR)/, $(LIB_STUFF)) \ $(addprefix $(INSTALL_DIR)/opsdir/lib/, $(LIB_STUFF)) control-install: $(LIBS) $(addprefix $(INSTALL_LIBDIR)/, $(LIB_STUFF)) fs-install: # # 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. # client: $(LIBS) client-install: client # client-libinstall client-libinstall: client-pylibinstall client-pllibinstall subboss-install: client client-libinstall # # XXX Fix the python install location. # client-pylibinstall: _tbevent.so $(INSTALL_PROGRAM) $(SRCDIR)/tbevent.py $(DESTDIR)$(CLIENT_BINDIR)/tbevent.py $(INSTALL_PROGRAM) _tbevent.so $(DESTDIR)$(CLIENT_BINDIR)/_tbevent.so client-pllibinstall: event.so $(INSTALL_PROGRAM) $(SRCDIR)/event.pm $(DESTDIR)$(CLIENT_BINDIR)/event.pm $(INSTALL_PROGRAM) event.so $(DESTDIR)$(CLIENT_BINDIR)/event.so clean: /bin/rm -f *.o libevent.a libevent_r.a *.So *.so *.py distclean: /bin/rm -f event.pm event_wrap.c event_wrap_py.c tbevent.py $(INSTALL_DIR)/opsdir/lib/%: % @echo "Installing $<" -mkdir -p $(INSTALL_DIR)/opsdir/lib $(INSTALL) $< $@