From: Joel Rosdahl Date: Thu, 15 Jul 2010 15:08:51 +0000 (+0200) Subject: Split the main function into a separate compilation unit X-Git-Tag: v3.1~180^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bf8a44fa642057c0d186bcb9bc0b181c7d664433;p=thirdparty%2Fccache.git Split the main function into a separate compilation unit This will allow linking another main function with ccache.o. --- diff --git a/Makefile.in b/Makefile.in index 42f902c91..827628b7a 100644 --- a/Makefile.in +++ b/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 = \ diff --git a/ccache.c b/ccache.c index c51104119..7e6f9af39 100644 --- 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 index 000000000..83c0abe4b --- /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); +}