about summary refs log tree commit diff
path: root/lib/Makefile
blob: a0f337457f0c0c1885ec0962674b292ec2088a13 (plain) (blame)
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
ifeq ($(SRCDIR)x,x)
  SRCDIR = $(CURDIR)/..
  BUILDDIR = $(SRCDIR)
endif
SUBDIR = lib
VPATH=.:$(SRCDIR)/$(SUBDIR)
DLLTOOL=dlltool
include $(BUILDDIR)/config.mk

ifeq ($(NETPBMLIBTYPE),unixstatic)
LIBNETPBM = libnetpbm.$(STATICLIBSUFFIX)
else
LIBNETPBM = $(NETPBMSHLIBPREFIX)netpbm$(DLLVER).$(NETPBMLIBSUFFIX)
endif

ifeq ($(STATICLIB_TOO),Y)
EXTRA_STATICLIB = libnetpbm.$(STATICLIBSUFFIX)
else
EXTRA_STATICLIB =
endif

ifeq ($(DONT_HAVE_PROCESS_MGMT),Y)
  LIBSYSTEM = libsystem_dummy.o
else
  LIBSYSTEM = libsystem.o
endif

LIBOBJECTS = libpm.o pmfileio.o fileio.o colorname.o \
	libpamd.o \
	libpbm1.o libpbm2.o libpbm3.o \
	libpbmfont.o pbmfontdata1.o pbmfontdata2.o \
	libpgm1.o libpgm2.o \
	libppm1.o libppm2.o libppmcmap.o libppmcolor.o libppmfuzzy.o \
	libppmd.o ppmdfont.o standardppmdfont.o path.o \
	libppmfloyd.o \
	libpnm1.o libpnm2.o libpnm3.o \
	libpam.o libpamread.o libpamwrite.o \
	libpamn.o libpammap.o libpamcolor.o \
	$(LIBSYSTEM) \

# Library objects to be linked but not built by common.mk:
LIBOBJECTS_X = \
  util/bitio.o \
  util/filename.o \
  util/io.o \
  util/mallocvar.o \
  util/matrix.o \
  util/nsleep.o \
  util/nstring.o \
  util/runlength.o \
  util/shhopt.o \
  util/token.o \
  util/vasprintf.o \

MANUALS3 = libnetpbm
MANUALS5 = pbm pgm ppm pnm pam

INTERFACE_HEADERS = colorname.h \
	pam.h pamdraw.h pammap.h pbm.h pbmfont.h \
	pgm.h pm.h pm_gamma.h pm_system.h pnm.h \
	ppm.h ppmcmap.h ppmdfont.h ppmdraw.h ppmfloyd.h \
	util/mallocvar.h util/runlength.h util/shhopt.h \

DATAFILES = rgb.txt

.PHONY: all
all: libnetpbm extra_staticlib

SUBDIRS = util
SCRIPTS = 
BINARIES = 

OMIT_LIBRARY_RULE = 1
ALL_INTERNAL_HEADER_FILES_ARE_QUALIFIED = Y
include $(SRCDIR)/common.mk

# The following must go after common.mk because $(LIBNETPBM) may 
# contain a reference to $(NETPBM_MAJOR_RELEASE).
.PHONY: libnetpbm
libnetpbm: $(LIBNETPBM)

.PHONY: extra_staticlib
extra_staticlib: $(EXTRA_STATICLIB)

#----------------------------------------------------------------------------
# Following are rules for building shared libraries.
# Note that the user may specify a shared library as his "main" library
# type, but request a static library in addition.
#----------------------------------------------------------------------------

$(LIBOBJECTS): CFLAGS_TARGET=$(CFLAGS_SHLIB)

libpbm3.o: CFLAGS_TARGET+=$(CFLAGS_SSE)

$(LIBOBJECTS): %.o: %.c importinc
	$(CC) -c $(INCLUDES) $(CFLAGS_ALL) -o $@ $<

MAJ = 11
MIN = $(NETPBM_MINOR_RELEASE)

SONAME = libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ)

ifeq ($(NETPBMLIBTYPE),irixshared)
# The libxxx.so link is needed to link the executables.
libnetpbm.$(NETPBMLIBSUFFIX): $(SONAME)
	rm -f $@
	$(SYMLINK) $< $@

PERLPROG = print "sgi$(MAJ)." . join(":sgi$(MAJ) . ", (0..$(MIN))) . "\n"

