willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 1 | # This makefile supports different OS and CPU setups. |
| 2 | # You should use it this way : |
| 3 | # make TARGET=os CPU=cpu |
| 4 | |
willy tarreau | 750a472 | 2005-12-17 13:21:24 +0100 | [diff] [blame] | 5 | # Select target OS. TARGET must match a system for which COPTS and LIBS are |
| 6 | # correctly defined below. |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame^] | 7 | #TARGET = linux26 |
willy tarreau | 750a472 | 2005-12-17 13:21:24 +0100 | [diff] [blame] | 8 | TARGET = linux24 |
| 9 | #TARGET = linux22 |
| 10 | #TARGET = solaris |
willy tarreau | 750a472 | 2005-12-17 13:21:24 +0100 | [diff] [blame] | 11 | #TARGET = openbsd |
| 12 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 13 | # pass CPU=<cpu_name> to make to optimize for a particular CPU |
| 14 | CPU = generic |
| 15 | #CPU = i586 |
| 16 | #CPU = i686 |
| 17 | #CPU = ultrasparc |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 18 | |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 19 | # By default, we use libc's regex. |
| 20 | REGEX=libc |
| 21 | #REGEX=pcre |
| 22 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 23 | # tools options |
| 24 | CC = gcc |
| 25 | LD = gcc |
| 26 | |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 27 | # This is the directory hosting include/pcre.h and lib/libpcre.* when REGEX=pcre |
willy tarreau | 2f6ba65 | 2005-12-17 13:57:42 +0100 | [diff] [blame] | 28 | PCREDIR := $(shell pcre-config --prefix 2>/dev/null || :) |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 29 | #PCREDIR=/usr/local |
| 30 | |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame^] | 31 | # This is for Linux 2.6 with netfilter and EPOLL |
| 32 | COPTS.linux26 = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL |
| 33 | LIBS.linux26 = |
| 34 | |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 35 | # This is for Linux 2.4 with netfilter |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame^] | 36 | COPTS.linux24 = -DNETFILTER -DENABLE_POLL |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 37 | LIBS.linux24 = |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 38 | |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 39 | # This is for Linux 2.2 |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame^] | 40 | COPTS.linux22 = -DUSE_GETSOCKNAME -DENABLE_POLL |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 41 | LIBS.linux22 = |
| 42 | |
| 43 | # This is for Solaris 8 |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame^] | 44 | COPTS.solaris = -fomit-frame-pointer -DSOLARIS -DENABLE_POLL |
willy tarreau | 9da061b | 2005-12-17 12:29:56 +0100 | [diff] [blame] | 45 | LIBS.solaris = -lnsl -lsocket |
| 46 | |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 47 | # This is for OpenBSD 3.0 |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame^] | 48 | COPTS.openbsd = -DENABLE_POLL |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 49 | LIBS.openbsd = |
| 50 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 51 | # CPU dependant optimizations |
| 52 | COPTS.generic = -O2 |
| 53 | COPTS.i586 = -O2 -march=i586 |
| 54 | COPTS.i686 = -O2 -march=i686 |
| 55 | COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc |
| 56 | |
| 57 | # options for standard regex library |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 58 | COPTS.libc= |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 59 | LIBS.libc= |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 60 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 61 | # options for libpcre |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 62 | COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include |
| 63 | LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre |
| 64 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 65 | # you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG=" |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 66 | #DEBUG = |
| 67 | DEBUG = -g |
willy tarreau | 9da061b | 2005-12-17 12:29:56 +0100 | [diff] [blame] | 68 | |
willy tarreau | 0174f31 | 2005-12-18 01:02:42 +0100 | [diff] [blame] | 69 | # if small memory footprint is required, you can reduce the buffer size. There |
| 70 | # are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory |
| 71 | # with 1000 concurrent sessions. |
| 72 | #SMALL_OPTS = -DBUFSIZE=8192 -DMAXREWRITE=1024 |
| 73 | SMALL_OPTS = |
| 74 | |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame^] | 75 | # redefine this if you want to add some special PATH to include/libs |
| 76 | ADDINC = |
| 77 | ADDLIB = |
| 78 | |
| 79 | # set some defines when needed. |
| 80 | # Known ones are -DENABLE_POLL, -DENABLE_EPOLL, and -DUSE_MY_EPOLL |
| 81 | DEFINE = |
willy tarreau | 0174f31 | 2005-12-18 01:02:42 +0100 | [diff] [blame] | 82 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 83 | # global options |
| 84 | TARGET_OPTS=$(COPTS.$(TARGET)) |
| 85 | REGEX_OPTS=$(COPTS.$(REGEX)) |
| 86 | CPU_OPTS=$(COPTS.$(CPU)) |
| 87 | |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame^] | 88 | COPTS=-I. $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(DEFINE) |
willy tarreau | ad90a0c | 2005-12-18 01:09:15 +0100 | [diff] [blame] | 89 | LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB) |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 90 | |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 91 | # - use -DSTATTIME=0 to disable statistics, else specify an interval in |
| 92 | # milliseconds. |
willy tarreau | a159808 | 2005-12-17 13:08:06 +0100 | [diff] [blame] | 93 | # - use -DTPROXY to compile with transparent proxy support. |
| 94 | CFLAGS = -Wall $(COPTS) $(DEBUG) -DSTATTIME=0 -DTPROXY |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 95 | LDFLAGS = -g |
| 96 | |
| 97 | all: haproxy |
| 98 | |
willy tarreau | 1235015 | 2005-12-18 01:03:27 +0100 | [diff] [blame] | 99 | haproxy: src/list.o src/chtbl.o src/hashpjw.o haproxy.o |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 100 | $(LD) $(LDFLAGS) -o $@ $^ $(LIBS) |
| 101 | |
| 102 | %.o: %.c |
| 103 | $(CC) $(CFLAGS) -c -o $@ $< |
| 104 | |
| 105 | clean: |
willy tarreau | 1235015 | 2005-12-18 01:03:27 +0100 | [diff] [blame] | 106 | rm -f *.[oas] *~ *.rej core haproxy test nohup.out gmon.out src/*.[oas] |
willy tarreau | efae184 | 2005-12-17 12:51:03 +0100 | [diff] [blame] | 107 | |