>>tree /f : Hello/ Makefile include/ hello.h lib/ hello.c Makefile src/ main.c Makefile
Hello/Makefile
hello: cd lib; make cd src; make gcc -Wall lib/hello.o src/main.o -o hello clean: cd lib; make clean cd src; make clean rm hello
Hello/lib/Makefile
hello.o : helloworld.c gcc -c -o hello.o -I ../include helloworld.c clean: rm hello.o
Hello/src/Makefile
main.o : main.c gcc -c -o main.o -I ../include main.c clean: rm main.o
Hello/include/hello.h
#ifndef HELLOWORLD_H #define HELLOWORLD_H void helloworld(); #endif
Hello/lib/hello.c
#include void helloworld() { ; }
Hello/src/main.c
#include int main() { helloworld(); while(1); return 0; }
>>make cd lib; make gcc -c -o hello.o -I ../include helloworl cd src; make gcc -c -o main.o -I ../include main.c gcc -Wall lib/hello.o src/main.o -o test