$(SONAME): \
    $(LIBOBJECTS) $(LIBOBJECTS_X) 
	$(LD) $(LDSHLIB) -o $@ $(LIBOBJECTS) $(LIBOBJECTS_X) \
          -lc \
	  -soname libnetpbm.$(NETPBMLIBSUFFIX) \
	  -set_version $(shell perl -e '$(PERLPROG)') \
	  $(LADD)
endif

ifeq ($(NETPBMLIBTYPE),unixshared)
# The libxxx.so link is needed to link the executables.
libnetpbm.$(NETPBMLIBSUFFIX): $(SONAME)
	rm -f $@
	$(SYMLINK) $< $@
# The $(SONAME) link is needed only to test the programs without
# installing the libraries (in that case, you also need to direct the 
# dynamic linker to the source directories, e.g. set LD_LIBRARY_PATH).
$(SONAME): libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).$(MIN)
	rm -f $@
	$(SYMLINK) $< $@
libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).$(MIN): $(LIBOBJECTS) $(LIBOBJECTS_X)
	$(LD) $(LDSHLIB) -o $@ $(LIBOBJECTS) $(LIBOBJECTS_X) \
          $(SHLIB_CLIB) -lm $(LADD)
endif

ifeq ($(NETPBMLIBTYPE),dll)
ifeq ($(STATICLIB_TOO),Y)
$(NETPBMSHLIBPREFIX)netpbm$(DLLVER).dll: $(LIBOBJECTS) $(LIBOBJECTS_X) libnetpbm.$(STATICLIBSUFFIX)
else
$(NETPBMSHLIBPREFIX)netpbm$(DLLVER).dll: $(LIBOBJECTS) $(LIBOBJECTS_X)
endif
	$(LD) $(LDSHLIB) -Wl,--export-all-symbols \
            -Wl,-soname,$(NETPBMSHLIBPREFIX)netpbm$(DLLVER).dll \
	    -Wl,--output-def,$(NETPBMSHLIBPREFIX)netpbm$(DLLVER).def \
            -Wl,--out-implib,libnetpbm.dll.a -o $@ $(LDFLAGS) \
            $(LIBOBJECTS) $(LIBOBJECTS_X) $(LDLIBS) $(LADD) 
endif

ifeq ($(NETPBMLIBTYPE),dylib)
libnetpbm.dylib: libnetpbm.$(MAJ).dylib
	rm -f $@
	$(SYMLINK) $< $@

libnetpbm.$(MAJ).dylib: libnetpbm.$(MAJ).$(MIN).dylib
	rm -f $@
	$(SYMLINK) $< $@

libnetpbm.$(MAJ).$(MIN).dylib: $(LIBOBJECTS) $(LIBOBJECTS_X) 
	$(LD) $(LDSHLIB) -o $@ $(LIBOBJECTS) $(LIBOBJECTS_X) \
           -lc $(LADD)
endif

#--------------------------------------------------------------------------
# The rule for building a static library is below (if needed).  This is
# tricky because the user can be building the static library as his main
# library or in addition to some other kind of main library.  In fact,
# he may have specified it both as the main library type and an 
# additional library type.  In that case, NETPBMLIBSUFFIX and 
# STATICLIBSUFFIX are redundant -- we hope they're the same.
# 
# We must not include a rule for static libraries if he doesn't want us
# to build any.  The library name we come up with might conflict with 
# the name of the library he actually is building.  In fact, in that case
# STATICLIB_SUFFIX may just be arbitrary.
#-----------------------------------------------------------------------------
ifeq ($(NETPBMLIBTYPE),unixstatic)
  BUILD_STATICLIB = Y
else
  ifeq ($(STATICLIB_TOO),Y)
    BUILD_STATICLIB = Y
  else
    BUILD_STATICLIB = N
  endif
endif

ifeq ($(BUILD_STATICLIB),Y)
libnetpbm.$(STATICLIBSUFFIX): $(LIBOBJECTS) $(LIBOBJECTS_X)
	-rm -f $@
	$(AR) rc $@ $(LIBOBJECTS) $(LIBOBJECTS_X)
	-$(RANLIB) $@
endif


# To avoid major hassles with having ppmdcfont available here, we just ship a
# pre-made standardppmfont.c, so this rule will not normally be used.  Though
# standardppmdfont.c depends upon standard.ppmdfont, we don't declare that
# here because when the user creates the source tree, the modification time of
# standard.ppmdfont may end up later than that of standardppmdfont.c, which
# would make the build want to rebuild it.
standardppmdfont.c:
	ppmdcfont <standard.ppmdfont >$@

