support commands in verilog mode
[gnucap-felix.git] / gnuplot.mk
blobbe0d5b2852ca8ca6babb286c81d90e46de8939fc
1 # Makefile for gnuplot related targets
2 # (c) 2012 felix salfelder
4 STYLE=data lines
5 GNUPLOT=gnuplot
6 SHELL=/bin/bash
7 COLOR=color
10 # get 4-5.1-3,5,8-9.3
11 # return {4..5}:{{1..3},5,{8..9}}:{3..3}
12 define rowlist_sh
13 comma=""; \
14 l=""; rbr=""; lbr=""; \
15 IFS=,; b=$$rowi; a=($$b); unset IFS; \
16 for i in $${a[*]}; do \
17 IFS=-; j=($$i); unset IFS;\
18 la=$${i[0]}; \
19 last=`expr $${#j[*]} - 1`; \
20 S=$$( seq -s, $${j[0]} $${j[$$last]} );\
21 S={$${j[0]}..$${j[$$last]}};\
22 l=$$l$$comma$$S; \
23 rowlist_=$$lbr$$l$$rbr; \
24 comma=","; lbr="{"; rbr="}"; \
25 done;
26 endef
28 define do_pscols2
29 $(shell echo processing $(1)>&2; \
30 colon=;\
31 pscols_tmp=$$( echo $(1) | sed -r 's/[^.]*((\.[0-9,-]+)+).*/\1/'); \
32 echo cols_raw $$pscols_tmp>&2; \
33 IFS=.; C=($$pscols_tmp); unset IFS;\
34 echo cols_raw $${C[*]}>&2; \
35 ret=;\
36 for rowi in $${C[*]}; do \
37 rowlist_=; $(rowlist_sh) \
38 ret=$$ret$$colon$$rowlist_; \
39 colon=:; \
40 done; echo $$ret; )
41 endef
43 sourcepattern='s/\(\(^\.\)*\)\.[0-9]\+\(\.[0-9,-]\+\)\+/\1.out/'
45 #FIXME: eps
46 .SECONDEXPANSION:
47 %.ps: $$(shell echo % | sed -e $(sourcepattern) )
48 CH="";\
49 head -n1 $< | grep '^[0-9\.Ee \t]*$$' >/dev/null; \
50 [[ $$? = 0 ]] || CH="set key autotitle columnhead;"; \
51 [[ $* =~ [^.]*\.[0-9]\.[0-9]\.[0-9] ]] && S=s; \
52 IFS=,; spl=$*; a=($$spl); unset IFS; \
53 # $(notdir $*); \
54 pscols_=$$(eval echo "\'$<\'\ using\ $(call do_pscols2,$(notdir $*))\,"); \
55 pscols_=$${pscols_%,} ; \
56 echo -e "set style ${STYLE}; \n \
57 $$CH \n \
58 set datafile commentschars \"\" \n \
59 set terminal postscript ${ORIENT} enhanced ${COLOR} dashed lw ${LW} 'Helvetica' 14; \n \
60 ${ECMD} set output '$@'; \n \
61 $${S}plot $$pscols_" | $(GNUPLOT)