From 7a6ee74fe3be18e7fe09f19511e8fd00e129baa3 Mon Sep 17 00:00:00 2001
From: Gabriele Baldassarre <gabriele@gabrielebaldassarre.com>
Date: Sun, 17 May 2020 22:03:14 +0000
Subject: Fix order of arguments in gcc


diff --git a/src/check/Makefile b/src/check/Makefile
index 171e94e..864b44c 100644
--- a/src/check/Makefile
+++ b/src/check/Makefile
@@ -61,7 +61,7 @@ include ../Makefile.inc
 				$(CC) $(CFLAGS) $(CLIBFLAGS) -I$(SCOTCHINCDIR) -c $(<) -o $(@)
 
 %$(EXE)	:	%.c
-		 		$(CC) $(CFLAGS) -I$(SCOTCHINCDIR) -L$(SCOTCHLIBDIR) $(<) -o $(@) $(SCOTCHLIBS) $(LDFLAGS)
+		 		$(CC) $(CFLAGS) $(LDFLAGS) -I$(SCOTCHINCLUDEDIR) -L$(SCOTCHLIBDIR) $(<) $(SCOTCHLIBS) $(LIBS) -o $(@)
 
 ##
 ##  Project rules.
diff --git a/src/esmumps/Makefile b/src/esmumps/Makefile
index cca7b51..d08571a 100644
--- a/src/esmumps/Makefile
+++ b/src/esmumps/Makefile
@@ -44,7 +44,7 @@ include ../Makefile.inc
 				$(CC) $(CFLAGS) $(CLIBFLAGS) -I$(includedir) -c $(<) -o $(@)
 
 %$(EXE)	:	%.c
-		 		$(CC) $(CFLAGS) -I$(includedir) $(<) -o $(@) -L. -lesmumps -L$(libdir) -lscotch -lscotcherrexit $(LDFLAGS)
+		 		$(CC) $(CFLAGS) $(LDFLAGS) -I$(includedir) $(<) -L$(libdir) -L. -l$(ESMUMPSLIB) -l$(SCOTCHLIB) -lscotch -l$(SCOTCHLIB)errexit $(LIBS) -o $(@)
 
 ##
 ##  Project rules.
@@ -52,7 +52,7 @@ include ../Makefile.inc
 
 .PHONY				:	ptscotch	scotch	ptinstall	install	clean	realclean
 
-scotch				:	clean
+scotch				:	clean common.h
 					$(MAKE) CC="$(CCS)" CCD="$(CCS)"	\
 					libesmumps$(LIB)			\
 					main_esmumps$(EXE)
diff --git a/src/libscotch/Makefile b/src/libscotch/Makefile
index 3c32d69..bc9bcd5 100644
--- a/src/libscotch/Makefile
+++ b/src/libscotch/Makefile
@@ -50,7 +50,7 @@ endif
 				$(CC) $(CFLAGS) $(CLIBFLAGS) -c $(<) -o $(@) -DSCOTCH_VERSION_NUM=$(VERSION) -DSCOTCH_RELEASE_NUM=$(RELEASE) -DSCOTCH_PATCHLEVEL_NUM=$(PATCHLEVEL)
 
 %$(EXE)	:	%.c
-		 		$(CC) $(CFLAGS) -DSCOTCH_VERSION_NUM=$(VERSION) -DSCOTCH_RELEASE_NUM=$(RELEASE) -DSCOTCH_PATCHLEVEL_NUM=$(PATCHLEVEL) $(<) -o $(@) $(LDFLAGS)
+		 		$(CC) $(CFLAGS) $(LDFLAGS) -DSCOTCH_VERSION=$(VERSION) -DSCOTCH_RELEASE=$(RELEASE) -DSCOTCH_PATCHLEVEL=$(PATCHLEVEL) $(<) $(LIBS)  -o $(@)
 
 ##
 ##  Project rules.
@@ -3067,14 +3067,14 @@ dummysizes$(EXE)		:	dummysizes.c				\
 					mapping.h				\
 					order.h					\
 					parser.h
-			 		$(CCD) $(CCDFLAGS) -DSCOTCH_VERSION_NUM=$(VERSION) -DSCOTCH_RELEASE_NUM=$(RELEASE) -DSCOTCH_PATCHLEVEL_NUM=$(PATCHLEVEL) $(<) -o $(@) $(LDFLAGS)
+			 		$(CCD) $(CFLAGS) $(LDFLAGS) -DSCOTCH_VERSION=$(VERSION) -DSCOTCH_RELEASE=$(RELEASE) -DSCOTCH_PATCHLEVEL=$(PATCHLEVEL) $(<) $(LIBS) -o $(@)
 
 ptdummysizes$(EXE)		:	dummysizes.c				\
 					module.h				\
 					common.h				\
 					dgraph.h				\
 					dorder.h
-			 		$(CCD) $(CCDFLAGS) -DSCOTCH_VERSION_NUM=$(VERSION) -DSCOTCH_RELEASE_NUM=$(RELEASE) -DSCOTCH_PATCHLEVEL_NUM=$(PATCHLEVEL) $(<) -o $(@) $(LDFLAGS)
+			 		$(CCD) $(CFLAGS) $(LDFLAGS) -DSCOTCH_VERSION=$(VERSION) -DSCOTCH_RELEASE=$(RELEASE) -DSCOTCH_PATCHLEVEL=$(PATCHLEVEL) $(<) $(LIBS) -o $(@)
 
 scotch.h			:	dummysizes$(EXE)			\
 					library.h
diff --git a/src/libscotch/parser_ll.l b/src/libscotch/parser_ll.l
index 82450f1..9a593d0 100644
--- a/src/libscotch/parser_ll.l
+++ b/src/libscotch/parser_ll.l
@@ -86,16 +86,25 @@
 #ifdef FLEX_SCANNER
 #define YY_ALWAYS_INTERACTIVE       1             /* Set the parser as interactive and read one char at a time */
 #define YY_INPUT(buf,result,max_size) { int c = stratParserInput (); result = (c == 0) ? YY_NULL : ((buf)[0] = c, 1); }
+
+# if YY_FLEX_MAJOR_VERSION > 2 ||                                                               \
+    YY_FLEX_MAJOR_VERSION == 2 && YY_FLEX_MINOR_VERSION > 6 ||                                  \
+    YY_FLEX_MAJOR_VERSION == 2 && YY_FLEX_MINOR_VERSION == 6 && YY_FLEX_SUBMINOR_VERSION >= 3
+ int yywrap() { return 1; }
+# else
+#  define yywrap()                  (1)           /* Always return end-of-file on end-of-string  */
+# endif
+
 #else /* FLEX_SCANNER */
 #undef  getc                                      /* Redirect I/O functions */
 #define getc                        yygetc
 #undef  yygetc
 #define yygetc(stream)              stratParserInput ()
+#define yywrap()                    (1)           /* Always return end-of-file on end-of-string  */
 #endif /* FLEX_SCANNER */
 
 #define YY_NO_UNPUT                               /* No prototype for yyunput as not defined     */
 #define YY_SKIP_YYWRAP                            /* No prototype for yywrap as defined as macro */
