/automaker

Automatically create a Makefile for C projects

Primary LanguageC

automaker-20101009
Jay Sullivan
Public Domain

This project is meant to automatically create a Makefile for C projects, provided you declare dependencies explicitly inside source files.  The Makefile's contents are organized in lexical (alphabetical) order.  


For example, given a source file 'test.c': to produce a Makefile that will produce 'test' along with any dependencies:

	$ automaker test.c > Makefile

automaker opens 'test.c' and looks for a comment section of the following format:
                       	
		/*
		%use stralloc_ready;
		%use stralloc_cats;
		*/

	The above would mean 'test' needs to be linked with 'stralloc_ready.o' and 'stralloc_cats.o', and any dependencies that come along with them (as defined in stralloc_ready.c and stralloc_cats.c).  Each file (with an .o suffix) would be added to test's Makefile entry, along with any more dependencies generated after checking the file (with a .c suffix) for any of its dependencies, recursively.   It then outputs a fully functioning Makefile which builds 'test'.

	You may supply more than one main source file.  For example:

	$ automaker test1.c test2.c test3.c > Makefile

	The above constructs a Makefile that creates executables 'test1', 'test2', and 'test3', linking them with all necessary dependencies.


Example : 
	'test' is created from 'test.c' and depends on functions from 'dep1.c', 'dep2.c', and 'dep3.c'.

	Sample source code for test.c :
		/*
		%use dep1;
		%use dep2;
		%use dep3;
		*/
		int main()
		{
		    dep1_func(); dep2_func(); dep3_func();
		    return 0;
		}

	To produce the Makefile to build test:

		$ automaker test.c > Makefile