View | Details | Raw Unified | Return to bug 54100
Collapse All | Expand All

(-)graphics/gd/Makefile (-27 / +7 lines)
Lines 7-38 Link Here
7
7
8
PORTNAME=	gd
8
PORTNAME=	gd
9
PORTVERSION=	1.8.4
9
PORTVERSION=	1.8.4
10
PORTREVISION=	6
10
PORTREVISION=	7
11
PORTEPOCH=	1
11
PORTEPOCH=	1
12
CATEGORIES+=	graphics
12
CATEGORIES+=	graphics
13
MASTER_SITES=	http://www.boutell.com/gd/http/ \
13
MASTER_SITES=	http://www.boutell.com/gd/http/ \
14
		ftp://ftp.boutell.com/pub/boutell/gd/ \
14
		ftp://ftp.boutell.com/pub/boutell/gd/ \
15
		http://virtual-estates.net/~mi/port-stuff/ \
16
		${MASTER_SITE_RINGSERVER}
15
		${MASTER_SITE_RINGSERVER}
17
MASTER_SITE_SUBDIR=	graphics/gd
16
MASTER_SITE_SUBDIR=	graphics/gd
18
DISTFILES=	${DISTNAME}${EXTRACT_SUFX} gd_gif_in.c.bz2
19
EXTRACT_ONLY=	${DISTNAME}${EXTRACT_SUFX}
20
17
21
MAINTAINER?=	ports@FreeBSD.org
18
MAINTAINER?=	ports@FreeBSD.org
22
COMMENT?=	A graphics library for fast image creation
19
COMMENT?=	A graphics library for fast creation of images
23
20
24
BUILD_DEPENDS=	freetype-config:${PORTSDIR}/print/freetype2     # XXX
21
LIB_DEPENDS=	jpeg.9:${PORTSDIR}/graphics/jpeg \
25
LIB_DEPENDS=	jpeg:${PORTSDIR}/graphics/jpeg \
22
		png.5:${PORTSDIR}/graphics/png \
26
		png:${PORTSDIR}/graphics/png \
23
		freetype.9:${PORTSDIR}/print/freetype2
27
		freetype:${PORTSDIR}/print/freetype2
28
.if !exists(/usr/bin/bzip2)
29
BUILD_DEPENDS+=	bzip2:${PORTSDIR}/archivers/bzip2
30
.endif
31
32
FREETYPE_CONFIG?=       ${LOCALBASE}/bin/freetype-config
33
24
34
USE_REINPLACE=	yes
25
MAKEFILE=	${FILESDIR}/Makefile.lib
35
MAKE_ENV=	FREETYPE_CONFIG="${FREETYPE_CONFIG}"
36
INSTALLS_SHLIB=	yes
26
INSTALLS_SHLIB=	yes
37
27
38
.if defined(WITH_X11)
28
.if defined(WITH_X11)
Lines 48-63 Link Here
48
.endif
38
.endif
49
39
50
post-extract:
40
post-extract:
51
	@${BZIP2_CMD} -dc ${DISTDIR}/${DIST_SUBDIR}/gd_gif_in.c.bz2 \
41
	@${CP} ${FILESDIR}/gd_gif_in.c ${WRKSRC}
52
		> ${WRKSRC}/gd_gif_in.c
53
54
post-patch:
55
	@${REINPLACE_CMD} -e 's|<malloc.h>|<stdlib.h>|g' ${WRKSRC}/gdcache.h
56
57
post-install:
58
.if !defined(NOPORTDOCS)
59
	@${MKDIR} ${DOCSDIR}
60
	${INSTALL_DATA} ${WRKSRC}/index.html ${DOCSDIR}
61
.endif
62
42
63
.include <bsd.port.mk>
43
.include <bsd.port.mk>
(-)graphics/gd/files/Makefile.lib (+36 lines)
Line 0 Link Here
1
# $FreeBSD$
2
3
PREFIX?=	/usr/local
4
SHLIB_VER?=	2
5
6
LIB=		gd1
7
LIBDIR=		${PREFIX}/lib
8
SHLIB_MAJOR=	${SHLIB_VER}
9
SHLIB_MINOR=	0
10
NOPROFILE=	yes
11
NOOBJ=		yes
12
13
INCS=		gd.h gd_io.h gdcache.h gdfontg.h gdfontl.h gdfontmb.h \
14
		gdfonts.h gdfontt.h
15
INCSDIR=	${PREFIX}/include/gd
16
INCDIR=		${INSCDIR}	# for pre-bsd.incs.mk API
17
18
SRCS=		gd.c gd_gd.c gd_gd2.c gd_io.c gd_io_dp.c gd_io_file.c gd_ss.c \
19
		gd_io_ss.c gd_png.c gd_jpeg.c gdxpm.c gdfontt.c gdfonts.c \
20
		gdfontmb.c gdfontl.c gdfontg.c gdtables.c gdft.c gdttf.c \
