-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
116 lines (103 loc) · 3.29 KB
/
Makefile
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# check for cygwin, get paths
ifeq ($(shell uname -o),Cygwin)
get-fullpath = $(shell cygpath -ma "$(1)")
get-uri = $(shell echo file:///$(call get-fullpath,$(1)) | sed -r 's/ /%20/g')
else
get-fullpath = $(shell readlink -f "$(1)")
get-uri = $(shell echo $(abspath $(1)) )
endif
# default values
IN_FILE_BASE = $(basename $(notdir $(IN_FILE)))
OUT_DIR = output/$(IN_FILE_BASE)
OUT_DIR_PATH = $(call get-fullpath,$(OUT_DIR))
IN_FILE_COPY = $(OUT_DIR_PATH)/$(notdir $(IN_FILE))
MAKEFILE_DIR = $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
CALABASH = $(MAKEFILE_DIR)/calabash/calabash.sh
DEBUG = no
DEBUG_DIR = $(OUT_DIR_PATH)/debug
DEBUG_DIR_URI = $(call get-uri,$(DEBUG_DIR))
STATUS_DIR = $(OUT_DIR_PATH)/status
STATUS_DIR_URI = $(call get-uri,$(STATUS_DIR))
HEAP = 1024m
DEVNULL = $(call get-fullpath,/dev/null)
usage:
@echo "Usage (one of):"
@echo " make conversion IN_FILE=myfile.docx"
@echo " make conversion IN_FILE=myfile.idml"
@echo ""
@echo " Sample file invocations:"
@echo " make conversion IN_FILE=../content/le-tex/whitepaper/de/transpect_wp_de.docx DEBUG=yes"
@echo ""
messages:
@echo ""
@echo "Makefile target: messages"
@echo ""
@echo "BASENAME: $(IN_FILE_BASE)"
@echo "OUT_DIR: $(OUT_DIR_PATH)"
@echo "MAKEFILE_DIR: $(MAKEFILE_DIR)"
@echo "CALABASH: $(CALABASH)"
@echo "DEBUG: $(DEBUG)"
@echo "DEBUG_DIR: $(DEBUG_DIR)"
@echo "STATUS_DIR: $(STATUS_DIR)"
checkinput:
@echo ""
@echo "Makefile target: checkinput"
@echo ""
ifeq ("$(wildcard $(IN_FILE))","")
@echo "[ERROR] File not found. Please check IN_FILE"
exit 1
else
@echo "File exists $(IN_FILE)"
endif
preprocess:
@echo ""
@echo "Makefile target: preprocess"
@echo ""
-rm -rf $(OUT_DIR_PATH)
-mkdir -p $(OUT_DIR_PATH)
-mkdir -p $(DEBUG_DIR)
-mkdir -p $(STATUS_DIR)
-cp $(IN_FILE) $(IN_FILE_COPY)
transpectdemo:
@echo ""
@echo "Makefile target: transpectdemo"
@echo ""
HEAP=$(HEAP) $(CALABASH) -D \
-o result=$(OUT_DIR_PATH)/$(IN_FILE_BASE).report.xhtml \
-o docbook=$(OUT_DIR_PATH)/$(IN_FILE_BASE).dbk.xml \
-o docbook-htmltables=$(OUT_DIR_PATH)/$(IN_FILE_BASE).dbk-htmltables.xml \
-o html=$(OUT_DIR_PATH)/$(IN_FILE_BASE).preview.xhtml \
$(call get-uri,a9s/common/xpl/trdemo-main.xpl) \
file=$(IN_FILE_COPY) \
status-dir-uri=$(STATUS_DIR_URI) \
debug-dir-uri=$(DEBUG_DIR_URI) \
debug=$(DEBUG)
postprocess:
@echo ""
@echo "Makefile target: postprocess"
@echo ""
ifneq ($(DEBUG),yes)
-rm -rf $(IN_FILE_COPY).tmp
-rm -rf $(OUT_DIR_PATH)/epub
-rm -rf $(DEBUG_DIR)
-rm -rf $(STATUS_DIR)
endif
archive:
@echo ""
@echo "Makefile target: archive"
@echo ""
# delete temporary zip files
-rm $(OUT_DIR_PATH)/$(IN_FILE_BASE).zip
cd $(OUT_DIR_PATH) && zip -r $(OUT_DIR_PATH)/$(IN_FILE_BASE).zip ./*
conversion: messages checkinput preprocess transpectdemo postprocess #archive
@echo ""
@echo "Makefile target: conversion FINISHED"
@echo ""
progress:
@ls -1rt $(STATUS_DIR)/*.txt | xargs -d'\n' -I § sh -c 'date "+%H:%M:%S " -r § | tr -d [:cntrl:]; cat §'
transpectdoc: $(addprefix $(MAKEFILE_DIR)/,$(FRONTEND_PIPELINES))
$(CALABASH) $(foreach pipe,$^,$(addprefix -i source=,$(call uri,$(pipe)))) \
$(call uri,$(MAKEFILE_DIR)/transpectdoc/xpl/transpectdoc.xpl) \
output-base-uri=$(call uri,$(MAKEFILEDIR)/doc/transpectdoc) \
project-name=transpect-demo \
debug=$(DEBUG) debug-dir-uri=$(DEBUG_DIR_URI)