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