-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
88 lines (65 loc) · 1.81 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Makefile
# Řešení IJC-DU1, příklad a), 20.3.2022
# Autor: Ondřej Zobal, FIT
CC = gcc
CFLAGS = -std=c11 -pedantic -Wall -Wextra
LDFLAGS = -Wall -Wextra
LIBS = -lm
STEGFILE = du1-obrazek.ppm
# Adds either debug info or optimization
ifeq ($(debug), 1)
CFLAGS += -g
LDFLAGS += -g
else
CFLAGS += -O2
endif
# Compile to 32bit
ifeq ($(32bit), 1)
CFLAGS += -m32
LDFLAGS += -m32
endif
.PHONY: all run clean primes-i-full
# Builds both variants of the program
all: primes primes-i steg-decode
# Builds and runs both variants of the program
run: all
./primes
./primes-i
# Removes objects and executable files.
clean:
find . -maxdepth 1 -type f -executable -exec rm {} +
rm *.o
### A)
# MAKROS
primes: primes.o eratosthenes.o error.o
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
# primes.o
primes.o: primes.c eratosthenes.h bitset.h
$(CC) $(CFLAGS) -c -o $@ primes.c
# eratosthenes.o
eratosthenes.o: eratosthenes.c eratosthenes.h bitset.h
$(CC) $(CFLAGS) -c -o $@ eratosthenes.c
# INLINES
# Calls another instance of make and builds primes with inline functions
primes-i: primes-i.o eratosthenes-i.o error.o
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
# primes-i.o
primes-i.o: primes.c eratosthenes.h bitset.h
$(CC) $(CFLAGS) -DUSE_INLINE -c -o $@ primes.c
# eratosthenes.o
eratosthenes-i.o: eratosthenes.c eratosthenes.h bitset.h
$(CC) $(CFLAGS) -DUSE_INLINE -c -o $@ eratosthenes.c
### B)
error.o: error.c error.h
$(CC) $(CFLAGS) -c -o $@ error.c
ppm.o: ppm.c ppm.h
$(CC) $(CFLAGS) -c -o $@ ppm.c
steg-decode.o: steg-decode.c ppm.h
$(CC) $(CFLAGS) -c -o $@ steg-decode.c
# Linking steg-decode
steg-decode: ppm.o eratosthenes.o error.o steg-decode.o
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
steg-encode.o: steg-encode.c
$(CC) $(CFLAGS) -c -o $@ $^
steg-encode: ppm.o eratosthenes$(SUFFIX).o error.o steg-encode.o
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)