21
		gdcache.c gdkanji.c wbmp.c gd_wbmp.c gdhelpers.c gd_gif_in.c
22
23
CFLAGS+=	-I${.CURDIR} -I${LOCALBASE}/include/freetype2/freetype \
24
		-I${LOCALBASE}/include/freetype2 -I${LOCALBASE}/include \
25
		-DHAVE_LIBPNG -DHAVE_LIBJPEG -DHAVE_LIBFREETYPE -DHAVE_LIBZ
26
LDADD=		-L${LOCALBASE}/lib -lfreetype -ljpeg -lpng -lz
27
28
.ifdef WITH_X11
29
CFLAGS+=	-I${X11BASE}/include/X11 -I${X11BASE}/include -DHAVE_LIBXPM
30
LDADD+=		-L${X11BASE}/lib -lXpm -lX11
31
.endif
32
33
beforeinstall:
34
	mkdir -p ${INCSDIR}
35
36
.include <bsd.lib.mk>
(-)graphics/gd/files/gd_gif_in.c (+561 lines)
Line 0 Link Here
1
#include <stdio.h>
2
#include <math.h>
3
#include <string.h>
4
#include <stdlib.h>
5
#include "gd.h"
6
7
/* Used only when debugging GIF compression code */
8
/* #define DEBUGGING_ENVARS */
9
10
#ifdef DEBUGGING_ENVARS
11
12
static int verbose_set = 0;
13
static int verbose;
14
#define VERBOSE (verbose_set?verbose:set_verbose())
15
16
static int set_verbose(void)
17
{
18
 verbose = !!getenv("GIF_VERBOSE");
19
 verbose_set = 1;
20
 return(verbose);
21
}
22
23
#else
24
25
#define VERBOSE 0
26
27
#endif
28
29
30
#define        MAXCOLORMAPSIZE         256
31
32
#define        TRUE    1
33
#define        FALSE   0
34
35
#define CM_RED         0
36
#define CM_GREEN       1
37
#define CM_BLUE                2
38
39
#define        MAX_LWZ_BITS            12
40
41
#define INTERLACE              0x40
42
#define LOCALCOLORMAP  0x80
43
#define BitSet(byte, bit)      (((byte) & (bit)) == (bit))
44
45
#define        ReadOK(file,buffer,len) (gdGetBuf(buffer, len, file) != 0)
46
47
#define LM_to_uint(a,b)                        (((b)<<8)|(a))
48
49
/* We may eventually want to use this information, but def it out for now */
50
#if 0
51
static struct {
52
       unsigned int    Width;
53
       unsigned int    Height;
54
       unsigned char   ColorMap[3][MAXCOLORMAPSIZE];
55
       unsigned int    BitPixel;
56
       unsigned int    ColorResolution;
57
       unsigned int    Background;
58
       unsigned int    AspectRatio;
59
} GifScreen;
60
#endif
61
62
static struct {
63
       int     transparent;
64
       int     delayTime;
65
       int     inputFlag;
66
       int     disposal;
67
} Gif89 = { -1, -1, -1, 0 };
68
69
static int ReadColorMap (gdIOCtx *fd, int number, unsigned char (*buffer)[256]);
70
static int DoExtension (gdIOCtx *fd, int label, int *Transparent);
71
static int GetDataBlock (gdIOCtx *fd, unsigned char *buf);
72
static int GetCode (gdIOCtx *fd, int code_size, int flag);
73
static int LWZReadByte (gdIOCtx *fd, int flag, int input_code_size);
74
75
static void ReadImage (gdImagePtr im, gdIOCtx *fd, int len, int height, unsigned char (*cmap)[256], int interlace); /*1.4//, int ignore); */
76
77
int ZeroDataBlock;
78
79
gdImagePtr
80
gdImageCreateFromGif(FILE *fdFile)
81
{
82
        gdIOCtx		*fd = gdNewFileCtx(fdFile);
83
        gdImagePtr    	im = 0;
84
85
        im = gdImageCreateFromGifCtx(fd);
86
87
        fd->free(fd);
88
89
        return im;
90
}
91
92
gdImagePtr
93
gdImageCreateFromGifCtx(gdIOCtxPtr fd)
94
{
95
       int imageNumber;
96
       int BitPixel;
97
       int ColorResolution;
98
       int Background;
99
       int AspectRatio;
100
       int Transparent = (-1);
101
       unsigned char   buf[16];
102
       unsigned char   c;
103
       unsigned char   ColorMap[3][MAXCOLORMAPSIZE];
104
       unsigned char   localColorMap[3][MAXCOLORMAPSIZE];
105
       int             imw, imh;
106
       int             useGlobalColormap;
107
       int             bitPixel;
108
       int	       i;
109
       /*1.4//int             imageCount = 0; */
110
       char            version[4];
111
112
       gdImagePtr im = 0;
113
       ZeroDataBlock = FALSE;
114
115
       /*1.4//imageNumber = 1; */
116
       if (! ReadOK(fd,buf,6)) {
117
		return 0;
118
	}
119
       if (strncmp((char *)buf,"GIF",3) != 0) {
120
		return 0;
121
	}
122
       strncpy(version, (char *)buf + 3, 3);
123
       version[3] = '\0';
124
125
       if ((strcmp(version, "87a") != 0) && (strcmp(version, "89a") != 0)) {
126
		return 0;
127
	}
128
       if (! ReadOK(fd,buf,7)) {
129
		return 0;
130
	}
131
       BitPixel        = 2<<(buf[4]&0x07);
132
       ColorResolution = (int) (((buf[4]&0x70)>>3)+1);
133
       Background      = buf[5];
134
       AspectRatio     = buf[6];
135
136
       if (BitSet(buf[4], LOCALCOLORMAP)) {    /* Global Colormap */
137
               if (ReadColorMap(fd, BitPixel, ColorMap)) {
138
			return 0;
139
		}
140
       }
141
       for (;;) {
142
               if (! ReadOK(fd,&c,1)) {
143
                       return 0;
144
               }
145
               if (c == ';') {         /* GIF terminator */
146
			goto terminated;
147
	       }
148
149
               if (c == '!') {         /* Extension */
150
                       if (! ReadOK(fd,&c,1)) {
151
                               return 0;
152
                       }
153
                       DoExtension(fd, c, &Transparent);
154
                       continue;
155
               }
156
157
               if (c != ',') {         /* Not a valid start character */
158
                       continue;
159
               }
160
161
               /*1.4//++imageCount; */
162
163
               if (! ReadOK(fd,buf,9)) {
164
	               return 0;
165
               }
166
167
               useGlobalColormap = ! BitSet(buf[8], LOCALCOLORMAP);
168
169
               bitPixel = 1<<((buf[8]&0x07)+1);
170
171
               imw = LM_to_uint(buf[4],buf[5]);
172
               imh = LM_to_uint(buf[6],buf[7]);
173
	       if (!(im = gdImageCreate(imw, imh))) {
174
			 return 0;
175
	       }
176
               im->interlace = BitSet(buf[8], INTERLACE);
177
               if (! useGlobalColormap) {
178
                       if (ReadColorMap(fd, bitPixel, localColorMap)) { 
179
                                 return 0;
180
                       }
181
                       ReadImage(im, fd, imw, imh, localColorMap, 
182
                                 BitSet(buf[8], INTERLACE)); 
183
                                 /*1.4//imageCount != imageNumber); */
184
               } else {
185
                       ReadImage(im, fd, imw, imh,
186
                                 ColorMap, 
187
                                 BitSet(buf[8], INTERLACE));
188
                                 /*1.4//imageCount != imageNumber); */
189
               }
190
               if (Transparent != (-1)) {
191
                       gdImageColorTransparent(im, Transparent);
192
               }	   
193
	       goto terminated;
194
       }
195
196
terminated:
197
       /* Terminator before any image was declared! */
198
       if (!im) {
199
		return 0;
200
       }
201
       /* Check for open colors at the end, so
202
          we can reduce colorsTotal and ultimately
203
          BitsPerPixel */
204
       for (i=((im->colorsTotal-1)); (i>=0); i--) {
205
		if (im->open[i]) {
206
                	im->colorsTotal--;
207
                } else {
208
                	break;
209
                }
210
       } 
211
       return im;
212
}
213
214
static int
215
ReadColorMap(gdIOCtx *fd, int number, unsigned char (*buffer)[256])
216
{
217
       int             i;
218
       unsigned char   rgb[3];
219
220
221
       for (i = 0; i < number; ++i) {
222
               if (! ReadOK(fd, rgb, sizeof(rgb))) {
223
                       return TRUE;
224
               }
225
               buffer[CM_RED][i] = rgb[0] ;
226
               buffer[CM_GREEN][i] = rgb[1] ;
227
               buffer[CM_BLUE][i] = rgb[2] ;
228
       }
229
230
231
       return FALSE;
232
}
233
234
static int
235
DoExtension(gdIOCtx *fd, int label, int *Transparent)
236
{
237
       static unsigned char     buf[256];
238
239
       switch (label) {
240
       case 0xf9:              /* Graphic Control Extension */
241
               (void) GetDataBlock(fd, (unsigned char*) buf);
242
               Gif89.disposal    = (buf[0] >> 2) & 0x7;
243
               Gif89.inputFlag   = (buf[0] >> 1) & 0x1;
244
               Gif89.delayTime   = LM_to_uint(buf[1],buf[2]);
245
               if ((buf[0] & 0x1) != 0)
246
                       *Transparent = buf[3];
247
248
               while (GetDataBlock(fd, (unsigned char*) buf) != 0)
249
                       ;
250
               return FALSE;
251
       default:
252
               break;
253
       }
254
       while (GetDataBlock(fd, (unsigned char*) buf) != 0)
255
               ;
256
257
       return FALSE;
258
}
259
260
static int
261
GetDataBlock_(gdIOCtx *fd, unsigned char *buf)
262
{
263
       unsigned char   count;
264
265
       if (! ReadOK(fd,&count,1)) {
266
               return -1;
267
       }
268
269
       ZeroDataBlock = count == 0;
270
271
       if ((count != 0) && (! ReadOK(fd, buf, count))) {
272
               return -1;
273
       }
274
275
       return count;
276
}
277
278
static int
279
GetDataBlock(gdIOCtx *fd, unsigned char *buf)
280
{
281
 int rv;
282
 int i;
283
284
 rv = GetDataBlock_(fd,buf);
285
 if (VERBOSE)
286
  { printf("[GetDataBlock returning %d",rv);
287
    if (rv > 0)
288
     { printf(":");
289
       for (i=0;i<rv;i++) printf(" %02x",buf[i]);
290
     }
291
    printf("]\n");
292
  }
293
 return(rv);
294
}
295
296
static int
297
GetCode_(gdIOCtx *fd, int code_size, int flag)
298
{
299
       static unsigned char    buf[280];
300
       static int              curbit, lastbit, done, last_byte;
301
       int                     i, j, ret;
302
       unsigned char           count;
303
304
       if (flag) {
305
               curbit = 0;
306
               lastbit = 0;
307
               done = FALSE;
308
               return 0;
309
       }
310
311
       if ( (curbit+code_size) >= lastbit) {
312
               if (done) {
313
                       if (curbit >= lastbit) {
314
                                /* Oh well */
315
                       }                        
316
                       return -1;
317
               }
318
               buf[0] = buf[last_byte-2];
319
               buf[1] = buf[last_byte-1];
320
321
               if ((count = GetDataBlock(fd, &buf[2])) == 0)
322
                       done = TRUE;
323
324
               last_byte = 2 + count;
325
               curbit = (curbit - lastbit) + 16;
326
               lastbit = (2+count)*8 ;
327
       }
328
329
       ret = 0;
330
       for (i = curbit, j = 0; j < code_size; ++i, ++j)
331
               ret |= ((buf[ i / 8 ] & (1 << (i % 8))) != 0) << j;
332
333
       curbit += code_size;
334
       return ret;
335
}
336
337
static int
338
GetCode(gdIOCtx *fd, int code_size, int flag)
339
{
340
 int rv;
341
342
 rv = GetCode_(fd,code_size,flag);
343
 if (VERBOSE) printf("[GetCode(,%d,%d) returning %d]\n",code_size,flag,rv);
344
 return(rv);
345
}
346
347
#define STACK_SIZE ((1<<(MAX_LWZ_BITS))*2)
348
static int
349
LWZReadByte_(gdIOCtx *fd, int flag, int input_code_size)
350
{
351
       static int      fresh = FALSE;
352
       int             code, incode;
353
       static int      code_size, set_code_size;
354
       static int      max_code, max_code_size;
355
       static int      firstcode, oldcode;
356
       static int      clear_code, end_code;
357
       static int      table[2][(1<< MAX_LWZ_BITS)];
358
       static int      stack[STACK_SIZE], *sp;
359
       register int    i;
360
361
       if (flag) {
362
               set_code_size = input_code_size;
363
               code_size = set_code_size+1;
364
               clear_code = 1 << set_code_size ;
365
               end_code = clear_code + 1;
366
               max_code_size = 2*clear_code;
367
               max_code = clear_code+2;
368
369
               GetCode(fd, 0, TRUE);
370
               
371
               fresh = TRUE;
372
373
               for (i = 0; i < clear_code; ++i) {
374
                       table[0][i] = 0;
375
                       table[1][i] = i;
376
               }
377
               for (; i < (1<<MAX_LWZ_BITS); ++i)
378
                       table[0][i] = table[1][0] = 0;
379
380
               sp = stack;
381
382
               return 0;
383
       } else if (fresh) {
384
               fresh = FALSE;
385
               do {
386
                       firstcode = oldcode =
387
                               GetCode(fd, code_size, FALSE);
388
               } while (firstcode == clear_code);
389
               return firstcode;
390
       }
391
392
       if (sp > stack)
393
               return *--sp;
394
395
       while ((code = GetCode(fd, code_size, FALSE)) >= 0) {
396
               if (code == clear_code) {
397
                       for (i = 0; i < clear_code; ++i) {
398
                               table[0][i] = 0;
399
                               table[1][i] = i;
400
                       }
401
                       for (; i < (1<<MAX_LWZ_BITS); ++i)
402
                               table[0][i] = table[1][i] = 0;
403
                       code_size = set_code_size+1;
404
                       max_code_size = 2*clear_code;
405
                       max_code = clear_code+2;
406
                       sp = stack;
407
                       firstcode = oldcode =
408
                                       GetCode(fd, code_size, FALSE);
409
                       return firstcode;
410
               } else if (code == end_code) {
411
                       int             count;
412
                       unsigned char   buf[260];
413
414
                       if (ZeroDataBlock)
415
                               return -2;
416
417
                       while ((count = GetDataBlock(fd, buf)) > 0)
418
                               ;
419
420
                       if (count != 0)
421
                       return -2;
422
               }
423
424
               incode = code;
425
426
	       if (sp == (stack + STACK_SIZE)) {
427
		       /* Bad compressed data stream */
428
		       return -1;
429
	       }
430
431
               if (code >= max_code) {
432
                       *sp++ = firstcode;
433
                       code = oldcode;
434
               }
435
436
               while (code >= clear_code) {
437
		       if (sp == (stack + STACK_SIZE)) {
438
			       /* Bad compressed data stream */
439
			       return -1;
440
		       }
441
                       *sp++ = table[1][code];
442
                       if (code == table[0][code]) {
443
                               /* Oh well */
444
                       }
445
                       code = table[0][code];
446
               }
447
448
               *sp++ = firstcode = table[1][code];
449
450
               if ((code = max_code) <(1<<MAX_LWZ_BITS)) {
451
                       table[0][code] = oldcode;
452
                       table[1][code] = firstcode;
453
                       ++max_code;
454
                       if ((max_code >= max_code_size) &&
455
                               (max_code_size < (1<<MAX_LWZ_BITS))) {
456
                               max_code_size *= 2;
457
                               ++code_size;
458
                       }
459
               }
460
461
               oldcode = incode;
462
463
               if (sp > stack)
464
                       return *--sp;
465
       }
466
       return code;
467
}
468
469
static int
470
LWZReadByte(gdIOCtx *fd, int flag, int input_code_size)
471
{
472
 int rv;
473
474
 rv = LWZReadByte_(fd,flag,input_code_size);
475
 if (VERBOSE) printf("[LWZReadByte(,%d,%d) returning %d]\n",flag,input_code_size,rv);
476
 return(rv);
477
}
478
479
static void
480
ReadImage(gdImagePtr im, gdIOCtx *fd, int len, int height, unsigned char (*cmap)[256], int interlace) /*1.4//, int ignore) */
481
{
482
       unsigned char   c;      
483
       int             v;
484
       int             xpos = 0, ypos = 0, pass = 0;
485
       int i;
486
       /* Stash the color map into the image */
487
       for (i=0; (i<gdMaxColors); i++) {
488
               im->red[i] = cmap[CM_RED][i];	
489
               im->green[i] = cmap[CM_GREEN][i];	
490
               im->blue[i] = cmap[CM_BLUE][i];	
491
               im->open[i] = 1;
492
       }
493
       /* Many (perhaps most) of these colors will remain marked open. */
494
       im->colorsTotal = gdMaxColors;
495
       /*
496
       **  Initialize the Compression routines
497
       */
498
       if (! ReadOK(fd,&c,1)) {
499
               return; 
500
       }
501
       if (LWZReadByte(fd, TRUE, c) < 0) {
502
               return;
503
       }
504
505
       /*
506
       **  If this is an "uninteresting picture" ignore it.
507
       **  REMOVED For 1.4
508
       */
509
       /*if (ignore) { */
510
       /*        while (LWZReadByte(fd, FALSE, c) >= 0) */
511
       /*                ; */
512
       /*        return; */
513
       /*} */
514
515
       while ((v = LWZReadByte(fd,FALSE,c)) >= 0 ) {
516
               /* This how we recognize which colors are actually used. */
517
               if (im->open[v]) {
518
                       im->open[v] = 0;
519
               }
520
               gdImageSetPixel(im, xpos, ypos, v);
521
               ++xpos;
522
               if (xpos == len) {
523
                       xpos = 0;
524
                       if (interlace) {
525
                               switch (pass) {
526
                               case 0:
527
                               case 1:
528
                                       ypos += 8; break;
529
                               case 2:
530
                                       ypos += 4; break;
531
                               case 3:
532
                                       ypos += 2; break;
533
                               }
534
535
                               if (ypos >= height) {
536
                                       ++pass;
537
                                       switch (pass) {
538
                                       case 1:
539
                                               ypos = 4; break;
540
                                       case 2:
541
                                               ypos = 2; break;
542
                                       case 3:
543
                                               ypos = 1; break;
544
                                       default:
545
                                               goto fini;
546
                                       }
547
                               }
548
                       } else {
549
                               ++ypos;
550
                       }
551
               }
552
               if (ypos >= height)
553
                       break;
554
       }
555
556
fini:
557
       if (LWZReadByte(fd,FALSE,c)>=0) {
558
               /* Ignore extra */
559
       }
560
}
561
(-)graphics/gd/files/patch-ac (-188 lines)
Lines 1-188 Link Here
1
--- Makefile.orig	Thu Feb 22 19:03:43 2001
2
+++ Makefile	Sun Dec 16 05:57:07 2001
3
@@ -3,22 +3,30 @@
4
 #If you do not have gcc, change the setting for COMPILER, but you must
