| 1 |
ifeq ($(SRCDIR)x,x) |
| 2 |
SRCDIR = $(CURDIR)/.. |
| 3 |
BUILDDIR = $(SRCDIR) |
| 4 |
endif |
| 5 |
SUBDIR = lib |
| 6 |
VPATH=.:$(SRCDIR)/$(SUBDIR) |
| 7 |
DLLTOOL=dlltool |
| 8 |
include $(BUILDDIR)/config.mk |
| 9 |
|
| 10 |
ifeq ($(NETPBMLIBTYPE),unixstatic) |
| 11 |
LIBNETPBM = libnetpbm.$(STATICLIBSUFFIX) |
| 12 |
else |
| 13 |
LIBNETPBM = $(NETPBMSHLIBPREFIX)netpbm$(DLLVER).$(NETPBMLIBSUFFIX) |
| 14 |
endif |
| 15 |
|
| 16 |
ifeq ($(STATICLIB_TOO),Y) |
| 17 |
EXTRA_STATICLIB = libnetpbm.$(STATICLIBSUFFIX) |
| 18 |
else |
| 19 |
EXTRA_STATICLIB = |
| 20 |
endif |
| 21 |
|
| 22 |
ifeq ($(DONT_HAVE_PROCESS_MGMT),Y) |
| 23 |
LIBSYSTEM = libsystem_dummy.o |
| 24 |
else |
| 25 |
LIBSYSTEM = libsystem.o |
| 26 |
endif |
| 27 |
|
| 28 |
LIBOBJECTS = libpm.o pmfileio.o fileio.o colorname.o \ |
| 29 |
libpamd.o \ |
| 30 |
libpbm1.o libpbm2.o libpbm3.o \ |
| 31 |
libpbmfont0.o libpbmfont1.o libpbmfont2.o \ |
| 32 |
pbmfontdata0.o pbmfontdata1.o pbmfontdata2.o \ |
| 33 |
libpgm1.o libpgm2.o \ |
| 34 |
libppm1.o libppm2.o libppmcmap.o libppmcolor.o libppmfuzzy.o \ |
| 35 |
libppmd.o ppmdfont.o standardppmdfont.o path.o \ |
| 36 |
libpnm1.o libpnm2.o libpnm3.o \ |
| 37 |
libpam.o libpamread.o libpamwrite.o \ |
| 38 |
libpamn.o libpammap.o libpamcolor.o \ |
| 39 |
$(LIBSYSTEM) \ |
| 40 |
|
| 41 |
# Library objects to be linked but not built by common.mk: |
| 42 |
LIBOBJECTS_X = \ |
| 43 |
util/bitio.o \ |
| 44 |
util/filename.o \ |
| 45 |
util/io.o \ |
| 46 |
util/mallocvar.o \ |
| 47 |
util/matrix.o \ |
| 48 |
util/nsleep.o \ |
| 49 |
util/nstring.o \ |
| 50 |
util/rand.o \ |
| 51 |
util/randsysrand.o \ |
| 52 |
util/randsysrandom.o \ |
| 53 |
util/randmersenne.o \ |
| 54 |
util/runlength.o \ |
| 55 |
util/shhopt.o \ |
| 56 |
util/token.o \ |
| 57 |
util/vasprintf.o \ |
| 58 |
|
| 59 |
MANUALS3 = libnetpbm |
| 60 |
MANUALS5 = pbm pgm ppm pnm pam |
| 61 |
|
| 62 |
INTERFACE_HEADERS = colorname.h \ |
| 63 |
pam.h pamdraw.h pammap.h pbm.h pbmfont.h pbmfontdata.h \ |
| 64 |
pgm.h pm.h pm_gamma.h pm_system.h pnm.h \ |
| 65 |
ppm.h ppmcmap.h ppmdfont.h ppmdraw.h \ |
| 66 |
util/mallocvar.h util/runlength.h util/shhopt.h \ |
| 67 |
|
| 68 |
DATAFILES = rgb.txt |
| 69 |
|
| 70 |
.PHONY: all |
| 71 |
all: libnetpbm extra_staticlib |
| 72 |
|
| 73 |
SUBDIRS = util |
| 74 |
SCRIPTS = |
| 75 |
BINARIES = |
| 76 |
|
| 77 |
OMIT_LIBRARY_RULE = 1 |
| 78 |
ALL_INTERNAL_HEADER_FILES_ARE_QUALIFIED = Y |
| 79 |
include $(SRCDIR)/common.mk |
| 80 |
|
| 81 |
# The following must go after common.mk because $(LIBNETPBM) may |
| 82 |
# contain a reference to $(NETPBM_MAJOR_RELEASE). |
| 83 |
.PHONY: libnetpbm |
| 84 |
libnetpbm: $(LIBNETPBM) |
| 85 |
|
| 86 |
.PHONY: extra_staticlib |
| 87 |
extra_staticlib: $(EXTRA_STATICLIB) |
| 88 |
|
| 89 |
#---------------------------------------------------------------------------- |
| 90 |
# Following are rules for building shared libraries. |
| 91 |
# Note that the user may specify a shared library as his "main" library |
| 92 |
# type, but request a static library in addition. |
| 93 |
#---------------------------------------------------------------------------- |
| 94 |
|
| 95 |
$(LIBOBJECTS): CFLAGS_TARGET=$(CFLAGS_SHLIB) |
| 96 |
|
| 97 |
libpbm3.o: CFLAGS_TARGET+=$(CFLAGS_SSE) |
| 98 |
|
| 99 |
# libsystem_dummy.o is in the following rule because we like to compile it |
| 100 |
# even when it's not part of the library, just for a test. |
| 101 |
|
| 102 |
$(LIBOBJECTS) libsystem_dummy.o: %.o: %.c importinc |
| 103 |
$(CC) -c $(INCLUDES) $(CFLAGS_ALL) -o $@ $< |
| 104 |
|
| 105 |
# The major number increases when there is a non-backward-compatible change |
| 106 |
# to the library at the binary level, meaning any client of the library needs |
| 107 |
# to keep using the old library until it has been recompiled for the new |
| 108 |
# library. We try very hard never to lose backward compatibility at the |
| 109 |
# source level, which would mean the client source code has to be modified |
| 110 |
# before it can use the new library. |
| 111 |
# |
| 112 |
# The major number might seem like it corresponds to the major version number |
| 113 |
# of Netpbm, but it does not. It is independent. |
| 114 |
# |
| 115 |
# Adding functions is backward compatible, so does not require a major number |
| 116 |
# change. |
| 117 |
# |
| 118 |
# The minor number must always increase within a major number. |
| 119 |
# |
| 120 |
# It is convenient to have the minor number equal to the minor version number |
| 121 |
# of Netpbm, but when we changed the Netpbm major version number from 10 to 11 |
| 122 |
# just to keep the minor version number 2 digits, we had to continue |
| 123 |
# increasing the library minor number, so we went to 100 + minor version |
| 124 |
# number. If we ever increase the library major number to 12, we can go back |
| 125 |
# to using the minor version number for the library minor number. |
| 126 |
|
| 127 |
MAJ := 11 |
| 128 |
$(eval MIN:=$(shell echo $$((100+$(NETPBM_MINOR_RELEASE))))) |
| 129 |
|
| 130 |
SONAME = libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ) |
| 131 |
|
| 132 |
ifeq ($(NETPBMLIBTYPE),irixshared) |
| 133 |
# The libxxx.so link is needed to link the executables. |
| 134 |
libnetpbm.$(NETPBMLIBSUFFIX): $(SONAME) |
| 135 |
rm -f $@ |
| 136 |
$(SYMLINK) $< $@ |
| 137 |
|
| 138 |
PERLPROG = print "sgi$(MAJ)." . join(":sgi$(MAJ) . ", (0..$(MIN))) . "\n" |
| 139 |
|
| 140 |
$(SONAME): \ |
| 141 |
$(LIBOBJECTS) $(LIBOBJECTS_X) |
| 142 |
$(LD) $(LDSHLIB) $(LDFLAGS) -o $@ $(LIBOBJECTS) $(LIBOBJECTS_X) \ |
| 143 |
-lc \ |
| 144 |
-soname libnetpbm.$(NETPBMLIBSUFFIX) \ |
| 145 |
-set_version $(shell perl -e '$(PERLPROG)') \ |
| 146 |
$(LADD) |
| 147 |
endif |
| 148 |
|
| 149 |
ifeq ($(NETPBMLIBTYPE),unixshared) |
| 150 |
# The libxxx.so link is needed to link the executables. |
| 151 |
libnetpbm.$(NETPBMLIBSUFFIX): $(SONAME) |
| 152 |
rm -f $@ |
| 153 |
$(SYMLINK) $< $@ |
| 154 |
# The $(SONAME) link is needed only to test the programs without |
| 155 |
# installing the libraries (in that case, you also need to direct the |
| 156 |
# dynamic linker to the source directories, e.g. set LD_LIBRARY_PATH). |
| 157 |
$(SONAME): libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).$(MIN) |
| 158 |
rm -f $@ |
| 159 |
$(SYMLINK) $< $@ |
| 160 |
libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).$(MIN): $(LIBOBJECTS) $(LIBOBJECTS_X) |
| 161 |
$(LD) $(LDSHLIB) $(LDFLAGS) -o $@ $(LIBOBJECTS) $(LIBOBJECTS_X) \ |
| 162 |
$(SHLIB_CLIB) -lm $(LADD) |
| 163 |
endif |
| 164 |
|
| 165 |
ifeq ($(NETPBMLIBTYPE),dll) |
| 166 |
ifeq ($(STATICLIB_TOO),Y) |
| 167 |
$(NETPBMSHLIBPREFIX)netpbm$(DLLVER).dll: $(LIBOBJECTS) $(LIBOBJECTS_X) libnetpbm.$(STATICLIBSUFFIX) |
| 168 |
else |
| 169 |
$(NETPBMSHLIBPREFIX)netpbm$(DLLVER).dll: $(LIBOBJECTS) $(LIBOBJECTS_X) |
| 170 |
endif |
| 171 |
$(LD) $(LDSHLIB) $(LDFLAGS) -Wl,--export-all-symbols \ |
| 172 |
-Wl,-soname,$(NETPBMSHLIBPREFIX)netpbm$(DLLVER).dll \ |
| 173 |
-Wl,--output-def,$(NETPBMSHLIBPREFIX)netpbm$(DLLVER).def \ |
| 174 |
-Wl,--out-implib,libnetpbm.dll.a -o $@ \ |
| 175 |
$(LIBOBJECTS) $(LIBOBJECTS_X) $(LDLIBS) $(LADD) |
| 176 |
endif |
| 177 |
|
| 178 |
ifeq ($(NETPBMLIBTYPE),dylib) |
| 179 |
libnetpbm.dylib: libnetpbm.$(MAJ).dylib |
| 180 |
rm -f $@ |
| 181 |
$(SYMLINK) $< $@ |
| 182 |
|
| 183 |
libnetpbm.$(MAJ).dylib: libnetpbm.$(MAJ).$(MIN).dylib |
| 184 |
rm -f $@ |
| 185 |
$(SYMLINK) $< $@ |
| 186 |
|
| 187 |
libnetpbm.$(MAJ).$(MIN).dylib: $(LIBOBJECTS) $(LIBOBJECTS_X) |
| 188 |
$(LD) $(LDSHLIB) $(LDFLAGS) -o $@ $(LIBOBJECTS) $(LIBOBJECTS_X) \ |
| 189 |
-lc $(LADD) |
| 190 |
endif |
| 191 |
|
| 192 |
#-------------------------------------------------------------------------- |
| 193 |
# The rule for building a static library is below (if needed). This is |
| 194 |
# tricky because the user can be building the static library as his main |
| 195 |
# library or in addition to some other kind of main library. In fact, |
| 196 |
# he may have specified it both as the main library type and an |
| 197 |
# additional library type. In that case, NETPBMLIBSUFFIX and |
| 198 |
# STATICLIBSUFFIX are redundant -- we hope they're the same. |
| 199 |
# |
| 200 |
# We must not include a rule for static libraries if he doesn't want us |
| 201 |
# to build any. The library name we come up with might conflict with |
| 202 |
# the name of the library he actually is building. In fact, in that case |
| 203 |
# STATICLIB_SUFFIX may just be arbitrary. |
| 204 |
#----------------------------------------------------------------------------- |
| 205 |
ifeq ($(NETPBMLIBTYPE),unixstatic) |
| 206 |
BUILD_STATICLIB = Y |
| 207 |
else |
| 208 |
ifeq ($(STATICLIB_TOO),Y) |
| 209 |
BUILD_STATICLIB = Y |
| 210 |
else |
| 211 |
BUILD_STATICLIB = N |
| 212 |
endif |
| 213 |
endif |
| 214 |
|
| 215 |
ifeq ($(BUILD_STATICLIB),Y) |
| 216 |
libnetpbm.$(STATICLIBSUFFIX): $(LIBOBJECTS) $(LIBOBJECTS_X) |
| 217 |
-rm -f $@ |
| 218 |
$(AR) rc $@ $(LIBOBJECTS) $(LIBOBJECTS_X) |
| 219 |
-$(RANLIB) $@ |
| 220 |
endif |
| 221 |
|
| 222 |
|
| 223 |
# To avoid major hassles with having ppmdcfont available here, we just ship a |
| 224 |
# pre-made standardppmfont.c, so this rule will not normally be used. Though |
| 225 |
# standardppmdfont.c depends upon standard.ppmdfont, we don't declare that |
| 226 |
# here because when the user creates the source tree, the modification time of |
| 227 |
# standard.ppmdfont may end up later than that of standardppmdfont.c, which |
| 228 |
# would make the build want to rebuild it. |
| 229 |
standardppmdfont.c: |
| 230 |
ppmdcfont <standard.ppmdfont >$@ |
| 231 |
|
| 232 |
# Note that we create a new compile.h only for the first make after a |
| 233 |
# make clean. This is good enough. We used to do stamp-date for |
| 234 |
# every build of "all" from the Netpbm top directory, but nowhere |
| 235 |
# else, so it was really sloppy. |
| 236 |
|
| 237 |
compile.h: |
| 238 |
$(SRCDIR)/buildtools/stamp-date >$@ || rm $@ |
| 239 |
|
| 240 |
$(LIBOBJECTS_X): FORCE |
| 241 |
@if [ ! -d $(dir $@) ] ; then mkdir $(dir $@) ; fi |
| 242 |
$(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \ |
| 243 |
SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@) |
| 244 |
|
| 245 |
libpm.o: compile.h |
| 246 |
|
| 247 |
# Install a shared library |
| 248 |
# |
| 249 |
.PHONY: install.lib |
| 250 |
ifeq ($(NETPBMLIBTYPE),unixshared) |
| 251 |
# install a Unix-style shared library |
| 252 |
install.lib: $(PKGDIR)/lib $(PKGDIR)/sharedlink |
| 253 |
cd $(PKGDIR)/lib ; rm -f libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).* |
| 254 |
$(INSTALL) -c -m $(INSTALL_PERM_LIBD) \ |
| 255 |
libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).$(MIN) $(PKGDIR)/lib/ |
| 256 |
cd $(PKGDIR)/lib/ ; \ |
| 257 |
rm -f libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ); \ |
| 258 |
$(SYMLINK) libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).$(MIN) $(SONAME) |
| 259 |
endif |
| 260 |
ifeq ($(NETPBMLIBTYPE),dll) |
| 261 |
#install a Windows DLL shared library |
| 262 |
#Note that unlike Unix libraries, a Windows DLL must go into a directory |
| 263 |
#that is in the PATH, so we use bin/ instead of lib/ |
| 264 |
install.lib: $(PKGDIR)/bin |
| 265 |
( cd $(PKGDIR)/bin ; rm -f $(NETPBMSHLIBPREFIX)netpbm$(DLLVER).dll ) |
| 266 |
$(INSTALL) -c $(STRIPFLAG) -m $(INSTALL_PERM_LIBD) \ |
| 267 |
$(NETPBMSHLIBPREFIX)netpbm$(DLLVER).dll $(PKGDIR)/bin/ |
| 268 |
endif |
| 269 |
ifeq ($(NETPBMLIBTYPE),dylib) |
| 270 |
# install a Darwin-style shared library |
| 271 |
install.lib: $(PKGDIR)/lib |
| 272 |
cd $(PKGDIR)/lib ; rm -f libnetpbm.*.dylib |
| 273 |
$(INSTALL) -c -m $(INSTALL_PERM_LIBD) libnetpbm.$(MAJ).$(MIN).dylib \ |
| 274 |
$(PKGDIR)/lib |
| 275 |
cd $(PKGDIR)/lib ; \ |
| 276 |
rm -f libnetpbm.$(MAJ).dylib; \ |
| 277 |
$(SYMLINK) libnetpbm.$(MAJ).$(MIN).dylib libnetpbm.$(MAJ).dylib |
| 278 |
endif |
| 279 |
|
| 280 |
.PHONY: install.hdr |
| 281 |
install.hdr: $(INTERFACE_HEADERS:%=%_installhdr) |
| 282 |
# You need to install the interface header files only if you are going to |
| 283 |
# compile programs that use the Netpbm libraries. Alternatively, you may |
| 284 |
# prefer not to "install" them, but just to access the Netpbm source |
| 285 |
# directory when you compile your programs. |
| 286 |
|
| 287 |
.PHONY: $(INTERFACE_HEADERS:%=%_installhdr) |
| 288 |
|
| 289 |
$(INTERFACE_HEADERS:%=%_installhdr): $(PKGDIR)/include/netpbm |
| 290 |
$(INSTALL) -c -m $(INSTALL_PERM_HDR) \ |
| 291 |
$(SRCDIR)/lib/$(@:%_installhdr=%) $(PKGDIR)/include/netpbm/ |
| 292 |
|
| 293 |
.PHONY: install.staticlib |
| 294 |
install.staticlib: $(PKGDIR)/staticlink |
| 295 |
$(INSTALL) -c -m $(INSTALL_PERM_LIBS) libnetpbm.$(STATICLIBSUFFIX) \ |
| 296 |
$(PKGDIR)/staticlink |
| 297 |
|
| 298 |
# Install a shared library stub -- the ".so" file used at link time to |
| 299 |
# prepare a program for dynamically linking a library at run time |
| 300 |
.PHONY: install.sharedlibstub |
| 301 |
install.sharedlibstub: $(PKGDIR)/sharedlink |
| 302 |
ifeq ($(NETPBMLIBTYPE),unixshared) |
| 303 |
# install the link-time (.so) links to the runtime libraries |
| 304 |
cd $(PKGDIR)/sharedlink ; \ |
| 305 |
rm -f libnetpbm.$(NETPBMLIBSUFFIX); \ |
| 306 |
$(SYMLINK) ../lib/libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ) \ |
| 307 |
libnetpbm.$(NETPBMLIBSUFFIX) |
| 308 |
endif |
| 309 |
ifeq ($(NETPBMLIBTYPE),dll) |
| 310 |
$(INSTALL) -c -m $(INSTALL_PERM_LIBS) libnetpbm.dll.a \ |
| 311 |
$(PKGDIR)/sharedlink |
| 312 |
endif |
| 313 |
ifeq ($(NETPBMLIBTYPE),dylib) |
| 314 |
cd $(PKGDIR)/sharedlink/ ; \ |
| 315 |
rm -f libnetpbm.dylib; \ |
| 316 |
$(SYMLINK) ../lib/libnetpbm.$(MAJ).$(MIN).dylib libnetpbm.dylib |
| 317 |
endif |
| 318 |
|
| 319 |
distclean clean: localclean |
| 320 |
|
| 321 |
.PHONY: localclean |
| 322 |
localclean: |
| 323 |
rm -f compile.h |
| 324 |
|
| 325 |
FORCE: |