I have a requirement where in I want to build the object files separately and link them together. Specifically I have a Makefile
to build some objects which I want to call from the wscript
file. I am able to call make
command from the wscript
file. But I am not able to figure out how to link these objects.
All the file contents are given below.
file1.c:
#include <stdio.h>
extern void hello () ;
int main ()
{
printf ("Hello file1\n") ;
hello () ;
return 0 ;
}
file2.c :
#include <stdio.h>
void hello ()
{
printf ("Hello file2\n") ;
}
Following are the contents of wscript
file.
def options(opt):
opt.load('compiler_c')
def configure(cnf):
cnf.load('compiler_c')
def build(bld):
bld(rule='cp ./../Makefile .')
bld(rule='make', always='True')
bld.program(features='c',
source=['file1.c'],
includes=['build'],
target='prog')
Makefile:
CC = /usr/bin/gcc
file2.o:
$(CC) -c ./../file2.c -o ./file2.o
Note : Beware of copying Makefile from here directly because of tabs.