#!/usr/bin/env bash
+#
+# Copyright 2019 Michael D. Lowis
+#-------------------------------------------------------------------------------
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+
+# Wrapper script for system compiler that enables some flags by default and scans
+# for library dependencies.
+#
+# Compilation Features:
+# * Enables --std=c99 -pedantic
+# * Enables -Wall -Wextra -Werror
+# * Defines AUTOLIB() macro to specify dependencies in sources and headers
+# * Auto-includes commonly include headers such as stddef.h, stdio.h, etc.
+#
+# Linking Features:
+# * Scans objects for AUTOLIB()-ed libs, and adds the -l flags for them
# predeclare our variables
declare -a objects
#define _POSIX_C_SOURCE 200809L
#define _XOPEN_SOURCE 700
#define AUTOLIB(n) \
- int __autolib_##n __attribute__ ((weak));'
+ int __autolib_##n __attribute__ ((weak));
+#include <stddef.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdarg.h>
+#include <errno.h>
+#include <limits.h>
+#include <sys/types.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <fcntl.h>
+' # end of runtime definition
# scan the rest of the options for lib paths, libs and objects
for i do
-L*) # Add libpaths to the search list
libpaths+=("${i#-L}") ;;
- -c) # Mark this as compilation only
+ -c|-E) # Mark this as compilation/preprocess only
compile=true ;;
esac
done
@license BSD 2-clause License
*/
-/* Standard Macros and Types */
-#include <stddef.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <errno.h>
-#include <limits.h>
-#include <assert.h>
-
-/* Useful Standard Functions */
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
+///* Standard Macros and Types */
+//#include <stddef.h>
+//#include <stdint.h>
+//#include <stdbool.h>
+//#include <errno.h>
+//#include <limits.h>
+//#include <assert.h>
+//
+///* Useful Standard Functions */
+//#include <signal.h>
+//#include <stdio.h>
+//#include <stdlib.h>
+//#include <stdarg.h>
+//#include <string.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"