Description: debianization: build
 Attempt to adapt the upstream building scheme to the Debian build
 machinery. Also meant to fix annoying warnings, to address Debian
 specific stuff in general.
Author: Jerome Benoit <calculus@rezozer.net>
Last-Update: 2016-07-16

--- a/src/evalmore.c
+++ b/src/evalmore.c
@@ -22,7 +22,7 @@
 #define S_IFIFO 0x100
 #elif !defined(MAC_CW)
 #include <sys/stat.h>
-/* #include <sys/wait.h> */
+#include <sys/wait.h>
 #ifndef S_IFIFO
 #ifdef __S_IFIFO
 #define S_IFIFO __S_IFIFO
--- a/src/Makefile
+++ b/src/Makefile
@@ -44,16 +44,17 @@
 CC= gcc
 
 CFLAGS?=
-CFLAGS+= -O3
-#CFLAGS+= -DLONGDOUBLE
+##CFLAGS+= -O3
+CFLAGS+=-Wno-unused-result
+#>>LONGDOUBLE<<#CFLAGS+= -DLONGDOUBLE
 
 #---------------------Start of system choices---------------------------------
 
 # Remove #'s from following 3 lines for generic Unix without builtin graphics.
 # Add -DOOGL to CFLAGS if you are using geomview.
 #CFLAGS+= -DGENERIC
-#GRAPH= nulgraph.o 
-#GRAPHLIB= 
+#GRAPH= nulgraph.o
+#GRAPHLIB=
 
 #---- Generic Unix -----------------------------------------------------------
 
@@ -67,14 +68,20 @@
 #GRAPHLIB= -lX11 
 #some places might have -lX11-mit
 
+#----- Linux with no X-windows -----------------------------------------------
+
+#>NOX<#CFLAGS+= -DLINUX -DOOGL -DPTHREADS
+#>NOX<#GRAPH= nulgraph.o
+#>NOX<#GRAPHLIB= -lpthread
+
 #----- Linux OpenGL ----------------------------------------------------------
 
 # Remove #'s from following 3 lines for LINUX with OpenGL GLUT graphics.
 # The graphics are on a second thread, so pthreads are needed.
 # NOTE: -DPTRHEADS is necessary with glutgraph.o.
-#CFLAGS+= -DLINUX -DOOGL -DPTHREADS
-#GRAPH= glutgraph.o
-#GRAPHLIB= -lGL -lGLU -lglut -lpthread
+#>GLUT<#CFLAGS+= -DLINUX -DOOGL -DPTHREADS
+#>GLUT<#GRAPH= glutgraph.o
+#>GLUT<#GRAPHLIB= -lGL -lGLU -lglut -lpthread
 # NOTE: It has been reported to me that RedHat 9 needs the following line
 # for GRAPHLIB, but earlier and later versions do okay with the GRAPHLIB
 # line just above.
@@ -85,8 +92,8 @@
 # It's up to you to install the quadmath library.
 # Remove #'s from previous 3 lines for LINUX with OpenGL GLUT graphics and from
 # the following 2 lines for LINUX with 128-bit floating point computation.
-#CFLAGS+= -DFLOAT128
-#GRAPHLIB+= -lquadmath
+#>>FLOAT128<<#CFLAGS+= -DFLOAT128
+#>>FLOAT128<<#GRAPHLIB+= -lquadmath
 
 #------ Linux Xwindows ------------------------------------------------------
 
@@ -219,6 +226,24 @@
 #GRAPH= nulgraph.o 
 #GRAPHLIB= 
 
+#-----------------------------------------------------------------------------
+
+### Read Compiling section (2.3.1) on how to allow commans based on
+### the METIS partitioning software.
+##CFLAGS+= -DMETIS
+##GRAPHLIB+= -lmetis
+
+# Read the NOTE related to readline support in header.
+CFLAGS+= -DUSE_READLINE
+GRAPHLIB+= -lreadline
+
+# Read the NOTE on how to append a default builtin path.
+CFLAGS+= -DENVEVOLVERPATHBUILTIN=\"/usr/share/doc/evolver-doc/html:/usr/share/doc/evolver-doc/examples\"
+
+# Debian package version.
+CFLAGS+= -DDEB_PKG_VERSION=\"$(DEB_PKG_VERSION)\"
+
+
 #-------------------End of system-specific options----------------------------
 
 OBJ= calcforc.o  variable.o trirevis.o  stringl.o stringq.o model.o\
@@ -238,14 +263,14 @@
 	 method4.o method5.o eval_sec.o sqcurve3.o metis.o lagrange.o
 
 
-evolver: makemark  $(OBJ)  $(GRAPH)
-	$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) $(GRAPH) $(GRAPHLIB) -o evolver -lm
+evolver$(EXEC_SUFFIX): makemark  $(OBJ)  $(GRAPH)
+	$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) $(GRAPH) $(GRAPHLIB) -o $@ -lm
 
 # This is to get global dependencies on the main header files.
 makemark: skeleton.h storage.h model.h web.h
-	if [[ -z "$(GRAPH)" ]] ; then (echo "ERROR: You need to uncomment your system's lines in Makefile.") ; fi
-	rm *.o || true
-	touch makemark
+	@if [[ -z "$(GRAPH)" ]] ; then (echo "ERROR: You need to uncomment your system's lines in Makefile.") ; fi
+	@rm -f *.o || true
+	@touch makemark
 
 .c.o:
 	$(CC) $(CPPFLAGS) $(CFLAGS) -c $<
--- a/src/variable.c
+++ b/src/variable.c
@@ -36,7 +36,11 @@
    char *VERSION = "Version 2.70a, August 27, 2013; Windows OpenGL";
 #endif
 #else
-char *VERSION = "Version 2.70a, August 27, 2013";
+#ifdef DEB_PKG_VERSION
+	char *VERSION = "Version 2.70a (Debian " DEB_PKG_VERSION "), August 27, 2013";
+#else
+	char *VERSION = "Version 2.70a, August 27, 2013";
+#endif
 #endif
 #endif
 #endif
--- a/src/tmain.c
+++ b/src/tmain.c
@@ -169,6 +169,9 @@
 				case 'V' :
 						sprintf(msg,
 								"%s - Surface Evolver %s"
+#ifdef DEB_PKG_VERSION
+								" (Debian " DEB_PKG_VERSION ")"
+#endif
 								"\n",
 							evolver_invocation_short_name,
 							evolver_version
