$NetBSD: patch-aa,v 1.14 2002/01/21 16:29:26 wiz Exp $

--- Makefile.orig	Thu Feb 22 18:03:43 2001
+++ Makefile
@@ -3,7 +3,8 @@
 #If you do not have gcc, change the setting for COMPILER, but you must
 #use an ANSI standard C compiler (NOT the old SunOS 4.1.3 cc
 #compiler; get gcc if you are still using it). 
-COMPILER=gcc
+#COMPILER=gcc
+INSTALL=$(LIBTOOL) install -c -m
 
 #If the ar command fails on your system, consult the ar manpage
 #for your system. 
@@ -12,12 +13,11 @@
 #If you don't have FreeType, libjpeg and/or Xpm installed, including the
 #header files, uncomment this (default). You really must install
 #libpng and zlib to get anywhere if you wish to create PNG images.
-CFLAGS=-O -DHAVE_LIBPNG -DHAVE_LIBJPEG
+#CFLAGS=-O -DHAVE_LIBPNG -DHAVE_LIBJPEG
 
 #If you do have FreeType, libjpeg and/or Xpm fully installed, uncomment a
 #variation of this and comment out the line above. See also LIBS below.
-#CFLAGS=-O -DHAVE_LIBXPM -DHAVE_LIBPNG -DHAVE_LIBJPEG \
-#	-DHAVE_LIBFREETYPE -DHAVE_LIBTTF 
+CFLAGS+=-DHAVE_LIBXPM -DHAVE_LIBPNG -DHAVE_LIBJPEG -DHAVE_LIBTTF 
 
 #To use the old FreeType 1.x library, add this additional #define
 #to the line above
@@ -30,13 +30,13 @@
 #Some systems are very picky about link order. They don't all agree
 #on the right order, either.
 
-LIBS=-lgd -lpng -lz -lm
+#LIBS=-lgd -lpng -lz -lm
 
 #If you do have FreeType, JPEG and/or Xpm fully installed, uncomment a 
 #variation of this and comment out the line above. Note that
 #Xpm requires X11. See also CFLAGS above.
 
-#LIBS=-lgd -lpng -lz -ljpeg -lfreetype -lm -lttf
+LIBS=$(LIBGD) -lpng -lz -ljpeg -lm -lttf -lintl
 
 #Note: for Freetype 1.x, use DHAVE_LIBTTF and -lttf instead.
 
@@ -45,7 +45,7 @@
 #ensure that the version of gd you are installing is used, and not an 
 #older release in your directory tree somewhere.
 
-INCLUDEDIRS=-I. -I/usr/include/freetype2 -I/usr/include/X11 -I/usr/X11R6/include/X11 -I/usr/local/include 
+INCLUDEDIRS=-I. ${CPPFLAGS}
 
 #Typical install locations for freetype, zlib, xpm and libpng libraries.
 #If yours are somewhere else, other than a standard location
@@ -55,16 +55,16 @@
 #on your system can't cause conflicts while building a new one.
 #This line shouldn't hurt if you don't actually have some of the
 #optional libraries and directories.
-LIBDIRS=-L. -L/usr/local/lib -L/usr/lib/X11 -L/usr/X11R6/lib
+LIBDIRS=${LDFLAGS}
 
 #Location where libgd.a should be installed by "make install".
-INSTALL_LIB=/usr/local/lib
+INSTALL_LIB=${PREFIX}/lib
 
 #Location where .h files should be installed by "make install".
-INSTALL_INCLUDE=/usr/local/include
+INSTALL_INCLUDE=${PREFIX}/include
 
 #Location where useful non-test programs should be installed by "make install".
-INSTALL_BIN=/usr/local/bin
+INSTALL_BIN=${PREFIX}/bin
 
 #
 #
@@ -74,7 +74,7 @@
 
 VERSION=1.8.4
 
-CC=$(COMPILER) $(INCLUDEDIRS)
+CC=$(LIBTOOL) $(COMPILER) $(INCLUDEDIRS)
 LINK=$(CC) $(LIBDIRS) $(LIBS)
 
 PROGRAMS=$(BIN_PROGRAMS) $(TEST_PROGRAMS)
@@ -82,75 +82,75 @@
 BIN_PROGRAMS=pngtogd pngtogd2 gdtopng gd2topng gd2copypal gdparttopng webpng
 TEST_PROGRAMS=gdtest gddemo gd2time gdtestft gdtestttf
 
-all: libgd.a $(PROGRAMS)
+LIBGD=libgd.la
 
-install: libgd.a $(BIN_PROGRAMS)
-	sh ./install-item 644 libgd.a $(INSTALL_LIB)/libgd.a
-	sh ./install-item 755 pngtogd $(INSTALL_BIN)/pngtogd
-	sh ./install-item 755 pngtogd2 $(INSTALL_BIN)/pngtogd2
-	sh ./install-item 755 gdtopng $(INSTALL_BIN)/gdtopng
-	sh ./install-item 755 gd2topng $(INSTALL_BIN)/gd2topng
-	sh ./install-item 755 gd2copypal $(INSTALL_BIN)/gd2copypal
-	sh ./install-item 755 gdparttopng $(INSTALL_BIN)/gdparttopng
-	sh ./install-item 755 webpng $(INSTALL_BIN)/webpng
-	sh ./install-item 755 bdftogd $(INSTALL_BIN)/bdftogd
-	sh ./install-item 644 gd.h $(INSTALL_INCLUDE)/gd.h
-	sh ./install-item 644 gdcache.h $(INSTALL_INCLUDE)/gdcache.h
-	sh ./install-item 644 gd_io.h $(INSTALL_INCLUDE)/gd_io.h
-	sh ./install-item 644 gdfontg.h $(INSTALL_INCLUDE)/gdfontg.h
-	sh ./install-item 644 gdfontl.h $(INSTALL_INCLUDE)/gdfontl.h
-	sh ./install-item 644 gdfontmb.h $(INSTALL_INCLUDE)/gdfontmb.h
-	sh ./install-item 644 gdfonts.h $(INSTALL_INCLUDE)/gdfonts.h
-	sh ./install-item 644 gdfontt.h $(INSTALL_INCLUDE)/gdfontt.h
+all: $(LIBGD) $(PROGRAMS)
 
-gddemo: gddemo.o libgd.a
+install: $(LIBGD) $(BIN_PROGRAMS)
+	sh $(INSTALL) 644 $(LIBGD) $(INSTALL_LIB)
+	sh $(INSTALL) 755 pngtogd $(INSTALL_BIN)/pngtogd
+	sh $(INSTALL) 755 pngtogd2 $(INSTALL_BIN)/pngtogd2
+	sh $(INSTALL) 755 gdtopng $(INSTALL_BIN)/gdtopng
+	sh $(INSTALL) 755 gd2topng $(INSTALL_BIN)/gd2topng
+	sh $(INSTALL) 755 gd2copypal $(INSTALL_BIN)/gd2copypal
+	sh $(INSTALL) 755 gdparttopng $(INSTALL_BIN)/gdparttopng
+	sh $(INSTALL) 755 webpng $(INSTALL_BIN)/webpng
+	sh $(INSTALL) 755 bdftogd $(INSTALL_BIN)/bdftogd
+	sh $(INSTALL) 644 gd.h $(INSTALL_INCLUDE)/gd.h
+	sh $(INSTALL) 644 gdcache.h $(INSTALL_INCLUDE)/gdcache.h
+	sh $(INSTALL) 644 gd_io.h $(INSTALL_INCLUDE)/gd_io.h
+	sh $(INSTALL) 644 gdfontg.h $(INSTALL_INCLUDE)/gdfontg.h
+	sh $(INSTALL) 644 gdfontl.h $(INSTALL_INCLUDE)/gdfontl.h
+	sh $(INSTALL) 644 gdfontmb.h $(INSTALL_INCLUDE)/gdfontmb.h
+	sh $(INSTALL) 644 gdfonts.h $(INSTALL_INCLUDE)/gdfonts.h
+	sh $(INSTALL) 644 gdfontt.h $(INSTALL_INCLUDE)/gdfontt.h
+
+gddemo: gddemo.o $(LIBGD)
 	$(CC) gddemo.o -o gddemo	$(LIBDIRS) $(LIBS)
 
-pngtogd: pngtogd.o libgd.a
+pngtogd: pngtogd.o $(LIBGD)
 	$(CC) pngtogd.o -o pngtogd	$(LIBDIRS) $(LIBS) 
 
-webpng: webpng.o libgd.a
+webpng: webpng.o $(LIBGD)
 	$(CC) webpng.o -o webpng	$(LIBDIRS) $(LIBS)
 
-pngtogd2: pngtogd2.o libgd.a
+pngtogd2: pngtogd2.o $(LIBGD)
 	$(CC) pngtogd2.o -o pngtogd2	$(LIBDIRS) $(LIBS)
 
-gdtopng: gdtopng.o libgd.a
+gdtopng: gdtopng.o $(LIBGD)
 	$(CC) gdtopng.o -o gdtopng	$(LIBDIRS) $(LIBS)
 
-gd2topng: gd2topng.o libgd.a
+gd2topng: gd2topng.o $(LIBGD)
 	$(CC) gd2topng.o -o gd2topng	$(LIBDIRS) $(LIBS)
 
-gd2copypal: gd2copypal.o libgd.a
+gd2copypal: gd2copypal.o $(LIBGD)
 	$(CC) gd2copypal.o -o gd2copypal	$(LIBDIRS) $(LIBS)
 
-gdparttopng: gdparttopng.o libgd.a
+gdparttopng: gdparttopng.o $(LIBGD)
 	$(CC) gdparttopng.o -o gdparttopng	$(LIBDIRS) $(LIBS)
 
-gdtest: gdtest.o libgd.a
+gdtest: gdtest.o $(LIBGD)
 	$(CC) gdtest.o -o gdtest	$(LIBDIRS) $(LIBS)
 
-gd2time: gd2time.o libgd.a
+gd2time: gd2time.o $(LIBGD)
 	$(CC) gd2time.o -o gd2time	$(LIBDIRS) $(LIBS)
 
-gdtestft: gdtestft.o libgd.a
+gdtestft: gdtestft.o $(LIBGD)
 	$(CC) --verbose gdtestft.o -o gdtestft $(LIBDIRS) $(LIBS)
-gdtestttf: gdtestttf.o libgd.a
+gdtestttf: gdtestttf.o $(LIBGD)
 	$(CC) --verbose gdtestttf.o -o gdtestttf $(LIBDIRS) $(LIBS)
 
-libgd.a: gd.o gd_gd.o gd_gd2.o gd_io.o gd_io_dp.o gd_io_file.o gd_ss.o \
+GD_OBJS= gd.o gd_gd.o gd_gd2.o gd_io.o gd_io_dp.o gd_io_file.o gd_ss.o \
 	gd_io_ss.o gd_png.o gd_jpeg.o gdxpm.o gdfontt.o gdfonts.o gdfontmb.o gdfontl.o \
 	gdfontg.o gdtables.o gdft.o gdttf.o gdcache.o gdkanji.o wbmp.o \
-	gd_wbmp.o gdhelpers.o gd.h gdfontt.h gdfonts.h gdfontmb.h gdfontl.h \
-	gdfontg.h gdhelpers.h
-	rm -f libgd.a
-	$(AR) rc libgd.a gd.o gd_gd.o gd_gd2.o gd_io.o gd_io_dp.o \
-		gd_io_file.o gd_ss.o gd_io_ss.o gd_png.o gd_jpeg.o gdxpm.o \
-		gdfontt.o gdfonts.o gdfontmb.o gdfontl.o gdfontg.o \
-		gdtables.o gdft.o gdttf.o gdcache.o gdkanji.o wbmp.o \
 		gd_wbmp.o gdhelpers.o
-	-ranlib libgd.a
+
+$(LIBGD): $(GD_OBJS) gd.h gdfontt.h gdfonts.h gdfontmb.h gdfontl.h \
+	gdfontg.h gdhelpers.h
+	rm -f $(LIBGD)
+	$(CC) -o $(LIBGD) $(GD_OBJS:.o=.lo) -rpath ${PREFIX}/lib \
+		-version-info $(GD_MAJOR):$(GD_MINOR) $(LIBDIRS) ${LIBS:C/${LIBGD}//g}
 
 clean:
-	rm -f *.o *.a ${PROGRAMS} test/gdtest.jpg test/gdtest.wbmp
+	$(LIBTOOL) rm -f *.o *.a ${PROGRAMS} test/gdtest.jpg test/gdtest.wbmp
 
