#!/usr/bin/make -f
# -*- makefile -*-

DEB_BUILD_OPTIONS += nocheck
DEB_DH_INSTALL_SOURCEDIR := debian/tmp
DEB_COMPRESS_EXCLUDE := .xml .py .Linux .rules .cnf .cfg .ice .mak .js Makefile


# Get number of hardware processors
PROCESSORS := $(shell grep -c ^processor /proc/cpuinfo)
ifeq ($(PROCESSORS),0)
  PROCESSORS:= 1
else
  ifneq ($(PROCESSORS),1)
    PROCESSORS:= $(shell expr $(PROCESSORS) - 1)
  endif
endif

V=3.4.2
RV=3.4
R=34

# Make the build target only dependent on build-arch
override DEB_BUILD_DEPENDENCIES = build-arch

include /usr/share/cdbs/1/rules/patchsys-quilt.mk
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/buildcore.mk

# Workaround compiler issues on optimized output on PPC
# As a conservative measure I will only enable optimizations on
# targets known to work
ifeq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
ifeq ($(shell dpkg-architecture -qDEB_BUILD_ARCH ), i386)
  OPTIMIZE=yes
endif
ifeq ($(shell dpkg-architecture -qDEB_BUILD_ARCH ), amd64)
  OPTIMIZE=yes
endif
endif

# Unsupported systems will fall back to upstream Linux building rules
UNAME := $(shell uname)
ifeq ($(shell test -f $(CURDIR)/cpp/config/Make.rules.$(UNAME) && echo 0),)
    UNAME := Linux
endif

build-orig-source:
	mkdir -p zeroc-ice-$(V)
	tar --exclude=debian --exclude=\*~ --exclude=\.svn --exclude=\*.pyc \
		--exclude=zeroc-ice-$(V) --exclude=accounts.txt -cf - . \
		| ( cd zeroc-ice-$(V) && tar xf - )
	tar -czf ../tarballs/zeroc-ice_$(V).orig.tar.gz zeroc-ice-$(V)
	$(RM) -r zeroc-ice-$(V)

include debian/rules-cpp.mk
include debian/rules-py.mk
include debian/rules-rb.mk
include debian/rules-php.mk
include debian/rules-java.mk
include debian/rules-cs.mk

