A simple Makefile Tutorial
Suppose we have three files:
c
// hellomake.h
#include <hellomake.h>
int main() {
// call a function in another file
myPrintHelloMake();
return(0);
}c
// hellomake.h
void myPrintHelloMake(void);c
// hellofunc.c
#include <stdio.h>
#include <hellomake.h>
void myPrintHelloMake(void) {
printf("Hello makefiles!\n");
return;
}Makefile1
makefile
hellomake: hellomake.c hellofunc.c
gcc -o hellomake hellomake.c hellofunc.c -I.makewith no arguments executes the first command in the file.- the list of files after
:makemakeknows that the rulehellomakeneeds to be executed if any of those files change.
