CPP: Add suport for thread-safety on Linux and Mac in non-Boost base/.
[platform/upstream/libphonenumber.git] / debian / rules
1 #!/usr/bin/make -f
2 # -*- makefile -*-
3
4 # Copyright (C) 2011 The Libphonenumber Authors
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17
18 # Uncomment this to turn on verbose mode.
19 #export DH_VERBOSE=1
20
21 ANT ?= ant
22 CMAKE ?= cmake
23 JAVA_HOME ?= /usr/lib/jvm/default-java
24
25 CMAKE_FLAGS := -DCMAKE_INSTALL_PREFIX=/usr
26 CPP_BUILD := cpp/build
27 JAVA_BUILD := java/build
28
29 ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
30   CFLAGS += -O0
31 else
32   CFLAGS += -O2
33 endif
34 ifeq (,$(filter nostrip,$(DEB_BUILD_OPTIONS)))
35   INSTALL_PROGRAM += -s
36 endif
37 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
38   NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
39   MAKEFLAGS += -j$(NUMJOBS)
40 endif
41
42 %:
43         dh $@ --with javahelper
44
45 override_dh_auto_configure:
46         mkdir -p $(CPP_BUILD) && cd $(CPP_BUILD) && $(CMAKE) $(CMAKE_FLAGS) ..
47
48 override_dh_auto_build:
49         $(MAKE) -C $(CPP_BUILD) phonenumber phonenumber-shared
50         $(ANT) -f $(JAVA_BUILD).xml jar
51
52 override_dh_auto_test:
53 ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
54         $(MAKE) -C $(CPP_BUILD) test
55         $(ANT) -f $(JAVA_BUILD).xml junit
56 endif
57
58 override_dh_auto_install:
59         dh_auto_install --builddirectory=$(CPP_BUILD)
60
61 override_dh_auto_clean:
62         -test -d $(CPP_BUILD) && $(MAKE) -C $(CPP_BUILD) clean
63         -$(ANT) -f $(JAVA_BUILD).xml clean