GNUmakefile.in 3.06 KB
Newer Older
Leigh B. Stoller's avatar
Leigh B. Stoller committed
1 2
#
# EMULAB-COPYRIGHT
3
# Copyright (c) 2000-2009 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
SRCDIR          = @srcdir@
TESTBED_SRCDIR  = @top_srcdir@
OBJDIR          = ../..
SUBDIR          = tools/pcapper
11
SYSTEM	       := $(shell uname -s)
12 13 14 15 16 17 18

include $(OBJDIR)/Makeconf

all: pcapper

include $(TESTBED_SRCDIR)/GNUmakerules

19 20 21 22 23 24 25 26 27 28 29 30 31 32
WITH_LTHREADS = 0

ifeq ($(SYSTEM),FreeBSD)
FBSDREL	:= $(shell uname -r | sed -e 's/\([^-][^-]*\)-.*/\1/')
FBSDMAJ := $(basename $(FBSDREL))
ifneq ($(FBSDMAJ),7)
ifneq ($(FBSDMAJ),8)
WITH_LTHREADS = 1
endif
endif
endif

ifeq ($(WITH_LTHREADS),1)
PTHREADCFLAGS += -D_THREAD_SAFE -I/usr/local/include/pthread/linuxthreads
33
PTHREADLIBS   = -L/usr/local/lib -llthread -llgcc_r
34 35 36 37
else
PTHREADCFLAGS = -D_THREAD_SAFE
PTHREADLIBS   = -lpthread
endif
38

39 40
ELVINFLAGS    = -I/usr/local/include
ELVINLIBS     = -L/usr/local/lib -lpubsub -lm
41 42
EVENTFLAGS    = -DEVENTSYS -I$(TESTBED_SRCDIR)/event/lib $(ELVINFLAGS)
EVENTOBJS     = $(OBJDIR)/event/lib/event.o $(OBJDIR)/event/lib/util.o
43
EVENTLIBS     = $(ELVINLIBS) -lcrypto
44

45 46
TBCFLAGS      = $(EVENTFLAGS) -I$(TESTBED_SRCDIR)/lib/libtb
TBLIBS        = $(EVENTOBJS) $(OBJDIR)/lib/libtb/libtb.a $(EVENTLIBS)
47 48 49

PCAPLIBS=-lpcap

50
CFLAGS  = -Wall $(PTHREADCFLAGS) \
51 52
	  -DEMULAB -g -DDROPROOT -DBOSSNODE=\"@BOSSNODE@\" \
	  -DCLIENT_BINDIR='"$(CLIENT_BINDIR)"'
53
LDFLAGS = $(LDSTATIC)
54

55 56
CFLAGS_FBSD    = $(CFLAGS) $(TBCFLAGS)
CFLAGS_FBSD_NE = $(CFLAGS)
57
CFLAGS_LINUX   = $(CFLAGS) -I/usr/include/pcap $(TBCFLAGS)
58

59 60
LIBS_FBSD      = $(PTHREADLIBS) $(TBLIBS) $(PCAPLIBS)
LIBS_FBSD_NE   = $(PTHREADLIBS) $(PCAPLIBS)
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
LIBS_LINUX     = -L/usr/lib -lpthread -lpcap $(TBLIBS) -ldl -lz

#
# XXX dynamically-determined Linux stuff, only do on Linux
#
ifeq ($(SYSTEM),Linux)
ifneq ($(wildcard /usr/lib/libpcap.a),)
NOPBL := $(shell nm /usr/lib/libpcap.a | grep -q pcap_breakloop; echo $$?)
else
NOPBL := 1
endif
ifeq ($(NOPBL),0)
CFLAGS_LINUX  += -DHAVE_PCAP_BREAKLOOP
endif
ifneq ($(wildcard /usr/kerberos/bin/krb5-config),)
76
LIBS_LINUX     = -L/usr/lib -lpthread -lpcap $(TBLIBS) \
77 78 79 80
		 `/usr/kerberos/bin/krb5-config --libs krb5` -ldl -lz
ifneq ($(wildcard /usr/lib/libkrb5support.a),)
LIBS_LINUX    += -lkrb5support
endif
81 82
endif
endif
83

84 85 86
# virtual (encapsulated) ethernet
#CFLAGS_FBSD   += -DVETH

87
clean:
88
	-rm -f pcapper*.o pcapper pcapper.noevents pcapper.linux *.debug
89

90 91 92 93 94 95 96
ifeq ($(SYSTEM),Linux)
#
# Note: Building on Linux with the event system is mighty tricky
#
pcapper: pcapper.c GNUmakefile
	$(CC) $(CFLAGS_LINUX) $(CPPFLAGS_LINUX) $< -o pcapper $(LIBS_LINUX)
else
97
pcapper: GNUmakefile pcapper.o
98
	$(CC) $(LDFLAGS) $(CFLAGS_FBSD) pcapper.o $(LIBS_FBSD) -o pcapper
99 100
		cp pcapper pcapper.debug
		strip pcapper
101
endif
102

103 104 105 106 107 108 109 110 111 112 113 114
pcapper.o: pcapper.c
	$(CC) -c -o pcapper.o $(CFLAGS_FBSD) $<

pcapper.noevents: GNUmakefile pcapper-noevents.o
	$(CC) $(LDFLAGS) $(CFLAGS_FBSD_NE) pcapper-noevents.o $(LIBS_FBSD_NE) \
		-o pcapper.noevents
		cp pcapper.noevents pcapper.noevents.debug
		strip pcapper.noevents

pcapper-noevents.o: pcapper.c
	$(CC) -c -o pcapper-noevents.o $(CFLAGS_FBSD_NE) $<

115 116 117
client:	pcapper

client-install: client
118
	$(INSTALL_PROGRAM) -s pcapper $(DESTDIR)$(CLIENT_BINDIR)/pcapper