graph ratio
[prads.git] / src / Makefile
blobee0cf37cebb0f1fe97afed8a203d3d04a7cf24e0
1 #Makefile
2 #CC=gcc
3 UNAME := $(shell uname -s)
4 CFLAGS+=-O3
6 # for finding static libraries
7 LIBDIR=/usr/lib/x86_64-linux-gnu
9 # RHEL5 libresolv doesnt export certain essential symbols, but they are present
10 ifneq ($(findstring 5.,$(shell [ -f /etc/redhat-release ] && cat /etc/redhat-release | awk '{ print $3 }')),)
11 LDFLAGS+=/usr/lib64/libresolv.a
12 endif
14 ifeq (${RELEASE},)
15 CFLAGS+=-DRELEASE='"$(shell git describe | cut -f2- -d_ | sed s/`git tag -l | grep -v /| tail -n1`//)"'
16 endif
18 # for using a newer libpcap
19 ifneq (${PCAPDIR},)
20 LDFLAGS+=-L${PCAPDIR}
21 else
22 PCAPDIR=${LIBDIR}
23 endif
25 ifeq (${STATIC},)
27 ifeq (${JEMALLOC},y)
28 CFLAGS+=-DUSE_JEMALLOC
29 LDFLAGS+=-ljemalloc
30 endif
31 # if you want to use perftools
32 ifeq (${TCMALLOC},y)
33 LDFLAGS+=-ltcmalloc
34 endif
35 LDFLAGS+=-lpcap -lpcre -lresolv
36 CFLAGS+=-DCONFDIR='"${CONFDIR}/"'
38 else
40 ifeq (${JEMALLOC},y)
41 CFLAGS+=-DUSE_JEMALLOC
42 LDFLAGS+=${LIBDIR}/libjemalloc.a
43 endif
45 ifeq (${TCMALLOC},y)
46 LDFLAGS+=/usr/lib/libtcmalloc_minimal.a
47 endif
49 CFLAGS+=-DCONFDIR='"prads.d/"' -static
50 LDFLAGS=-static
51 LDFLAGS+=${LIBDIR}/libpcre.a ${PCAPDIR}/libpcap.a ${LIBDIR}/libresolv.a
53 endif
55 ifneq (${DEBUG},)
56 CFLAGS = -g -DDEBUG -Wall -DCONFDIR='"${CONFDIR}/"'
57 endif
58 ifneq (${PROFILE},)
59 CFLAGS=-g -pg -DCONFDIR='"${CONFDIR}/"'
60 endif
61 ifneq (${PPROF},)
62 LDFLAGS+=-lprofiler
63 endif
64 ifneq (${EXTRADEBUG},)
65 CFLAGS+= -DDUMP_HASH -DDEBUG_HASH -DDEBUG=2 -DDEBUG=2
66 endif
67 ifneq (${DEBUG_PACKET},)
68 CFLAGS+= -DDEBUG_PACKET
69 endif
70 ifeq ($(UNAME), FreeBSD)
71 LDFLAGS= -L/usr/local/lib -lpcre -lpcap
72 CPPFLAGS= -I/usr/local/include
73 endif
75 BUILD=gnu
76 ifeq (${BUILD},osx)
77 CFLAGS+=-I/opt/local/include/ -DOSX
78 CONFDIR=/opt/etc/prads
79 else
80 CFLAGS+=-D__USE_GNU
81 CONFDIR=../etc
82 endif
84 SERVICE_OBJ = servicefp/servicefp.o servicefp/tcpc.o servicefp/tcps.o servicefp/udps.o
86 IPFP_OBJ = ipfp/ipfp.o ipfp/udp_fp.o ipfp/icmp_fp.o
87 LOG_OBJ = output-plugins/log_dispatch.o output-plugins/log_stdout.o output-plugins/log_file.o output-plugins/log_fifo.o output-plugins/log_ringbuffer.o output-plugins/log_sguil.o
88 CXT_OBJ = cxt.o
89 MODULES = dhcp.o dump_dns.o mac.o ${SERVICE_OBJ} ${IPFP_OBJ} ${CXT_OBJ} ${LOG_OBJ}
90 OBJECTS = bstrlib.o sig_tcp.o config.o sys_func.o assets.o prads.o ${MODULES}
91 SHM_CLIENT_OBJECTS = shm-client.o
93 all: prads shm-client
95 osx:
96 $(MAKE) BUILD=osx
98 prads: $(OBJECTS)
99 $(CC) $(CFLAGS) -o $@ $(OBJECTS) $(LDFLAGS)
101 shm-client: $(SHM_CLIENT_OBJECTS)
102 $(CC) $(CFLAGS) -o $@ $(SHM_CLIENT_OBJECTS) $(LDFLAGS)
104 static:
105 $(MAKE) STATIC=y prads
107 debug:
108 ${MAKE} DEBUG=y
110 profile:
111 ${MAKE} PROFILE=y
113 clean:
114 -rm -fv $(OBJECTS)
115 -rm -f prads
117 indent:
118 find -type f -name '*.[ch]' | xargs indent -kr -i4 -cdb -sc -sob -ss -ncs -ts8 -nut
120 # oldschool header file dependency checking.
121 deps:
122 -rm -f deps.d
123 for i in $(subst .o,.c,$(OBJECTS)); do gcc -MM $$i >> deps.d; done
125 ifneq ($(wildcard deps.d),)
126 include deps.d
127 endif
129 tags: *.h *.c
130 ctags -R