Index: uspace/lib/c/generic/stacktrace.c
===================================================================
--- uspace/lib/c/generic/stacktrace.c	(revision d11a1811118ec8e5eb8ca4beae291275a4ce36b6)
+++ uspace/lib/c/generic/stacktrace.c	(revision 90f067d9953467ef02183dc07726c6d41b1014f0)
@@ -38,4 +38,5 @@
 #include <sys/types.h>
 #include <errno.h>
+#include <unistd.h>
 
 static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data);
Index: uspace/lib/c/generic/stats.c
===================================================================
--- uspace/lib/c/generic/stats.c	(revision d11a1811118ec8e5eb8ca4beae291275a4ce36b6)
+++ uspace/lib/c/generic/stats.c	(revision 90f067d9953467ef02183dc07726c6d41b1014f0)
@@ -40,4 +40,5 @@
 #include <inttypes.h>
 #include <malloc.h>
+#include <unistd.h>
 
 #define SYSINFO_STATS_MAX_PATH  64
Index: uspace/lib/c/generic/sysinfo.c
===================================================================
--- uspace/lib/c/generic/sysinfo.c	(revision d11a1811118ec8e5eb8ca4beae291275a4ce36b6)
+++ uspace/lib/c/generic/sysinfo.c	(revision 90f067d9953467ef02183dc07726c6d41b1014f0)
@@ -39,4 +39,5 @@
 #include <malloc.h>
 #include <bool.h>
+#include <unistd.h>
 
 /** Get sysinfo keys size
Index: uspace/lib/c/generic/time.c
===================================================================
--- uspace/lib/c/generic/time.c	(revision d11a1811118ec8e5eb8ca4beae291275a4ce36b6)
+++ uspace/lib/c/generic/time.c	(revision 90f067d9953467ef02183dc07726c6d41b1014f0)
@@ -43,4 +43,5 @@
 #include <ddi.h>
 #include <libc.h>
+#include <unistd.h>
 
 /** Pointer to kernel shared variables with time */
Index: uspace/lib/c/include/errno.h
===================================================================
--- uspace/lib/c/include/errno.h	(revision d11a1811118ec8e5eb8ca4beae291275a4ce36b6)
+++ uspace/lib/c/include/errno.h	(revision 90f067d9953467ef02183dc07726c6d41b1014f0)
@@ -37,5 +37,4 @@
 
 #include <abi/errno.h>
-#include <fibril.h>
 
 #define errno  (*(__errno()))
Index: uspace/lib/c/include/stdio.h
===================================================================
--- uspace/lib/c/include/stdio.h	(revision d11a1811118ec8e5eb8ca4beae291275a4ce36b6)
+++ uspace/lib/c/include/stdio.h	(revision 90f067d9953467ef02183dc07726c6d41b1014f0)
@@ -39,5 +39,4 @@
 #include <stdarg.h>
 #include <str.h>
-#include <adt/list.h>
 
 #ifndef NVERIFY_PRINTF
Index: uspace/lib/clui/tinput.h
===================================================================
--- uspace/lib/clui/tinput.h	(revision d11a1811118ec8e5eb8ca4beae291275a4ce36b6)
+++ uspace/lib/clui/tinput.h	(revision 90f067d9953467ef02183dc07726c6d41b1014f0)
@@ -37,6 +37,4 @@
 #define LIBCLUI_TINPUT_H_
 
-#include <adt/list.h>
-#include <async.h>
 #include <inttypes.h>
 #include <io/console.h>
Index: uspace/lib/drv/generic/logbuf.c
===================================================================
--- uspace/lib/drv/generic/logbuf.c	(revision d11a1811118ec8e5eb8ca4beae291275a4ce36b6)
+++ uspace/lib/drv/generic/logbuf.c	(revision 90f067d9953467ef02183dc07726c6d41b1014f0)
@@ -35,4 +35,5 @@
 #include <ddf/log.h>
 #include <assert.h>
+#include <unistd.h>
 
 /** Formatting string for printing number of not-printed items. */
Index: uspace/lib/drv/include/ddf/interrupt.h
===================================================================
--- uspace/lib/drv/include/ddf/interrupt.h	(revision d11a1811118ec8e5eb8ca4beae291275a4ce36b6)
+++ uspace/lib/drv/include/ddf/interrupt.h	(revision 90f067d9953467ef02183dc07726c6d41b1014f0)
@@ -36,4 +36,6 @@
 #define DDF_INTERRUPT_H_
 
+#include <libarch/common.h>
+#include <libarch/types.h>
 #include <abi/ddi/irq.h>
 #include <adt/list.h>
Index: uspace/lib/posix/Makefile
===================================================================
--- uspace/lib/posix/Makefile	(revision d11a1811118ec8e5eb8ca4beae291275a4ce36b6)
+++ uspace/lib/posix/Makefile	(revision 90f067d9953467ef02183dc07726c6d41b1014f0)
@@ -43,4 +43,5 @@
 	fcntl.c \
 	fnmatch.c \
