summaryrefslogtreecommitdiff
path: root/docs/src/source-highlight/Makefile
blob: cffa6b6dfdd087a25635f0e84b9bfe4b781b9dd4 (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
# the source-highlight language defs and lang.map dir
HL_DIR=/usr/share/source-highlight
DEPS=$(wildcard $(HL_DIR)/*)

LOC_HL_DIR=.

# languages for which we provide our own .lang files
# this includes overriding languages listed in HL_DIR
EMCLANGS=$(wildcard *.lang)

# grep arg to suppress user defined langs already in lang.map
GREPARG= $(patsubst %, -e %,$(EMCLANGS))

# examples
PDF_TARGETS := $(patsubst %.txt, %.pdf, $(wildcard *.txt))
HTML_TARGETS := $(patsubst %.txt, %.html ,$(wildcard *.txt))

# tests with HTML output without going through asciidoc
TEST_SRCS := hal-test.hal ini-test.ini ngc-test.ngc
TEST_TARGETS := hal-test.html ini-test.html ngc-test.html


TARGET=local/lang.map
ASCIIDOC_ARGS=-a source_highlight_dir=local -f emc-langs-source-highlight.conf

all:	$(TARGET)

$(TARGET): $(EMCLANGS) $(DEPS)
ifeq (,$(findstring lang.map,$(wildcard $(HL_DIR)/*)))#
	$(error $(HL_DIR)/lang.map does not exist - are you sure \
	the 'source-highlight'  package is installed?)
endif
	rm -rf local
	cp -r $(HL_DIR) local
	mv local/lang.map local/lang.map.dist
	cp *.lang local
	grep -v $(GREPARG) local/lang.map.dist >$(TARGET)
	for i in $(EMCLANGS); do \
             echo `basename $$i .lang` '=' $$i >>$(TARGET) ; \
        done

examples: $(TARGET) $(HTML_TARGETS) $(PDF_TARGETS) tests


tests: 	$(TARGET) $(TEST_TARGETS)


%.html:	%.ini
	source-highlight --data-dir=local --input $< --output $@

%.html:	%.ngc
	source-highlight --data-dir=local --input $< --output $@

%.html:	%.hal
	source-highlight --data-dir=local --input $< --output $@

clean:
	-rm -rf local $(HTML_TARGETS) $(PDF_TARGETS) $(TEST_TARGETS)

$(PDF_TARGETS):  %.pdf: %.txt
	a2x -v -f pdf $<

$(HTML_TARGETS): %.html: %.txt
	asciidoc $(ASCIIDOC_ARGS) -v  $<