@@ -94,6 +94,7 @@ enum fp_abi {
enum {
OS_UNKNOWN,
+ OS_NONE,
OS_UNIX,
OS_CYGWIN,
OS_DARWIN,
@@ -925,6 +925,16 @@ static char **handle_param(char *arg, char **next)
return next;
}
+static char **handle_os(char *arg, char **next)
+{
+ if (*arg++ != '=')
+ die("missing argument for --os option");
+
+ target_os(arg);
+
+ return next;
+}
+
static char **handle_version(char *arg, char **next)
{
printf("%s\n", SPARSE_VERSION);
@@ -941,6 +951,7 @@ static char **handle_long_options(char *arg, char **next)
{
static struct switches cmd[] = {
{ "arch", handle_arch, 1 },
+ { "os", handle_os, 1 },
{ "param", handle_param, 1 },
{ "version", handle_version },
{ NULL, NULL }
@@ -464,6 +464,16 @@ Look for system headers in the multiarch subdirectory \fIdir\fR.
The \fIdir\fR name would normally take the form of the target's
normalized GNU triplet. (e.g. i386-linux-gnu).
.
+.TP
+.B \-\-os=\fIOS\fR
+Specify the target Operating System.
+This only makes a few differences with the predefined types.
+The accepted values are: linux, unix, freebsd, netbsd, opensd, sunos, darwin
+and cygwin.
+
+The default OS is the one of the machine used to build Sparse if it can be
+detected, oherwise some generic settings are used.
+.
.SH DEBUG OPTIONS
.TP
.B \-fmem-report
@@ -136,6 +136,35 @@ enum machine target_parse(const char *name)
return MACH_UNKNOWN;
}
+void target_os(const char *name)
+{
+ static const struct os {
+ const char *name;
+ int os;
+ } oses[] = {
+ { "cygwin", OS_CYGWIN },
+ { "darwin", OS_DARWIN },
+ { "freebsd", OS_FREEBSD },
+ { "linux", OS_LINUX },
+ { "native", OS_NATIVE, },
+ { "netbsd", OS_NETBSD },
+ { "none", OS_NONE },
+ { "openbsd", OS_OPENBSD },
+ { "sunos", OS_SUNOS },
+ { "unix", OS_UNIX },
+ { NULL },
+ }, *p;
+
+ for (p = &oses[0]; p->name; p++) {
+ if (!strcmp(p->name, name)) {
+ arch_os = p->os;
+ return;
+ }
+ }
+
+ die("invalid os: %s", name);
+}
+
void target_config(enum machine mach)
{
@@ -105,6 +105,7 @@ extern const struct target target_x86_64;
extern const struct target *arch_target;
enum machine target_parse(const char *name);
+void target_os(const char *name);
void target_config(enum machine mach);
void target_init(void);
This is not needed when doing native 'compilation' but is quite handy when testing the predefined types & macros. The supported OSes are: 'linux', 'freebsd', 'openbsd', 'netbsd' 'darwin', 'sunos', 'cygwin' and a generic 'unix'. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- machine.h | 1 + options.c | 11 +++++++++++ sparse.1 | 10 ++++++++++ target.c | 29 +++++++++++++++++++++++++++++ target.h | 1 + 5 files changed, 52 insertions(+)