3 RUN_FANGLE=$(AWK) -f $(FANGLE)
5 LYX_SOURCE=$(LITERATE_SOURCE) # but only the .lyx files
6 TEX_SOURCE=$(LYX_SOURCE:.lyx=.tex)
7 EXTRA_DIST+=$(TEX_SOURCE)
8 TEXMACS_SOURCE=$(LITERATE_SOURCE) # but only the .tm files
9 TXT_SOURCE=$(LITERATE_SOURCE:.tm=.txt)
10 EXTRA_DIST+=$(TXT_SOURCE)
11 FANGLE_SOURCE=$(TXT_SOURCE)
12 FANGLE_SOURCE_STAMP=$(FANGLE_SOURCE).stamp
14 FANGLE_SOURCES:=$(shell \
15 $(RUN_FANGLE) -r $(FANGLE_SOURCE) |\
16 sed -e 's/^[<][<]//;s/[>][>]$$//;/^$(FANGLE_PREFIX)/!d' \
17 -e 's/^$(FANGLE_PREFIX)/\.\//' )
18 if_extension=$(if $(findstring $(suffix $(1)),$(2)),$(3),$(4))
22 fangle=$(RUN_FANGLE) $(call if_extension,$(2),$(C_EXTENSIONS),$(nf_line)) -R"$(2)" $(1)
23 indent_options=-npro -kr -i8 -ts8 -sob -l80 -ss -ncs
24 indent=$(call if_extension,$(1),$(C_EXTENSIONS), | indent $(indent_options))
25 fangle_extract=@mkdir -p $(dir $(1)) && \
26 $(call fangle,$(2),$(1)) > "$(1).tmp" && \
27 cat "$(1).tmp" $(indent) | cpif "$(1)" \
28 && rm -f -- "$(1).tmp" || \
29 (echo error fangling $(1) from $(2) ; exit 1)
30 define FANGLE_template
32 $$(call fangle_extract,$(1),$(2))
35 FANGLE_PDF+=$(TEX_SOURCE:.tex=.pdf)
36 FANGLE_PDF+=$(LITERATE_SOURCE:.tm=.pdf)
37 FANGLE_DOCS=$(FANGLE_PDF)
43 rm -f -- $(TEX_SOURCE)
47 texmacs -s -c $< $@ -q
50 rm -f -- $(TXT_SOURCE)
52 $(FANGLE_SOURCE_STAMP): $(FANGLE_SOURCE) \
54 echo -n > $(FANGLE_SOURCE_STAMP)
56 rm -f $(FANGLE_SOURCE_STAMP)
58 .PHONY: echo_fangle_sources
59 echo_fangle_sources: ; @echo $(FANGLE_SOURCES)
60 .PHONY: fangle_sources
61 fangle_sources: $(FANGLE_SOURCE_STAMP)
62 .PHONY: clean_fangle_sources
63 clean_fangle_sources: ; \
64 rm -f -- $(FANGLE_SOURCE_STAMP) $(FANGLE_SOURCES)
65 $(foreach source,$(FANGLE_SOURCES),\
66 $(eval $(call FANGLE_template,$(source),$(FANGLE_SOURCE))) \
68 _distclean: clean_fangle_sources
71 pdflatex $< && pdflatex $<
74 rm -f -- $(FANGLE_PDF) $(TEX_SOURCE:.tex=.toc) \
75 $(TEX_SOURCE:.tex=.log) $(TEX_SOURCE:.tex=.aux)
76 clean_pdf: clean_pdf_tex
79 texmacs -s -c $< $@ -q
82 rm -f -- $(FANGLE_PDF)
83 clean_pdf: clean_pdf_texmacs
85 fangle_docs: $(FANGLE_DOCS)
87 .PHONEY: clean_fangle_docs
88 clean_fangle_docs: clean_tex clean_pdf
89 clean: clean_fangle_docs
91 distclean_fangle_docs: clean_tex clean_fangle_docs
92 distclean: clean distclean_fangle_docs