aboutsummaryrefslogtreecommitdiff
path: root/test/example/Makefile
blob: 4363cc2762d1eff641c182d62655398531df74a8 (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
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
# Copyright (c) 2013, Linaro Limited
# All rights reserved.
#
# SPDX-License-Identifier:     BSD-3-Clause

ODP_ROOT = ../..
ARCH     = linux-generic
ODP_LIB  = $(ODP_ROOT)/arch/$(ARCH)
ODP_INC  = $(ODP_ROOT)/include
OBJ_DIR  = ./obj
LIB      = $(ODP_LIB)/lib/odp.a
ODP_APP  = odp_example

CC       ?= @gcc

E_FLAGS  = -W -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
E_FLAGS += -Wmissing-declarations -Wold-style-definition -Wpointer-arith
E_FLAGS += -Wcast-align -Wnested-externs -Wcast-qual -Wformat-nonliteral
E_FLAGS += -Wformat-security -Wundef -Wwrite-strings

CFLAGS  += -O3
CFLAGS  += -pthread
CFLAGS  += -I.
CFLAGS  += -I$(ODP_INC)
CFLAGS  += $(E_FLAGS)
CFLAGS  += $(EXTRA_CFLAGS)
#Debug turned on per default
ifeq ($(ODP_EXAMPLE_DEBUG), 0)
CFLAGS  += -DODP_DEBUG=0
else
CFLAGS  += -DODP_DEBUG=1
endif

LDFLAGS += -pthread
LDFLAGS += -lrt
LDFLAGS += $(EXTRA_CFLAGS)

OBJS     =
OBJS    += $(OBJ_DIR)/odp_example.o

DEPS     = $(OBJS:.o=.d)

.PHONY: all
all: $(OBJ_DIR) $(ODP_APP)

-include $(DEPS)

$(OBJ_DIR):
	mkdir $(OBJ_DIR)

$(LIB):
	@echo Building $@
	$(MAKE) -C $(ODP_LIB) libs

#
# Compile rules
#
$(OBJ_DIR)/%.o: %.c
	@echo Compiling $<
	$(CC) -c -MD $(CFLAGS) -o $@ $<

#
# Link rule
#
$(ODP_APP): $(LIB) $(OBJS)
	$(CC) $(LDFLAGS) $(OBJS) $(LIB) -o $@

.PHONY: libs
libs:
	$(MAKE) -C $(ODP_LIB) libs

.PHONY: docs
docs:
	$(MAKE) -C $(ODP_LIB) docs

.PHONY: clean
clean:
	rm -rf $(OBJ_DIR)
	rm -f $(ODP_APP)
	$(MAKE) -C $(ODP_LIB) clean

.PHONY: install
install:
	install -d $(DESTDIR)$(prefix)/lib
	install -m 0644 ${LIB} $(DESTDIR)$(prefix)/lib/
	install -d $(DESTDIR)$(prefix)/share/odp
	install -m 0755 $(ODP_APP) $(DESTDIR)$(prefix)/share/odp/