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 |
willy tarreau | 64a3cc3 | 2005-12-18 01:13:11 +0100 | [diff] [blame] | 9 | #TARGET = linux24e |
willy tarreau | 750a472 | 2005-12-17 13:21:24 +0100 | [diff] [blame] | 10 | #TARGET = linux22 |
| 11 | #TARGET = solaris |
willy tarreau | 750a472 | 2005-12-17 13:21:24 +0100 | [diff] [blame] | 12 | #TARGET = openbsd |
| 13 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 14 | # pass CPU=<cpu_name> to make to optimize for a particular CPU |
| 15 | CPU = generic |
| 16 | #CPU = i586 |
| 17 | #CPU = i686 |
| 18 | #CPU = ultrasparc |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 19 | |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 20 | # By default, we use libc's regex. |
| 21 | REGEX=libc |
| 22 | #REGEX=pcre |
| 23 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 24 | # tools options |
| 25 | CC = gcc |
| 26 | LD = gcc |
| 27 | |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 28 | # 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] | 29 | PCREDIR := $(shell pcre-config --prefix 2>/dev/null || :) |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 30 | #PCREDIR=/usr/local |
| 31 | |
willy tarreau | 64a3cc3 | 2005-12-18 01:13:11 +0100 | [diff] [blame] | 32 | # This is for standard Linux 2.6 with netfilter and epoll() |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame] | 33 | COPTS.linux26 = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL |
| 34 | LIBS.linux26 = |
| 35 | |
willy tarreau | b952e1d | 2005-12-18 01:31:20 +0100 | [diff] [blame^] | 36 | # This is for enhanced Linux 2.4 with netfilter and epoll() patch. |
| 37 | # Warning! If kernel is 2.4 with epoll-lt <= 0.21, then you must add |
| 38 | # -DEPOLL_CTL_MOD_WORKAROUND to workaround a very rare bug. |
| 39 | #COPTS.linux24e = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL -DUSE_MY_EPOLL -DEPOLL_CTL_MOD_WORKAROUND |
willy tarreau | 64a3cc3 | 2005-12-18 01:13:11 +0100 | [diff] [blame] | 40 | COPTS.linux24e = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL -DUSE_MY_EPOLL |
| 41 | LIBS.linux24e = |
| 42 | |
| 43 | # This is for standard Linux 2.4 with netfilter but without epoll() |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame] | 44 | COPTS.linux24 = -DNETFILTER -DENABLE_POLL |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 45 | LIBS.linux24 = |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 46 | |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 47 | # This is for Linux 2.2 |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame] | 48 | COPTS.linux22 = -DUSE_GETSOCKNAME -DENABLE_POLL |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 49 | LIBS.linux22 = |
| 50 | |
| 51 | # This is for Solaris 8 |
willy tarreau | 64a3cc3 | 2005-12-18 01:13:11 +0100 | [diff] [blame] | 52 | COPTS.solaris = -fomit-frame-pointer -DENABLE_POLL -DFD_SETSIZE=65536 |
willy tarreau | 9da061b | 2005-12-17 12:29:56 +0100 | [diff] [blame] | 53 | LIBS.solaris = -lnsl -lsocket |
| 54 | |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 55 | # This is for OpenBSD 3.0 |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame] | 56 | COPTS.openbsd = -DENABLE_POLL |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 57 | LIBS.openbsd = |
| 58 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 59 | # CPU dependant optimizations |
| 60 | COPTS.generic = -O2 |
| 61 | COPTS.i586 = -O2 -march=i586 |
| 62 | COPTS.i686 = -O2 -march=i686 |
| 63 | COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc |
| 64 | |
| 65 | # options for standard regex library |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 66 | COPTS.libc= |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 67 | LIBS.libc= |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 68 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 69 | # options for libpcre |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 70 | COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include |
| 71 | LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre |
| 72 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 73 | # you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG=" |
willy tarreau | 64a3cc3 | 2005-12-18 01:13:11 +0100 | [diff] [blame] | 74 | #DEBUG = -g -DDEBUG_MEMORY |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 75 | DEBUG = -g |
willy tarreau | 9da061b | 2005-12-17 12:29:56 +0100 | [diff] [blame] | 76 | |
willy tarreau | 0174f31 | 2005-12-18 01:02:42 +0100 | [diff] [blame] | 77 | # if small memory footprint is required, you can reduce the buffer size. There |
| 78 | # are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory |
willy tarreau | 64a3cc3 | 2005-12-18 01:13:11 +0100 | [diff] [blame] | 79 | # with 1000 concurrent sessions. Putting it slightly lower than a page size |
| 80 | # will avoid the additionnal paramters to overflow a page. |
| 81 | #SMALL_OPTS = -DBUFSIZE=8100 -DMAXREWRITE=1000 |
willy tarreau | 0174f31 | 2005-12-18 01:02:42 +0100 | [diff] [blame] | 82 | SMALL_OPTS = |
| 83 | |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame] | 84 | # redefine this if you want to add some special PATH to include/libs |
| 85 | ADDINC = |
| 86 | ADDLIB = |
| 87 | |
| 88 | # set some defines when needed. |
| 89 | # Known ones are -DENABLE_POLL, -DENABLE_EPOLL, and -DUSE_MY_EPOLL |
| 90 | DEFINE = |
willy tarreau | 0174f31 | 2005-12-18 01:02:42 +0100 | [diff] [blame] | 91 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 92 | # global options |
| 93 | TARGET_OPTS=$(COPTS.$(TARGET)) |
| 94 | REGEX_OPTS=$(COPTS.$(REGEX)) |
| 95 | CPU_OPTS=$(COPTS.$(CPU)) |
| 96 | |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame] | 97 | COPTS=-I. $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(DEFINE) |
willy tarreau | ad90a0c | 2005-12-18 01:09:15 +0100 | [diff] [blame] | 98 | LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB) |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 99 | |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 100 | # - use -DSTATTIME=0 to disable statistics, else specify an interval in |
| 101 | # milliseconds. |
willy tarreau | a159808 | 2005-12-17 13:08:06 +0100 | [diff] [blame] | 102 | # - use -DTPROXY to compile with transparent proxy support. |
| 103 | CFLAGS = -Wall $(COPTS) $(DEBUG) -DSTATTIME=0 -DTPROXY |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 104 | LDFLAGS = -g |
| 105 | |
| 106 | all: haproxy |
| 107 | |
willy tarreau | 1235015 | 2005-12-18 01:03:27 +0100 | [diff] [blame] | 108 | haproxy: src/list.o src/chtbl.o src/hashpjw.o haproxy.o |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 109 | $(LD) $(LDFLAGS) -o $@ $^ $(LIBS) |
| 110 | |
| 111 | %.o: %.c |
| 112 | $(CC) $(CFLAGS) -c -o $@ $< |
| 113 | |
| 114 | clean: |
willy tarreau | 1235015 | 2005-12-18 01:03:27 +0100 | [diff] [blame] | 115 | 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] | 116 | |