Skip to content

Commit

Permalink
Split the main function into a separate compilation unit
Browse files Browse the repository at this point in the history
This will allow linking another main function with ccache.o.
  • Loading branch information
jrosdahl committed Jul 15, 2010
1 parent c58b743 commit bf8a44f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile.in
Expand Up @@ -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 = \
Expand Down
7 changes: 3 additions & 4 deletions ccache.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
28 changes: 28 additions & 0 deletions 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.