5
 #use an ANSI standard C compiler (NOT the old SunOS 4.1.3 cc
6
 #compiler; get gcc if you are still using it). 
7
-COMPILER=gcc
8
+COMPILER=${CC}
9
 
10
 #If the ar command fails on your system, consult the ar manpage
11
 #for your system. 
12
-AR=ar
13
+#AR=ar
14
 
15
 #If you don't have FreeType, libjpeg and/or Xpm installed, including the
16
 #header files, uncomment this (default). You really must install
17
 #libpng and zlib to get anywhere if you wish to create PNG images.
18
-CFLAGS=-O -DHAVE_LIBPNG -DHAVE_LIBJPEG
19
+CFLAGS+=-DHAVE_LIBPNG -DHAVE_LIBJPEG -DHAVE_LIBFREETYPE
20
 
21
 #If you do have FreeType, libjpeg and/or Xpm fully installed, uncomment a
22
 #variation of this and comment out the line above. See also LIBS below.
23
 #CFLAGS=-O -DHAVE_LIBXPM -DHAVE_LIBPNG -DHAVE_LIBJPEG \
24
 #	-DHAVE_LIBFREETYPE -DHAVE_LIBTTF 
25
 
26
+.if defined(WITH_X11)
27
+CFLAGS+=-DHAVE_XPM 
28
+.endif
29
+
30
+.if defined(JISX0208)
31
+CFLAGS+=-DJISX0208
32
+.endif
33
+
34
 #To use the old FreeType 1.x library, add this additional #define
