summaryrefslogtreecommitdiff
path: root/Makefile
blob: 3f8404e7592f23a260d6ed7fa7f85bd1d0f9b473 (plain)
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# Makefile for building mupdf and related stuff
# Valid option to make:
# CFG=[rel|dbg] - dbg if not given
# WITH_JASPER=[yes|no] -default: yes

# Symbolic names for HOST variable
HOST_LINUX := Linux
HOST_MAC := Darwin
HOST_CYGWIN := CYGWIN_NT-6.0

# HOST can be: Linux, Darwin, CYGWIN_NT-6.0
HOST := $(shell uname -s)

VPATH=base:raster:world:stream:mupdf:apps

# make dbg default target if none provided
ifeq ($(CFG),)
CFG=dbg
endif

ifeq ($(WITH_JASPER),)
WITH_JASPER=yes
endif

INCS = -I include

FREETYPE_CFLAGS  = `freetype-config --cflags`
FREETYPE_LDFLAGS = `freetype-config --libs`

FONTCONFIG_CFLAGS  = `pkg-config fontconfig --cflags`
FONTCONFIG_LDFLAGS = `pkg-config fontconfig --libs`

# cc-option
# Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)

cc-option = $(shell if $(CC) $(OP_CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
              > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)

CFLAGS += -g -Wall
CFLAGS += $(call cc-option, -Wno-pointer-sign, "")

ifeq ($(CFG),dbg)
CFLAGS += -O0  ${INCS}
else
CFLAGS += -O2 ${INCS} -DNDEBUG
endif

ifeq ($(HOST),$(HOST_LINUX))
CFLAGS += -std=gnu99 -DHAVE_C99
endif

ifeq ($(HOST),$(HOST_MAC))
CFLAGS += -std=gnu99 -DHAVE_C99
endif

CFLAGS += ${FREETYPE_CFLAGS} ${FONTCONFIG_CFLAGS}

LDFLAGS += ${FREETYPE_LDFLAGS} ${FONTCONFIG_LDFLAGS} -lm -ljpeg

ifeq ($(WITH_JASPER),yes)
CFLAGS += -DHAVE_JASPER
LDFLAGS += -ljasper
endif

OUTDIR=obj-$(CFG)

BASE_SRC = \
	base_memory.c \
	base_error.c \
	base_hash.c \
	base_matrix.c \
	base_rect.c \
	base_rune.c \

ifeq ($(HOST),$(HOST_LINUX))
BASE_SRC += \
	util_strlcat.c \
	util_strlcpy.c

CFLAGS += -DNEED_STRLCPY
endif

# ./base/util_strsep.c \
#./base/util_getopt.c
#./base/base_cleanname.c
#./base/base_cpudep.c

STREAM_SRC = \
	crypt_arc4.c \
	crypt_crc32.c \
	crypt_md5.c \
	filt_a85d.c \
	filt_a85e.c \
	filt_ahxd.c \
	filt_ahxe.c \
	filt_arc4.c \
	filt_faxd.c \
	filt_faxdtab.c \
	filt_faxe.c \
	filt_faxetab.c \
	filt_flate.c \
	filt_lzwd.c \
	filt_lzwe.c \
	filt_null.c \
	filt_pipeline.c \
	filt_predict.c \
	filt_rld.c \
	filt_rle.c \
	obj_array.c \
	obj_dict.c \
	obj_parse.c \
	obj_print.c \
	obj_simple.c \
	stm_buffer.c \
	stm_filter.c \
	stm_misc.c \
	stm_open.c \
	stm_read.c \
	stm_write.c \
	filt_dctd.c \
	filt_dcte.c \

ifeq ($(WITH_JASPER),yes)
STREAM_SRC += filt_jpxd.c
endif

#filt_jbig2d.c \

RASTER_SRC = \
	archx86.c \
	blendmodes.c \
	imagescale.c \
	pathfill.c \
	pixmap.c \
	glyphcache.c \
	imageunpack.c \
	pathscan.c \
	porterduff.c \
	imagedraw.c \
	meshdraw.c \
	pathstroke.c \
	render.c \

WORLD_SRC = \
	node_misc1.c \
	node_misc2.c \
	node_optimize.c \
	node_path.c \
	node_text.c \
	node_toxml.c \
	node_tree.c \
	res_colorspace.c \
	res_font.c \
	res_image.c \
	res_shade.c \

#node_tolisp.c \

MUPDF_SRC = \
	pdf_annot.c \
	pdf_build.c \
	pdf_cmap.c \
	pdf_colorspace1.c \
	pdf_colorspace2.c \
	pdf_crypt.c \
	pdf_debug.c \
	pdf_doctor.c \
	pdf_font.c \
	pdf_fontagl.c \
	pdf_fontenc.c \
	pdf_function.c \
	pdf_image.c \
	pdf_interpret.c \
	pdf_lex.c \
	pdf_nametree.c \
	pdf_open.c \
	pdf_outline.c \
	pdf_page.c \
	pdf_pagetree.c \
	pdf_parse.c \
	pdf_pattern.c \
	pdf_repair.c \
	pdf_resources.c \
	pdf_save.c \
	pdf_shade.c \
	pdf_shade1.c \
	pdf_shade4.c \
	pdf_store.c \
	pdf_stream.c \
	pdf_type3.c \
	pdf_unicode.c \
	pdf_xobject.c \
	pdf_xref.c \
	pdf_fontfilefc.c \

# pdf_fontfile.c \  # Built-in fonts
# pdf_fontfilems.c \ # windows fonts

LIBS_SRC = \
	${BASE_SRC} \
	${STREAM_SRC} \
	${RASTER_SRC} \
	${WORLD_SRC} \
	${MUPDF_SRC} \

PDFTOOL_SRC = \
	${LIBS_SRC} \
	pdftool.c
PDFTOOL_OBJ = $(patsubst %.c, $(OUTDIR)/FITZ_%.o, ${PDFTOOL_SRC})
PDFTOOL_APP = ${OUTDIR}/pdftool

all: inform ${OUTDIR} ${PDFTOOL_APP}

$(OUTDIR):
	@mkdir -p $(OUTDIR)

$(PDFTOOL_APP): ${PDFTOOL_OBJ}
	$(CC) -g -o $@ $^ ${LDFLAGS}

$(OUTDIR)/FITZ_%.o: %.c
	$(CC) -c $(CFLAGS) -o $@ $<

inform:
ifneq ($(CFG),rel)
ifneq ($(CFG),dbg)
	@echo "Invalid configuration: '"$(CFG)"'"
	@echo "Valid configurations: rel, dbg (e.g. make CFG=dbg)"
	@exit 1
endif
endif

clean: inform
	rm -rf obj-$(CFG)

cleanall:
	rm -rf obj-*

#./apps/common/pdfapp.c
#./apps/mozilla/moz_main.c
#./apps/mozilla/npunix.c
#./apps/unix/x11pdf.c
#./apps/unix/ximage.c
#./apps/windows/winmain.c