willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 1 | # This makefile is dedicated to OpenBSD (and possibly other BSDs) |
Willy Tarreau | 4eeec09 | 2006-10-15 23:50:42 +0200 | [diff] [blame] | 2 | # You should use it this way : |
| 3 | # make TARGET=os CPU=cpu |
Willy Tarreau | f2ef8c5 | 2007-07-11 09:19:31 +0200 | [diff] [blame] | 4 | # |
| 5 | # Some optional components may be added, such as DLMALLOC : |
| 6 | # |
| 7 | # make TARGET=freebsd CPU=i686 DLMALLOC_SRC=/usr/local/src/dlmalloc.c \ |
| 8 | # OPT_OBJS=src/dlmalloc.o |
Willy Tarreau | 4eeec09 | 2006-10-15 23:50:42 +0200 | [diff] [blame] | 9 | |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 10 | # Select target OS. TARGET must match a system for which COPTS and LIBS are |
| 11 | # correctly defined below. |
| 12 | TARGET = openbsd |
| 13 | |
| 14 | # pass CPU=<cpu_name> to make to optimize for a particular CPU |
| 15 | CPU = generic |
Willy Tarreau | a5899aa | 2010-11-28 07:41:00 +0100 | [diff] [blame] | 16 | #CPU = native |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 17 | #CPU = i586 |
| 18 | #CPU = i686 |
| 19 | #CPU = ultrasparc |
| 20 | |
| 21 | # By default, we use libc's regex. WARNING! On Solaris 8/Sparc, group |
| 22 | # references seem broken using libc ! Use pcre instead. |
| 23 | REGEX=libc |
| 24 | #REGEX=pcre |
| 25 | #REGEX=static-pcre |
| 26 | |
| 27 | # tools options |
| 28 | CC = gcc |
| 29 | LD = gcc |
| 30 | |
Willy Tarreau | 4eeec09 | 2006-10-15 23:50:42 +0200 | [diff] [blame] | 31 | # This is the directory hosting include/pcre.h and lib/libpcre.* when REGEX=pcre |
| 32 | PCREDIR!= pcre-config --prefix 2>/dev/null || : |
| 33 | #PCREDIR=/usr/local |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 34 | |
Willy Tarreau | 4eeec09 | 2006-10-15 23:50:42 +0200 | [diff] [blame] | 35 | # This is for OpenBSD 3.0 and above |
Willy Tarreau | 1e63130a | 2007-04-09 12:03:06 +0200 | [diff] [blame] | 36 | COPTS.openbsd = -DENABLE_POLL -DENABLE_KQUEUE |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 37 | LIBS.openbsd = |
| 38 | |
| 39 | # CPU dependant optimizations |
| 40 | COPTS.generic = -O2 |
Willy Tarreau | a5899aa | 2010-11-28 07:41:00 +0100 | [diff] [blame] | 41 | COPTS.native = -O2 -march=native |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 42 | COPTS.i586 = -O2 -march=i586 |
| 43 | COPTS.i686 = -O2 -march=i686 |
| 44 | COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc |
| 45 | |
| 46 | # options for standard regex library |
| 47 | COPTS.libc= |
| 48 | LIBS.libc= |
| 49 | |
| 50 | # options for libpcre |
| 51 | COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include |
| 52 | LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre |
| 53 | |
| 54 | # options for static libpcre |
| 55 | COPTS.static-pcre=-DUSE_PCRE -I$(PCREDIR)/include |
| 56 | LIBS.static-pcre=-L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic |
| 57 | |
| 58 | # you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG=" |
| 59 | #DEBUG = -g -DDEBUG_MEMORY -DDEBUG_FULL |
| 60 | DEBUG = -g |
| 61 | |
| 62 | # if small memory footprint is required, you can reduce the buffer size. There |
| 63 | # are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory |
| 64 | # with 1000 concurrent sessions. Putting it slightly lower than a page size |
| 65 | # will avoid the additionnal paramters to overflow a page. 8030 bytes is |
| 66 | # exactly 5.5 TCP segments of 1460 bytes. |
| 67 | #SMALL_OPTS = |
| 68 | SMALL_OPTS = -DBUFSIZE=8030 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=1024 |
| 69 | |
| 70 | # redefine this if you want to add some special PATH to include/libs |
| 71 | ADDINC = |
| 72 | ADDLIB = |
| 73 | |
Willy Tarreau | f2ef8c5 | 2007-07-11 09:19:31 +0200 | [diff] [blame] | 74 | # redefine this if you want to add some special .o files |
| 75 | OPT_OBJS = |
| 76 | |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 77 | # set some defines when needed. |
Willy Tarreau | 4eeec09 | 2006-10-15 23:50:42 +0200 | [diff] [blame] | 78 | # Known ones are -DENABLE_POLL |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 79 | # - use -DTPROXY to compile with transparent proxy support. |
Willy Tarreau | 64bc40b | 2011-03-23 20:00:53 +0100 | [diff] [blame] | 80 | # - use -DUSE_GETADDRINFO to use of getaddrinfo() to resolve IPv6 host names |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 81 | DEFINE = -DTPROXY |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 82 | |
Willy Tarreau | f2ef8c5 | 2007-07-11 09:19:31 +0200 | [diff] [blame] | 83 | # May be changed to patch PAGE_SIZE on every platform when using dlmalloc |
| 84 | DLMALLOC_THRES=4096 |
| 85 | |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 86 | # global options |
| 87 | TARGET_OPTS=$(COPTS.$(TARGET)) |
| 88 | REGEX_OPTS=$(COPTS.$(REGEX)) |
| 89 | CPU_OPTS=$(COPTS.$(CPU)) |
Willy Tarreau | 3c9a3fb | 2010-11-28 08:28:15 +0100 | [diff] [blame] | 90 | SPEC_OPTS=-fno-strict-aliasing |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 91 | |
Willy Tarreau | ec69256 | 2007-09-09 23:31:11 +0200 | [diff] [blame] | 92 | VERSION != cat VERSION 2>/dev/null || touch VERSION |
| 93 | SUBVERS != cat SUBVERS 2>/dev/null || touch SUBVERS |
| 94 | VERDATE != cat VERDATE 2>/dev/null || touch VERDATE |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 95 | |
Willy Tarreau | ec69256 | 2007-09-09 23:31:11 +0200 | [diff] [blame] | 96 | VER_OPTS := -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\" \ |
| 97 | -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\" |
| 98 | |
Willy Tarreau | 45cb4fb | 2009-10-26 21:10:04 +0100 | [diff] [blame] | 99 | # This one can be changed to look for ebtree files in an external directory |
| 100 | EBTREE_DIR := ebtree |
| 101 | |
| 102 | COPTS = -Iinclude -I$(EBTREE_DIR) $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) \ |
Willy Tarreau | 3c9a3fb | 2010-11-28 08:28:15 +0100 | [diff] [blame] | 103 | $(SPEC_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(VER_OPTS) $(DEFINE) |
Willy Tarreau | ec69256 | 2007-09-09 23:31:11 +0200 | [diff] [blame] | 104 | LIBS = $(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB) |
| 105 | CFLAGS = -Wall $(COPTS) $(DEBUG) |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 106 | LDFLAGS = -g |
| 107 | |
Willy Tarreau | dd81598 | 2007-10-16 12:25:14 +0200 | [diff] [blame] | 108 | OBJS = src/haproxy.o src/sessionhash.o src/base64.o src/protocols.o \ |
Willy Tarreau | 4eeec09 | 2006-10-15 23:50:42 +0200 | [diff] [blame] | 109 | src/uri_auth.o src/standard.o src/buffers.o src/log.o src/task.o \ |
Willy Tarreau | 982b6e3 | 2009-01-25 13:49:53 +0100 | [diff] [blame] | 110 | src/time.o src/fd.o src/pipe.o src/regex.o src/cfgparse.o src/server.o \ |
Willy Tarreau | 03fa5df | 2010-05-24 21:02:37 +0200 | [diff] [blame] | 111 | src/checks.o src/queue.o src/frontend.o src/proxy.o src/proto_uxst.o \ |
Willy Tarreau | c63190d | 2012-05-11 14:23:52 +0200 | [diff] [blame] | 112 | src/proto_http.o src/sock_raw.o src/appsession.o src/backend.o \ |
Emeric Brun | 2b920a1 | 2010-09-23 18:30:22 +0200 | [diff] [blame] | 113 | src/peers.o src/stream_interface.o src/dumpstats.o src/proto_tcp.o \ |
Willy Tarreau | bc5258d | 2009-05-10 09:00:20 +0200 | [diff] [blame] | 114 | src/session.o src/hdr_idx.o src/ev_select.o src/signal.o \ |
Willy Tarreau | f09c660 | 2012-02-13 17:12:08 +0100 | [diff] [blame] | 115 | src/lb_chash.o src/lb_fwlc.o src/lb_fwrr.o src/lb_map.o src/lb_fas.o \ |
Willy Tarreau | e6d2e4d | 2007-11-15 23:56:17 +0100 | [diff] [blame] | 116 | src/ev_poll.o src/ev_kqueue.o \ |
Willy Tarreau | 2ac5718 | 2012-04-19 15:24:50 +0200 | [diff] [blame] | 117 | src/arg.o src/acl.o src/memory.o src/freq_ctr.o \ |
Willy Tarreau | cd3b094 | 2012-04-27 21:52:18 +0200 | [diff] [blame] | 118 | src/auth.o src/stick_table.o src/sample.o |
Willy Tarreau | 45cb4fb | 2009-10-26 21:10:04 +0100 | [diff] [blame] | 119 | |
| 120 | EBTREE_OBJS = $(EBTREE_DIR)/ebtree.o \ |
| 121 | $(EBTREE_DIR)/eb32tree.o $(EBTREE_DIR)/eb64tree.o \ |
| 122 | $(EBTREE_DIR)/ebmbtree.o $(EBTREE_DIR)/ebsttree.o \ |
| 123 | $(EBTREE_DIR)/ebimtree.o $(EBTREE_DIR)/ebistree.o |
Willy Tarreau | 4eeec09 | 2006-10-15 23:50:42 +0200 | [diff] [blame] | 124 | |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 125 | all: haproxy |
| 126 | |
Willy Tarreau | 45cb4fb | 2009-10-26 21:10:04 +0100 | [diff] [blame] | 127 | haproxy: $(OBJS) $(OPT_OBJS) $(EBTREE_OBJS) |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 128 | $(LD) $(LDFLAGS) -o $@ $> $(LIBS) |
| 129 | |
Willy Tarreau | 4eeec09 | 2006-10-15 23:50:42 +0200 | [diff] [blame] | 130 | .SUFFIXES: .c.o |
willy tarreau | d0a05bd | 2006-05-18 01:22:27 +0200 | [diff] [blame] | 131 | |
Willy Tarreau | 4eeec09 | 2006-10-15 23:50:42 +0200 | [diff] [blame] | 132 | .c.o: |
| 133 | $(CC) $(CFLAGS) -c -o $@ $> |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 134 | |
Willy Tarreau | 7b066db | 2007-12-02 11:28:59 +0100 | [diff] [blame] | 135 | src/haproxy.o: src/haproxy.c |
| 136 | $(CC) $(CFLAGS) -DBUILD_TARGET='"$(TARGET)"' -DBUILD_CC='"$(CC)"' \ |
| 137 | -DBUILD_CPU='"$(CPU)"' -DBUILD_REGEX='"$(REGEX)"' \ |
| 138 | -DBUILD_OPTS='"$(COPTS)"' -c -o $@ $> |
| 139 | |
Willy Tarreau | f2ef8c5 | 2007-07-11 09:19:31 +0200 | [diff] [blame] | 140 | src/dlmalloc.o: $(DLMALLOC_SRC) |
| 141 | $(CC) $(CFLAGS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $> |
| 142 | |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 143 | clean: |
Willy Tarreau | 45cb4fb | 2009-10-26 21:10:04 +0100 | [diff] [blame] | 144 | rm -f *.[oas] src/*.[oas] ebtree/*.[oas] haproxy test |
| 145 | for dir in . src include/* doc ebtree; do rm -f $$dir/*~ $$dir/*.rej $$dir/core; done |
Willy Tarreau | 4eeec09 | 2006-10-15 23:50:42 +0200 | [diff] [blame] | 146 | rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION) nohup.out gmon.out |
Willy Tarreau | ec69256 | 2007-09-09 23:31:11 +0200 | [diff] [blame] | 147 | |
| 148 | version: |
| 149 | @echo "VERSION: $(VERSION)" |
| 150 | @echo "SUBVERS: $(SUBVERS)" |
| 151 | @echo "VERDATE: $(VERDATE)" |