35
 #to the line above
36
 #-DHAVE_LIBTTF 
37
@@ -30,7 +38,7 @@
38
 #Some systems are very picky about link order. They don't all agree
39
 #on the right order, either.
40
 
41
-LIBS=-lgd -lpng -lz -lm
42
+LIBS=-lgd -lpng -lz -ljpeg -lm `$(FREETYPE_CONFIG) --libs`
43
 
44
 #If you do have FreeType, JPEG and/or Xpm fully installed, uncomment a 
45
 #variation of this and comment out the line above. Note that
46
@@ -38,6 +46,10 @@
47
 
48
 #LIBS=-lgd -lpng -lz -ljpeg -lfreetype -lm -lttf
49
 
50
+.if defined(WITH_X11)
51
+LIBS+=-lXpm -lX11
52
+.endif
53
+
54
 #Note: for Freetype 1.x, use DHAVE_LIBTTF and -lttf instead.
55
 
56
 #Typical install locations for freetype, zlib, xpm, libjpeg and libpng header 
57
@@ -45,7 +57,11 @@
58
 #ensure that the version of gd you are installing is used, and not an 
59
 #older release in your directory tree somewhere.
60
 
61
-INCLUDEDIRS=-I. -I/usr/include/freetype2 -I/usr/include/X11 -I/usr/X11R6/include/X11 -I/usr/local/include 
62
+INCLUDEDIRS=-I. `$(FREETYPE_CONFIG) --cflags` -I${LOCALBASE}/include
63
+
64
+.if defined(WITH_X11)
65
+INCLUDEDIRS+=-I${X11BASE}/include/X11 -I${X11BASE}/include
66
+.endif
67
 
