diff --git a/main/mailx/APKBUILD b/main/mailx/APKBUILD
index f656301b6e638aef48dfa188653c29cbfce68ed2..a2bad3f47606d0339995674a1d1624565c70bac8 100644
--- a/main/mailx/APKBUILD
+++ b/main/mailx/APKBUILD
@@ -2,7 +2,7 @@
 # Maintainer: Michael Mason <ms13sp@gmail.com>
 pkgname=mailx
 pkgver=8.1.1
-pkgrel=0
+pkgrel=1
 pkgdesc="A commandline utility for sending email"
 url="http://www.opengroup.org/onlinepubs/007908799/xcu/mailx.html"
 arch="all"
@@ -14,6 +14,7 @@ install=""
 subpackages="$pkgname-doc"
 source="ftp://ftp.archlinux.org/other/mailx/$pkgname-$pkgver-fixed.tar.gz
 	mailx-8.1.1.patch
+	musl-fix.patch
 	mailx-gcc4.patch"
 
 _builddir="$srcdir/$pkgname-$pkgver-fixed"
@@ -23,7 +24,7 @@ prepare() {
 	cd "$_builddir"
 	for i in $source; do
 		case $i in
-		*.patch) msg $i; patch -p0 -i "$srcdir"/$i || return 1;;
+		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
 		esac
 	done
 	sed -i 's#/man/#/share/man/#' Makefile
@@ -40,5 +41,14 @@ package() {
 }
 
 md5sums="63cad526ac64b57bcba2c0daaa1f3048  mailx-8.1.1-fixed.tar.gz
-d66b9f419c5d215271ed434f5d780843  mailx-8.1.1.patch
-8716c7c7b3f5d348443230e2fe543bf6  mailx-gcc4.patch"
+117ea0424ca1cfeb85b1e7f9bf945f6a  mailx-8.1.1.patch
+bf07d61361ca99fe41b3197f930d6359  musl-fix.patch
+ea6d343c73cc62f8d5e83ec357aaf72f  mailx-gcc4.patch"
+sha256sums="bb6b481bd2af066e5b2f96267f5b0a886a4fbd11bb2c9b316b113c667abf893f  mailx-8.1.1-fixed.tar.gz
+7b1c21bc41af2de1f1ffc96431793c2c05321d8a7cae41f9adb619cb3feda274  mailx-8.1.1.patch
+2a19d3217933983971ebbe20faab538e11f814598818c4110dd16570c166a1ee  musl-fix.patch
+cab097de50b169cfeb3d71bf2ef68074e215af5f24c16704ed15766551d0377c  mailx-gcc4.patch"
+sha512sums="adfb1ae796505f2706d03e34ae9b89f45dd878d55014ae8fab91fbf4b53f1bd97e0ac78ce1af5999adf62e99230f91d9539605ae388cf6c16e8334c14c0cce10  mailx-8.1.1-fixed.tar.gz
+05c4185ef54601c9bae6b6505201a9b357f69d9d22c4b992a9ba52f4022b8dec2d0e5b97654fff7c9f303bdcc87ab8bb279a7293fdd538d4291dcd99f6eae1d4  mailx-8.1.1.patch
+de633d557552c38e221cd48c0cf6cefe108f22332eab5e155183463b0209a08b1ae6754508a12bf9f261a345b2feb1a4e607167d51b7a16e60d47c3c02d0218f  musl-fix.patch
+e3fa1016da2cd1583e1ba2f6cd05566385607e144da2766101e4bf8c8dc089c4b956d1d90ccc040e5faf31c98d0855a0bc909bf0d6538df34925e798bba1a074  mailx-gcc4.patch"
diff --git a/main/mailx/mailx-8.1.1.patch b/main/mailx/mailx-8.1.1.patch
index 536c28fc561f17be8ebfd66762f19cbf06e65f00..f1c9519c0c3ef8f0d96097baacd42a2439fb540d 100644
--- a/main/mailx/mailx-8.1.1.patch
+++ b/main/mailx/mailx-8.1.1.patch
@@ -1,5 +1,5 @@
---- Makefile	Thu Mar 16 09:30:36 2000
-+++ Makefile	Wed Feb 27 12:50:09 2002
+--- ./Makefile	Thu Mar 16 09:30:36 2000
++++ ./Makefile	Wed Feb 27 12:50:09 2002
 @@ -7,18 +7,20 @@
  BINOWN = root
  BINGRP = mail
diff --git a/main/mailx/mailx-gcc4.patch b/main/mailx/mailx-gcc4.patch
index 54740a2302035853a83fc90bdf38b0cedc8c90ac..18452759c39877392947fdd0832d3c687ddafff8 100644
--- a/main/mailx/mailx-gcc4.patch
+++ b/main/mailx/mailx-gcc4.patch
@@ -1,7 +1,7 @@
 K. Piche:  Unofficial patch for mailx.
 
---- dotlock.c.orig      2005-09-18 20:28:20.000000000 -0400
-+++ dotlock.c   2005-09-18 20:26:59.000000000 -0400
+--- ./dotlock.c.orig      2005-09-18 20:28:20.000000000 -0400
++++ ./dotlock.c   2005-09-18 20:26:59.000000000 -0400
 @@ -47,6 +47,7 @@
  #include <errno.h>
  #include <signal.h>
