net/mlx5: fix VLAN push action validation
[dpdk.git] / examples / ethtool / lib / Makefile
index 2576910..a33040e 100644 (file)
@@ -1,37 +1,49 @@
 # SPDX-License-Identifier: BSD-3-Clause
-# Copyright(c) 2015 Intel Corporation
+# Copyright(c) 2015-2020 Intel Corporation
 
-ifeq ($(RTE_SDK),)
-$(error "Please define RTE_SDK environment variable")
-endif
-
-# Default target, can be overwritten by command line or environment
-RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
-include $(RTE_SDK)/mk/rte.vars.mk
+PKGCONF ?= pkg-config
 
-ifneq ($(CONFIG_RTE_EXEC_ENV),"linuxapp")
-$(error This application can only operate in a linuxapp environment, \
-please change the definition of the RTE_TARGET environment variable)
+ifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0)
+$(error "no installation of DPDK found")
+endif
+ifneq ($(shell uname),Linux)
+$(error This application can only operate in a linux environment)
 endif
 
 # library name
-LIB = librte_ethtool.a
-
-LIBABIVER := 1
-
-# all source are stored in SRC-Y
-SRCS-y := rte_ethtool.c
+LIB = librte_ethtool.so
+LIB_STATIC = librte_ethtool.a
+SRCS = rte_ethtool.c
 
 CFLAGS += -O3
-CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -fPIC
 CFLAGS += -DALLOW_EXPERIMENTAL_API
 
-ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
-ifeq ($(CONFIG_RTE_LIBRTE_IXGBE_PMD),y)
-LDLIBS += -lrte_pmd_ixgbe
-endif
+PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
+CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
+LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
+LDFLAGS += -Wl,--no-undefined $(LDFLAGS_SHARED)
+
+# check for ixgbe by grepping pre-processor output
+ifneq ($(shell $(CC) $(CFLAGS) -dM -E - < /dev/null | grep IXGBE),)
+LDFLAGS += -lrte_net_ixgbe
 endif
-LDLIBS += -lrte_eal -lrte_ethdev
 
-include $(RTE_SDK)/mk/rte.extlib.mk
+.PHONY: all clean static shared
+all shared: build/$(LIB)
+static: build/$(LIB_STATIC)
+
+clean:
+       rm -f build/$(LIB)
+       test -d build && rmdir -p build || true
+
+build:
+       @mkdir -p $@
+
+build/%.so: $(SRCS) Makefile $(PC_FILE) | build
+       $(CC) $(CFLAGS) -o $@ -shared $(SRCS) $(LDFLAGS)
+
+build/%.a: $(SRCS) Makefile $(PC_FILE) | build
+       $(CC) $(CFLAGS) -c $(SRCS) -o build/$(SRCS).o
+       $(AR) -cr $@ build/*.o