-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
43 lines (30 loc) · 885 Bytes
/
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
# Usage:
# Run 'make test' to execute the test program.
# Run 'make valgrind' to run the test program in Valgrind.
# Run 'make clean' to remove compiled files.
#LIB source files.
LIBSRC = config_rw_lib.c config_rw_test.c
LIBOBJ = $(LIBSRC:.c=.o)
LIBOUT = libconfigrw
#APP source files.
APPSRC = config_rw_test.c
APPOBJ = $(APPSRC:.c=.o)
APPOUT = config_rw_test
# include directories
INCLUDES = -I. -I/usr/local/include
# C compiler flags (-g -O2 -Wall)
CCFLAGS = -g -Wall -Wextra -std=c99 -D_XOPEN_SOURCE=500
# compiler
CCC = gcc
.SUFFIXES: .c
default: $(LIBOUT) $(APPOUT)
.c.o:
$(CCC) $(INCLUDES) $(CCFLAGS) -c $< -o $@
$(LIBOUT): $(LIBOBJ)
ar rcs lib$(LIBOUT).a $(LIBOBJ)
$(APPOUT): $(APPOBJ)
$(CCC) $(CFLAGS) -static $(APPOBJ) -L. -l$(LIBOUT) -o $(APPOUT)
clean:
rm -f $(APPOBJ) $(APPOUT) $(LIBOBJ) lib$(LIBOUT).a
valgrind:
valgrind --tool=memcheck ./$(APPOUT)