1ifeq ($(SRCDIR)x,x) 2 SRCDIR = $(CURDIR)/../.. 3 BUILDDIR = $(SRCDIR) 4endif 5SUBDIR = converter/other 6VPATH=.:$(SRCDIR)/$(SUBDIR) 7 8include $(BUILDDIR)/config.mk 9 10# The pkg-config test used to be just 'pkg-config libxml-2.0', without the 11# --exists, and on at least one system, it does the same thing as --exists: 12# exit code 0 if the package exists; 1 if it does not, with no Standard 13# Output. But we have evidence that on one system, it issues the whole 14# package not found try a different path, blah, blah, blah message that 15# looks like a failure in the build. We're hoping --exists does not do that. 16# But maybe we didn't do --exists in the first place because it doesn't exist 17# on older pkg-config. 19.09.20. 18# 19# Note that --exists is better for another reason - it fails when the named 20# package exists, but it is unusable because its prerequisite packages don't. 21# 22# Also note that in both cases, the shell command fails if pkg-config 23# doesn't even exist. 24 25TEST_PKGCONFIG_LIBXML2 := \ 26 if $(PKG_CONFIG) libxml-2.0 --exists; then echo exists; fi 27 28ifneq ($(shell $(TEST_PKGCONFIG_LIBXML2)),) 29 # pkg-config works and says libxml2 exists on this system 30 XML2_LIBS = $(shell $(PKG_CONFIG) libxml-2.0 --libs) 31 XML2_CFLAGS = $(shell $(PKG_CONFIG) libxml-2.0 --cflags) 32else 33 ifeq ($(shell xml2-config --version),) 34 XML2_LIBS=NONE 35 XML2_CFLAGS=NONE 36 else 37 XML2_LIBS=$(shell xml2-config --libs) 38 XML2_CFLAGS=$(shell xml2-config --cflags) 39 endif 40endif 41 42SUBDIRS = jbig pnmtopalm jpeg2000 cameratopam pamtosvg 43ifneq ($(BUILD_FIASCO), N) 44 SUBDIRS += fiasco 45endif 46 47ifneq ($(TIFFLIB),NONE) 48 ifneq ($(TIFFHDR_DIR)x,x) 49 EXTERN_INCLUDES += -I$(TIFFHDR_DIR) 50 endif 51endif 52 53TEST_PKGCONFIG_LIBPNG := \ 54 if $(PKG_CONFIG) libpng$(PNGVER) --exists; then echo exists; fi 55 56ifneq ($(shell $(TEST_PKGCONFIG_LIBPNG)),) 57 # pkg-config works and says libpng exists on this system 58 HAVE_PNGLIB = Y 59 EXTERN_INCLUDES += $(shell $(PKG_CONFIG) libpng$(PNGVER) --cflags) 60else 61 ifneq ($(shell libpng$(PNGVER)-config --version),) 62 # No pkg-config, but we have libpng-config on this system 63 HAVE_PNGLIB = Y 64 EXTERN_INCLUDES += $(shell libpng$(PNGVER)-config --cflags) 65 else 66 # System can't tell us where libpng is; use stuff from config.mk 67 ifneq ($(PNGLIB),NONE) 68 HAVE_PNGLIB = Y 69 ifneq ($(PNGHDR_DIR)x,x) 70 EXTERN_INCLUDES += -I$(PNGHDR_DIR) 71 endif 72 ifneq ($(ZHDR_DIR)x,x) 73 EXTERN_INCLUDES += -I$(ZHDR_DIR) 74 endif 75 endif 76 endif 77endif 78 79ifneq ($(JPEGLIB),NONE) 80 ifneq ($(JPEGHDR_DIR)x,x) 81 EXTERN_INCLUDES += -I$(JPEGHDR_DIR) 82 endif 83endif 84ifneq ($(URTLIB),NONE) 85 ifneq ($(URTHDR_DIR)x,x) 86 EXTERN_INCLUDES += -I$(URTHDR_DIR) 87 endif 88endif 89ifneq ($(XML2_LIBS),NONE) 90 ifneq ($(XML2_CFLAGS),NONE) 91 EXTERN_INCLUDES += $(XML2_CFLAGS) 92 endif 93endif 94 95ifeq ($(TIFFLIB),NONE) 96 TIFF_PREREQ_MISSING = Y 97endif 98 99TIFFLIB_EXTRALIBS = 100ifeq ($(TIFFLIB_NEEDS_JPEG),Y) 101 ifeq ($(JPEGLIB),NONE) 102 TIFF_PREREQ_MISSING = Y 103 else 104 TIFFLIB_EXTRALIBS += $(JPEGLIB) 105 endif 106endif 107ifeq ($(TIFFLIB_NEEDS_Z),Y) 108 ifeq ($(ZLIB),NONE) 109 TIFF_PREREQ_MISSING = Y 110 else 111 TIFFLIB_EXTRALIBS += $(ZLIB) 112 endif 113endif 114 115# TIFFLIB_USERLIBS is for the user to set manually, on the make command line 116# or manually added to config.mk. There are arcane situations where the TIFF 117# library refers to additional libraries not handled above. 118 119TIFFLIB_EXTRALIBS += $(TIFFLIB_USERLIBS) 120 121# Pnmtops's "flate" compression function requires libz. But if we don't 122# have libz, we still build Pnmtops; we just omit the flate compression 123# capability. 124ifeq ($(ZLIB),NONE) 125 PNMTOPS_ZLIB_OPT = 126 PNMTOPS_NOFLATE_OPT = -DNOFLATE 127else 128 PNMTOPS_ZLIB_OPT = $(ZLIB) 129 PNMTOPS_NOFLATE_OPT = 130endif 131 132 133PORTBINARIES = avstopam bmptopnm fitstopnm \ 134 gemtopnm giftopnm hdifftopam infotopam \ 135 pamtoavs pamtodjvurle pamtofits pamtogif \ 136 pamtohdiff pamtohtmltbl pamtompfont pamtooctaveimg \ 137 pamtopam pamtopdbimg pamtopfm pamtopnm pamtosrf pamtouil \ 138 pamtowinicon pamtoxvmini \ 139 pbmtopgm pdbimgtopam pfmtopam \ 140 pgmtopbm pgmtoppm ppmtopgm pnmtoddif \ 141 pnmtopclxl pnmtorast \ 142 pnmtosgi pnmtosir pamtotga pnmtoxwd \ 143 rasttopnm rlatopam sgitopnm sirtopnm srftopam sunicontopnm \ 144 winicontopam xwdtopnm yuy2topam zeisstopnm 145 146ifneq ($(DONT_HAVE_PROCESS_MGMT),Y) 147 PORTBINARIES += pstopnm pnmtops 148endif 149 150ifeq ($(HAVE_PNGLIB),Y) 151 PORTBINARIES += pamtopng pnmtopng pngtopam 152endif 153ifneq ($(JPEGLIB),NONE) 154 PORTBINARIES += jpegtopnm pnmtojpeg 155endif 156ifneq ($(TIFF_PREREQ_MISSING),Y) 157 PORTBINARIES += tifftopnm pamtotiff pnmtotiffcmyk 158endif 159ifneq ($(URTLIB),NONE) 160 PORTBINARIES += rletopnm pnmtorle 161endif 162 163ifneq ($(XML2_LIBS),NONE) 164endif 165 166BINARIES = $(PORTBINARIES) 167 168MERGEBINARIES = $(BINARIES) 169 170EXTRA_OBJECTS = exif.o rast.o ipdb.o srf.o 171ifeq ($(HAVE_PNGLIB),Y) 172 EXTRA_OBJECTS += pngtxt.o 173 EXTRA_OBJECTS += pngx.o 174endif 175ifneq ($(JPEGLIB),NONE) 176 EXTRA_OBJECTS += jpegdatasource.o 177endif 178ifneq (($TIFF_PREREQ_MISSING),Y) 179 EXTRA_OBJECTS += tiff.o 180endif 181 182OBJECTS = $(BINARIES:%=%.o) $(EXTRA_OBJECTS) 183MERGE_OBJECTS = $(MERGEBINARIES:%=%.o2) $(EXTRA_OBJECTS) 184 185HAVE_MERGE_COMPAT=YES 186 187pnmtops.o pnmtops.o2: CFLAGS_TARGET=$(PNMTOPS_NOFLATE_OPT) 188 189SCRIPTS = anytopnm pnmtoplainpnm 190 191.PHONY: all 192all: $(BINARIES) $(SUBDIRS:%=%/all) 193 194include $(SRCDIR)/common.mk 195 196ifeq ($(NEED_RUNTIME_PATH),Y) 197 LIBOPTR = -runtime 198else 199 LIBOPTR = 200endif 201 202LIBOPTS_TIFF = $(shell $(LIBOPT) \ 203 $(LIBOPTR) $(TIFFLIB) $(TIFFLIB_EXTRALIBS)) 204 205tifftopnm pamtotiff pnmtotiffcmyk: tiff.o 206tifftopnm pamtotiff pnmtotiffcmyk: ADDL_OBJECTS = tiff.o 207tifftopnm pamtotiff pnmtotiffcmyk: \ 208 LDFLAGS_TARGET = \ 209 $(shell $(LIBOPT) $(LIBOPTR) $(TIFFLIB) $(TIFFLIB_EXTRALIBS)) 210 211ifneq ($(shell $(TEST_PKGCONFIG_LIBPNG)),) 212 # pkg-config works and says libpng exists on this system 213 PNGLIB_LIBOPTS = $(shell $(PKG_CONFIG) libpng$(PNGVER) --libs) 214else 215 ifneq ($(shell libpng$(PNGVER)-config --version),) 216 # No pkg-config, but we have libpng-config on this system 217 PNGLIB_LIBOPTS = $(shell libpng$(PNGVER)-config --ldflags) 218 else 219 # System can't tell us where libpng is; use stuff from config.mk 220 PNGLIB_LIBOPTS = $(shell $(LIBOPT) $(LIBOPTR) $(PNGLIB) $(ZLIB)) 221 endif 222endif 223 224pngtopam: pngx.o 225pngtopam: ADDL_OBJECTS = pngx.o 226pngtopam: LDFLAGS_TARGET = $(PNGLIB_LIBOPTS) 227 228pamtopng: pngx.o pngtxt.o 229pamtopng: ADDL_OBJECTS = pngx.o pngtxt.o 230pamtopng: LDFLAGS_TARGET = $(PNGLIB_LIBOPTS) 231 232pnmtopng: pngx.o pngtxt.o 233pnmtopng: ADDL_OBJECTS = pngx.o pngtxt.o 234pnmtopng: LDFLAGS_TARGET = $(PNGLIB_LIBOPTS) 235 236jpegtopnm: jpegdatasource.o exif.o 237jpegtopnm: ADDL_OBJECTS = jpegdatasource.o exif.o 238jpegtopnm: LDFLAGS_TARGET = $(shell $(LIBOPT) $(LIBOPTR) $(JPEGLIB)) 239 240srftopam pamtosrf: srf.o 241srftopam pamtosrf: ADDL_OBJECTS = srf.o 242 243pnmtojpeg: LDFLAGS_TARGET = $(shell $(LIBOPT) $(LIBOPTR) $(JPEGLIB)) 244 245 246# If URTLIB is BUNDLED_URTLIB, then we're responsible for building it, which 247# means it needs to be a dependency: 248ifeq ($(URTLIB), $(BUNDLED_URTLIB)) 249rletopnm pnmtorle: $(URTLIB) 250endif 251 252rletopnm pnmtorle: LDFLAGS_TARGET = $(shell $(LIBOPT) $(URTLIB)) 253 254pnmtops: LDFLAGS_TARGET = $(shell $(LIBOPT) $(PNMTOPS_ZLIB_OPT)) 255 256pnmtorast rasttopnm: rast.o 257pnmtorast rasttopnm: ADDL_OBJECTS = rast.o 258 259pdbimgtopam pamtopdbimg: ipdb.o 260pdbimgtopam pamtopdbimg: ADDL_OBJECTS = ipdb.o 261 262# Declare dependencies on created header files (symbolic links, actually). 263 264bmptopnm.o bmptopnm.o2: bmp.h 265 266pamtotga.o pamtotga.o2: tga.h 267 268install.bin install.merge: install.bin.local 269.PHONY: install.bin.local 270install.bin.local: $(PKGDIR)/bin 271# Remember that $(SYMLINK) might just be a copy command. 272# backward compatibility: program used to be named pnmnoraw 273 cd $(PKGDIR)/bin ; \ 274 $(SYMLINK) pnmtoplainpnm$(EXE) pnmnoraw$(EXE) 275# backward compatibility: program used to be gemtopbm 276 cd $(PKGDIR)/bin ; \ 277 $(SYMLINK) gemtopnm$(EXE) gemtopbm$(EXE) 278# In October 2001, pnmtojpeg replaced ppmtojpeg 279ifneq ($(JPEGLIB),NONE) 280 cd $(PKGDIR)/bin ; \ 281 $(SYMLINK) pnmtojpeg$(EXE) ppmtojpeg$(EXE) 282endif 283# In March 2002, bmptopnm replaced bmptoppm 284 cd $(PKGDIR)/bin ; \ 285 $(SYMLINK) bmptopnm$(EXE) bmptoppm$(EXE) 286# In May 2002, pamtouil replaced ppmtouil 287 cd $(PKGDIR)/bin ; \ 288 $(SYMLINK) pamtouil$(EXE) ppmtouil$(EXE) 289# In July 2002, pamtotga replaced ppmtotga 290 cd $(PKGDIR)/bin ; \ 291 $(SYMLINK) pamtotga$(EXE) ppmtotga$(EXE) 292# In March 2005, we realized that pamtopnm obviates pnmtopnm 293 cd $(PKGDIR)/bin ; \ 294 $(SYMLINK) pamtopnm$(EXE) pnmtopnm$(EXE) 295# In October 2005, pamtofits replaced pnmtofits 296 cd $(PKGDIR)/bin ; \ 297 $(SYMLINK) pamtofits$(EXE) pnmtofits$(EXE) 298ifneq ($(TIFF_PREREQ_MISSING),Y) 299# In October 2005, pamtotiff replaced pnmtotiff 300 cd $(PKGDIR)/bin ; \ 301 $(SYMLINK) pamtotiff$(EXE) pnmtotiff$(EXE) 302endif 303ifeq ($(HAVE_PNGLIB),Y) 304# In September 2009, pngtopam replaced pngtopnm 305 cd $(PKGDIR)/bin ; \ 306 $(SYMLINK) pngtopam$(EXE) pngtopnm$(EXE) 307endif 308# In December 2010, sunicontopnm replaced icontopbm 309 cd $(PKGDIR)/bin ; \ 310 $(SYMLINK) sunicontopnm$(EXE) icontopbm$(EXE) 311ifeq ($(HAVE_PNGLIB),Y) 312# In June 2015, pamtopng replaced pamrgbapng 313 cd $(PKGDIR)/bin ; \ 314 $(SYMLINK) pamtopng$(EXE) pamrgbatopng$(EXE) 315endif 316 317mergecomptrylist: 318 cat /dev/null >$@ 319 echo "TRY(\"bmptoppm\", main_bmptopnm);" >>$@ 320 echo "TRY(\"gemtopbm\", main_gemtopnm);" >>$@ 321ifneq ($(JPEGLIB),NONE) 322 echo "TRY(\"ppmtojpeg\", main_pnmtojpeg);" >>$@ 323endif 324 echo "TRY(\"ppmtouil\", main_pamtouil);" >>$@ 325 echo "TRY(\"ppmtotga\", main_pamtotga);" >>$@ 326 echo "TRY(\"pnmtopnm\", main_pamtopnm);" >>$@ 327 echo "TRY(\"pnmtofits\", main_pamtofits);" >>$@ 328ifneq ($(TIFF_PREREQ_MISSING),Y) 329 echo "TRY(\"pnmtotiff\", main_pamtotiff);" >>$@ 330endif 331ifeq ($(HAVE_PNGLIB),Y) 332 echo "TRY(\"pngtopnm\", main_pngtopam);" >>$@ 333endif 334 echo "TRY(\"icontopbm\", main_sunicontopnm);" >>$@ 335ifeq ($(HAVE_PNGLIB),Y) 336 echo "TRY(\"pamrgbatopng\", main_pamtopng);" >>$@ 337endif 338