-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
70 lines (54 loc) · 1.36 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Makefile
# Author: Rushy Panchal
# Configuration
CC := gcc -Wall
RM := rm -rfv
LIBS := -lpng
SRC_LIBS = $(BUILD)/image.o
SRC := src
BIN := bin
BUILD := build
ITER := 250
SIZE := 1000
EXP := 2
# Other configuration
vpath % src
vpath %.asm src/mach-x86
vpath %.o build
### Patterns
# Object files (from C)
$(BUILD)/%.o: %.c | $(BUILD)
$(CC) $(CFLAGS) -c $< -o $@
# Object files (from x86)
$(BUILD)/%.o: %.asm | $(BUILD)
$(CC) $(CFLAGS) -c $< -o $@
### Build Tasks
all: $(BIN)/mandelbrot $(BIN)/mandelbrot-x86
debug: CFLAGS=-g
debug: all
profile: CFLAGS=-pg
profile: all
$(BIN):
@mkdir -p $@
$(BUILD):
@mkdir -p $@
# Binary Executable(s)
$(BIN)/mandelbrot: $(BUILD)/mandelbrot.o $(SRC_LIBS) \
$(BUILD)/generate_mandelbrot_set.o | $(BIN)
$(CC) $(CFLAGS) $(LIBS) $^ -o $@
$(BIN)/mandelbrot-x86: $(BUILD)/mandelbrot.o $(SRC_LIBS) \
$(BUILD)/generate_mandelbrot_set-x86.o | $(BIN)
$(CC) $(CFLAGS) $(LIBS) $^ -o $@
$(BIN)/imgdiff: $(BUILD)/image.o $(BUILD)/imgdiff.o $(SRC_LIBS) | $(BIN)
$(CC) $(CFLAGS) $(LIBS) $^ -o $@
# Object File(s)
$(BUILD)/image.o: image.c image.h
### Other Tasks
test: CFLAGS=-O3 -D NDEBUG
test: all $(BIN)/imgdiff
time $(BIN)/mandelbrot mandelbrot.png $(SIZE) $(SIZE) $(ITER) $(EXP)
time $(BIN)/mandelbrot-x86 mandelbrot-x86.png $(SIZE) $(SIZE) $(ITER) $(EXP)
$(BIN)/imgdiff mandelbrot.png mandelbrot-x86.png
clean:
$(RM) $(BUILD)
$(RM) $(BIN)