-#define yywrap()                    (1)           /* Always return end-of-file on end-of-string  */
 
 /*
 **  The static variables.
diff --git a/src/scotch/Makefile b/src/scotch/Makefile
index 7bd0c5b..758db08 100644
--- a/src/scotch/Makefile
+++ b/src/scotch/Makefile
@@ -41,13 +41,13 @@ libdir		= ../../lib
 include ../Makefile.inc
 
 %$(EXE)	:	%$(OBJ)
-		 		$(CC) $(CFLAGS) -I$(includedir) -I../libscotch $(<) -o $(@) -L$(libdir) -l$(SCOTCHLIB) -lscotch -l$(SCOTCHLIB)errexit $(LDFLAGS)
+		 		$(CC) $(CFLAGS) $(LDFLAGS) -I$(includedir) -I../libscotch $(<) -L$(libdir) -l$(SCOTCHLIB) -lscotch -l$(SCOTCHLIB)errexit $(LIBS) -o $(@)
 
 %$(OBJ)	:	%.c
 				$(CC) $(CFLAGS) -I$(includedir) -I../libscotch -c $(<) -o $(@)
 
 %$(EXE)	:	%.c
-		 		$(CC) $(CFLAGS) -I$(includedir) -I../libscotch $(<) -o $(@) -L$(libdir) -l$(SCOTCHLIB) -lscotch -l$(SCOTCHLIB)errexit $(LDFLAGS)
+		 		$(CC) $(CFLAGS) $(LDFLAGS) -I$(includedir) -I../libscotch $(<) -L$(libdir) -l$(SCOTCHLIB) -lscotch -l$(SCOTCHLIB)errexit $(LIBS) -o $(@)
 
 ##
 ##  Project rules.
@@ -209,7 +209,7 @@ dgpart$(EXE)			:	dgmap.c					\
 					$(libdir)/libptscotch$(LIB)		\
 					$(libdir)/libptscotcherrexit$(LIB)	\
 					dgmap.h
-			 		$(CC) $(CFLAGS) -I$(includedir) -I../libscotch $(<) -DSCOTCH_COMPILE_PART -o $(@) -L$(libdir) -lptscotch -lscotch -lptscotcherrexit $(LDFLAGS)
+			 		$(CC) $(CFLAGS) $(LDFLAGS) -I$(includedir) -I../libscotch $(<) -DSCOTCH_COMPILE_PART -L$(libdir) -lptscotch -lscotch -lptscotcherrexit $(LIBS) -o $(@)
 
 dgscat$(EXE)			:	dgscat.c				\
 					../libscotch/module.h			\
@@ -321,7 +321,7 @@ gout$(EXE)			:	gout_c.c				\
 					gout_o.c				\
 					$(includedir)/scotch.h			\
 					$(libdir)/libscotch$(LIB)
-					$(CC) $(CFLAGS) -I../libscotch -I$(includedir) gout_c.c gout_o.c -o $(@) -L$(libdir) -lscotch -lscotcherrexit $(LDFLAGS)
+					$(CC) $(CFLAGS) $(LDFLAGS) -I../libscotch -I$(includedir) gout_c.c gout_o.c -L$(libdir) -lscotch -lscotcherrexit $(LIBS) -o $(@)
 
 gpart$(EXE)			:	gmap.c					\
 					../libscotch/module.h			\
@@ -330,7 +330,7 @@ gpart$(EXE)			:	gmap.c					\
 					$(libdir)/libscotch$(LIB)		\
 					$(libdir)/libscotcherrexit$(LIB)	\
 					gmap.h
-			 		$(CC) $(CFLAGS) -I$(includedir) -I../libscotch $(<) -DSCOTCH_COMPILE_PART -o $(@) -L$(libdir) -lscotch -lscotcherrexit $(LDFLAGS)
+			 		$(CC) $(CFLAGS) $(LDFLAGS) -I$(includedir) -I../libscotch $(<) -DSCOTCH_COMPILE_PART -L$(libdir) -lscotch -lscotcherrexit $(LIBS) -o $(@)
 
 gscat$(EXE)			:	gscat.c					\
 					../libscotch/module.h			\
-- 
2.26.0


From f42d8fdfc0d14c5ef0abc86f1f249ce0d7835225 Mon Sep 17 00:00:00 2001
From: Gabriele Baldassarre <gabriele@gabrielebaldassarre.com>
Date: Mon, 18 May 2020 20:05:36 +0000
Subject: Hardwrite lib names in esmumps


diff --git a/src/esmumps/Makefile b/src/esmumps/Makefile
index d08571a..2cfe2d5 100644
--- a/src/esmumps/Makefile
+++ b/src/esmumps/Makefile
@@ -44,7 +44,7 @@ include ../Makefile.inc
 				$(CC) $(CFLAGS) $(CLIBFLAGS) -I$(includedir) -c $(<) -o $(@)
 
 %$(EXE)	:	%.c
-		 		$(CC) $(CFLAGS) $(LDFLAGS) -I$(includedir) $(<) -L$(libdir) -L. -l$(ESMUMPSLIB) -l$(SCOTCHLIB) -lscotch -l$(SCOTCHLIB)errexit $(LIBS) -o $(@)
+		 		$(CC) $(CFLAGS) $(LDFLAGS) -I$(includedir) $(<) -L$(libdir) -L. -lesmumps -lscotch -lscotcherrexit $(LIBS) -o $(@)
 
 ##
 ##  Project rules.
-- 
2.26.0


From 38d538d48bbdc4b728f325e7ea696646c562c220 Mon Sep 17 00:00:00 2001
From: Gabriele Baldassarre <gabriele@gabrielebaldassarre.com>
Date: Tue, 19 May 2020 23:12:30 +0000
Subject: Fix includedir path


diff --git a/src/check/Makefile b/src/check/Makefile
index 864b44c..3d3ef0a 100644
--- a/src/check/Makefile
+++ b/src/check/Makefile
@@ -61,7 +61,7 @@ include ../Makefile.inc
 				$(CC) $(CFLAGS) $(CLIBFLAGS) -I$(SCOTCHINCDIR) -c $(<) -o $(@)
 
 %$(EXE)	:	%.c
-		 		$(CC) $(CFLAGS) $(LDFLAGS) -I$(SCOTCHINCLUDEDIR) -L$(SCOTCHLIBDIR) $(<) $(SCOTCHLIBS) $(LIBS) -o $(@)
+		 		$(CC) $(CFLAGS) $(SCOTCHLIBS) $(LDFLAGS) -I$(SCOTCHINCDIR) -L$(SCOTCHLIBDIR) $(<) $(LIBS) -o $(@)
 
 ##
 ##  Project rules.
-- 
2.26.0