68
 #Typical install locations for freetype, zlib, xpm and libpng libraries.
69
 #If yours are somewhere else, other than a standard location
70
@@ -55,16 +71,20 @@
71
 #on your system can't cause conflicts while building a new one.
72
 #This line shouldn't hurt if you don't actually have some of the
73
 #optional libraries and directories.
74
-LIBDIRS=-L. -L/usr/local/lib -L/usr/lib/X11 -L/usr/X11R6/lib
75
+LIBDIRS=-L. -L${LOCALBASE}/lib -Wl,--rpath,${LOCALBASE}/lib
76
+
77
+.if defined(WITH_X11)
78
+LIBDIRS+=-L${X11BASE}/lib -Wl,--rpath,${X11BASE}/lib
79
+.endif
80
 
81
 #Location where libgd.a should be installed by "make install".
82
-INSTALL_LIB=/usr/local/lib
83
+INSTALL_LIB=${PREFIX}/lib
84
 
85
 #Location where .h files should be installed by "make install".
86
-INSTALL_INCLUDE=/usr/local/include
87
+INSTALL_INCLUDE=${PREFIX}/include/gd
88
 
89
 #Location where useful non-test programs should be installed by "make install".
90
-INSTALL_BIN=/usr/local/bin
91
+INSTALL_BIN=${PREFIX}/bin
92
 
