-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
93 lines (65 loc) · 2.51 KB
/
Makefile
File metadata and controls
93 lines (65 loc) · 2.51 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# To build with a specific architecture, set the ARCH flag on the make command line like this:
# make ARCH=i386
# or
# make ARCH=x86_64
CFLAGS=-g -Wall -Werror -Wextra -O0 -std=c11 -D_POSIX_C_SOURCE=2
CFLAGS_PARALLEL=-fopenmp -DUSE_PARALLEL
ifdef ARCH
LDFLAGS+=-arch ${ARCH}
CFLAGS+=-arch ${ARCH}
endif
ifdef USE_PARALLEL
CFLAGS+=-fopenmp -DUSE_PARALLEL
LDFLAGS+=-fopenmp
endif
all: huffcode huffcode_seq
# Build a sequential-only binary (for comparison/testing)
ifndef USE_PARALLEL
all: libhuffman.a
endif
## Sequential huffcode (no parallel runtime support)
huffcode_seq: huffcode_seq.o libhuffman.a
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ huffcode_seq.o libhuffman.a
## Default huffcode with runtime parallel support (compiled with -DUSE_PARALLEL)
huffcode: huffcode_parallel.o huffman.o huffman_parallel.o bwt.o mtf.o rle.o
$(CC) $(CFLAGS) $(CFLAGS_PARALLEL) $(LDFLAGS) -o $@ huffcode_parallel.o huffman.o huffman_parallel.o bwt.o mtf.o rle.o
huffman.o: huffman.h bwt.h mtf.h rle.h
bwt.o: bwt.h
mtf.o: mtf.h
rle.o: rle.h
# Compile huffcode twice: a sequential binary and a parallel-capable binary.
huffcode_seq.o: huffcode.c huffman.h
$(CC) $(CFLAGS) -c -o $@ huffcode.c
huffcode_parallel.o: huffcode.c huffman.h huffman_parallel.h
$(CC) $(CFLAGS) $(CFLAGS_PARALLEL) -c -o $@ huffcode.c
# Compile the parallel implementation with openmp flags
huffman_parallel.o: huffman_parallel.c huffman.h huffman_parallel.h
$(CC) $(CFLAGS) $(CFLAGS_PARALLEL) -c -o $@ huffman_parallel.c
ifndef USE_PARALLEL
libhuffman.a: huffman.o bwt.o mtf.o rle.o
$(AR) r $@ $^
endif
## Test binary for compression pipeline
test_pipeline: test_pipeline.o libhuffman.a huffcode
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ test_pipeline.o libhuffman.a
test_pipeline.o: test_pipeline.c huffman.h bwt.h mtf.h rle.h
$(CC) $(CFLAGS) -c -o $@ test_pipeline.c
check: check_seq check_parallel check_pipeline
check_seq: huffcode_seq
./run_tests.sh --huffcode ./huffcode_seq
check_parallel: huffcode
./run_tests.sh --huffcode ./huffcode
check_pipeline: test_pipeline
./test_pipeline
valgrind_check: valgrind_seq valgrind_parallel
valgrind_seq: huffcode_seq
./run_tests.sh --huffcode ./huffcode_seq --use-valgrind
valgrind_parallel: huffcode
./run_tests.sh --huffcode ./huffcode --use-valgrind
clean:
$(RM) -r *.o *~ core huffcode huffcode.exe libhuffman.a test_pipeline test_compression_pipeline scratch
.PHONY: all clean check valgrind_check p parallel huffcode huffcode_seq
## Convenience targets to build only the parallel binary
parallel: huffcode
# Short alias
p: parallel