+	getopt.c \
 	locale.c \
 	math.c \
Index: uspace/lib/posix/getopt.c
===================================================================
--- uspace/lib/posix/getopt.c	(revision 90f067d9953467ef02183dc07726c6d41b1014f0)
+++ uspace/lib/posix/getopt.c	(revision 90f067d9953467ef02183dc07726c6d41b1014f0)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2012 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libposix
+ * @{
+ */
+/** @file Command line argument parsing.
+ */
+#define LIBPOSIX_INTERNAL
+
+#include "internal/common.h"
+#include "libc/getopt.h"
+#include "getopt.h"
+
+
+int posix_getopt_long(int argc, char * const argv[],
+    const char *opt_string, const struct option *long_opts, int *long_index)
+{
+	return getopt_long(argc, argv, opt_string, long_opts, long_index);
+}
+
Index: uspace/lib/posix/getopt.h
===================================================================
--- uspace/lib/posix/getopt.h	(revision 90f067d9953467ef02183dc07726c6d41b1014f0)
+++ uspace/lib/posix/getopt.h	(revision 90f067d9953467ef02183dc07726c6d41b1014f0)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2012 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libposix
+ * @{
+ */
+/** @file Command line argument parsing.
+ */
+#ifndef POSIX_GETOPT_H
+#define POSIX_GETOPT_H
+
+#include "unistd.h"
+
+/* Option Arguments */
+#define no_argument        0
+#define required_argument  1
+#define optional_argument  2
+
+#ifndef LIBPOSIX_INTERNAL
+struct option {
+	const char *name;
+	int has_arg;
+	int *flag;
+	int val;
+};
+#endif
+
+extern int posix_getopt_long(int, char * const [], const char *, const struct option *, int *);
+
+
+#ifndef LIBPOSIX_INTERNAL
+	#define getopt_long posix_getopt_long
+#endif
+
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/posix/pwd.c
===================================================================
--- uspace/lib/posix/pwd.c	(revision d11a1811118ec8e5eb8ca4beae291275a4ce36b6)
+++ uspace/lib/posix/pwd.c	(revision 90f067d9953467ef02183dc07726c6d41b1014f0)
@@ -38,4 +38,5 @@
 #include "string.h"
 #include "errno.h"
+#include "assert.h"
 
 static bool entry_read = false;
Index: uspace/lib/posix/stdbool.h
===================================================================
--- uspace/lib/posix/stdbool.h	(revision d11a1811118ec8e5eb8ca4beae291275a4ce36b6)
+++ uspace/lib/posix/stdbool.h	(revision 90f067d9953467ef02183dc07726c6d41b1014f0)
@@ -37,5 +37,9 @@
 
 #ifdef LIBC_BOOL_H_
-	#error "You can't include bool.h and stdbool.h at the same time."
+#	ifndef POSIX_STDIO_H_
+#		ifndef POSIX_STDLIB_H_
+#			error "You can't include bool.h and stdbool.h at the same time."
+#		endif
+#	endif
 #endif
 #define LIBC_BOOL_H_
Index: uspace/lib/posix/time.c
===================================================================
--- uspace/lib/posix/time.c	(revision d11a1811118ec8e5eb8ca4beae291275a4ce36b6)
+++ uspace/lib/posix/time.c	(revision 90f067d9953467ef02183dc07726c6d41b1014f0)
@@ -45,4 +45,5 @@
 #include "errno.h"
 #include "signal.h"
+#include "assert.h"
 
 #include "libc/malloc.h"
Index: uspace/lib/posix/unistd.c
===================================================================
--- uspace/lib/posix/unistd.c	(revision d11a1811118ec8e5eb8ca4beae291275a4ce36b6)
+++ uspace/lib/posix/unistd.c	(revision 90f067d9953467ef02183dc07726c6d41b1014f0)
@@ -49,4 +49,5 @@
 /* Array of environment variable strings (NAME=VALUE). */
 char **posix_environ = NULL;
+char *posix_optarg;
 
 /**
Index: uspace/lib/posix/unistd.h
===================================================================
--- uspace/lib/posix/unistd.h	(revision d11a1811118ec8e5eb8ca4beae291275a4ce36b6)
+++ uspace/lib/posix/unistd.h	(revision 90f067d9953467ef02183dc07726c6d41b1014f0)
@@ -43,6 +43,5 @@
 #define _exit exit
 
-/* Option Arguments */
-extern char *optarg;
+extern char *posix_optarg;
 extern int optind, opterr, optopt;
 extern int getopt(int, char * const [], const char *);
@@ -144,4 +143,6 @@
 
 #ifndef LIBPOSIX_INTERNAL
+	#define optarg posix_optarg
+
 	#define environ posix_environ
 
