GNUmakefile.in 3.8 KB
Newer Older
Leigh B. Stoller's avatar
Leigh B. Stoller committed
1 2
#
# EMULAB-COPYRIGHT
Timothy Stack's avatar
 
Timothy Stack committed
3
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
Leigh B. Stoller's avatar
Leigh B. Stoller committed
4 5 6
# All rights reserved.
#

7 8 9 10 11 12 13
SRCDIR		= @srcdir@
TESTBED_SRCDIR	= @top_srcdir@
OBJDIR		= ../..
SUBDIR		= event/lib

include $(OBJDIR)/Makeconf

14
SYSTEM	       := $(shell uname -s)
15 16
LIBS		= libevent.a
SWIGLIBS        =
17 18
# Re-entrant, multi-threaded version on FreeBSD, not on Linux or Windows clients.
ifeq ($(SYSTEM),FreeBSD)
19 20
LIBS           += libevent_r.a
SWIGLIBS       += event.so _tbevent.so
21
endif
22
PROGRAMS	= $(LIBS) $(SWIGLIBS)
23 24

all:		$(PROGRAMS)
25 26 27

include $(TESTBED_SRCDIR)/GNUmakerules

28
#CFLAGS += -DDEBUG
29
CFLAGS += -O2 -g -static -I. -Wall
Timothy Stack's avatar
 
Timothy Stack committed
30 31
SCFLAGS = $(CFLAGS) `$(ELVIN_CONFIG) --cflags vin4c`
TCFLAGS = $(CFLAGS) `$(ELVIN_CONFIG) --cflags vin4mt`
32
# Special CFLAGS w/o warnings, for SWIG-generated code
33
CFLAGS_NOWARN += -O2 -g -static -I.
Timothy Stack's avatar
 
Timothy Stack committed
34
CFLAGS_NOWARN += `$(ELVIN_CONFIG) --cflags vin4c`
35 36 37
ifeq ($(SYSTEM),Linux)
PCORE  = -I/usr/lib/perl5/5.6.1/i386-linux/CORE
else
38 39 40 41
FBSDVERSION    := $(shell uname -v | sed -e 's/FreeBSD \([0-9]\).*/FreeBSD\1/')
ifeq ($(FBSDVERSION),FreeBSD5)
PCORE  = -I/usr/local/lib/perl5/5.6.1/mach/CORE
else
42
PCORE  = -I/usr/libdata/perl/5.00503/mach/CORE
43
PYCORE = -I/usr/local/include/python2.3
44
endif
45
endif
46 47

OBJS	= event.o util.o
48
POBJS	= event_r.o util.o
49 50 51 52 53

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

54 55 56 57
libevent_r.a:	$(POBJS)
	$(AR) crv $@ $(POBJS)
	$(RANLIB) $@

58
$(OBJS):	event.h
59 60 61
$(POBJS):	event.h

event_r.o:	event.c
62 63 64 65 66 67
	$(CC) $(TCFLAGS) -DTHREADED -c -o event_r.o $<

event.o:	event.c
	$(CC) $(SCFLAGS) -c -o event.o $<
util.o:		util.c
	$(CC) $(SCFLAGS) -c -o util.o $<
68

69 70 71
#
# These three targets are for the perl binding to the event system
# 
72 73

#
74
# SWIG has some horribly annoying behavior and bugs that we have to work
75 76 77 78 79 80 81 82
# 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
	swig1.1 -exportall -dnone -perl5 -shadow -I$(SRCDIR) $(SRCDIR)/event.i
	cat $(SRCDIR)/event.pm.tail >> event.pm
	mv event.pm  $(SRCDIR)
83 84

event_wrap.o:	$(SRCDIR)/event_wrap.c
85
	$(CC) -c $(CFLAGS_NOWARN) $(PCORE) $<
86

87 88 89 90
#
# Note: The python version of the wrappers do not seem to be afflicted by the
# same problems as the perl one.
#
91
swig-pywrappers: event.i event.h event.c tbevent.py.tail
92 93 94 95 96
	swig -python -I$(SRCDIR) -o $(SRCDIR)/event_wrap_py.c -module tbevent \
		$(SRCDIR)/event.i
	cat $(SRCDIR)/tbevent.py.tail >> $(SRCDIR)/tbevent.py
	touch $@

97
# $(SRCDIR)/event_wrap_py.c: swig-pywrappers
98 99 100 101

event_wrap_py.o: $(SRCDIR)/event_wrap_py.c
	$(CC) -c $(CFLAGS_NOWARN) $(PYCORE) $<

102
event.so:	event.o event_wrap.o util.o
Timothy Stack's avatar
 
Timothy Stack committed
103
	ld -shared $^ `$(ELVIN_CONFIG) --libs vin4c` -lcrypto -o event.so
Leigh B. Stoller's avatar
Leigh B. Stoller committed
104

105
_tbevent.so:	event.o event_wrap_py.o util.o
Timothy Stack's avatar
 
Timothy Stack committed
106
	ld -shared $^ `$(ELVIN_CONFIG) --libs vin4c` -lcrypto -o $@
107 108

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

110 111
install: $(addprefix $(INSTALL_LIBDIR)/, $(LIB_STUFF)) \
	$(addprefix $(INSTALL_DIR)/opsdir/lib/, $(LIB_STUFF))
112

113 114
control-install:	libevent_r.a \
			$(addprefix $(INSTALL_LIBDIR)/, $(LIB_STUFF))
Leigh B. Stoller's avatar
Leigh B. Stoller committed
115

116 117 118 119 120 121 122 123
#
# Right now we don't bother with the dynamic libs since all of the existing
# clients are statically linked.  Also, the dynamic libs include the SWIG stubs
# and that stuff needs work to build on Linux and FBSD5.
#
client: $(LIBS)
client-install: client # client-libinstall

124 125 126
#
# XXX Fix the python install location.
#
127
client-libinstall:
128 129
	$(INSTALL_PROGRAM) $(SRCDIR)/event.pm $(DESTDIR)$(CLIENT_BINDIR)/event.pm
	$(INSTALL_PROGRAM) event.so $(DESTDIR)$(CLIENT_BINDIR)/event.so
130
	$(INSTALL_PROGRAM) $(SRCDIR)/tbevent.py $(DESTDIR)$(CLIENT_BINDIR)/tbevent.py
131
	$(INSTALL_PROGRAM) _tbevent.so $(DESTDIR)$(CLIENT_BINDIR)/_tbevent.so
132

133
clean:
134
	/bin/rm -f *.o libevent.a libevent_r.a *.so *.py
135 136 137 138 139

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