Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
extractor
gesa
Commits
524ac86c
Commit
524ac86c
authored
Jan 11, 2018
by
jkvis
Browse files
Building multiple test targets
parent
ededc38a
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/.gitignore
View file @
524ac86c
tests
*.out
tests/Makefile
View file @
524ac86c
INC_LIB
=
$(
shell
find ..
-name
'*.a'
)
LIB_DIR
=
$(
dir
$(INC_LIB)
)
LIB_NAME
=
$(
notdir
$(INC_LIB)
)
INC_DIR
=
../include
INC_DIR
=
.
../include
SOURCES
=
$(
shell
find
.
-name
'*.c'
)
OBJECTS
=
$(SOURCES:.c=.o)
DEPS
=
$(OBJECTS:.o=.d)
TARGET
=
tests
TARGETS
=
$(
filter
./test_%,
$(OBJECTS)
)
SHARED
=
$(
filter-out
$(TARGETS)
,
$(OBJECTS)
)
CC
=
gcc
CFLAGS
=
-march
=
native
-O0
-DDEBUG
-ggdb3
...
...
@@ -15,17 +16,16 @@ CPPFLAGS = $(addprefix -I, $(INC_DIR)) -Wall -Wextra -pedantic
.PHONY
:
all clean run_tests
all
:
$(
TARGET
)
all
:
$(
OBJECTS) $(TARGETS:.o=.out
)
run_tests
:
$(TARGET)
@
echo
running tests...
./
$<
run_tests
:
all
@
-
$(
foreach
T,
$(TARGETS:.o=.out)
, ./
$T
;
)
clean
:
rm
-f
$(OBJECTS)
$(DEPS)
$(TARGET)
rm
-f
$(OBJECTS)
$(DEPS)
$(TARGET
S:.o=
)
$(TARGET
)
:
$(OBJECTS
)
$(CC)
$(CFLAGS)
$(CPPFLAGS)
$^
$(
addprefix
-L
,
$(LIB_DIR)
)
$(
addprefix
-l
,
$(LIB_NAME:lib%.a=%)
$(LIB_NAME:lib%.a=%)
)
-o
$@
$(TARGET
S
:
.o=.out): $(SHARED
)
$(CC)
$(CFLAGS)
$(CPPFLAGS)
$
(
@:.out
=
.o
)
$^
$(
addprefix
-L
,
$(LIB_DIR)
)
$(
addprefix
-l
,
$(LIB_NAME:lib%.a=%)
$(LIB_NAME:lib%.a=%)
)
-o
$@
-include
$(DEPS)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment