• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
21include /usr/share/cdbs/1/rules/debhelper.mk
22include /usr/share/cdbs/1/class/maven.mk
23
24JAVA_HOME := /usr/lib/jvm/default-java
25DEB_MAVEN_DOC_TARGET := javadoc:jar javadoc:aggregate
26
27CMAKE ?= cmake
28
29CMAKE_FLAGS := -DCMAKE_INSTALL_PREFIX=/usr
30CPP_BUILD := cpp/build
31JAVA_BUILD := java/build
32
33# CMake doesn't read CPPFLAGS and dh_auto commands are not used in this rules
34# file so we have to manually set the flags here to ensure that hardening flags
35# are used:
36CFLAGS += $(CPPFLAGS)
37CXXFLAGS += $(CPPFLAGS)
38
39ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
40  CFLAGS += -O0
41else
42  CFLAGS += -O2
43endif
44ifeq (,$(filter nostrip,$(DEB_BUILD_OPTIONS)))
45  INSTALL_PROGRAM += -s
46endif
47ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
48  NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
49  MAKEFLAGS += -j$(NUMJOBS)
50endif
51
52#%:
53#	dh $@ --with javahelper
54
55#override_dh_auto_configure:
56configure/libphonenumber7::
57	mkdir -p $(CPP_BUILD) && cd $(CPP_BUILD) && $(CMAKE) $(CMAKE_FLAGS) ..
58
59#override_dh_auto_build:
60#	( cd tools/java && $(MVN) package )
61#	mkdir java/lib
62#	ln -s /usr/share/java/junit4.jar java/lib/junit-4.8.1.jar
63#	$(ANT) -f $(JAVA_BUILD).xml jar
64build/libphonenumber7::
65	ln -sf cpp-build-1.0-SNAPSHOT.jar tools/java/cpp-build/target/cpp-build-1.0-SNAPSHOT-jar-with-dependencies.jar
66	ln -sf /usr/share/java/protobuf.jar tools/java/cpp-build/target/protobuf-java-debian.jar
67	$(MAKE) -C $(CPP_BUILD) phonenumber phonenumber-shared
68
69#override_dh_auto_test:
70#ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
71#	$(MAKE) -C $(CPP_BUILD) test
72#	$(ANT) -f $(JAVA_BUILD).xml junit
73#endif
74
75# Hack for multiarch: CMake doesn't really support libdir so we just manually
76# move /usr/lib/* to a proper multiarch location.
77#override_dh_auto_install:
78common-install-arch::
79	dh_auto_install --builddirectory=$(CPP_BUILD)
80	mkdir -p debian/tmp/usr/lib-$(DEB_HOST_MULTIARCH)
81	mv debian/tmp/usr/lib/* debian/tmp/usr/lib-$(DEB_HOST_MULTIARCH)
82	mv debian/tmp/usr/lib-$(DEB_HOST_MULTIARCH) \
83		debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)
84
85#override_dh_auto_clean:
86clean::
87	-test -d $(CPP_BUILD) && $(MAKE) -C $(CPP_BUILD) clean
88	#-$(ANT) -f $(JAVA_BUILD).xml clean
89	#-( cd tools/java && $(MVN) clean )
90