"Fossies" - the Fresh Open Source Software Archive

Member "pp-2.14.3/Makefile" (24 Nov 2021, 8651 Bytes) of package /linux/privat/pp-2.14.3.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "Makefile": 2.14.2_vs_2.14.3.

    1 # PP
    2 # Copyright (C) 2015-2021 Christophe Delord
    3 # http://cdelord.fr/pp
    4 #
    5 # This file is part of PP.
    6 #
    7 # PP is free software: you can redistribute it and/or modify
    8 # it under the terms of the GNU General Public License as published by
    9 # the Free Software Foundation, either version 3 of the License, or
   10 # (at your option) any later version.
   11 #
   12 # PP is distributed in the hope that it will be useful,
   13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
   14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   15 # GNU General Public License for more details.
   16 #
   17 # You should have received a copy of the GNU General Public License
   18 # along with PP.  If not, see <http://www.gnu.org/licenses/>.
   19 
   20 SHELL = /bin/bash
   21 .SHELLFLAGS = -o pipefail -c
   22 
   23 title = /bin/echo -e "\x1b[1m\x1b[32m\#\#\#\# $1\x1b[0m"
   24 ok = /bin/echo -e "\x1b[1m\x1b[32m[OK] $1\x1b[0m"
   25 
   26 #####################################################################
   27 # Platform detection
   28 #####################################################################
   29 
   30 OS := $(shell uname)
   31 
   32 export STACK_WORK	:= .stack-work
   33 BUILD 				:= $(STACK_WORK)
   34 BIN_DIR 			:= $(shell stack path --local-install-root)/bin
   35 
   36 PP 		= $(BIN_DIR)/pp
   37 PP_WINE	= $(BUILD)/wine/pp.exe
   38 
   39 compile: $(PP)
   40 doc: README.md doc/pp.html
   41 dist: pp.tgz
   42 
   43 all: compile doc test dist
   44 
   45 # Linux
   46 ifeq "$(OS)" "Linux"
   47 
   48 dist: pp-linux-$(shell uname -m).txz
   49 .PHONY: wine
   50 wine: pp-win.7z
   51 
   52 # MacOS
   53 else ifeq "$(OS)" "Darwin"
   54 
   55 dist: pp-darwin-$(shell uname -m).txz
   56 
   57 # Windows
   58 else ifeq "$(shell echo $(OS) | grep 'MSYS\|MINGW\|CYGWIN' >/dev/null && echo Windows)" "Windows"
   59 
   60 dist: pp-win.7z
   61 
   62 # Unknown platform (please contribute ;-)
   63 else
   64 $(error "Unknown platform: $(OS)")
   65 endif
   66 
   67 RESOLVER := $(shell awk '$$1=="resolver:" { print $$2 }' stack.yaml)
   68 
   69 TAG = src/Tag.hs
   70 $(shell ( test -d .git || ! test -f $(TAG) ) && ./tag.sh $(TAG))
   71 
   72 install: $(PP)
   73 	@$(call title,"installing $<")
   74 	stack install
   75 	@$(call ok,"installation done")
   76 
   77 clean:
   78 	stack clean
   79 	rm -rf $(BUILD)
   80 	rm -f doc/pp.html
   81 	rm -rf doc/img
   82 	rm -f pp*.{tgz,7z,txz}
   83 
   84 .DELETE_ON_ERROR:
   85 
   86 #####################################################################
   87 # README
   88 #####################################################################
   89 
   90 README.md: $(PP)
   91 README.md: doc/pp.md
   92 	@$(call title,"preprocessing $<")
   93 	@mkdir -p doc/img
   94 	stack exec -- pp -en -img=doc/img -DRESOLVER=$(RESOLVER) -DREADME $< | pandoc -f markdown -t gfm > $@
   95 	@$(call ok,"$@")
   96 
   97 #####################################################################
   98 # archives
   99 #####################################################################
  100 
  101 pp.tgz: Makefile $(wildcard app/*) $(wildcard doc/pp.*) $(wildcard src/*) $(wildcard tools/*) $(wildcard test/*) $(wildcard test/subdir/*) tag.sh README.md LICENSE .gitignore Setup.hs pp.cabal stack.yaml package.yaml
  102 	@$(call title,"source archive: $@")
  103 	tar -czf $@ $^
  104 
  105 ifeq "$(OS)" "Linux"
  106 pp-win.7z: $(PP_WINE)
  107 else
  108 pp-win.7z: $(PP)
  109 endif
  110 pp-win.7z: doc/pp.html
  111 	@$(call title,"Windows binary archive: $@")
  112 	7z -mx9 a $@ $(shell realpath $^)
  113 
  114 pp-linux-%.txz: $(PP) doc/pp.html
  115 	@$(call title,"Linux binary archive: $@")
  116 	tar cJf $@ --transform='s,.*/,,' $^
  117 
  118 pp-darwin-%.txz: $(PP) doc/pp.html
  119 	@$(call title,"MacOS binary archive: $@")
  120 	gtar cJf $@ --transform='s,.*/,,' $^
  121 
  122 #####################################################################
  123 # Dependencies
  124 #####################################################################
  125 
  126 PLANTUML = Plantuml
  127 PLANTUML_URL_1 = http://sourceforge.net/projects/plantuml/files/plantuml.jar
  128 PLANTUML_URL_2 = http://cdelord.fr/pp/plantuml.jar
  129 
  130 DITAA = Ditaa
  131 DITAA_URL = https://github.com/stathissideris/ditaa/releases/download/v0.11.0/ditaa-0.11.0-standalone.jar
  132 
  133 BLOB = tools/blob.hs
  134 
  135 $(BUILD)/%Jar_c.c $(BUILD)/%Jar.hs: $(BUILD)/%.jar $(BLOB)
  136 	@$(call title,"converting $< to C")
  137 	@mkdir -p $(dir $@)
  138 	stack --resolver $(RESOLVER) $(BLOB) $<
  139 	@$(call ok,"$@")
  140 
  141 $(BUILD)/$(PLANTUML).jar:
  142 	@$(call title,"downloading $(notdir $@)")
  143 	@mkdir -p $(dir $@)
  144 	wget $(PLANTUML_URL_1) -O $@ || wget $(PLANTUML_URL_2) -O $@
  145 	@$(call ok,"$@")
  146 
  147 $(BUILD)/$(DITAA).jar:
  148 	@$(call title,"downloading $(notdir $@)")
  149 	@mkdir -p $(dir $@)
  150 	wget $(DITAA_URL) -O $@
  151 	@$(call ok,"$@")
  152 
  153 #####################################################################
  154 # PP
  155 #####################################################################
  156 
  157 LIB_SOURCES = $(wildcard src/*.hs)
  158 LIB_SOURCES += $(BUILD)/$(PLANTUML)Jar_c.c $(BUILD)/$(PLANTUML)Jar.hs
  159 LIB_SOURCES += $(BUILD)/$(DITAA)Jar_c.c $(BUILD)/$(DITAA)Jar.hs
  160 PP_SOURCES = app/pp.hs
  161 
  162 $(PP): package.yaml
  163 $(PP): $(PP_SOURCES) $(LIB_SOURCES)
  164 	@$(call title,"building $@")
  165 	stack build
  166 	@$(call ok,"$@")
  167 
  168 $(PP_WINE): package.yaml
  169 $(PP_WINE): $(PP_SOURCES) $(LIB_SOURCES)
  170 	@$(call title,"building $@")
  171 	@mkdir -p $(dir $@)
  172 	wine ghc --make $(PP_SOURCES) $(LIB_SOURCES) -o $@ -dumpdir $(dir $@) -hidir $(dir $@) -odir $(dir $@) -outputdir $(dir $@) -stubdir $(dir $@) -tmpdir $(dir $@)
  173 	@$(call ok,"$@")
  174 
  175 doc/pp.html: $(PP) doc/pp.css
  176 doc/pp.html: doc/pp.md
  177 	@$(call title,"preprocessing $<")
  178 	@mkdir -p $(dir $@) doc/img
  179 	stack exec -- pp -en -img=doc/img -DRESOLVER=$(RESOLVER) $< | pandoc --toc --self-contained -c doc/pp.css -f markdown -t html5 > $@
  180 	@$(call ok,"$@")
  181 
  182 #####################################################################
  183 # tests
  184 #####################################################################
  185 
  186 .PHONY: test hspec test-md test-rst test-formats
  187 
  188 test: hspec test-md test-rst test-md-d test-formats
  189 	@$(call ok,"all pp tests passed!")
  190 
  191 # Hspec tests
  192 
  193 hspec: test/Spec.hs $(LIB_SOURCES)
  194 	stack test
  195 
  196 # Markdown test
  197 
  198 test-md: $(BUILD)/pp-test.output test/pp-test.ref
  199 	@$(call title,"checking $<")
  200 	diff -b -B $^
  201 	@$(call ok,"Markdown test passed!")
  202 
  203 $(BUILD)/pp-test.output: $(PP) doc/pp.css
  204 $(BUILD)/pp-test.output: test/pp-test.md test/subdir/pp-test.i test/subdir/pp-test-lib.i test/subdir/mustache.yaml test/subdir/mustache.json
  205 	@$(call title,"preprocessing $<")
  206 	@mkdir -p $(BUILD)/img
  207 	TESTENVVAR=42 stack exec -- pp -md -img="[$(BUILD)/]img" -DRESOLVER=$(RESOLVER) -en -html -import=test/subdir/pp-test-lib.i $< > $@
  208 	pandoc --toc -c doc/pp.css -f markdown -t html5 $@ -o $(@:.output=.html)
  209 
  210 .PHONY: ref
  211 ref: $(BUILD)/pp-test.output
  212 	meld $< test/pp-test.ref 2>/dev/null
  213 
  214 # reStructuredText test
  215 
  216 test-rst: $(BUILD)/pp-test-rst.output test/pp-test-rst.ref
  217 	@$(call title,"checking $<")
  218 	diff -b -B $^
  219 	@$(call ok,"reStructuredText test passed!")
  220 
  221 $(BUILD)/pp-test-rst.output: $(PP) doc/pp.css
  222 $(BUILD)/pp-test-rst.output: test/pp-test.rst
  223 	@$(call title,"preprocessing $<")
  224 	@mkdir -p $(BUILD)/img
  225 	TESTENVVAR=42 stack exec -- pp -rst -img="[$(BUILD)/]img" -en -html $< > $@
  226 	pandoc --toc -c doc/pp.css -f rst -t html5 $@ -o $(@:.output=.html)
  227 
  228 .PHONY: ref-rst
  229 ref-rst: $(BUILD)/pp-test-rst.output
  230 	meld $< test/pp-test-rst.ref 2>/dev/null
  231 
  232 # Dependency list test
  233 
  234 test-md-d: $(BUILD)/pp-test.d test/pp-test.d.ref
  235 	@$(call title,"checking $<")
  236 	diff -b -B $^
  237 	@$(call ok,"Dependency test passed!")
  238 
  239 $(BUILD)/pp-test.d: $(PP)
  240 $(BUILD)/pp-test.d: test/pp-test.md test/subdir/pp-test.i test/subdir/pp-test-lib.i
  241 	@$(call title,"tracking dependencies of $<")
  242 	@mkdir -p $(BUILD)/img
  243 	TESTENVVAR=42 stack exec -- pp -M outputfile -md -img="[$(BUILD)/]img" -DRESOLVER=$(RESOLVER) -en -html -import=test/subdir/pp-test-lib.i $< > $@
  244 
  245 .PHONY: ref-d
  246 ref-d: $(BUILD)/pp-test.d
  247 	meld $< test/pp-test.d.ref 2>/dev/null
  248 
  249 # Diagram formats tests
  250 
  251 test-formats: $(BUILD)/test-format.html \
  252 			  $(BUILD)/test-format.pdf \
  253 			  $(BUILD)/test-format.odt \
  254 			  $(BUILD)/test-format.epub
  255 
  256 $(BUILD)/test-format.html: $(PP)
  257 $(BUILD)/test-format.html: test/formats.md
  258 	@$(call title,"checking default diagram formats for HTML documents")
  259 	stack exec -- pp -img="[$(BUILD)/]img" -html $< | pandoc -t html -o $@
  260 	@$(call ok,"default diagram formats for HTML documents works!")
  261 
  262 $(BUILD)/test-format.pdf: $(PP)
  263 $(BUILD)/test-format.pdf: test/formats.md
  264 	@$(call title,"checking default diagram formats for PDF documents")
  265 	stack exec -- pp -img="$(BUILD)/img" -pdf $< | pandoc -t latex -o $@
  266 	@$(call ok,"default diagram formats for PDF documents works!")
  267 
  268 $(BUILD)/test-format.odt: $(PP)
  269 $(BUILD)/test-format.odt: test/formats.md
  270 	@$(call title,"checking default diagram formats for ODT documents")
  271 	stack exec -- pp -img="$(BUILD)/img" -odf $< | pandoc -t odt -o $@
  272 	@$(call ok,"default diagram formats for ODT documents works!")
  273 
  274 $(BUILD)/test-format.epub: $(PP)
  275 $(BUILD)/test-format.epub: test/formats.md
  276 	@$(call title,"checking default diagram formats for EPUB documents")
  277 	stack exec -- pp -img="$(BUILD)/img" -epub $< | pandoc -t epub -o $@
  278 	@$(call ok,"default diagram formats for EPUB documents works!")