xref: /dpdk/examples/timer/Makefile (revision 8549295d)
13998e2a0SBruce Richardson# SPDX-License-Identifier: BSD-3-Clause
23998e2a0SBruce Richardson# Copyright(c) 2010-2014 Intel Corporation
3af75078fSIntel
40eba4adeSBruce Richardson# binary name
50eba4adeSBruce RichardsonAPP = timer
60eba4adeSBruce Richardson
70eba4adeSBruce Richardson# all source are stored in SRCS-y
80eba4adeSBruce RichardsonSRCS-y := main.c
90eba4adeSBruce Richardson
1022119c45SBruce Richardson# Build using pkg-config variables if possible
114131ad5dSBruce Richardsonifeq ($(shell pkg-config --exists libdpdk && echo 0),0)
1222119c45SBruce Richardson
131842d194SBruce Richardsonall: shared
141842d194SBruce Richardson.PHONY: shared static
151842d194SBruce Richardsonshared: build/$(APP)-shared
161842d194SBruce Richardson	ln -sf $(APP)-shared build/$(APP)
171842d194SBruce Richardsonstatic: build/$(APP)-static
181842d194SBruce Richardson	ln -sf $(APP)-static build/$(APP)
1922119c45SBruce Richardson
2012a652a0SBruce RichardsonPKGCONF ?= pkg-config
21ca926852SBruce Richardson
2269b1bb49SBruce RichardsonPC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
23ca926852SBruce RichardsonCFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
24ca926852SBruce RichardsonLDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
25*8549295dSBruce RichardsonLDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)
261842d194SBruce Richardson
271842d194SBruce Richardsonbuild/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
281842d194SBruce Richardson	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
291842d194SBruce Richardson
301842d194SBruce Richardsonbuild/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
311842d194SBruce Richardson	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
3222119c45SBruce Richardson
3322119c45SBruce Richardsonbuild:
3422119c45SBruce Richardson	@mkdir -p $@
3522119c45SBruce Richardson
3622119c45SBruce Richardson.PHONY: clean
3722119c45SBruce Richardsonclean:
381842d194SBruce Richardson	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
397e9562a1SBruce Richardson	test -d build && rmdir -p build || true
4022119c45SBruce Richardson
4122119c45SBruce Richardsonelse # Build using legacy build system
4222119c45SBruce Richardson
43af75078fSIntelifeq ($(RTE_SDK),)
44af75078fSIntel$(error "Please define RTE_SDK environment variable")
45af75078fSIntelendif
46af75078fSIntel
47e9c65942SBruce Richardson# Default target, detect a build directory, by looking for a path with a .config
48e9c65942SBruce RichardsonRTE_TARGET ?= $(notdir $(abspath $(dir $(firstword $(wildcard $(RTE_SDK)/*/.config)))))
49af75078fSIntel
50af75078fSIntelinclude $(RTE_SDK)/mk/rte.vars.mk
51af75078fSIntel
52af75078fSIntelCFLAGS += -O3
53af75078fSIntelCFLAGS += $(WERROR_FLAGS)
5478d44153SSunil Kumar KoriCFLAGS += -DALLOW_EXPERIMENTAL_API
55af75078fSIntel
56af75078fSIntel# workaround for a gcc bug with noreturn attribute
57af75078fSIntel# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
58af75078fSIntelifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
59af75078fSIntelCFLAGS_main.o += -Wno-return-type
60af75078fSIntelendif
61af75078fSIntel
62af75078fSIntelinclude $(RTE_SDK)/mk/rte.extapp.mk
6322119c45SBruce Richardsonendif
64