93
 #
94
 #
95
@@ -74,34 +94,43 @@
96
 
97
 VERSION=1.8.4
98
 
99
-CC=$(COMPILER) $(INCLUDEDIRS)
100
-LINK=$(CC) $(LIBDIRS) $(LIBS)
101
+CFLAGS+=$(INCLUDEDIRS)
102
 
103
 PROGRAMS=$(BIN_PROGRAMS) $(TEST_PROGRAMS)
104
 
105
 BIN_PROGRAMS=pngtogd pngtogd2 gdtopng gd2topng gd2copypal gdparttopng webpng
106
 TEST_PROGRAMS=gdtest gddemo gd2time gdtestft gdtestttf
107
 
108
-all: libgd.a $(PROGRAMS)
109
+SOVER=2
110
+
111
+.SUFFIXES: .c .so .o
112
 
113
-install: libgd.a $(BIN_PROGRAMS)
114
-	sh ./install-item 644 libgd.a $(INSTALL_LIB)/libgd.a
115
-	sh ./install-item 755 pngtogd $(INSTALL_BIN)/pngtogd
116
-	sh ./install-item 755 pngtogd2 $(INSTALL_BIN)/pngtogd2
117
-	sh ./install-item 755 gdtopng $(INSTALL_BIN)/gdtopng
118
-	sh ./install-item 755 gd2topng $(INSTALL_BIN)/gd2topng
119
-	sh ./install-item 755 gd2copypal $(INSTALL_BIN)/gd2copypal
120
-	sh ./install-item 755 gdparttopng $(INSTALL_BIN)/gdparttopng
121
-	sh ./install-item 755 webpng $(INSTALL_BIN)/webpng
122
-	sh ./install-item 755 bdftogd $(INSTALL_BIN)/bdftogd
123
-	sh ./install-item 644 gd.h $(INSTALL_INCLUDE)/gd.h
124
-	sh ./install-item 644 gdcache.h $(INSTALL_INCLUDE)/gdcache.h
125
-	sh ./install-item 644 gd_io.h $(INSTALL_INCLUDE)/gd_io.h
126
-	sh ./install-item 644 gdfontg.h $(INSTALL_INCLUDE)/gdfontg.h
127
-	sh ./install-item 644 gdfontl.h $(INSTALL_INCLUDE)/gdfontl.h
128
-	sh ./install-item 644 gdfontmb.h $(INSTALL_INCLUDE)/gdfontmb.h
129
-	sh ./install-item 644 gdfonts.h $(INSTALL_INCLUDE)/gdfonts.h
130
-	sh ./install-item 644 gdfontt.h $(INSTALL_INCLUDE)/gdfontt.h
131
+.c.so:
132
+	$(CC) -fpic -DPIC $(CFLAGS) -o $@ -c $<
133
+
134
+all: libgd.a libgd.so.$(SOVER) $(PROGRAMS)
135
+
136
+install: libgd.a libgd.so.$(SOVER) $(BIN_PROGRAMS)
137
+	-mkdir -p $(INSTALL_LIB) $(INSTALL_INCLUDE) $(INSTALL_BIN)
138
+	${BSD_INSTALL_DATA} libgd.a $(INSTALL_LIB)/libgd.a
139
+	${BSD_INSTALL_DATA} libgd.so.$(SOVER) $(INSTALL_LIB)/libgd.so.$(SOVER)
140
+	-ln -sf libgd.so.$(SOVER) $(INSTALL_LIB)/libgd.so
141
+	${BSD_INSTALL_PROGRAM} pngtogd $(INSTALL_BIN)/pngtogd
142
+	${BSD_INSTALL_PROGRAM} pngtogd2 $(INSTALL_BIN)/pngtogd2
143
+	${BSD_INSTALL_PROGRAM} gdtopng $(INSTALL_BIN)/gdtopng
144
+	${BSD_INSTALL_PROGRAM} gd2topng $(INSTALL_BIN)/gd2topng
145
+	${BSD_INSTALL_PROGRAM} gd2copypal $(INSTALL_BIN)/gd2copypal
146
+	${BSD_INSTALL_PROGRAM} gdparttopng $(INSTALL_BIN)/gdparttopng
147
+	${BSD_INSTALL_PROGRAM} webpng $(INSTALL_BIN)/webpng
148
+	${BSD_INSTALL_SCRIPT} bdftogd $(INSTALL_BIN)/bdftogd
149
+	${BSD_INSTALL_DATA} gd.h $(INSTALL_INCLUDE)/gd.h
150
+	${BSD_INSTALL_DATA} gdcache.h $(INSTALL_INCLUDE)/gdcache.h
151
+	${BSD_INSTALL_DATA} gd_io.h $(INSTALL_INCLUDE)/gd_io.h
152
+	${BSD_INSTALL_DATA} gdfontg.h $(INSTALL_INCLUDE)/gdfontg.h
153
+	${BSD_INSTALL_DATA} gdfontl.h $(INSTALL_INCLUDE)/gdfontl.h
154
+	${BSD_INSTALL_DATA} gdfontmb.h $(INSTALL_INCLUDE)/gdfontmb.h
155
+	${BSD_INSTALL_DATA} gdfonts.h $(INSTALL_INCLUDE)/gdfonts.h
156
+	${BSD_INSTALL_DATA} gdfontt.h $(INSTALL_INCLUDE)/gdfontt.h
157
 