# Note that we create a new compile.h only for the first make after a
# make clean.  This is good enough.  We used to do stamp-date for
# every build of "all" from the Netpbm top directory, but nowhere
# else, so it was really sloppy.

compile.h:
	$(SRCDIR)/buildtools/stamp-date >$@ || rm $@

$(LIBOBJECTS_X): FORCE
	@if [ ! -d $(dir $@) ] ; then mkdir $(dir $@) ; fi
	$(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \
		SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@) 

libpm.o: compile.h

# Install a shared library
#
.PHONY: install.lib
ifeq ($(NETPBMLIBTYPE),unixshared)
# install a Unix-style shared library
install.lib: $(PKGDIR)/lib $(PKGDIR)/link
	cd $(PKGDIR)/lib ; rm -f libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).*
	$(INSTALL) -c -m $(INSTALL_PERM_LIBD) \
	  libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).$(MIN)  $(PKGDIR)/lib/
	cd $(PKGDIR)/lib/ ; \
          rm -f libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ); \
          $(SYMLINK) libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).$(MIN) $(SONAME)
endif
ifeq ($(NETPBMLIBTYPE),dll)
#install a Windows DLL shared library
#Note that unlike Unix libraries, a Windows DLL must go into a directory
#that is in the PATH, so we use bin/ instead of lib/
install.lib: $(PKGDIR)/bin
	( cd $(PKGDIR)/bin ; rm -f $(NETPBMSHLIBPREFIX)netpbm$(DLLVER).dll )
	$(INSTALL) -c $(STRIPFLAG) -m $(INSTALL_PERM_LIBD) \
          $(NETPBMSHLIBPREFIX)netpbm$(DLLVER).dll $(PKGDIR)/bin/
endif
ifeq ($(NETPBMLIBTYPE),dylib)
# install a Darwin-style shared library
install.lib: $(PKGDIR)/lib
	cd $(PKGDIR)/lib ; rm -f libnetpbm.*.dylib
	$(INSTALL) -c -m $(INSTALL_PERM_LIBD) libnetpbm.$(MAJ).$(MIN).dylib \
	   $(PKGDIR)/lib
	cd $(PKGDIR)/lib ; \
          rm -f libnetpbm.$(MAJ).dylib; \
          $(SYMLINK) libnetpbm.$(MAJ).$(MIN).dylib libnetpbm.$(MAJ).dylib
endif

.PHONY: install.hdr
install.hdr: $(INTERFACE_HEADERS:%=%_installhdr)
# You need to install the interface header files only if you are going to
# compile programs that use the Netpbm libraries.  Alternatively, you may
# prefer not to "install" them, but just to access the Netpbm source
# directory when you compile your programs.

.PHONY: $(INTERFACE_HEADERS:%=%_installhdr)

$(INTERFACE_HEADERS:%=%_installhdr): $(PKGDIR)/include/netpbm
	$(INSTALL) -c -m $(INSTALL_PERM_HDR) \
	  $(SRCDIR)/lib/$(@:%_installhdr=%) $(PKGDIR)/include/netpbm/

.PHONY: install.staticlib
install.staticlib: $(PKGDIR)/link
	$(INSTALL) -c -m $(INSTALL_PERM_LIBS) libnetpbm.$(STATICLIBSUFFIX) \
	  $(PKGDIR)/link

# Install a shared library stub -- the ".so" file used at link time to
# prepare a program for dynamically linking a library at run time 
.PHONY: install.sharedlibstub
install.sharedlibstub: $(PKGDIR)/link
ifeq ($(NETPBMLIBTYPE),unixshared)
# install the link-time (.so) links to the runtime libraries
	cd $(PKGDIR)/link ; \
          rm -f libnetpbm.$(NETPBMLIBSUFFIX); \
          $(SYMLINK) ../lib/libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ) \
            libnetpbm.$(NETPBMLIBSUFFIX)
endif
ifeq ($(NETPBMLIBTYPE),dll)
	$(INSTALL) -c -m $(INSTALL_PERM_LIBS) libnetpbm.dll.a $(PKGDIR)/link
endif
ifeq ($(NETPBMLIBTYPE),dylib)
	cd $(PKGDIR)/link/ ; \
          rm -f libnetpbm.dylib; \
	$(SYMLINK) ../lib/libnetpbm.$(MAJ).$(MIN).dylib libnetpbm.dylib
endif

distclean clean: localclean

.PHONY: localclean
localclean:
	rm -f compile.h

FORCE: