Fix for 687214, FreeBSD build issues.

Alex Cherepanov <[email protected]>
Newsgroups gmane.comp.printing.ghostscript.patches
Organization Coscript Software
Message-ID <[email protected]>
This is a preliminary fix for compiling GS with BSD make.
BSD make changes the current directory to ./obj when it has a
chance. This breaks GS makefiles.

This patch detects that make changes the directory and works
with absolute paths. The patch works but a few things are not
completed yet or need more discussion.

(1) I'm mot convinced that this is a right way to work around the
problem. CNU guidelines advise not to use ./obj directory in the
build tree. This is by far the easiest and most reliable solution.

(2) There's no error checking in the code that tests BSD make.
Suggestions are welcome.

(3) Only autoconf build has been tested. Other makefiles are broken.

(4) We force the build in ./obj directory instead of enabling BSD make
to use any directory it pleases.

_______________________________________________
gs-code-review mailing list
[email protected]
http://www.ghostscript.com/mailman/listinfo/gs-code-review
makefile.diff (text/plain, 4 KB)
Index: gs/src/configure.ac
===================================================================
RCS file: /cvs/ghostscript/gs/src/configure.ac,v
retrieving revision 1.45
diff -b -u -r1.45 configure.ac
--- a/gs/src/configure.ac	27 Apr 2004 06:04:03 -0000	1.45
+++ b/gs/src/configure.ac	17 May 2004 14:48:05 -0000
@@ -39,6 +39,22 @@
 AC_PROG_RANLIB
 #AC_PROG_INSTALL
 
+# Check whether make descends into ./obj directory.
+# Use absolute paths everywhere if it does.
+CWD=`pwd`
+rm -rf confdir
+mkdir confdir
+cd confdir
+mkdir obj
+echo 'test:' >Makefile
+echo '	pwd' >>Makefile
+MWD=`make | sed '$!d'`
+if test "x$CWD/confdir" = "x$MWD" ; then
+   CWD=.
+fi
+cd ..
+rm -rf confdir
+
 dnl --------------------------------------------------
 dnl Set build flags based on environment
 dnl --------------------------------------------------
@@ -390,4 +406,5 @@
 
 AC_SUBST(OPT_CFLAGS)
 AC_SUBST(GCFLAGS)
+AC_SUBST(CWD)
 AC_OUTPUT(Makefile)
Index: gs/src/Makefile.in
===================================================================
RCS file: /cvs/ghostscript/gs/src/Makefile.in,v
retrieving revision 1.35
diff -b -u -r1.35 Makefile.in
--- a/gs/src/Makefile.in	30 Apr 2004 22:31:58 -0000	1.35
+++ b/gs/src/Makefile.in	17 May 2004 14:48:05 -0000
@@ -25,14 +25,15 @@
 # source, generated intermediate file, and object directories
 # for the graphics library (GL) and the PostScript/PDF interpreter (PS).
 
-BINDIR=./bin
-GLSRCDIR=./src
-GLGENDIR=./obj
-GLOBJDIR=./obj
-PSSRCDIR=./src
-PSLIBDIR=./lib
-PSGENDIR=./obj
-PSOBJDIR=./obj
+MAKEDIR=@CWD@
+BINDIR=@CWD@/bin
+GLSRCDIR=@CWD@/src
+GLGENDIR=@CWD@/obj
+GLOBJDIR=@CWD@/obj
+PSSRCDIR=@CWD@/src
+PSLIBDIR=@CWD@/lib
+PSGENDIR=@CWD@/obj
+PSOBJDIR=@CWD@/obj
 
 # Do not edit the next group of lines.
 
@@ -138,7 +139,7 @@
 # You may need to change this if the IJG library version changes.
 # See jpeg.mak for more information.
 
-JSRCDIR=@LIBJPEGDIR@
+JSRCDIR=@CWD@/@LIBJPEGDIR@
 JVERSION=6
 
 # Note: if a shared library is used, it may not contain the
@@ -155,35 +156,35 @@
 # See libpng.mak for more information.
 
 SHARE_LIBPNG=@SHARE_LIBPNG@
-PSRCDIR=@LIBPNGDIR@
+PSRCDIR=@CWD@/@LIBPNGDIR@
 LIBPNG_NAME=png
 
 # Define the directory where the zlib sources are stored.
 # See zlib.mak for more information.
 
 SHARE_ZLIB=@SHARE_ZLIB@
-ZSRCDIR=@ZLIBDIR@
+ZSRCDIR=@CWD@/@ZLIBDIR@
 #ZLIB_NAME=gz
 ZLIB_NAME=z
 
 # Choose shared or compiled in libjbig2dec and source location
 SHARE_JBIG2=@SHARE_JBIG2@
-JBIG2SRCDIR=@JBIG2DIR@
+JBIG2SRCDIR=@CWD@/@JBIG2DIR@
 
 # Choose shared of compiled in libjasper (JPXDecode support) and source location
 SHARE_JASPER=@SHARE_JASPER@
-JASPERSRCDIR=@JASPERDIR@
+JASPERSRCDIR=@CWD@/@JASPERDIR@
 
 # Define the directory where the icclib source are stored.
 # See icclib.mak for more information
 
-ICCSRCDIR=icclib
+ICCSRCDIR=@CWD@/icclib
 
 # Define the directory where the ijs source is stored,
 # and the process forking method to use for the server.
 # See ijs.mak for more information.
  
-IJSSRCDIR=@IJSDIR@
+IJSSRCDIR=@CWD@/@IJSDIR@
 IJSEXECTYPE=unix
 
 # Define how to build the library archives.  (These are not used in any
Index: gs/src/unix-end.mak
===================================================================
RCS file: /cvs/ghostscript/gs/src/unix-end.mak,v
retrieving revision 1.6
diff -b -u -r1.6 unix-end.mak
--- a/gs/src/unix-end.mak	11 Dec 2003 02:22:11 -0000	1.6
+++ b/gs/src/unix-end.mak	17 May 2004 14:48:05 -0000
@@ -40,10 +40,10 @@
  PSGENDIR=$(PSGENDIR)/$(PGRELDIR) PSOBJDIR=$(PSOBJDIR)/$(PGRELDIR)
 
 pg: PGDIRS
-	$(MAKE) $(PGDEFS) default
+	cd $(MAKEDIR); $(MAKE) $(PGDEFS) default
 
 pgclean: PGDIRS
-	$(MAKE) $(PGDEFS) clean
+	cd $(MAKEDIR); $(MAKE) $(PGDEFS) clean
 
 # Define a rule for building debugging configurations.
 DEBUGDIRS: STDDIRS
@@ -59,10 +59,10 @@
  PSGENDIR=$(PSGENDIR)/$(DEBUGRELDIR) PSOBJDIR=$(PSOBJDIR)/$(DEBUGRELDIR)
 
 debug: DEBUGDIRS
-	$(MAKE) $(DEBUGDEFS) default
+	cd $(MAKEDIR); $(MAKE) $(DEBUGDEFS) default
 
 debugclean: DEBUGDIRS
-	$(MAKE) $(DEBUGDEFS) clean
+	cd $(MAKEDIR); $(MAKE) $(DEBUGDEFS) clean
 
 # The rule for gconfigv.h is here because it is shared between Unix and
 # DV/X environments.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.