1# tumble: build a PDF file from image files
2# Makefile
3# Copyright 2001, 2002, 2003, 2017 Eric Smith <spacewar@gmail.com>
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 2 as
7# published by the Free Software Foundation.  Note that permission is
8# not granted to redistribute this program under the terms of any
9# other version of the General Public License.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111  USA
19#
20#  2010-09-02 [JDB] Allow building in a directory separate from the source and
21#                   add PNG and blank-page support files.  Also change the
22#                   "include" of dependencies to suppress an error if the
23#                   dependency files are not present.
24
25
26# Conditionals:  uncomment the following defines as nessary.  Note that a
27# "0" value is considered true by make, so to disable conditionals comment
28# them out or set them to a null string.
29
30#DEBUG=1
31#EFENCE=1
32#STATIC=1
33CTL_LANG=1
34
35
36CFLAGS := $(CFLAGS)
37LDFLAGS := $(LDFLAGS)
38LDLIBS = -ltiff -ljpeg -lnetpbm -lz -lm
39
40ifdef DEBUG
41CFLAGS := $(CFLAGS) -g
42LDFLAGS := $(LDFLAGS) -g
43else
44CFLAGS := $(CFLAGS)
45endif
46
47ifdef EFENCE
48LDLIBS := $(LDLIBS) -lefence -lpthread
49endif
50
51ifdef STATIC
52LDLIBS := -Wl,-static $(LDLIBS)
53endif
54
55
56LEX = flex
57YACC = bison
58YFLAGS = -d -v
59
60
61# -----------------------------------------------------------------------------
62# You shouldn't have to change anything below this point, but if you do please
63# let me know why so I can improve this Makefile.
64# -----------------------------------------------------------------------------
65
66VERSION = 0.36
67
68PACKAGE = tumble
69
70TARGETS = tumble
71
72CSRCS = tumble.c semantics.c tumble_input.c \
73	tumble_tiff.c tumble_jpeg.c tumble_pbm.c tumble_png.c tumble_blank.c \
74	bitblt.c bitblt_table_gen.c bitblt_g4.c g4_table_gen.c \
75	pdf.c pdf_util.c pdf_prim.c pdf_name_tree.c \
76	pdf_bookmark.c pdf_page_label.c \
77	pdf_text.c pdf_g4.c pdf_jpeg.c pdf_png.c
78OSRCS = scanner.l parser.y
79HDRS = tumble.h tumble_input.h semantics.h bitblt.h bitblt_tables.h \
80	pdf.h pdf_private.h pdf_util.h pdf_prim.h pdf_name_tree.h
81MISC = COPYING README INSTALL Makefile
82
83DISTFILES = $(MISC) $(HDRS) $(CSRCS) $(OSRCS)
84DISTNAME = $(PACKAGE)-$(VERSION)
85
86BIN_DISTFILES = COPYING README $(TARGETS)
87
88
89AUTO_CSRCS = bitblt_tables.c g4_tables.c
90AUTO_HDRS = bitblt_tables.h g4_tables.h
91
92ifdef CTL_LANG
93AUTO_CSRCS += scanner.c parser.tab.c
94AUTO_HDRS += parser_tab.h
95AUTO_MISC = parser.output
96endif
97
98
99CDEFINES = -DTUMBLE_VERSION=$(VERSION)
100
101ifdef CTL_LANG
102CDEFINES += -DCTL_LANG
103endif
104
105CFLAGS := $(CFLAGS) $(CDEFINES)
106
107
108-include Maketest
109
110
111all: $(TARGETS) $(TEST_TARGETS)
112
113
114TUMBLE_OBJS = tumble.o semantics.o tumble_input.o \
115		tumble_tiff.o tumble_jpeg.o tumble_pbm.o tumble_png.o tumble_blank.o \
116		bitblt.o bitblt_g4.o bitblt_tables.o g4_tables.o \
117		pdf.o pdf_util.o pdf_prim.o pdf_name_tree.o \
118		pdf_bookmark.o pdf_page_label.o \
119		pdf_text.o pdf_g4.o pdf_jpeg.o pdf_png.o
120
121ifdef CTL_LANG
122TUMBLE_OBJS += scanner.o parser.tab.o
123endif
124
125tumble: $(TUMBLE_OBJS)
126	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
127
128
129bitblt_tables.h: bitblt_table_gen
130	./bitblt_table_gen -h >bitblt_tables.h
131
132bitblt_tables.c: bitblt_table_gen
133	./bitblt_table_gen -c >bitblt_tables.c
134
135bitblt_table_gen: bitblt_table_gen.o
136
137g4_tables.h: g4_table_gen
138	./g4_table_gen -h >g4_tables.h
139
140g4_tables.c: g4_table_gen
141	./g4_table_gen -c >g4_tables.c
142
143g4_table_gen: g4_table_gen.o
144
145
146dist: $(DISTFILES)
147	-rm -rf $(DISTNAME)
148	mkdir $(DISTNAME)
149	for f in $(DISTFILES); do ln $$f $(DISTNAME)/$$f; done
150	tar --gzip -chf $(DISTNAME).tar.gz $(DISTNAME)
151	-rm -rf $(DISTNAME)
152
153
154bin-dist-rh: $(BIN_DISTFILES) /etc/redhat-release
155	tar --gzip -chf $(DISTNAME)-rh$(shell sed 's/^Red Hat Linux release \([0-9][0-9.]*\) (.*)/\1/' </etc/redhat-release).tar.gz $(BIN_DISTFILES)
156
157bin-dist-fc: $(BIN_DISTFILES) /etc/fedora-release
158	tar --gzip -chf $(DISTNAME)-fc$(shell sed 's/^Fedora Core release \([0-9][0-9.]*\) (.*)/\1/' </etc/fedora-release).tar.gz $(BIN_DISTFILES)
159
160clean:
161	rm -f *.o *.d $(TARGETS) $(AUTO_CSRCS) $(AUTO_HDRS) $(AUTO_MISC)
162
163very_clean:
164	rm -f *.o *.d $(TARGETS) $(AUTO_CSRCS) $(AUTO_HDRS) $(AUTO_MISC) \
165		*~ *.pdf
166
167wc:
168	wc -l $(HDRS) $(CSRCS) $(OSRCS) $(MISC)
169
170ls-lt:
171	ls -lt $(HDRS) $(CSRCS) $(OSRCS) $(MISC)
172
173
174%.tab.c %.tab.h %.output: %.y
175	$(YACC) $(YFLAGS) $<
176
177
178ALL_CSRCS = $(CSRCS) $(AUTO_CSRCS) $(TEST_CSRCS)
179
180DEPENDS = $(ALL_CSRCS:.c=.d)
181
182%.d: %.c
183	$(CC) -M -MG $(CFLAGS) $< | sed -e 's@ \([A-Za-z]\):/@ /\1/@g' -e 's@^\(.*\)\.o:@\1.d \1.o:@' > $@
184
185-include $(DEPENDS)
186
187CHANGELOG.html: CHANGELOG.md
188	cmark $< >$@
189