1#
2# $Id: Makefile,v 1.7 1995/03/06 14:00:00 leisner Exp leisner $
3ifeq "$(origin CC)" "default"
4CC=gcc
5endif
6
7# use cp backup option if you have gnu cp
8#CP=cp
9#CP=cp -b
10
11# where you want to install
12ifndef PREFIX
13PREFIX=/usr/local
14endif
15
16# which shell do we use for the cflow to script?
17# I know it works on bash on unix, it also should work with
18# msh on ms-dog
19ifndef CFLOW_SHELL
20CFLOW_SHELL=$(PREFIX)/bin/bash
21endif
22
23# actual location of prcc
24PRCC_LOC=$(PREFIX)/bin/prcc
25
26# actual location of prcg
27PRCG_LOC=$(PREFIX)/bin/prcg
28
29# CFLOW_SHELL=/usr/gnu/bin/bash
30
31PROGS=prcc prcg
32# I've seen very long names, and it broke badly with them...
33
34DEFS=-DNAME_MAX=50
35
36# Set if you use Gray Watson dmalloc library
37# MALLOC_DEBUG=true
38ifdef MALLOC_DEBUG
39LOADLIBES=-L$(HOME)/lib -ldmalloc
40endif
41
42#DEBUG=-g
43#OPT=-O
44CFLAGS+=$(DEBUG) $(OPT) $(DEFS)
45
46# set this to where to install
47BINDIR=$(DESTDIR)$(PREFIX)/bin
48MANDIR=$(DESTDIR)$(PREFIX)/man/man1
49
50SRCS=cflow.sh prcc.c prcg.c
51
52PROGS=	prcc prcg
53
54all: $(PROGS)  cflow
55
56$(PROGS):	%:	%.o
57
58
59
60PROTOTYPES= prcc.prototypes.h prcg.prototypes.h
61
62
63
64.PHONY:  $(PROTOTYPES)
65prototypes: 	$(PROTOTYPES)
66
67
68install:	install-cflow  install-bins install-man
69
70install-bins: $(BINDIR)/prcc $(BINDIR)/prcg
71
72install-cflow:	$(BINDIR)/cflow
73
74install-man:	$(MANDIR)/cflow.1.gz
75
76$(BINDIR)/prcc $(BINDIR)/prcg: $(BINDIR)/%:	%
77	$(BSD_INSTALL_PROGRAM) $^ $@
78
79$(BINDIR)/cflow:	cflow
80	$(BSD_INSTALL_SCRIPT) $^ $@
81
82$(MANDIR)/cflow.1.gz:	cflow.1
83	$(BSD_INSTALL_MAN) $^ $(MANDIR)
84	gzip -9nf $(MANDIR)/cflow.1
85
86cflow:	cflow.sh
87	sed -e "s;@CFLOW_SHELL@;$(CFLOW_SHELL);g" \
88	    -e "s;@PRCC@;$(PRCC_LOC);" \
89	    -e "s;@PRCG@;$(PRCG_LOC);" $< >$@
90	chmod +x $@
91
92
93test:	cflow
94	./cflow -X 'errno.h stdlib.h' prcc.c >test.prcc
95	./cflow -X 'errno.h stdlib.h' -i prcc.c >test.i.prcc
96	diff examples/prcc.cflow test.prcc
97	diff examples/prcc.i.cflow test.i.prcc
98	# if we got this far, remove examples
99	rm test.i.prcc test.prcc
100
101$(PROTOTYPES):	%.prototypes.h:	%.c
102	cproto -s $^ >$@
103
104clean::
105	-rm $(PROGS) *.o test.prcc test.i.prcc
106
107
108DISTFILES= cflow.lsm $(PROTOTYPES)  TODO  examples cflow.txt cflow.1 $(SRCS) INSTALL  README Makefile
109
110tar:	cflow.txt examples
111	tar -czf cflow.tar.gz $(DISTFILES)
112	@rm cflow.txt
113
114
115shar:	cflow.txt examples
116	shar -T $(DISTFILES)  >cflow.shar
117	@rm cflow.txt
118
119.PHONY: examples
120examples:
121	-mkdir examples
122	cflow -X 'errno.h stdlib.h' prcc.c >examples/prcc.cflow
123	cflow -X 'errno.h stdlib.h' -i prcc.c >examples/prcc.i.cflow
124
125
126rcsdiff:
127	rcsdiff cflow.1 cflow.sh prcc.c prcg.c Makefile
128
129
130cflow.txt:	cflow.1
131	groff -Tascii -mandoc $< >$@
132
133dos-cflow:
134	$(MAKE) CFLOW_SHELL=/marty/bin/shdos16 PREFIX=/dos/marty  install-cflow
135zip:
136
137