Skip to content

Instantly share code, notes, and snippets.

@obstschale
Created October 16, 2013 07:30
Show Gist options
  • Save obstschale/7003963 to your computer and use it in GitHub Desktop.
Save obstschale/7003963 to your computer and use it in GitHub Desktop.
Template: Simple makefile for compiling C programs using gcc
# CC is the compiler which will be used
CC=gcc
# CFLAGS are the options I'll pass to the compiler
CFLAGS=-c -Wall
all: hello
hello: main.o factorial.o hello.o
$(CC) main.o factorial.o hello.o -o hello
main.o: main.cpp
$(CC) $(CFLAGS) main.cpp
factorial.o: factorial.cpp
$(CC) $(CFLAGS) factorial.cpp
hello.o: hello.cpp
$(CC) $(CFLAGS) hello.cpp
clean:
rm -rf *o hello
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment