Indentation.
[cparser] / main.c
diff --git a/main.c b/main.c
index 339a1cf..2497541 100644 (file)
--- a/main.c
+++ b/main.c
 #include "warning.h"
 
 #ifndef PREPROCESSOR
-#define PREPROCESSOR "cpp -std=c99 -U__WCHAR_TYPE__ -D__WCHAR_TYPE__=int -U__SIZE_TYPE__ -D__SIZE_TYPE__=__SIZE_TYPE__ -m32 -U__STRICT_ANSI__"
+#ifdef __APPLE__
+#define PREPROCESSOR "gcc -E -std=c99 -U__WCHAR_TYPE__ -D__WCHAR_TYPE__=int -U__SIZE_TYPE__ -D__SIZE_TYPE__=unsigned\\ long -m32 -U__STRICT_ANSI__"
+#else
+#define PREPROCESSOR "cpp -std=c99 -U__WCHAR_TYPE__ -D__WCHAR_TYPE__=int -U__SIZE_TYPE__ -D__SIZE_TYPE__=unsigned\\ long -m32 -U__STRICT_ANSI__"
+#endif
 #endif
 
 #ifndef LINKER
 #endif
 
 #ifndef ASSEMBLER
+#ifdef __APPLE__
+#define ASSEMBLER "gcc -c -xassembler"
+#else
 #define ASSEMBLER "as --32"
 #endif
+#endif
 
 /** The current c mode/dialect. */
 unsigned int c_mode = _C89|_C99|_GNUC;
@@ -115,6 +123,7 @@ extern bool print_parenthesis;
 static int             verbose;
 static struct obstack  cppflags_obst, ldflags_obst;
 static char            dep_target[1024];
+static const char     *outname;
 
 typedef struct file_list_entry_t file_list_entry_t;
 
@@ -259,12 +268,17 @@ static FILE *preprocess(const char *fname)
 
        obstack_printf(&cppflags_obst, "%s", PREPROCESSOR);
        if (dep_target[0] != '\0') {
-               obstack_printf(&cppflags_obst, " -MF %s", dep_target);
+               add_flag(&cppflags_obst, "-MF");
+               add_flag(&cppflags_obst, "%s", dep_target);
+               if (outname != NULL) {
+                               add_flag(&cppflags_obst, "-MQ");
+                               add_flag(&cppflags_obst, "%s", outname);
+               }
        }
        if (flags[0] != '\0') {
                obstack_printf(&cppflags_obst, " %s", flags);
        }
-       obstack_printf(&cppflags_obst, " %s", fname);
+       add_flag(&cppflags_obst, "%s", fname);
 
        obstack_1grow(&cppflags_obst, '\0');
        const char *buf = obstack_finish(&cppflags_obst);
@@ -497,7 +511,6 @@ int main(int argc, char **argv)
 {
        initialize_firm();
 
-       const char        *outname              = NULL;
        const char        *dumpfunction         = NULL;
        compile_mode_t     mode                 = CompileAssembleLink;
        int                opt_level            = 1;
@@ -567,6 +580,11 @@ int main(int argc, char **argv)
                break;
        }
 
+#ifdef __APPLE__
+       /* Darwin expects the stack to be aligned to 16byte boundary */
+       firm_be_option("ia32-stackalign=4");
+#endif
+
        /* parse rest of options */
        filetype_t  forced_filetype = FILETYPE_AUTODETECT;
        bool        help_displayed  = false;