]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Split the main function into a separate compilation unit
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 15 Jul 2010 15:08:51 +0000 (17:08 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 15 Jul 2010 17:20:33 +0000 (19:20 +0200)
This will allow linking another main function with ccache.o.

Makefile.in
ccache.c
main.c [new file with mode: 0644]

index 42f902c9140443c6807ca6bf89056750c9af9589..827628b7a7f249a4916ed65cad4eaa67b4214367 100644 (file)
@@ -19,7 +19,7 @@ libs = @LIBS@ -lm
 sources = \
     ccache.c mdfour.c hash.c execute.c util.c args.c stats.c version.c \
     cleanup.c snprintf.c unify.c manifest.c hashtable.c hashtable_itr.c \
-    murmurhashneutral2.c hashutil.c getopt_long.c exitfn.c
+    murmurhashneutral2.c hashutil.c getopt_long.c exitfn.c main.c
 all_sources = $(sources) @extra_sources@
 
 headers = \
index c51104119972aa5849430044bc47594ce67ae89f..7e6f9af39086a1a504c4d0ad2567fd924cfe3a0e 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -1995,7 +1995,7 @@ static void check_cache_dir(void)
 }
 
 /* the main program when not doing a compile */
-static int ccache_main(int argc, char *argv[])
+static int ccache_main_options(int argc, char *argv[])
 {
        int c;
        size_t v;
@@ -2110,8 +2110,7 @@ static void setup_uncached_err(void)
        }
 }
 
-
-int main(int argc, char *argv[])
+int ccache_main(int argc, char *argv[])
 {
        char *p;
        char *program_name;
@@ -2154,7 +2153,7 @@ int main(int argc, char *argv[])
                /* if the first argument isn't an option, then assume we are
                   being passed a compiler name and options */
                if (argv[1][0] == '-') {
-                       return ccache_main(argc, argv);
+                       return ccache_main_options(argc, argv);
                }
        }
        free(program_name);
diff --git a/main.c b/main.c
new file mode 100644 (file)
index 0000000..83c0abe
--- /dev/null
+++ b/main.c
@@ -0,0 +1,28 @@
+/*
+ * ccache -- a fast C/C++ compiler cache
+ *
+ * Copyright (C) 2010 Joel Rosdahl
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+int
+ccache_main(int argc, char *argv[]);
+
+int
+main(int argc, char *argv[])
+{
+       return ccache_main(argc, argv);
+}