File: Makefile

package info (click to toggle)
dpic 2023.06.01-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,868 kB
  • sloc: ansic: 10,262; yacc: 5,827; makefile: 286; sh: 156; awk: 129; sed: 32
file content (139 lines) | stat: -rw-r--r-- 3,878 bytes parent folder | download
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Makefile for dpic
# Type `make' to compile the sources and produce an executable file
# Type `make install' or, to install in /usr/local, type
# `make PREFIX=local install'  You might have to to precede the command
# with `sudo'.
# 
# To comple in safe mode, type 'make SAFEMODE=-DSAFE_MODE'
#
# To enable debug, type `make DEBUG=-DDDEBUG'
# Then e.g., `./dpic -1 <options> <file>.pic' writes level-1 debug information
# to file dpic.log.  Alternately, insert the line &1 in the diagram source.
#
# Linux expects "make DESTDIR=xxx PREFIX=yyy install":
DESTDIR = /usr
PREFIX = .
DEST = ${DESTDIR}/${PREFIX}/bin

# Activate debug:
# DEBUG = -DDDEBUG
# Debug with -g flag:
# DEBUG = -g -DDDEBUG

# Server operation: Use the -z option or uncomment the following to compile
# with read and write access (sh and copy) to arbitrary files disabled.
# SAFEMODE= -DSAFE_MODE

# For DJGPP compilation:
# CFLAGS += -mcpu=pentium -march=i386

# MinGW
# LIBS += -lm -liberty

#--------------------------------------------------------------------------

MANDIR = $(DESTDIR)/$(PREFIX)/share/man/man1
DOCDIR = $(DESTDIR)/$(PREFIX)/share/doc/dpic

#-----------------------------------------------------------------------

DEFS=   
LIBS += -lm 

CC=gcc
CFLAGS += $(DEBUG) $(SAFEMODE) $(DEFS)
LDFLAGS += $(LIBS)
CPPFLAGS +=

BISON = bison

#DATE = `date +%Y.%m.%d`
DATE=2023.06.01

#-----------------------------------------------------------------------

OBJECTS = main.o parser.o backend.o

CMPRS = awk '{ b=b" "$$0; if(length(b) > 60){print b; b=""}}; END{print b}'

TABLES = entryhp.h entrytv.h lxch.h lxhp.h lxnp.h lxtv.h lxcst.h tokens.y \
  lxvars.h

dpic: $(OBJECTS)
	@if test "$(DEBUG)" != "" ; then make test/bisonlog.sed ; fi
	$(CC) $(CFLAGS) -o dpic $(OBJECTS) $(LDFLAGS)

main.o: main.c dpic.h $(TABLES) dpic.tab.h dpic.tab.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c main.c

backend.o: backend.c ps.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c backend.c

parser.o: parscst.h dpic.tab.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c -o parser.o dpic.tab.c

dpic.tab.c dpic.tab.h: dpic.y
	$(BISON) -d dpic.y
#	$(BISON) -d --debug --verbose dpic.y
	if test "$(DEBUG)" != "" ; then sed -f produce.sed dpic.tab.c > xxx ; \
      mv xxx dpic.tab.c ; fi

dpic.y: $(TABLES) parser.w
	sed -e '/end tokens/,$$d'  parser.w > dpic.y
	cat tokens.y >> dpic.y
	sed -e '1,/start tokens/d' parser.w >> dpic.y

parscst.h: dpic.y
	$(BISON) --verbose dpic.y
	sed -e '1,/^Grammar/d' -e 's/://' dpic.output | \
      sed -e '1,3d' -e '/^Terminals/,$$d' | awk -f mkparscst.awk > parscst.h
	sed -e '1,/^Grammar/d' dpic.output | \
      sed -e '/^Terminals/,$$d' | sed -e 's/^......//' > grammar.txt

test/bisonlog.sed: parscst.h
	mkdir -p test
	sed -e \
      's%^.define \([^ ]*\) [^0-9]*\([0-9][0-9]*\)$$%s/\\(Production(.\*,p=\2\\))/\\1=\1)/%' \
       parscst.h > test/bisonlog.sed

$(TABLES): dpic.toks
	awk -f lextables.awk dpic.toks
	sed -f lexerr.sed tokens.y > xxx; mv xxx tokens.y

install: installdpic installdocs

installdpic: dpic
	mkdir -p $(DEST)
	if test -x dpic.exe ; then \
      strip dpic.exe; install dpic.exe $(DEST) ; \
    else \
      strip dpic; install -m 755 dpic $(DEST) ; \
    fi

installdocs: dpic-doc.pdf
	mkdir -p $(DOCDIR)
	mkdir -p $(MANDIR)
	install -m 644 dpic-doc.pdf $(DOCDIR)
	install -m 644 doc/dpictools.pic $(DOCDIR)
	cat doc/dpic.1 | gzip > $(MANDIR)/dpic.1.gz

uninstall:
	rm -f $(DOCDIR)/dpic-doc.pdf
	rm -f $(DOCDIR)/dpictools.pic
	rm -f $(MANDIR)/dpic.1.gz
	rm -f $(DEST)/dpic $(DEST)/dpic.exe

clean:
	rm -f dpic dpic.exe *.o

veryclean: clean
	rm -f entr* *.list lxch.h lxcst.h lxhp.h lxmax.h lxnp.h lxtv.h lxvars.h
	rm -f lxcst.p
	rm -f Grammar.src parscst.h
	rm -f tabletoks tokens tokens.y tvterminals sortedtoks
	rm -f *.tab.c *.tab.h dpic.y errors
	rm -f *.o dpic.exe *stackdump *.log *.output test/bisonlog.sed
	( cd test; rm -f *.ps *.dvi *.aux *.log *stackdump )


distclean: clean