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