summaryrefslogtreecommitdiff
path: root/qpid/python/Makefile
blob: 31547c8f57009a67a03065ddd3e916dab1cab2e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#

PREFIX=/usr/local
EXEC_PREFIX=$(PREFIX)/bin
DATA_DIR=$(PREFIX)/share

PYTHON_LIB=$(shell python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(prefix='$(PREFIX)')")
PYTHON_VERSION=$(shell python -c "from distutils.sysconfig import get_python_version; print get_python_version()")

ddfirst=$(shell ddir=$(DATA_DIR) && echo $${ddir:0:1})
ifeq ($(ddfirst),/)
AMQP_SPEC_DIR=$(DATA_DIR)/amqp
else
AMQP_SPEC_DIR=$(PWD)/$(DATA_DIR)/amqp
endif

DIRS=qmf qpid mllib models examples tests tests_0-8 tests_0-9 tests_0-10
SRCS=$(shell find $(DIRS) -name "*.py") qpid_config.py
BUILD=build
TARGETS=$(SRCS:%.py=$(BUILD)/%.py)

PYCC=python -c "import compileall, sys; compileall.compile_dir(sys.argv[1])"

all: build

$(BUILD)/%.py: %.py
	@mkdir -p $(shell dirname $@)
	./preppy $(PYTHON_VERSION) < $< > $@

build: $(TARGETS)

.PHONY: doc

doc:
	@mkdir -p $(BUILD)
	epydoc qpid.messaging -o $(BUILD)/doc --no-private --no-sourcecode --include-log

install: build
	install -d $(PYTHON_LIB)

	install -d $(PYTHON_LIB)/mllib
	install -pm 0644 LICENSE.txt NOTICE.txt $(BUILD)/mllib/*.* $(PYTHON_LIB)/mllib
	$(PYCC) $(PYTHON_LIB)/mllib

	install -d $(PYTHON_LIB)/qpid
	install -pm 0644 LICENSE.txt NOTICE.txt README.txt $(BUILD)/qpid/*.* $(PYTHON_LIB)/qpid
	TDIR=$(shell mktemp -d) && \
		sed s@AMQP_SPEC_DIR=.*@AMQP_SPEC_DIR='"$(AMQP_SPEC_DIR)"'@ \
		$(BUILD)/qpid_config.py > $${TDIR}/qpid_config.py && \
		install -pm 0644 $${TDIR}/qpid_config.py $(PYTHON_LIB) && \
		rm -rf $${TDIR}

	install -d $(PYTHON_LIB)/qpid/tests
	install -pm 0644 $(BUILD)/qpid/tests/*.* $(PYTHON_LIB)/qpid/tests
	$(PYCC) $(PYTHON_LIB)/qpid

	install -d $(PYTHON_LIB)/qmf
	install -pm 0644 LICENSE.txt NOTICE.txt qmf/*.* $(PYTHON_LIB)/qmf
	$(PYCC) $(PYTHON_LIB)/qmf

	install -d $(PYTHON_LIB)/tests
	install -pm 0644 $(BUILD)/tests/*.* $(PYTHON_LIB)/tests
	$(PYCC) $(PYTHON_LIB)/tests

	install -d $(PYTHON_LIB)/tests_0-8
	install -pm 0644 $(BUILD)/tests_0-8/*.* $(PYTHON_LIB)/tests_0-8
	$(PYCC) $(PYTHON_LIB)/tests_0-8

	install -d $(PYTHON_LIB)/tests_0-9
	install -pm 0644 $(BUILD)/tests_0-9/*.* $(PYTHON_LIB)/tests_0-9
	$(PYCC) $(PYTHON_LIB)/tests_0-9

	install -d $(PYTHON_LIB)/tests_0-10
	install -pm 0644 $(BUILD)/tests_0-10/*.* $(PYTHON_LIB)/tests_0-10
	$(PYCC) $(PYTHON_LIB)/tests_0-10

	install -d $(EXEC_PREFIX)
	install -pm 0755 qpid-python-test commands/* $(EXEC_PREFIX)

clean:
	rm -rf $(BUILD)