158
 gddemo: gddemo.o libgd.a
159
 	$(CC) gddemo.o -o gddemo	$(LIBDIRS) $(LIBS)
160
@@ -138,18 +167,21 @@
161
 gdtestttf: gdtestttf.o libgd.a
162
 	$(CC) --verbose gdtestttf.o -o gdtestttf $(LIBDIRS) $(LIBS)
163
 
164
-libgd.a: gd.o gd_gd.o gd_gd2.o gd_io.o gd_io_dp.o gd_io_file.o gd_ss.o \
165
+OBJS= gd.o gd_gd.o gd_gd2.o gd_io.o gd_io_dp.o gd_io_file.o gd_ss.o \
166
 	gd_io_ss.o gd_png.o gd_jpeg.o gdxpm.o gdfontt.o gdfonts.o gdfontmb.o gdfontl.o \
167
 	gdfontg.o gdtables.o gdft.o gdttf.o gdcache.o gdkanji.o wbmp.o \
168
-	gd_wbmp.o gdhelpers.o gd.h gdfontt.h gdfonts.h gdfontmb.h gdfontl.h \
169
+	gd_wbmp.o gdhelpers.o gd_gif_in.o
170
+INCS= gd.h gdfontt.h gdfonts.h gdfontmb.h gdfontl.h \
171
 	gdfontg.h gdhelpers.h
