Dragan Dosen | 59bb97a | 2017-06-02 12:03:16 +0200 | [diff] [blame] | 1 | DESTDIR = |
| 2 | PREFIX = /usr/local |
| 3 | BINDIR = $(PREFIX)/bin |
| 4 | |
David Carlier | 80ebd30 | 2017-06-07 12:39:16 +0100 | [diff] [blame] | 5 | CC ?= gcc |
Dragan Dosen | 59bb97a | 2017-06-02 12:03:16 +0200 | [diff] [blame] | 6 | LD = $(CC) |
| 7 | |
David Carlier | 80ebd30 | 2017-06-07 12:39:16 +0100 | [diff] [blame] | 8 | CXX ?= g++ |
Dragan Dosen | 59bb97a | 2017-06-02 12:03:16 +0200 | [diff] [blame] | 9 | |
| 10 | ifeq ($(MOD_DEFENDER_SRC),) |
| 11 | MOD_DEFENDER_SRC := ./mod_defender_src |
| 12 | endif |
| 13 | |
| 14 | ifeq ($(APACHE2_INC),) |
| 15 | APACHE2_INC := /usr/include/apache2 |
| 16 | endif |
| 17 | |
| 18 | ifeq ($(APR_INC),) |
| 19 | APR_INC := /usr/include/apr-1.0 |
| 20 | endif |
| 21 | |
David Carlier | 80ebd30 | 2017-06-07 12:39:16 +0100 | [diff] [blame] | 22 | ifeq ($(EVENT_LIB),) |
| 23 | EVENT_LIB := -levent |
| 24 | endif |
| 25 | |
| 26 | ifeq ($(EVENT_INC),) |
| 27 | EVENT_INC := /usr/include |
| 28 | endif |
| 29 | |
| 30 | CFLAGS += -g -Wall -pthread |
Willy Tarreau | fc80e30 | 2020-05-27 11:05:33 +0200 | [diff] [blame] | 31 | INCS += -I../../include -I$(MOD_DEFENDER_SRC) -I$(APACHE2_INC) -I$(APR_INC) -I$(EVENT_INC) |
Christian Ruppert | 57dc283 | 2017-11-30 10:11:36 +0100 | [diff] [blame] | 32 | LIBS += -lpthread $(EVENT_LIB) -levent_pthreads -lapr-1 -laprutil-1 -lstdc++ -lm |
Dragan Dosen | 59bb97a | 2017-06-02 12:03:16 +0200 | [diff] [blame] | 33 | |
| 34 | CXXFLAGS = -g -std=gnu++11 |
| 35 | CXXINCS += -I$(MOD_DEFENDER_SRC) -I$(MOD_DEFENDER_SRC)/deps -I$(APACHE2_INC) -I$(APR_INC) |
| 36 | |
| 37 | SRCS = standalone.o spoa.o defender.o \ |
| 38 | $(wildcard $(MOD_DEFENDER_SRC)/deps/libinjection/*.c) |
| 39 | OBJS = $(patsubst %.c, %.o, $(SRCS)) |
| 40 | |
| 41 | CXXSRCS = $(wildcard $(MOD_DEFENDER_SRC)/*.cpp) |
| 42 | CXXOBJS = $(patsubst %.cpp, %.o, $(CXXSRCS)) |
| 43 | |
| 44 | defender: $(OBJS) $(CXXOBJS) |
Christian Ruppert | 57dc283 | 2017-11-30 10:11:36 +0100 | [diff] [blame] | 45 | $(LD) $(LDFLAGS) -o $@ $^ $(LIBS) |
Dragan Dosen | 59bb97a | 2017-06-02 12:03:16 +0200 | [diff] [blame] | 46 | |
| 47 | install: defender |
| 48 | install defender $(DESTDIR)$(BINDIR) |
| 49 | |
| 50 | clean: |
| 51 | rm -f defender $(OBJS) $(CXXOBJS) |
| 52 | |
| 53 | %.o: %.c |
| 54 | $(CC) $(CFLAGS) $(INCS) -c -o $@ $< |
| 55 | |
| 56 | %.o: %.cpp |
| 57 | $(CXX) $(CXXFLAGS) $(CXXINCS) -c -o $@ $< |