The empty Makefile is valid

A Unix trick that took me too many years to realize

This is less of a “Today I learned” article, but more like a Unix trick that took me too long to realize.

Create a new directory with a hello world C program:

$ ls
$ cat > hello.c
#include <stdio.h>

int main() {
  puts("Hello, world!");
  return 0;
}

💡 The empty or non-existent Makefile is a valid makefile for this C program:

$ make hello                # build "hello"
cc     hello.c   -o hello
$ ./hello
Hello, world!

Comments