aboutsummaryrefslogtreecommitdiff
path: root/shunit2-2.0.3/Makefile
blob: effbcca365e7aaeafdb31884e19d28eb4bc9e84b (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
# $Id$

PROG=shunit2

BIN_DIR=$(PWD)/bin
BUILD_DIR=$(PWD)/build
DIST_DIR=$(PWD)/dist
LIB_DIR=$(PWD)/lib
SHARE_DIR=$(PWD)/share
SRC_DIR=$(PWD)/src
TEST_DIR=$(PWD)/test
TMP_DIR=$(PWD)/tmp

DOCBOOK_BUILD_DIR=$(BUILD_DIR)/docbook
DOCBOOK_SHARE_DIR=$(SHARE_DIR)/docbook

DOCBOOK_SRC_DIR=$(SRC_DIR)/docbook
EXAMPLES_SRC_DIR=$(SRC_DIR)/examples
SHELL_SRC_DIR=$(SRC_DIR)/shell
TEST_SRC_DIR=$(SRC_DIR)/test

HTML_XSL=$(SHARE_DIR)/docbook/tldp-xsl/21MAR2004/html/tldp-one-page.xsl

all: build docs

build: build-prep
	cp -p $(SHELL_SRC_DIR)/$(PROG) $(BUILD_DIR)

build-clean:
	rm -fr $(BUILD_DIR)

build-prep:
	@mkdir -p $(BUILD_DIR)

docs: docs-transform-shelldoc docs-transform-docbook

docs-prep:
	@mkdir -p $(DOCBOOK_BUILD_DIR)
	@echo "Preparing documentation for parsing"
	@isoDate=`date "+%Y-%m-%d"`; \
	find $(DOCBOOK_SRC_DIR) -name "*.xml" |\
	while read f; do \
	  bn=`basename $$f`; \
	  sed -e "s/@@ISO_DATE@@/$$isoDate/g" $$f >$(DOCBOOK_BUILD_DIR)/$$bn; \
	done

docs-extract-shelldoc: docs-prep
	@echo "Extracting the ShellDoc"
	@$(BIN_DIR)/extractDocs.pl $(SHELL_SRC_DIR)/$(PROG) >$(BUILD_DIR)/$(PROG)_shelldoc.xml

docs-transform-shelldoc: docs-prep docs-extract-shelldoc
	@echo "Parsing the extracted ShellDoc"
	@xsltproc $(SHARE_DIR)/resources/shelldoc.xslt $(BUILD_DIR)/$(PROG)_shelldoc.xml >$(DOCBOOK_BUILD_DIR)/functions.xml

docs-transform-docbook: docs-docbook-prep docs-prep
	@echo "Parsing the documentation with DocBook"
	@xsltproc $(HTML_XSL) $(DOCBOOK_BUILD_DIR)/$(PROG).xml >$(BUILD_DIR)/$(PROG).html

docs-docbook-prep:
	@if [ ! -d "$(DOCBOOK_SHARE_DIR)/docbook-xml" \
	  -o ! -d "$(DOCBOOK_SHARE_DIR)/docbook-xsl" ]; \
	then \
	  echo "Preparing DocBook structure"; \
	  $(BIN_DIR)/docbookPrep.sh "$(DOCBOOK_SHARE_DIR)"; \
	fi

test: test-prep
	@echo "executing $(PROG) unit tests"
	( cd $(TEST_DIR); $(TEST_SRC_DIR)/run-test-suite )

test-clean:
	rm -fr $(TEST_DIR)

test-prep: build test-clean
	@mkdir -p $(TEST_DIR)
	cp -p $(TEST_SRC_DIR)/test* $(TEST_DIR)
	cp -p $(TEST_SRC_DIR)/run-test-suite $(TEST_DIR)
	cp -p $(BUILD_DIR)/$(PROG) $(TEST_DIR)

dist: dist-clean build docs
	@mkdir $(DIST_DIR)
	cp -p $(BUILD_DIR)/$(PROG) $(DIST_DIR)
	cp -p $(BUILD_DIR)/$(PROG).html $(DIST_DIR)

clean: build-clean test-clean
	rm -fr $(TMP_DIR)

dist-clean: clean
	rm -fr $(DIST_DIR)