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