| 1 |
# D-ITG Main Makefile |
| 2 |
|
| 3 |
################### |
| 4 |
# Dynamic Options # |
| 5 |
################### |
| 6 |
|
| 7 |
# Enable SCTP support if specified on command line (requires kernel version >= 2.5.15) |
| 8 |
ifdef sctp |
| 9 |
CXXOPT += -DSCTP |
| 10 |
LDOPT += -lsctp |
| 11 |
endif |
| 12 |
|
| 13 |
# Enable DCCP support if specified on command line (requires kernel version >= 2.6.14-rc1) |
| 14 |
ifdef dccp |
| 15 |
CXXOPT += -DDCCP |
| 16 |
endif |
| 17 |
|
| 18 |
# Set debug level as specified on command line (debug level may be increased to have more information) |
| 19 |
ifdef debug |
| 20 |
CXXOPT += -DDEBUG=$(debug) -O0 -ggdb |
| 21 |
else |
| 22 |
CXXOPT += -O2 |
| 23 |
endif |
| 24 |
|
| 25 |
# Disable bursty flows if specified on command line. |
| 26 |
ifneq ($(bursty),off) |
| 27 |
CXXOPT += -DBURSTY |
| 28 |
endif |
| 29 |
|
| 30 |
# Disable support for receiving multiple data flows on the same listening port if specified on command line. |
| 31 |
ifneq ($(multiport),off) |
| 32 |
CXXOPT += -DMULTIPORT |
| 33 |
endif |
| 34 |
|
| 35 |
################## |
| 36 |
# Static options # |
| 37 |
################## |
| 38 |
|
| 39 |
# Locals |
| 40 |
VERSION=$(shell cat ../VERSION) |
| 41 |
REVISION=$(shell [ -d ../.svn ] && svnversion -n || cat ../REVISION) |
| 42 |
RELEASE += -DVERSION="\"$(VERSION)\"" |
| 43 |
RELEASE += -DREVISION="\"$(REVISION)\"" |
| 44 |
|
| 45 |
COMPONENTS = ITGSend ITGRecv ITGLog ITGDec libITG ITGManager |
| 46 |
WARNINGS = -Wall -Wno-deprecated -Wno-strict-aliasing |
| 47 |
PREFIX = /usr/local |
| 48 |
|
| 49 |
# OS dependent options |
| 50 |
OS := $(shell uname) |
| 51 |
ifeq ($(OS),Linux) |
| 52 |
OSFLAGS := -DUNIX |
| 53 |
endif |
| 54 |
ifeq ($(OS),FreeBSD) |
| 55 |
OSFLAGS := -DUNIX -DBSD |
| 56 |
endif |
| 57 |
ifeq ($(OS),Darwin) |
| 58 |
OSFLAGS := -DUNIX -DBSD -DOSX |
| 59 |
# Warning! At the moment D-ITG has no support for IPv6 on Apple OSX |
| 60 |
CXXOPT += -DNOIPV6 |
| 61 |
endif |
| 62 |
|
| 63 |
# gcc version dependent options |
| 64 |
GCC_VERSION = $(shell gcc -dumpversion | cut -f1 -d.) |
| 65 |
GCC_MAJOR = $(shell gcc -dumpversion | cut -f2 -d.) |
| 66 |
GCC_MINOR = $(shell gcc -dumpversion | cut -f3 -d.) |
| 67 |
ifeq ($(GCC_VERSION),4) |
| 68 |
ifeq ($(shell expr $(GCC_MAJOR) \>= 4),1) |
| 69 |
WARNINGS += -Wno-unused-result |
| 70 |
endif |
| 71 |
endif |
| 72 |
|
| 73 |
# Global options |
| 74 |
export OS |
| 75 |
export RM = rm -f |
| 76 |
export CP = cp |
| 77 |
export MV = mv |
| 78 |
export SUFFIX = |
| 79 |
export SOSUFFIX = .so |
| 80 |
export CXXFLAGS = $(CXXOPT) $(OSFLAGS) $(RELEASE) $(WARNINGS) -fPIC |
| 81 |
export LDFLAGS = -lpthread -lm $(LDOPT) $(shell dpkg-buildflags --get LDFLAGS) |
| 82 |
export BASEDIR = $(shell pwd) |
| 83 |
export BIN = $(shell dirname $(BASEDIR))/bin |
| 84 |
export COMMON = $(BASEDIR)/common/ |
| 85 |
export NRCLEAN = $(BASEDIR)/ITGSend/newran/ |
| 86 |
export EXEC_DIR = /usr/local/bin |
| 87 |
export CXX = g++ |
| 88 |
export RANLIB = ranlib |
| 89 |
export THOBJS = common/thread.o |
| 90 |
export OBJS = common/ITG.o common/timestamp.o common/serial.o common/pipes.o |
| 91 |
|
| 92 |
################# |
| 93 |
# Generic Rules # |
| 94 |
################# |
| 95 |
|
| 96 |
.PHONY: $(COMPONENTS) |
| 97 |
all: check head $(COMPONENTS) |
| 98 |
@ printf '\n----------------------------------------------------------\n' |
| 99 |
@ echo 'D-ITG executables created in $(BIN)' |
| 100 |
|
| 101 |
##### |
| 102 |
help: |
| 103 |
@ echo '----------------' |
| 104 |
@ echo 'Building options' |
| 105 |
@ echo '----------------' |
| 106 |
@ echo ' debug=<N> : enable debug mode using verbosity level N' |
| 107 |
@ echo ' multiport=off : disable support for receiving multiple flows on the same port number' |
| 108 |
@ echo ' bursty=off : disable support for bursty flows' |
| 109 |
ifeq ($(OS),Linux) |
| 110 |
@ echo ' dccp=on : enable DCCP transport protocol support' |
| 111 |
@ echo ' sctp=on : enable SCTP transport protocol support' |
| 112 |
@ echo ' T=win : cross-compile binaries for Windows' |
| 113 |
endif |
| 114 |
@ echo '-------------' |
| 115 |
@ echo 'Building tips' |
| 116 |
@ echo '-------------' |
| 117 |
@ echo ' - To build D-ITG with options use the following syntax:' |
| 118 |
@ echo ' $(MAKE) clean all [options]' |
| 119 |
|
| 120 |
##### |
| 121 |
head: |
| 122 |
@ printf '\n---------------------\n' |
| 123 |
@ echo 'Current configuration' |
| 124 |
@ echo '---------------------' |
| 125 |
@ printf 'Enabled features*: ' |
| 126 |
ifdef debug |
| 127 |
@ printf 'debug=$(debug) ' |
| 128 |
endif |
| 129 |
ifdef dccp |
| 130 |
@ printf 'dccp ' |
| 131 |
endif |
| 132 |
ifdef sctp |
| 133 |
@ printf 'sctp ' |
| 134 |
endif |
| 135 |
ifneq ($(bursty),off) |
| 136 |
@ printf 'bursty ' |
| 137 |
endif |
| 138 |
ifneq ($(multiport),off) |
| 139 |
@ printf 'multiport ' |
| 140 |
endif |
| 141 |
@ echo |
| 142 |
@ echo 'Version: $(VERSION)' |
| 143 |
@ echo 'Revision: $(REVISION)' |
| 144 |
@ echo 'Compiler: $(CXX)' |
| 145 |
@ echo 'OS: $(OS)' |
| 146 |
@ echo 'OS Flags: $(OSFLAGS)' |
| 147 |
@ echo '------------------------------------------------' |
| 148 |
@ echo '* Run "$(MAKE) help" for available options and tips' |
| 149 |
@ printf '\n---------------------\n' |
| 150 |
@ echo 'Building common files' |
| 151 |
@ echo '---------------------' |
| 152 |
|
| 153 |
###### |
| 154 |
check: |
| 155 |
@ printf '\n---------------------\n' |
| 156 |
@ echo 'Checking dependencies' |
| 157 |
@ echo '---------------------' |
| 158 |
ifdef dccp |
| 159 |
ifneq ($(OS),Linux) |
| 160 |
@ echo 'DCCP protocol currently supported only on Linux.' |
| 161 |
@ exit 1 |
| 162 |
endif |
| 163 |
endif |
| 164 |
ifdef sctp |
| 165 |
ifeq ($(OS),Linux) |
| 166 |
@ printf 'SCTP development library...' |
| 167 |
@ [ -e /usr/include/netinet/sctp.h -o -e /usr/local/include/netinet/sctp.h ] \ |
| 168 |
&& { echo 'found' ; } \ |
| 169 |
|| { printf 'not found.\nPlease install SCTP development libraries and try again.\n' ; exit 1 ; } |
| 170 |
else |
| 171 |
@ echo 'SCTP protocol currently supported only on Linux.' |
| 172 |
@ exit 1 |
| 173 |
endif |
| 174 |
endif |
| 175 |
@ echo 'All dependencies satisfied.' |
| 176 |
|
| 177 |
############## |
| 178 |
$(COMPONENTS): $(THOBJS) $(OBJS) |
| 179 |
@ printf '\n-------------------\n' |
| 180 |
@ echo 'Building $@' |
| 181 |
@ echo '-------------------' |
| 182 |
@ $(MAKE) -C $@ --no-print-directory |
| 183 |
|
| 184 |
########### |
| 185 |
check_ditg: |
| 186 |
@ [ -e $(PREFIX)/bin/ITGSend ] || { echo 'D-ITG is not installed.' ; exit 1 ; } |
| 187 |
|
| 188 |
########## |
| 189 |
check_uid: |
| 190 |
@ [ `id -u` -eq 0 ] || { echo 'You need to be root to install D-ITG.' ; exit 1; } |
| 191 |
|
| 192 |
######## |
| 193 |
install: check_uid |
| 194 |
@ echo '----------------' |
| 195 |
@ echo 'Installing D-ITG' |
| 196 |
@ echo '----------------' |
| 197 |
@ mkdir -p "$(PREFIX)/bin" |
| 198 |
@ for e in ITGSend ITGRecv ITGLog ITGDec ITGManager; do \ |
| 199 |
echo -n "Copying $${e}..." ;\ |
| 200 |
$(CP) $(BIN)/$${e}$(SUFFIX) "$(PREFIX)/bin" ;\ |
| 201 |
echo 'done' ;\ |
| 202 |
done |
| 203 |
@ mkdir -p "$(PREFIX)/lib" |
| 204 |
@ printf "Copying libITG$(SOSUFFIX)..." |
| 205 |
@ $(CP) $(BIN)/libITG$(SOSUFFIX) "$(PREFIX)/lib" |
| 206 |
@ echo 'done' |
| 207 |
@ printf '\n----------------------------------------------------------\n' |
| 208 |
@ echo 'D-ITG installed in $(BIN)' |
| 209 |
|
| 210 |
########## |
| 211 |
uninstall: check_uid check_ditg |
| 212 |
@ echo '------------------' |
| 213 |
@ echo 'Uninstalling D-ITG' |
| 214 |
@ echo '------------------' |
| 215 |
@ printf "Removing components..." |
| 216 |
@ $(RM) $(PREFIX)/bin/ITG*$(SUFFIX) |
| 217 |
@ echo 'done' |
| 218 |
@ printf "Removing libITG$(SOSUFFIX)..." |
| 219 |
@ $(RM) $(PREFIX)/lib/libITG$(SOSUFFIX) |
| 220 |
@ echo 'done' |
| 221 |
|
| 222 |
###### |
| 223 |
clean: |
| 224 |
@ echo '----------------' |
| 225 |
@ echo 'Cleaning sources' |
| 226 |
@ echo '----------------' |
| 227 |
@ printf 'Cleaning common files...' |
| 228 |
@ $(RM) $(COMMON)/*.o |
| 229 |
@ echo 'done' |
| 230 |
@ for c in ITGSend ITGRecv ITGLog ITGDec libITG ITGManager; do \ |
| 231 |
printf "Cleaning $${c}..." ;\ |
| 232 |
$(MAKE) -C $${c} --no-print-directory clean ;\ |
| 233 |
echo 'done' ;\ |
| 234 |
done |
| 235 |
|
| 236 |
#--------------- |
| 237 |
include common.mk |
| 238 |
#--------------- |
| 239 |
|
| 240 |
# EOF |