blob: db1fefd2b8faa7b3197a657b3040727639619d3d (
plain)
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
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Compilation Options
# Debug mode (allowing to debug the library via gdb):
# DEBUG = yes
# Specify your favourite C compiler here (e.g. tcc):
CC = gcc
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Preparations
LIB = libmagi.a
# Compile under the most strict conditions:
CFLAGS = -xc -ansi -pedantic -Wall
# Debug and optimisation are not compatible:
ifeq '$(DEBUG)' 'yes'
CFLAGS += -g -O0
else
CFLAGS += -O3
endif
# Object files listing:
SRC_DIR = src
SRC = $(wildcard $(SRC_DIR)/*.c)
OBJ = $(SRC:.c=.o)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Targets
# 'make' produces library by default:
default: $(LIB)
# Cleaning means removing everything automatically produced:
clean:
rm -f $(OBJ) $(LIB) deps.mk
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Compilation
# Compile object files from corresponding source and header:
%.o: %.c %.h
$(CC) $(CFLAGS) -c $< -o $@
# Packing object files into library:
$(LIB): $(OBJ)
ar rcs $@ $^
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Dependencies
# Generating dependencies description file:
deps.mk: $(SRC)
$(CC) -MM $^ > $@
# While cleaning we need to remove it, not include:
ifneq "clean" "$(MAKECMDGOALS)"
-include deps.mk
endif
|