diff --git a/main/mailx/musl-fix.patch b/main/mailx/musl-fix.patch
new file mode 100644
index 0000000000000000000000000000000000000000..8b409b286d5e06c058c88d67cddb6ae668964533
--- /dev/null
+++ b/main/mailx/musl-fix.patch
@@ -0,0 +1,126 @@
+--- mailx-8.1.1-fixed.orig/cmd2.c
++++ mailx-8.1.1-fixed/cmd2.c
+@@ -383,7 +383,7 @@
+ 	void *v;
+ {
+ 	int pid;
+-	extern union wait wait_status;
++	extern int wait_status;
+ 
+ 	switch (pid = vfork()) {
+ 	case -1:
+@@ -396,7 +396,7 @@
+ 	printf("Okie dokie");
+ 	fflush(stdout);
+ 	wait_child(pid);
+-	if (wait_status.w_coredump)
++	if (WCOREDUMP(wait_status))
+ 		printf(" -- Core dumped.\n");
+ 	else
+ 		printf(" -- Can't dump core.\n");
+--- mailx-8.1.1-fixed.orig/def.h
++++ mailx-8.1.1-fixed/def.h
+@@ -43,6 +43,7 @@
+  */
+ 
+ #include <sys/param.h>
++#include <sys/cdefs.h>
+ #include <sys/stat.h>
+ #include <sys/time.h>
+ 
+--- mailx-8.1.1-fixed.orig/extern.h
++++ mailx-8.1.1-fixed/extern.h
+@@ -37,6 +37,8 @@
+  *	$NetBSD: extern.h,v 1.4 1996/06/08 19:48:21 christos Exp $
+  */
+ 
++#include <sys/cdefs.h>
++
+ struct name;
+ struct name *cat __P((struct name *, struct name *));
+ struct name *delname __P((struct name *, char []));
+--- mailx-8.1.1-fixed.orig/fio.c
++++ mailx-8.1.1-fixed/fio.c
+@@ -47,7 +47,6 @@
+ #include <sys/wait.h>
+ 
+ #include <unistd.h>
+-#include <paths.h>
+ #include <errno.h>
+ #include "extern.h"
+ 
+@@ -326,7 +325,7 @@
+ 	register char *cp, *shell;
+ 	int pivec[2];
+ 	struct stat sbuf;
+-	extern union wait wait_status;
++	extern int wait_status;
+ 
+ 	/*
+ 	 * The order of evaluation is "%" and "#" expand into constants.
+@@ -378,7 +377,7 @@
+ 	close(pivec[1]);
+ 	l = read(pivec[0], xname, BUFSIZ);
+ 	close(pivec[0]);
+-	if (wait_child(pid) < 0 && wait_status.w_termsig != SIGPIPE) {
++	if (wait_child(pid) < 0 && WIFSIGNALED(wait_status) && WTERMSIG(wait_status) != SIGPIPE) {
+ 		fprintf(stderr, "\"%s\": Expansion failed.\n", name);
+ 		return NOSTR;
+ 	}
+--- mailx-8.1.1-fixed.orig/pathnames.h
++++ mailx-8.1.1-fixed/pathnames.h
+@@ -44,3 +44,4 @@
+ #define	_PATH_TILDE	"/usr/share/misc/mail.tildehelp"
+ #define	_PATH_MASTER_RC	"/etc/mail.rc"
+ #define	_PATH_MORE	"/usr/bin/more"
++#define	_PATH_CSHELL	"/bin/csh"
+--- mailx-8.1.1-fixed.orig/popen.c
++++ mailx-8.1.1-fixed/popen.c
+@@ -62,7 +62,7 @@
+ 	int pid;
+ 	char done;
+ 	char free;
+-	union wait status;
++	int status;
+ 	struct child *link;
+ };
+ static struct child *child;
+@@ -341,7 +341,7 @@
+ 	int signo;
+ {
+ 	int pid;
+-	union wait status;
++	int status;
+ 	register struct child *cp;
+ 
+ 	while ((pid =
+@@ -356,7 +356,7 @@
+ 	}
+ }
+ 
+-union wait wait_status;
++int wait_status;
+ 
+ /*
+  * Wait for a specific child to die.
+@@ -376,7 +376,9 @@
+ 	wait_status = cp->status;
+ 	delchild(cp);
+ 	sigprocmask(SIG_SETMASK, &oset, NULL);
+-	return wait_status.w_status ? -1 : 0;
++	if (WIFEXITED(wait_status) && WEXITSTATUS(wait_status) == 0)
++		return 0;
++	return -1;
+ }
+ 
+ /*
+--- mailx-8.1.1-fixed.orig/quit.c
++++ mailx-8.1.1-fixed/quit.c
+@@ -43,6 +43,7 @@
+ #endif /* not lint */
+ 
+ #include "rcv.h"
++#include <sys/file.h>
+ #include <fcntl.h>
+ #include "extern.h"
+