aboutsummaryrefslogtreecommitdiff
path: root/examples/Makefile
blob: 8f5282c32185dae0a8e0cecb1d354b2df5dc66ac (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
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#     Compilation Options
# Debug mode (allowing to debug the examples via gdb):
# DEBUG    = yes
# Specify your favourite C compiler here (e.g. tcc):
CC       = gcc


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#     Preparations
EXAMPLES = append cookie upload echo

# 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

# Including magi library headers and setting linker to use it:
INCLUDE  = -I ../include
LFLAGS   = -L.. -lmagi

# Specification of library file to produce it, if not provided:
MAGI     = ../libmagi.a


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#     Targets
# 'make' produces all examples by default:
default: $(EXAMPLES)

# Cleaning means removing everything automatically produced:
clean:
	rm -f $(EXAMPLES)


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#     Compilation
# Compile executables from corresponding sources and library:
%: %.c $(MAGI)
	$(CC) $(CFLAGS) $(INCLUDE) $< $(LFLAGS) -o $@

# Run make for library to produce it:
$(MAGI):
	cd ..; $(MAKE)