blob: f9fb9f9a8749ea719c621efef12c824a73af2ef6 [file] [log] [blame]
willy tarreaueedaa9f2005-12-17 14:08:03 +01001# This makefile supports different OS and CPU setups.
2# You should use it this way :
3# make TARGET=os CPU=cpu
4
willy tarreau750a4722005-12-17 13:21:24 +01005# Select target OS. TARGET must match a system for which COPTS and LIBS are
6# correctly defined below.
willy tarreau750a4722005-12-17 13:21:24 +01007TARGET = linux24
8#TARGET = linux22
9#TARGET = solaris
willy tarreau750a4722005-12-17 13:21:24 +010010#TARGET = openbsd
11
willy tarreaueedaa9f2005-12-17 14:08:03 +010012# pass CPU=<cpu_name> to make to optimize for a particular CPU
13CPU = generic
14#CPU = i586
15#CPU = i686
16#CPU = ultrasparc
willy tarreau0f7af912005-12-17 12:21:26 +010017
willy tarreau036e1ce2005-12-17 13:46:33 +010018# By default, we use libc's regex.
19REGEX=libc
20#REGEX=pcre
21
willy tarreaueedaa9f2005-12-17 14:08:03 +010022# tools options
23CC = gcc
24LD = gcc
25
willy tarreau036e1ce2005-12-17 13:46:33 +010026# This is the directory hosting include/pcre.h and lib/libpcre.* when REGEX=pcre
willy tarreau2f6ba652005-12-17 13:57:42 +010027PCREDIR := $(shell pcre-config --prefix 2>/dev/null || :)
willy tarreau036e1ce2005-12-17 13:46:33 +010028#PCREDIR=/usr/local
29
willy tarreau5cbea6f2005-12-17 12:48:26 +010030# This is for Linux 2.4 with netfilter
willy tarreaueedaa9f2005-12-17 14:08:03 +010031COPTS.linux24 = -DNETFILTER
willy tarreau5cbea6f2005-12-17 12:48:26 +010032LIBS.linux24 =
willy tarreau0f7af912005-12-17 12:21:26 +010033
willy tarreau5cbea6f2005-12-17 12:48:26 +010034# This is for Linux 2.2
willy tarreaueedaa9f2005-12-17 14:08:03 +010035COPTS.linux22 = -DUSE_GETSOCKNAME
willy tarreau5cbea6f2005-12-17 12:48:26 +010036LIBS.linux22 =
37
38# This is for Solaris 8
willy tarreaueedaa9f2005-12-17 14:08:03 +010039COPTS.solaris = -fomit-frame-pointer -DSOLARIS
willy tarreau9da061b2005-12-17 12:29:56 +010040LIBS.solaris = -lnsl -lsocket
41
willy tarreau5cbea6f2005-12-17 12:48:26 +010042# This is for OpenBSD 3.0
willy tarreaueedaa9f2005-12-17 14:08:03 +010043COPTS.openbsd =
willy tarreau5cbea6f2005-12-17 12:48:26 +010044LIBS.openbsd =
45
willy tarreaueedaa9f2005-12-17 14:08:03 +010046# CPU dependant optimizations
47COPTS.generic = -O2
48COPTS.i586 = -O2 -march=i586
49COPTS.i686 = -O2 -march=i686
50COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
51
52# options for standard regex library
willy tarreau036e1ce2005-12-17 13:46:33 +010053COPTS.libc=
willy tarreaueedaa9f2005-12-17 14:08:03 +010054LIBS.libc=
willy tarreau036e1ce2005-12-17 13:46:33 +010055
willy tarreaueedaa9f2005-12-17 14:08:03 +010056# options for libpcre
willy tarreau036e1ce2005-12-17 13:46:33 +010057COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include
58LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre
59
willy tarreaueedaa9f2005-12-17 14:08:03 +010060# you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG="
willy tarreau5cbea6f2005-12-17 12:48:26 +010061#DEBUG =
62DEBUG = -g
willy tarreau9da061b2005-12-17 12:29:56 +010063
willy tarreaueedaa9f2005-12-17 14:08:03 +010064# global options
65TARGET_OPTS=$(COPTS.$(TARGET))
66REGEX_OPTS=$(COPTS.$(REGEX))
67CPU_OPTS=$(COPTS.$(CPU))
68
69COPTS=$(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS)
willy tarreau036e1ce2005-12-17 13:46:33 +010070LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX))
willy tarreau0f7af912005-12-17 12:21:26 +010071
willy tarreau5cbea6f2005-12-17 12:48:26 +010072# - use -DSTATTIME=0 to disable statistics, else specify an interval in
73# milliseconds.
willy tarreaua1598082005-12-17 13:08:06 +010074# - use -DTPROXY to compile with transparent proxy support.
75CFLAGS = -Wall $(COPTS) $(DEBUG) -DSTATTIME=0 -DTPROXY
willy tarreau0f7af912005-12-17 12:21:26 +010076LDFLAGS = -g
77
78all: haproxy
79
80haproxy: haproxy.o
81 $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
82
83%.o: %.c
84 $(CC) $(CFLAGS) -c -o $@ $<
85
86clean:
willy tarreau25c4ea52005-12-18 00:49:49 +010087 rm -f *.[oas] *~ *.rej core haproxy test nohup.out gmon.out
willy tarreauefae1842005-12-17 12:51:03 +010088