Skip to content

Instantly share code, notes, and snippets.

@arjkb
Created April 19, 2017 20:22
Show Gist options
  • Save arjkb/aa1c73aca3d9add77630d9f819413232 to your computer and use it in GitHub Desktop.
Save arjkb/aa1c73aca3d9add77630d9f819413232 to your computer and use it in GitHub Desktop.
Makefile for graph-coloring project.
CC=gcc
CFLAGS=-g
OBJS=greedy.o random.o randomgraph.o sig.o
all: greedy random randomgraph sig
greedy: greedy.o
$(CC) $(CFLAGS) -o greedy greedy.o
random: random.o
$(CC) $(CFLAGS) -o random random.o
randomgraph: randomgraph.o
$(CC) $(CFLAGS) -o randomgraph randomgraph.o
sig: sig.o
$(CC) $(CFLAGS) -o sig sig.o
greedy.o: greedy.c
$(CC) -c $(CFLAGS) greedy.c
greedy.o: greedy.c
$(CC) -c $(CFLAGS) greedy.c
greedy.o: greedy.c
$(CC) -c $(CFLAGS) greedy.c
greedy.o: greedy.c
$(CC) -c $(CFLAGS) greedy.c
.PHONY: clean
clean:
rm greedy random randomgraph sig *.o
@arjkb
Copy link
Author

arjkb commented Apr 19, 2017

Easiest way to get started is to click on RAW and save the Makefie in the directory that contains the rest of the .c files.

The following would work on Linux or Mac.

To compile all C sources and create their executables, run:

$ make

To compile a specific C file, run make filename (filename specified here should NOT have .c extension).
For instance, to create the executable for greedy.c, run:

$ make greedy

To remove all object files and executables, run:

$ make clean

To run the executable, type ./executable.
For instance, to run the executable for greedy.c (which you get after running make greedy or just make), run:

$ ./greedy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment