| 1 |
VERSION := $(shell sed -ne 's/^version=\(.*\)/\1/p' version.properties) |
| 2 |
BINDINGS = java mono perl python ruby php |
| 3 |
FILES = Makefile version.properties ChangeLog COPYING |
| 4 |
DESTDIR = |
| 5 |
PREFIX = /usr/local |
| 6 |
RUBY ?= ruby |
| 7 |
PYTHON ?= python3 |
| 8 |
PERL ?= perl |
| 9 |
PERL_LIBRHASH_TYPE ?= auto |
| 10 |
PERL_OPTIMIZE ?= -O2 -g -Wall |
| 11 |
ARCHIVE_GZIP = rhash-bindings-$(VERSION)-src.tar.gz |
| 12 |
COPYDIR = rhash-bindings-$(VERSION) |
| 13 |
CP = cp -l --parents |
| 14 |
|
| 15 |
all: configure build test |
| 16 |
clean: distclean |
| 17 |
|
| 18 |
configure: $(patsubst %, configure-%, $(filter perl ruby php, $(BINDINGS))) |
| 19 |
build: $(patsubst %, build-%, $(BINDINGS)) |
| 20 |
test: $(patsubst %, test-%, $(BINDINGS)) |
| 21 |
install: $(patsubst %, install-%, $(filter perl ruby php, $(BINDINGS))) |
| 22 |
distclean: $(patsubst %, clean-%, $(BINDINGS)) |
| 23 |
|
| 24 |
configure-perl: perl/Makefile |
| 25 |
configure-ruby: ruby/Makefile |
| 26 |
configure-php: php/Makefile |
| 27 |
|
| 28 |
perl/Makefile: perl/Makefile.PL |
| 29 |
cd perl && LIBRHASH="$(PERL_LIBRHASH_TYPE)" $(PERL) Makefile.PL INSTALLDIRS=vendor |
| 30 |
|
| 31 |
php/Makefile: php/config.m4 |
| 32 |
cd php && phpize && ./configure --with-rhash |
| 33 |
|
| 34 |
ruby/Makefile: ruby/extconf.rb |
| 35 |
$(RUBY) -C ruby extconf.rb |
| 36 |
|
| 37 |
build-java: |
| 38 |
+$(MAKE) -C java build-binary |
| 39 |
|
| 40 |
build-perl: configure-perl |
| 41 |
+$(MAKE) -C perl OPTIMIZE="$(PERL_OPTIMIZE)" |
| 42 |
|
| 43 |
build-php: configure-php |
| 44 |
+$(MAKE) -C php |
| 45 |
|
| 46 |
build-python: |
| 47 |
cd python && $(PYTHON) -m build |
| 48 |
|
| 49 |
build-ruby: configure-ruby |
| 50 |
+$(MAKE) -C ruby |
| 51 |
|
| 52 |
build-mono: |
| 53 |
+$(MAKE) -C mono |
| 54 |
|
| 55 |
test-java: |
| 56 |
+$(MAKE) -C java test |
| 57 |
|
| 58 |
test-perl: |
| 59 |
+$(MAKE) -C perl test |
| 60 |
|
| 61 |
test-php: |
| 62 |
+$(MAKE) -C php test TEST_PHP_ARGS=-q |
| 63 |
|
| 64 |
test-ruby: |
| 65 |
$(RUBY) -C ruby -I. test_rhash.rb |
| 66 |
|
| 67 |
test-mono: |
| 68 |
+$(MAKE) -C mono test |
| 69 |
|
| 70 |
test-python: |
| 71 |
cd python && PYTHONPATH=. $(PYTHON) tests/rhash_test.py |
| 72 |
|
| 73 |
install-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 |
|
| 77 |
install-perl: |
| 78 |
+$(MAKE) -C perl install DESTDIR=$(DESTDIR) |
| 79 |
|
| 80 |
install-php: |
| 81 |
+$(MAKE) -C php install INSTALL_ROOT=$(DESTDIR) |
| 82 |
|
| 83 |
copy-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 |
|
| 91 |
gzip: 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 |
|
| 97 |
PERL_PKG_VER = $(shell [ -f perl/Rhash.pm ] && sed -ne "s/^our \+.VERSION *= *'\([0-9\.]*\)';/\1/p;" perl/Rhash.pm) |
| 98 |
PERL_PKG = Crypt-RHash-$(PERL_PKG_VER) |
| 99 |
|
| 100 |
cpan: |
| 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 |
|
| 114 |
clean-java: |
| 115 |
+$(MAKE) -C java distclean |
| 116 |
clean-mono: |
| 117 |
+$(MAKE) -C mono clean |
| 118 |
clean-ruby: |
| 119 |
+[ ! -f ruby/Makefile ] || $(MAKE) -C ruby distclean |
| 120 |
clean-perl: |
| 121 |
+[ ! -f perl/Makefile ] || $(MAKE) -C perl distclean |
| 122 |
clean-php: |
| 123 |
[ ! -f php/configure ] || (cd php && phpize --clean) |
| 124 |
clean-python: |
| 125 |
rm -rf python/dist/ python/rhash_Rhash.egg-info/ python/tests/__pycache__/ |