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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
# config
srcdir = .
VPATH = $(srcdir)
-include Make.config
include $(srcdir)/mk/Variables.mk
resdir = $(DESTDIR)$(RESDIR)
# fixup flags
CFLAGS += -DVERSION='"$(VERSION)"' -I$(srcdir)
CFLAGS += -Wno-pointer-sign
# hard build deps
PKG_CONFIG = pkg-config
PKGS_IDA := libexif
PKGS_FBI := freetype2 fontconfig libdrm libexif
PKGS_FBPDF := libdrm poppler-glib gbm epoxy cairo-gl
HAVE_DEPS := $(shell $(PKG_CONFIG) $(PKGS_FBI) $(PKGS_FBPDF) && echo yes)
ifeq ($(HAVE_LINUX_FB_H),yes)
ifneq ($(HAVE_DEPS),yes)
.PHONY: deps
deps:
@echo "Build dependencies missing for fbi and/or fbpdf."
@echo " fbi needs: $(PKGS_FBI)"
@echo " fbpdf needs: $(PKGS_FBPDF)"
@echo "Please install."
@false
endif
endif
# default target
all: build
# what to build
TARGETS := exiftran thumbnail.cgi
ifeq ($(HAVE_LINUX_FB_H),yes)
TARGETS += fbi fbpdf kbdtest
endif
ifeq ($(HAVE_MOTIF),yes)
TARGETS += ida
endif
#################################################################
# poor man's autoconf ;-)
include $(srcdir)/mk/Autoconf.mk
ac_jpeg_ver = $(shell \
$(call ac_init,for libjpeg version);\
$(call ac_s_cmd,echo JPEG_LIB_VERSION \
| cpp -include jpeglib.h | tail -n 1);\
$(call ac_fini))
define make-config
LIB := $(LIB)
RESDIR := $(call ac_resdir)
HAVE_ENDIAN_H := $(call ac_header,endian.h)
HAVE_LINUX_FB_H := $(call ac_header,linux/fb.h)
HAVE_NEW_EXIF := $(call ac_header,libexif/exif-log.h)
HAVE_GLIBC := $(call ac_func,fopencookie)
HAVE_STRSIGNAL := $(call ac_func,strsignal)
HAVE_LIBPCD := $(call ac_lib,pcd_open,pcd)
HAVE_LIBGIF := $(call ac_lib,DGifOpenFileName,gif)
HAVE_LIBPNG := $(call ac_pkg_config,libpng)
HAVE_LIBTIFF := $(call ac_pkg_config,libtiff-4)
HAVE_LIBWEBP := $(call ac_pkg_config,libwebp)
HAVE_LIBSANE := $(call ac_lib,sane_init,sane)
HAVE_LIBCURL := $(call ac_lib,curl_easy_init,curl)
HAVE_LIBLIRC := $(call ac_lib,lirc_init,lirc_client)
HAVE_MOTIF := $(call ac_lib,XmStringGenerate,Xm,-L/usr/X11R6/$(LIB) -lXpm -lXt -lXext -lX11)
JPEG_VER := $(call ac_jpeg_ver)
endef
# transposing
CFLAGS += -Ijpeg/$(JPEG_VER)
# transparent http/ftp access using curl depends on fopencookie (glibc)
ifneq ($(HAVE_GLIBC),yes)
HAVE_LIBCURL := no
endif
# catch fopen calls for transparent ftp/http access
ifeq ($(HAVE_LIBCURL),yes)
ida fbi : CFLAGS += -D_GNU_SOURCE
ida fbi : LDFLAGS += -Wl,--wrap=fopen
endif
########################################################################
# conditional stuff
includes = ENDIAN_H STRSIGNAL NEW_EXIF
libraries = PCD GIF PNG TIFF WEBP CURL SANE LIRC
ida_libs = PCD GIF PNG TIFF WEBP CURL SANE
fbi_libs = PCD GIF PNG TIFF WEBP CURL LIRC
PNG_LDLIBS := $(shell $(PKG_CONFIG) --libs libpng)
TIFF_LDLIBS := $(shell $(PKG_CONFIG) --libs libtiff-4)
WEBP_LDLIBS := $(shell $(PKG_CONFIG) --libs libwebp)
PCD_LDLIBS := -lpcd
GIF_LDLIBS := -lgif
SANE_LDLIBS := -lsane
CURL_LDLIBS := -lcurl
LIRC_LDLIBS := -llirc_client
PNG_OBJS := rd/read-png.o wr/write-png.o
TIFF_OBJS := rd/read-tiff.o wr/write-tiff.o
WEBP_OBJS := rd/read-webp.o
PCD_OBJS := rd/read-pcd.o
GIF_OBJS := rd/read-gif.o
SANE_OBJS := sane.o
CURL_OBJS := curl.o
LIRC_OBJS := lirc.o
# common objs
OBJS_READER := readers.o rd/read-ppm.o rd/read-bmp.o rd/read-jpeg.o
OBJS_WRITER := writers.o wr/write-ppm.o wr/write-ps.o wr/write-jpeg.o
# update various flags depending on HAVE_*
CFLAGS += $(call ac_inc_cflags,$(includes))
CFLAGS += $(call ac_lib_cflags,$(libraries))
CFLAGS += $(call ac_lib_mkvar,$(libraries),CFLAGS)
LDFLAGS += $(call ac_lib_mkvar,$(libraries),LDFLAGS)
# link which conditional libs
ida : LDLIBS += $(call ac_lib_mkvar,$(ida_libs),LDLIBS)
fbi : LDLIBS += $(call ac_lib_mkvar,$(fbi_libs),LDLIBS)
########################################################################
# rules for the small tools
# jpeg/exif libs
exiftran : LDLIBS += -ljpeg -lexif -lm
thumbnail.cgi : LDLIBS += -lexif -lm
exiftran: exiftran.o genthumbnail.o jpegtools.o \
jpeg/$(JPEG_VER)/transupp.o \
filter.o op.o readers.o rd/read-jpeg.o
thumbnail.cgi: thumbnail.cgi.o
########################################################################
# rules for ida
# object files
OBJS_IDA := \
ida.o man.o hex.o x11.o viewer.o dither.o icons.o \
parseconfig.o idaconfig.o fileops.o desktop.o \
RegEdit.o selections.o xdnd.o jpeg/$(JPEG_VER)/transupp.o \
filebutton.o filelist.o browser.o jpegtools.o \
op.o filter.o lut.o color.o \
rd/read-xwd.o rd/read-xpm.o
OBJS_IDA += $(call ac_lib_mkvar,$(ida_libs),OBJS)
# for X11 + Motif
ida : CFLAGS += -I/usr/X11R6/include
ida : LDFLAGS += -L/usr/X11R6/$(LIB)
ida : LDLIBS += -lXm -lXpm -lXt -lXext -lX11
# jpeg/exif libs
ida : CFLAGS += $(shell $(PKG_CONFIG) --cflags $(PKGS_IDA))
ida : LDLIBS += $(shell $(PKG_CONFIG) --libs $(PKGS_IDA))
ida : LDLIBS += -ljpeg -lm
# RegEdit.c is good old K&R ...
RegEdit.o : CFLAGS += -Wno-missing-prototypes -Wno-strict-prototypes -Wno-maybe-uninitialized
ida: $(OBJS_IDA) $(OBJS_READER) $(OBJS_WRITER)
Ida.ad.h: Ida.ad $(srcdir)/fallback.pl
perl $(srcdir)/fallback.pl < $< > $@
logo.h: logo.jpg
hexdump -v -e '1/1 "0x%02x,"' < $< > $@
echo >> $@ # make gcc 3.x happy
ida.o: Ida.ad.h logo.h
########################################################################
# rules for fbi
# object files
OBJS_FBI := \
fbi.o vt.o kbd.o fbtools.o drmtools.o fb-gui.o desktop.o \
parseconfig.o fbiconfig.o \
jpegtools.o jpeg/$(JPEG_VER)/transupp.o \
dither.o filter.o op.o
OBJS_FBI += $(filter-out wr/%,$(call ac_lib_mkvar,$(fbi_libs),OBJS))
# font + drm + jpeg/exif libs
fbi : CFLAGS += $(shell $(PKG_CONFIG) --cflags $(PKGS_FBI))
fbi : LDLIBS += $(shell $(PKG_CONFIG) --libs $(PKGS_FBI))
fbi : LDLIBS += -ljpeg -lm
fbi: $(OBJS_FBI) $(OBJS_READER)
########################################################################
# rules for fbpdf
# object files
OBJS_FBPDF := \
fbpdf.o vt.o kbd.o fbtools.o drmtools.o drmtools-egl.o \
fbiconfig.o parseconfig.o
# font + drm + jpeg/exif libs
fbpdf : CFLAGS += $(shell $(PKG_CONFIG) --cflags $(PKGS_FBPDF))
fbpdf : LDLIBS += $(shell $(PKG_CONFIG) --libs $(PKGS_FBPDF))
fbpdf: $(OBJS_FBPDF)
########################################################################
# rules for kbdtest
kbdtest : kbdtest.o kbd.o
########################################################################
# general rules
.PHONY: check-libjpeg build install clean distclean realclean
build: check-libjpeg $(TARGETS)
check-libjpeg:
@test -d jpeg/$(JPEG_VER) || \
( echo "Need files from libjpeg $(JPEG_VER) in jpeg/"; false)
install: build
$(INSTALL_DIR) $(bindir)
$(INSTALL_DIR) $(mandir)/man1
$(INSTALL_BINARY) exiftran $(bindir)
$(INSTALL_DATA) $(srcdir)/exiftran.man $(mandir)/man1/exiftran.1
ifeq ($(HAVE_LINUX_FB_H),yes)
$(INSTALL_BINARY) fbi $(bindir)
$(INSTALL_SCRIPT) fbgs $(bindir)
$(INSTALL_SCRIPT) fbpdf $(bindir)
$(INSTALL_DATA) $(srcdir)/fbi.man $(mandir)/man1/fbi.1
$(INSTALL_DATA) $(srcdir)/fbgs.man $(mandir)/man1/fbgs.1
endif
ifeq ($(HAVE_MOTIF),yes)
$(INSTALL_BINARY) ida $(bindir)
$(INSTALL_DATA) $(srcdir)/ida.man $(mandir)/man1/ida.1
$(INSTALL_DIR) $(resdir)/app-defaults
$(INSTALL_DATA) $(srcdir)/Ida.ad $(resdir)/app-defaults/Ida
endif
clean:
-rm -f *.o jpeg/$(JPEG_VER)/*.o rd/*.o wr/*.o $(depfiles) core core.*
realclean distclean: clean
-rm -f Make.config
-rm -f $(TARGETS) *~ rd/*~ wr/*~ xpm/*~ Ida.ad.h logo.h
include $(srcdir)/mk/Compile.mk
-include $(depfiles)
########################################################################
# maintainer stuff
include $(srcdir)/mk/Maintainer.mk
#sync::
# cp $(srcdir)/../xawtv/common/parseconfig.[ch] $(srcdir)
# cp $(srcdir)/../xawtv/console/fbtools.[ch] $(srcdir)
|