Index: Portfile
===================================================================
--- Portfile	(revision 150205)
+++ Portfile	(working copy)
@@ -76,6 +76,7 @@
 
 # patches related to changes in install paths
 patchfiles-append  patch-texk_chktex_Makefile.in.diff \
+                   patch-texk_gregorio.diff \
                    patch-texk_kpathsea_Makefile.in.diff \
                    patch-texk_tex4htk_Makefile.in.diff \
                    patch-texk_texlive_linked_scripts_Makefile.in.diff \
Index: files/patch-texk_gregorio.diff
===================================================================
--- files/patch-texk_gregorio.diff	(nonexistent)
+++ files/patch-texk_gregorio.diff	(working copy)
@@ -0,0 +1,334 @@
+https://trac.macports.org/ticket/51779
+https://github.com/gregorio-project/gregorio/pull/1186
+http://tug.org/svn/texlive?view=revision&revision=41705
+
+--- texk/gregorio/config_.h.in.orig
++++ texk/gregorio/config_.h.in
+@@ -3,6 +3,9 @@
+ /* Define if building universal (internal helper macro) */
+ #undef AC_APPLE_UNIVERSAL_BUILD
+ 
++/* The normal alignment of `uint32_t', in bytes. */
++#undef ALIGNOF_UINT32_T
++
+ /* Define to 1 if the `closedir' function returns void instead of `int'. */
+ #undef CLOSEDIR_VOID
+ 
+--- texk/gregorio/configure.orig
++++ texk/gregorio/configure
+@@ -2186,6 +2186,189 @@ $as_echo "$ac_res" >&6; }
+   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ 
+ } # ac_fn_c_check_member
++
++# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
++# --------------------------------------------
++# Tries to find the compile-time value of EXPR in a program that includes
++# INCLUDES, setting VAR accordingly. Returns whether the value could be
++# computed
++ac_fn_c_compute_int ()
++{
++  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
++  if test "$cross_compiling" = yes; then
++    # Depending upon the size, compute the lo and hi bounds.
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++$4
++int
++main ()
++{
++static int test_array [1 - 2 * !(($2) >= 0)];
++test_array [0] = 0;
++return test_array [0];
++
++  ;
++  return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++  ac_lo=0 ac_mid=0
++  while :; do
++    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++$4
++int
++main ()
++{
++static int test_array [1 - 2 * !(($2) <= $ac_mid)];
++test_array [0] = 0;
++return test_array [0];
++
++  ;
++  return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++  ac_hi=$ac_mid; break
++else
++  as_fn_arith $ac_mid + 1 && ac_lo=$as_val
++			if test $ac_lo -le $ac_mid; then
++			  ac_lo= ac_hi=
++			  break
++			fi
++			as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++  done
++else
++  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++$4
++int
++main ()
++{
++static int test_array [1 - 2 * !(($2) < 0)];
++test_array [0] = 0;
++return test_array [0];
++
++  ;
++  return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++  ac_hi=-1 ac_mid=-1
++  while :; do
++    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++$4
++int
++main ()
++{
++static int test_array [1 - 2 * !(($2) >= $ac_mid)];
++test_array [0] = 0;
++return test_array [0];
++
++  ;
++  return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++  ac_lo=$ac_mid; break
++else
++  as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val
++			if test $ac_mid -le $ac_hi; then
++			  ac_lo= ac_hi=
++			  break
++			fi
++			as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++  done
++else
++  ac_lo= ac_hi=
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++# Binary search between lo and hi bounds.
++while test "x$ac_lo" != "x$ac_hi"; do
++  as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val
++  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++$4
++int
++main ()
++{
++static int test_array [1 - 2 * !(($2) <= $ac_mid)];
++test_array [0] = 0;
++return test_array [0];
++
++  ;
++  return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++  ac_hi=$ac_mid
++else
++  as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++done
++case $ac_lo in #((
++?*) eval "$3=\$ac_lo"; ac_retval=0 ;;
++'') ac_retval=1 ;;
++esac
++  else
++    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++$4
++static long int longval () { return $2; }
++static unsigned long int ulongval () { return $2; }
++#include <stdio.h>
++#include <stdlib.h>
++int
++main ()
++{
++
++  FILE *f = fopen ("conftest.val", "w");
++  if (! f)
++    return 1;
++  if (($2) < 0)
++    {
++      long int i = longval ();
++      if (i != ($2))
++	return 1;
++      fprintf (f, "%ld", i);
++    }
++  else
++    {
++      unsigned long int i = ulongval ();
++      if (i != ($2))
++	return 1;
++      fprintf (f, "%lu", i);
++    }
++  /* Do not output a trailing newline, as this causes \r\n confusion
++     on some platforms.  */
++  return ferror (f) || fclose (f) != 0;
++
++  ;
++  return 0;
++}
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
++  echo >>conftest.val; read $3 <conftest.val; ac_retval=0
++else
++  ac_retval=1
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++  conftest.$ac_objext conftest.beam conftest.$ac_ext
++rm -f conftest.val
++
++  fi
++  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
++  as_fn_set_status $ac_retval
++
++} # ac_fn_c_compute_int
+ cat >config.log <<_ACEOF
+ This file contains any messages produced by compilers while
+ running configure, to aid debugging if configure makes a mistake.
+@@ -12707,7 +12890,7 @@ else
+     We can't simply define LARGE_OFF_T to be 9223372036854775807,
+     since some C++ compilers masquerading as C compilers
+     incorrectly reject 9223372036854775807.  */
+-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
++#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ 		       && LARGE_OFF_T % 2147483647 == 1)
+ 		      ? 1 : -1];
+@@ -12753,7 +12936,7 @@ else
+     We can't simply define LARGE_OFF_T to be 9223372036854775807,
+     since some C++ compilers masquerading as C compilers
+     incorrectly reject 9223372036854775807.  */
+-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
++#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ 		       && LARGE_OFF_T % 2147483647 == 1)
+ 		      ? 1 : -1];
+@@ -12777,7 +12960,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+     We can't simply define LARGE_OFF_T to be 9223372036854775807,
+     since some C++ compilers masquerading as C compilers
+     incorrectly reject 9223372036854775807.  */
+-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
++#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ 		       && LARGE_OFF_T % 2147483647 == 1)
+ 		      ? 1 : -1];
+@@ -12822,7 +13005,7 @@ else
+     We can't simply define LARGE_OFF_T to be 9223372036854775807,
+     since some C++ compilers masquerading as C compilers
+     incorrectly reject 9223372036854775807.  */
+-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
++#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ 		       && LARGE_OFF_T % 2147483647 == 1)
+ 		      ? 1 : -1];
+@@ -12846,7 +13029,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+     We can't simply define LARGE_OFF_T to be 9223372036854775807,
+     since some C++ compilers masquerading as C compilers
+     incorrectly reject 9223372036854775807.  */
+-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
++#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ 		       && LARGE_OFF_T % 2147483647 == 1)
+ 		      ? 1 : -1];
+@@ -13623,6 +13806,42 @@ fi
+ done
+ 
+ 
++# The cast to long int works around a bug in the HP C Compiler,
++# see AC_CHECK_SIZEOF for more information.
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking alignment of uint32_t" >&5
++$as_echo_n "checking alignment of uint32_t... " >&6; }
++if ${ac_cv_alignof_uint32_t+:} false; then :
++  $as_echo_n "(cached) " >&6
++else
++  if ac_fn_c_compute_int "$LINENO" "(long int) offsetof (ac__type_alignof_, y)" "ac_cv_alignof_uint32_t"        "$ac_includes_default
++#ifndef offsetof
++# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0)
++#endif
++typedef struct { char x; uint32_t y; } ac__type_alignof_;"; then :
++
++else
++  if test "$ac_cv_type_uint32_t" = yes; then
++     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
++as_fn_error 77 "cannot compute alignment of uint32_t
++See \`config.log' for more details" "$LINENO" 5; }
++   else
++     ac_cv_alignof_uint32_t=0
++   fi
++fi
++
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_alignof_uint32_t" >&5
++$as_echo "$ac_cv_alignof_uint32_t" >&6; }
++
++
++
++cat >>confdefs.h <<_ACEOF
++#define ALIGNOF_UINT32_T $ac_cv_alignof_uint32_t
++_ACEOF
++
++
++
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5
+ $as_echo_n "checking whether byte ordering is bigendian... " >&6; }
+ if ${ac_cv_c_bigendian+:} false; then :
+# --- texk/gregorio/configure.ac.orig
+# +++ texk/gregorio/configure.ac
+# @@ -97,6 +97,8 @@ dnl Checks for header files.
+#  AC_CHECK_HEADERS([stdint.h])
+#  AC_CHECK_HEADERS([stdalign.h])
+#  
+# +AC_CHECK_ALIGNOF(uint32_t)
+# +
+#  AC_C_BIGENDIAN
+#  
+#  AC_SUBST([GREGORIO_TREE], [gregorio-src])
+--- texk/gregorio/gregorio-src/src/sha1.c.orig
++++ texk/gregorio/gregorio-src/src/sha1.c
+@@ -37,15 +37,6 @@
+ #include <stdlib.h>
+ #include <string.h>
+ 
+-#ifdef HAVE_STDALIGN_H
+-#include <stdalign.h>
+-#ifdef __clang__
+-#pragma clang diagnostic ignored "-Wc11-extensions"
+-#endif
+-#else
+-#define alignof(x) sizeof(x)
+-#endif
+-
+ #ifdef WORDS_BIGENDIAN
+ #define SWAP(n) (n)
+ #else
+@@ -167,7 +158,7 @@ void sha1_process_bytes(const void *buffer, size_t len, struct sha1_ctx *ctx)
+     if (len >= 64) {
+         /* architecture and data-specific; LCOV_EXCL_START */
+ #if !_STRING_ARCH_unaligned
+-#define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0)
++#define UNALIGNED_P(p) ((uintptr_t) (p) % ALIGNOF_UINT32_T != 0)
+         if (UNALIGNED_P(buffer)) {
+             while (len > 64) {
+                 sha1_process_block(memcpy(ctx->buffer, buffer, 64), 64, ctx);
