  	sigset_t sigmask;
 -	struct timespec timespec = { .tv_sec = 1, .tv_nsec = 0 };
 -	int sig, waiting = 0;
-+    int sig, err, waiting = 0;
++	int sig, err, waiting = 0;
  
  	sigemptyset(&sigmask);
  	sigaddset(&sigmask, SIGQUIT);
  	sigaddset(&sigmask, SIGHUP);
-+    sigaddset(&sigmask, SIGALRM);
++	sigaddset(&sigmask, SIGALRM);
  
  	while(1) {
 -		if(waiting)

 #include <sys/sysinfo.h>
 #include <sys/sysmacros.h>
+#endif
+
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/resource.h>
@@ -2235,6 +2240,7 @@ void initialise_threads(int fragment_buffer_size, int data_buffer_size)
 	sigemptyset(&sigmask);
 	sigaddset(&sigmask, SIGQUIT);
 	sigaddset(&sigmask, SIGHUP);

 }
 
diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
index a45b77f..3607448 100644
--- a/squashfs-tools/mksquashfs.c
+++ b/squashfs-tools/mksquashfs.c
@@ -35,7 +35,12 @@
 #include <stddef.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifndef linux
+#include <sys/sysctl.h>
+#else
+#include <sys/sysinfo.h>
 #include <sys/sysmacros.h>
+#endif
 #include <fcntl.h>
 #include <errno.h>
 #include <dirent.h>
@@ -50,7 +55,10 @@
 #include <sys/wait.h>
 #include <limits.h>
 #include <ctype.h>
-#include <sys/sysinfo.h>
+
+#ifndef FNM_EXTMATCH /* glibc extension */
+	#define FNM_EXTMATCH 0
+#endif
 
 #ifndef linux
 #define __BYTE_ORDER BYTE_ORDER
@@ -4348,6 +4356,7 @@ void initialise_threads(int readq, int fragq, int bwriteq, int fwriteq,
 	sigemptyset(&sigmask);
 	sigaddset(&sigmask, SIGQUIT);
 	sigaddset(&sigmask, SIGHUP);