172
+
173
+libgd.a:	$(INCS) $(OBJS)
174
 	rm -f libgd.a
175
-	$(AR) rc libgd.a gd.o gd_gd.o gd_gd2.o gd_io.o gd_io_dp.o \
176
-		gd_io_file.o gd_ss.o gd_io_ss.o gd_png.o gd_jpeg.o gdxpm.o \
177
-		gdfontt.o gdfonts.o gdfontmb.o gdfontl.o gdfontg.o \
178
-		gdtables.o gdft.o gdttf.o gdcache.o gdkanji.o wbmp.o \
179
-		gd_wbmp.o gdhelpers.o
180
+	$(AR) rc libgd.a $(OBJS)
181
 	-ranlib libgd.a
182
+
183
+libgd.so.$(SOVER):	$(INCS) $(OBJS:.o=.so)
184
+	$(CC) -shared -Wl,-x,-soname,$@ -o $@ $(OBJS:.o=.so) $(LIBDIRS) $(LIBS)
185
+	ln -sf libgd.so.$(SOVER) libgd.so
186
 
187
 clean:
188
 	rm -f *.o *.a ${PROGRAMS} test/gdtest.jpg test/gdtest.wbmp
(-)graphics/gd/files/patch-gdcache.h (+10 lines)
Line 0 Link Here
1
--- gdcache.h.orig	Wed Feb  7 04:44:02 2001
2
+++ gdcache.h	Fri Jul  4 21:58:32 2003
3
@@ -40,7 +40,6 @@
4
 /* header                                                */
5
 /*********************************************************/
6
 
7
-#include <malloc.h>
8
 #ifndef NULL
9
 #define NULL (void *)0
10
 #endif
(-)graphics/gd/files/patch-gif (-4 lines)
Lines 9-15 Link Here
9
+gdImagePtr gdImageCreateFromGif(FILE *fd);
9
+gdImagePtr gdImageCreateFromGif(FILE *fd);
10
+gdImagePtr gdImageCreateFromGifCtx(gdIOCtxPtr in);
10
+gdImagePtr gdImageCreateFromGifCtx(gdIOCtxPtr in);
11
 gdImagePtr gdImageCreateFromPng(FILE *fd);
11
 gdImagePtr gdImageCreateFromPng(FILE *fd);
12
--- gd_gif_in.c	Fri Jul 27 16:13:45 2001
13
+++ gd_gif_in.c	Fri Jul 27 16:14:46 2001
14
@@ -6,1 +6,0 @@
15
-#include "io.h"
(-)graphics/gd/pkg-plist (-13 / +3 lines)
Lines 1-11 Link Here
1
bin/bdftogd
2
bin/gd2copypal
3
bin/gd2topng
4
bin/gdparttopng
5
bin/gdtopng
6
bin/pngtogd
7
bin/pngtogd2
8
bin/webpng
9
include/gd/gd.h
1
include/gd/gd.h
10
include/gd/gd_io.h
2
include/gd/gd_io.h
11
include/gd/gdcache.h
3
include/gd/gdcache.h
Lines 14-22 Link Here
14
include/gd/gdfontmb.h
6
include/gd/gdfontmb.h
15
include/gd/gdfonts.h
7
include/gd/gdfonts.h
16
include/gd/gdfontt.h
8
include/gd/gdfontt.h
17
lib/libgd.a
9
lib/libgd1.a
18
lib/libgd.so
10
lib/libgd1.so
19
lib/libgd.so.2
11
lib/libgd1.so.2
20
%%PORTDOCS%%share/doc/gd/index.html
21
%%PORTDOCS%%@dirrm share/doc/gd
22
@dirrm include/gd
12
@dirrm include/gd

Return to bug 54100