Permalink
Browse files

Split the main function into a separate compilation unit

This will allow linking another main function with ccache.o.
  • Loading branch information...
1 parent c58b743 commit bf8a44fa642057c0d186bcb9bc0b181c7d664433 @jrosdahl committed Jul 15, 2010
Showing with 32 additions and 5 deletions.
  1. +1 −1 Makefile.in
  2. +3 −4 ccache.c
  3. +28 −0 main.c
View
2 Makefile.in
@@ -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 = \
View
7 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);
View
28 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);
+}

0 comments on commit bf8a44f

Please sign in to comment.