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 | 750a472 | 2005-12-17 13:21:24 +0100 | [diff] [blame] | 7 | TARGET = linux24 |
| 8 | #TARGET = linux22 |
| 9 | #TARGET = solaris |
willy tarreau | 750a472 | 2005-12-17 13:21:24 +0100 | [diff] [blame] | 10 | #TARGET = openbsd |
| 11 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 12 | # pass CPU=<cpu_name> to make to optimize for a particular CPU |
| 13 | CPU = generic |
| 14 | #CPU = i586 |
| 15 | #CPU = i686 |
| 16 | #CPU = ultrasparc |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 17 | |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 18 | # By default, we use libc's regex. |
| 19 | REGEX=libc |
| 20 | #REGEX=pcre |
| 21 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 22 | # tools options |
| 23 | CC = gcc |
| 24 | LD = gcc |
| 25 | |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 26 | # 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] | 27 | PCREDIR := $(shell pcre-config --prefix 2>/dev/null || :) |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 28 | #PCREDIR=/usr/local |
| 29 | |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 30 | # This is for Linux 2.4 with netfilter |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 31 | COPTS.linux24 = -DNETFILTER |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 32 | LIBS.linux24 = |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 33 | |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 34 | # This is for Linux 2.2 |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 35 | COPTS.linux22 = -DUSE_GETSOCKNAME |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 36 | LIBS.linux22 = |
| 37 | |
| 38 | # This is for Solaris 8 |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 39 | COPTS.solaris = -fomit-frame-pointer -DSOLARIS |
willy tarreau | 9da061b | 2005-12-17 12:29:56 +0100 | [diff] [blame] | 40 | LIBS.solaris = -lnsl -lsocket |
| 41 | |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 42 | # This is for OpenBSD 3.0 |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 43 | COPTS.openbsd = |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 44 | LIBS.openbsd = |
| 45 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 46 | # CPU dependant optimizations |
| 47 | COPTS.generic = -O2 |
| 48 | COPTS.i586 = -O2 -march=i586 |
| 49 | COPTS.i686 = -O2 -march=i686 |
| 50 | COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc |
| 51 | |
| 52 | # options for standard regex library |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 53 | COPTS.libc= |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 54 | LIBS.libc= |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 55 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 56 | # options for libpcre |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 57 | COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include |
| 58 | LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre |
| 59 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 60 | # you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG=" |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 61 | #DEBUG = |
| 62 | DEBUG = -g |
willy tarreau | 9da061b | 2005-12-17 12:29:56 +0100 | [diff] [blame] | 63 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 64 | # global options |
| 65 | TARGET_OPTS=$(COPTS.$(TARGET)) |
| 66 | REGEX_OPTS=$(COPTS.$(REGEX)) |
| 67 | CPU_OPTS=$(COPTS.$(CPU)) |
| 68 | |
| 69 | COPTS=$(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 70 | LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX)) |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 71 | |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 72 | # - use -DSTATTIME=0 to disable statistics, else specify an interval in |
| 73 | # milliseconds. |
willy tarreau | a159808 | 2005-12-17 13:08:06 +0100 | [diff] [blame] | 74 | # - use -DTPROXY to compile with transparent proxy support. |
| 75 | CFLAGS = -Wall $(COPTS) $(DEBUG) -DSTATTIME=0 -DTPROXY |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 76 | LDFLAGS = -g |
| 77 | |
| 78 | all: haproxy |
| 79 | |
| 80 | haproxy: haproxy.o |
| 81 | $(LD) $(LDFLAGS) -o $@ $^ $(LIBS) |
| 82 | |
| 83 | %.o: %.c |
| 84 | $(CC) $(CFLAGS) -c -o $@ $< |
| 85 | |
| 86 | clean: |
willy tarreau | 25c4ea5 | 2005-12-18 00:49:49 +0100 | [diff] [blame^] | 87 | rm -f *.[oas] *~ *.rej core haproxy test nohup.out gmon.out |
willy tarreau | efae184 | 2005-12-17 12:51:03 +0100 | [diff] [blame] | 88 | |