1VERSION := $(shell sed -ne 's/^version=\(.*\)/\1/p' version.properties) 2BINDINGS = java mono perl python ruby php 3FILES = Makefile version.properties ChangeLog COPYING 4DESTDIR = 5PREFIX = /usr/local 6RUBY ?= ruby 7PYTHON ?= python 8PERL ?= perl 9PERL_LIBRHASH_TYPE ?= auto 10PERL_OPTIMIZE ?= -O2 -g -Wall 11ARCHIVE_GZIP = rhash-bindings-$(VERSION)-src.tar.gz 12COPYDIR = rhash-bindings-$(VERSION) 13CP = cp -l --parents 14 15all: configure build test 16clean: distclean 17 18configure: $(patsubst %, configure-%, $(filter perl ruby php, $(BINDINGS))) 19build: $(patsubst %, build-%, $(BINDINGS)) 20test: $(patsubst %, test-%, $(BINDINGS)) 21install: $(patsubst %, install-%, $(filter perl ruby php, $(BINDINGS))) 22distclean: $(patsubst %, clean-%, $(BINDINGS)) 23 24configure-perl: perl/Makefile 25configure-ruby: ruby/Makefile 26configure-php: php/Makefile 27 28perl/Makefile: perl/Makefile.PL 29 cd perl && LIBRHASH="$(PERL_LIBRHASH_TYPE)" $(PERL) Makefile.PL INSTALLDIRS=vendor 30 31php/Makefile: php/config.m4 32 cd php && phpize && ./configure --with-rhash 33 34ruby/Makefile: ruby/extconf.rb 35 $(RUBY) -C ruby extconf.rb 36 37build-java: 38 +$(MAKE) -C java build-binary 39 40build-perl: configure-perl 41 +$(MAKE) -C perl OPTIMIZE="$(PERL_OPTIMIZE)" 42 43build-php: configure-php 44 +$(MAKE) -C php 45 46build-python: 47# not required 48 49build-ruby: configure-ruby 50 +$(MAKE) -C ruby 51 52build-mono: 53 +$(MAKE) -C mono 54 55test-java: 56 +$(MAKE) -C java test 57 58test-perl: 59 +$(MAKE) -C perl test 60 61test-php: 62 +$(MAKE) -C php test TEST_PHP_ARGS=-q 63 64test-ruby: 65 $(RUBY) -C ruby -I. test_rhash.rb 66 67test-mono: 68 +$(MAKE) -C mono test 69 70test-python: 71 $(PYTHON) python/test_rhash.py 72 73install-ruby: 74# clear MAKEFLAGS to overcome ruby1.8 mkmf concurrency bug 75 +MAKEFLAGS= $(MAKE) -C ruby install DESTDIR=$(DESTDIR) sitedir=$(DESTDIR)/usr/lib/ruby 76 77install-perl: 78 +$(MAKE) -C perl install DESTDIR=$(DESTDIR) 79 80install-php: 81 +$(MAKE) -C php install INSTALL_ROOT=$(DESTDIR) 82 83copy-dist: 84 mkdir -p $(COPYDIR) 85 find java ruby python -type f -regex '.*\(\.\([hc]\|java\|py\|rb\|txt\)\|Makefile\)' -exec $(CP) '{}' $(COPYDIR)/ \; 86 find mono -type f -regex '.*\(\.\([hc]\|cs\|xml\|txt\|snk\|sln\|csproj\|config\)\|Makefile\)' -exec $(CP) '{}' "$(COPYDIR)/" \; 87 $(CP) $(shell sed -e 's/\([^ ]*\).*/perl\/\1/' perl/MANIFEST) "$(COPYDIR)/" 88 find php -type f -regex '.*\.\(m4\|c\|h\|phpt\)' -exec $(CP) '{}' "$(COPYDIR)/" \; 89 $(CP) $(FILES) "$(COPYDIR)/" 90 91gzip: distclean 92 rm -rf "$(COPYDIR)" $(ARCHIVE_GZIP) 93 +$(MAKE) copy-dist 94 tar -czf $(ARCHIVE_GZIP) --owner=root:0 --group=root:0 "$(COPYDIR)" 95 rm -rf "$(COPYDIR)" 96 97PERL_PKG_VER = $(shell [ -f perl/Rhash.pm ] && sed -ne "s/^our \+.VERSION *= *'\([0-9\.]*\)';/\1/p;" perl/Rhash.pm) 98PERL_PKG = Crypt-RHash-$(PERL_PKG_VER) 99 100cpan: 101 [ -f ../librhash/rhash.h ] 102 echo "$(PERL_PKG_VER)" | grep -q '^[0-9\.]\+$$' 103 rm -rf $(PERL_PKG)/ $(PERL_PKG).tar.gz 104 mkdir -p $(PERL_PKG)/librhash/ 105 grep -q / perl/MANIFEST && mkdir -p `sed -ne '/\//s/\([^\/]*\/\).*/$(PERL_PKG)\/\1/p' perl/MANIFEST | sort | uniq` 106 for f in `sed 's/ .*//' perl/MANIFEST`; do cp perl/$$f $(PERL_PKG)/$$f; done 107 cp ../docs/CONTRIBUTING.md ../COPYING $(PERL_PKG)/ 108 cp ../librhash/*.[hc] ../version.h $(PERL_PKG)/librhash/ 109 ( echo CONTRIBUTING.md; echo COPYING ) >> $(PERL_PKG)/MANIFEST 110 find $(PERL_PKG)/librhash/ -type f -printf "librhash/%f\n" | sort >> $(PERL_PKG)/MANIFEST 111 tar -czf $(PERL_PKG).tar.gz --owner=root:0 --group=root:0 $(PERL_PKG)/ 112 rm -rf $(PERL_PKG)/ 113 114clean-java: 115 +$(MAKE) -C java distclean 116clean-mono: 117 +$(MAKE) -C mono clean 118clean-ruby: 119 +[ ! -f ruby/Makefile ] || $(MAKE) -C ruby distclean 120clean-perl: 121 +[ ! -f perl/Makefile ] || $(MAKE) -C perl distclean 122clean-php: 123 [ ! -f php/configure ] || (cd php && phpize --clean) 124clean-python: 125 rm -f python/*.pyc 126