summaryrefslogtreecommitdiff
path: root/lib/Makefile
blob: 0f740996e4fb2a3172c05ed2e3f8203155ff4003 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Uncomment these if you are on OS X and want to build universal libraries.
# This is only important if you intend to produce a Ledger binary for
# installation.

STOW_ROOT	= /usr/local/stow
PRODUCTS	= $(HOME)/Products

GCC_VERSION	= 4.7
BOOST_VERSION	= 1_49_0

CC		= gcc-mp-$(GCC_VERSION)
ifeq ($(CC),clang)
CXX		= clang++
LD		= llvm-ld
DIR_SUFFIX	= clang
OPTJ		=
else
CXX		= g++-mp-$(GCC_VERSION)
LD		= gcc-mp-$(GCC_VERSION)
DIR_SUFFIX	= gcc$(subst .,,$(GCC_VERSION))
OPTJ		= #-j8
endif
CFLAGS		= $(CPPFLAGS) -g2 -ggdb
LDFLAGS		= -g2 -ggdb

BOOST_SOURCE	= boost-release
ifeq ($(GCC_VERSION),4.7)
BOOST_DEFINES   = define=_GLIBCXX__PTHREADS=1
else
BOOST_DEFINES   = 
endif
ifeq ($(CC),clang)
BOOST_TOOLSET	= clang
else
BOOST_TOOLSET	= darwin
endif
BOOST_FLAGS	= toolset=$(BOOST_TOOLSET) --layout=versioned \
		  link=shared threading=single $(BOOST_DEFINES)
BOOST_DIR	= boost_$(BOOST_VERSION)-$(DIR_SUFFIX)
BOOST_STOW	= $(STOW_ROOT)/$(BOOST_DIR)
BOOST_BUILD	= $(PRODUCTS)/$(BOOST_DIR)
ICU_FLAGS	= -sHAVE_ICU=1 -sICU_PATH=$(STOW_ROOT)/icu-$(DIR_SUFFIX)
BOOST_ICU_DIR	= boost_$(BOOST_VERSION)-icu-$(DIR_SUFFIX)
BOOST_ICU_STOW	= $(STOW_ROOT)/$(BOOST_ICU_DIR)
BOOST_ICU_BUILD = $(PRODUCTS)/$(BOOST_ICU_DIR)

all: boost-build #icu-build boost-icu-build

prepare-boost:
	perl -i -pe 's/local command = \[ common\.get-invocation-command darwin : g\+\+ : .*/local command = [ common.get-invocation-command darwin : g++ : $(CXX) ] ;/;' $(BOOST_SOURCE)/tools/build/v2/tools/darwin.jam
	perl -i -pe 's/flags darwin\.compile OPTIONS : -no-cpp-precomp -gdwarf-2 (-fexceptions )?;/flags darwin\.compile OPTIONS : -gdwarf-2 \1;/;' $(BOOST_SOURCE)/tools/build/v2/tools/darwin.jam

boost-build: prepare-boost
	(cd $(BOOST_SOURCE) && \
	 sh bootstrap.sh && \
	 ./b2 $(OPTJ) debug --prefix=$(BOOST_STOW) \
	    --build-dir=$(BOOST_BUILD) $(BOOST_FLAGS) install)

icu-build:
	-(cd icu/source; make distclean)
	(cd icu/source; sh autogen.sh; \
	 ./configure CPPFLAGS="$(CPPFLAGS)" \
		     CFLAGS="$(CFLAGS)" \
		     LDFLAGS="$(LDFLAGS)" \
		     CC="$(CC)" CXX="$(CXX)" LD="$(LD)" \
		     --enable-static --enable-debug \
		     --prefix=$(STOW_ROOT)/icu-$(DIR_SUFFIX) && \
	 make install)

boost-icu-build:
	(cd $(BOOST_SOURCE) && \
	 sh bootstrap.sh && \
	 ./bjam $(OPTJ) debug --prefix=$(BOOST_ICU_STOW) \
	    --build-dir=$(BOOST_ICU_BUILD) \
	    $(BOOST_FLAGS) $(ICU_FLAGS) install)

clean:
	-rm -fr $(BOOST_STOW) $(BOOST_BUILD)
	-rm -fr $(BOOST_ICU_STOW) $(BOOST_ICU_BUILD)
	-rm -fr $(STOW_ROOT)/icu-$(DIR_SUFFIX)
	-(cd icu/source; make distclean)

lib-clean:
	-(cd icu/source; make distclean)