|
Packit Service |
5befb9 |
###############################################################################
|
|
Packit Service |
5befb9 |
# Makefile script for PQoS sample application
|
|
Packit Service |
5befb9 |
#
|
|
Packit Service |
5befb9 |
# @par
|
|
Packit Service |
5befb9 |
# BSD LICENSE
|
|
Packit Service |
5befb9 |
#
|
|
Packit Service |
8a4b7a |
# Copyright(c) 2014-2020 Intel Corporation. All rights reserved.
|
|
Packit Service |
5befb9 |
# All rights reserved.
|
|
Packit Service |
5befb9 |
#
|
|
Packit Service |
5befb9 |
# Redistribution and use in source and binary forms, with or without
|
|
Packit Service |
5befb9 |
# modification, are permitted provided that the following conditions
|
|
Packit Service |
5befb9 |
# are met:
|
|
Packit Service |
5befb9 |
#
|
|
Packit Service |
5befb9 |
# * Redistributions of source code must retain the above copyright
|
|
Packit Service |
5befb9 |
# notice, this list of conditions and the following disclaimer.
|
|
Packit Service |
5befb9 |
# * Redistributions in binary form must reproduce the above copyright
|
|
Packit Service |
5befb9 |
# notice, this list of conditions and the following disclaimer in
|
|
Packit Service |
5befb9 |
# the documentation and/or other materials provided with the
|
|
Packit Service |
5befb9 |
# distribution.
|
|
Packit Service |
5befb9 |
# * Neither the name of Intel Corporation nor the names of its
|
|
Packit Service |
5befb9 |
# contributors may be used to endorse or promote products derived
|
|
Packit Service |
5befb9 |
# from this software without specific prior written permission.
|
|
Packit Service |
5befb9 |
#
|
|
Packit Service |
5befb9 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
Packit Service |
5befb9 |
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
Packit Service |
5befb9 |
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
Packit Service |
5befb9 |
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
Packit Service |
5befb9 |
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
Packit Service |
5befb9 |
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
Packit Service |
5befb9 |
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
Packit Service |
5befb9 |
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
Packit Service |
5befb9 |
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
Packit Service |
5befb9 |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
Packit Service |
5befb9 |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit Service |
5befb9 |
#
|
|
Packit Service |
5befb9 |
###############################################################################
|
|
Packit Service |
5befb9 |
|
|
Packit Service |
5befb9 |
LIBDIR ?= ../lib
|
|
Packit Service |
5befb9 |
LDFLAGS = -L$(LIBDIR) -pie -z noexecstack -z relro -z now
|
|
Packit Service |
5befb9 |
LDLIBS = -lpqos -lpthread
|
|
Packit Service |
5befb9 |
CFLAGS = -I$(LIBDIR) \
|
|
Packit Service |
5befb9 |
-W -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes \
|
|
Packit Service |
5befb9 |
-Wmissing-declarations -Wold-style-definition -Wpointer-arith \
|
|
Packit Service |
5befb9 |
-Wcast-qual -Wundef -Wwrite-strings \
|
|
Packit Service |
8a4b7a |
-Wformat -Wformat-security -fstack-protector -fPIE \
|
|
Packit Service |
5befb9 |
-Wunreachable-code -Wsign-compare -Wno-endif-labels
|
|
Packit Service |
5befb9 |
ifneq ($(EXTRA_CFLAGS),)
|
|
Packit Service |
5befb9 |
CFLAGS += $(EXTRA_CFLAGS)
|
|
Packit Service |
5befb9 |
endif
|
|
Packit Service |
8a4b7a |
ifneq ($(EXTRA_LDFLAGS),)
|
|
Packit Service |
8a4b7a |
LDFLAGS += $(EXTRA_LDFLAGS)
|
|
Packit Service |
8a4b7a |
endif
|
|
Packit Service |
5befb9 |
|
|
Packit Service |
5befb9 |
# ICC and GCC options
|
|
Packit Service |
5befb9 |
ifeq ($(CC),icc)
|
|
Packit Service |
5befb9 |
else
|
|
Packit Service |
5befb9 |
CFLAGS += -Wcast-align \
|
|
Packit Service |
5befb9 |
-Wnested-externs \
|
|
Packit Service |
5befb9 |
-Wmissing-noreturn
|
|
Packit Service |
5befb9 |
endif
|
|
Packit Service |
5befb9 |
|
|
Packit Service |
8a4b7a |
IS_GCC = $(shell $(CC) -v 2>&1 | grep -c "^gcc version ")
|
|
Packit Service |
8a4b7a |
# GCC-only options
|
|
Packit Service |
8a4b7a |
ifeq ($(IS_GCC),1)
|
|
Packit Service |
8a4b7a |
CFLAGS += -fno-strict-overflow \
|
|
Packit Service |
8a4b7a |
-fno-delete-null-pointer-checks \
|
|
Packit Service |
8a4b7a |
-fwrapv
|
|
Packit Service |
8a4b7a |
endif
|
|
Packit Service |
8a4b7a |
|
|
Packit Service |
5befb9 |
# DEBUG build
|
|
Packit Service |
5befb9 |
ifeq ($(DEBUG),y)
|
|
Packit Service |
5befb9 |
CFLAGS += -g -ggdb -O0 -DDEBUG
|
|
Packit Service |
5befb9 |
else
|
|
Packit Service |
8a4b7a |
CFLAGS += -g -O2 -D_FORTIFY_SOURCE=2
|
|
Packit Service |
8a4b7a |
endif
|
|
Packit Service |
8a4b7a |
|
|
Packit Service |
8a4b7a |
# RMID CUSTOM
|
|
Packit Service |
8a4b7a |
ifeq ($(RMID_CUSTOM),y)
|
|
Packit Service |
8a4b7a |
CFLAGS += -DPQOS_RMID_CUSTOM
|
|
Packit Service |
5befb9 |
endif
|
|
Packit Service |
5befb9 |
|
|
Packit Service |
5befb9 |
# Build targets and dependencies
|
|
Packit Service |
5befb9 |
APP = pqos
|
|
Packit Service |
5befb9 |
MAN = pqos.8
|
|
Packit Service |
5befb9 |
|
|
Packit Service |
5befb9 |
# XXX: modify as desired
|
|
Packit Service |
5befb9 |
PREFIX ?= /usr/local
|
|
Packit Service |
5befb9 |
BIN_DIR = $(PREFIX)/bin
|
|
Packit Service |
5befb9 |
MAN_DIR = $(PREFIX)/man/man8
|
|
Packit Service |
5befb9 |
|
|
Packit Service |
5befb9 |
SRCS = $(sort $(wildcard *.c))
|
|
Packit Service |
5befb9 |
OBJS = $(SRCS:.c=.o)
|
|
Packit Service |
5befb9 |
DEPFILES = $(SRCS:.c=.d)
|
|
Packit Service |
5befb9 |
|
|
Packit Service |
5befb9 |
all: $(APP)
|
|
Packit Service |
5befb9 |
|
|
Packit Service |
5befb9 |
$(APP): $(OBJS)
|
|
Packit Service |
5befb9 |
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
|
|
Packit Service |
5befb9 |
|
|
Packit Service |
5befb9 |
%.o: %.c %.d
|
|
Packit Service |
5befb9 |
|
|
Packit Service |
5befb9 |
%.d: %.c
|
|
Packit Service |
5befb9 |
$(CC) -MM -MP -MF $@ $(CFLAGS) $<
|
|
Packit Service |
5befb9 |
cat $@ | sed 's/$(@:.d=.o)/$@/' >> $@
|
|
Packit Service |
5befb9 |
|
|
Packit Service |
5befb9 |
.PHONY: clean install uninstall
|
|
Packit Service |
5befb9 |
|
|
Packit Service |
5befb9 |
install: $(APP) $(MAN)
|
|
Packit Service |
5befb9 |
ifeq ($(shell uname), FreeBSD)
|
|
Packit Service |
5befb9 |
install -d $(BIN_DIR)
|
|
Packit Service |
5befb9 |
install -d $(MAN_DIR)
|
|
Packit Service |
5befb9 |
install -s $(APP) $(BIN_DIR)
|
|
Packit Service |
5befb9 |
install $(APP)-msr $(BIN_DIR)
|
|
Packit Service |
5befb9 |
install -m 0444 $(MAN) $(MAN_DIR)
|
|
Packit Service |
5befb9 |
ln -f -s $(MAN) $(MAN_DIR)/$(APP)-msr.8
|
|
Packit Service |
5befb9 |
else
|
|
Packit Service |
5befb9 |
install -D -s $(APP) $(BIN_DIR)/$(APP)
|
|
Packit Service |
5befb9 |
install -D $(APP)-msr $(BIN_DIR)/$(APP)-msr
|
|
Packit Service |
5befb9 |
install -D $(APP)-os $(BIN_DIR)/$(APP)-os
|
|
Packit Service |
5befb9 |
install -m 0444 $(MAN) -D $(MAN_DIR)/$(MAN)
|
|
Packit Service |
5befb9 |
ln -f -s $(MAN) $(MAN_DIR)/$(APP)-msr.8
|
|
Packit Service |
5befb9 |
ln -f -s $(MAN) $(MAN_DIR)/$(APP)-os.8
|
|
Packit Service |
5befb9 |
endif
|
|
Packit Service |
5befb9 |
|
|
Packit Service |
5befb9 |
uninstall:
|
|
Packit Service |
5befb9 |
-rm $(BIN_DIR)/$(APP)
|
|
Packit Service |
5befb9 |
-rm $(MAN_DIR)/$(MAN)
|
|
Packit Service |
5befb9 |
-rm $(BIN_DIR)/$(APP)-msr
|
|
Packit Service |
5befb9 |
-rm $(MAN_DIR)/$(APP)-msr.8
|
|
Packit Service |
5befb9 |
ifneq ($(shell uname), FreeBSD)
|
|
Packit Service |
5befb9 |
-rm $(BIN_DIR)/$(APP)-os
|
|
Packit Service |
5befb9 |
-rm $(MAN_DIR)/$(APP)-os.8
|
|
Packit Service |
5befb9 |
endif
|
|
Packit Service |
5befb9 |
|
|
Packit Service |
5befb9 |
clean:
|
|
Packit Service |
5befb9 |
-rm -f $(APP) $(OBJS) $(DEPFILES) ./*~
|
|
Packit Service |
5befb9 |
|
|
Packit Service |
5befb9 |
CHECKPATCH?=checkpatch.pl
|
|
Packit Service |
8a4b7a |
.PHONY: checkpatch
|
|
Packit Service |
8a4b7a |
checkpatch:
|
|
Packit Service |
5befb9 |
$(CHECKPATCH) --no-tree --no-signoff --emacs \
|
|
Packit Service |
8a4b7a |
--ignore CODE_INDENT,INITIALISED_STATIC,LEADING_SPACE,SPLIT_STRING,UNSPECIFIED_INT,ARRAY_SIZE,\
|
|
Packit Service |
8a4b7a |
SPDX_LICENSE_TAG,CONST_STRUCT \
|
|
Packit Service |
5befb9 |
-f main.c -f main.h -f monitor.c -f monitor.h -f alloc.c -f alloc.h -f profiles.c -f profiles.h \
|
|
Packit Service |
8a4b7a |
-f cap.h -f cap.c -f common.h -f common.c
|
|
Packit Service |
8a4b7a |
|
|
Packit Service |
8a4b7a |
CLANGFORMAT?=clang-format
|
|
Packit Service |
8a4b7a |
.PHONY: clang-format
|
|
Packit Service |
8a4b7a |
clang-format:
|
|
Packit Service |
8a4b7a |
@for file in "cap.c" "cap.h" "common.c"; do \
|
|
Packit Service |
8a4b7a |
echo "Checking style $$file"; \
|
|
Packit Service |
8a4b7a |
$(CLANGFORMAT) -style=file "$$file" | diff "$$file" - | tee /dev/stderr | [ $$(wc -c) -eq 0 ] || \
|
|
Packit Service |
8a4b7a |
{ echo "ERROR: $$file has style problems"; exit 1; } \
|
|
Packit Service |
8a4b7a |
done
|
|
Packit Service |
8a4b7a |
|
|
Packit Service |
8a4b7a |
.PHONY: style
|
|
Packit Service |
8a4b7a |
style:
|
|
Packit Service |
8a4b7a |
$(MAKE) checkpatch
|
|
Packit Service |
8a4b7a |
$(MAKE) clang-format
|
|
Packit Service |
5befb9 |
|
|
Packit Service |
5befb9 |
CPPCHECK?=cppcheck
|
|
Packit Service |
5befb9 |
.PHONY: cppcheck
|
|
Packit Service |
5befb9 |
cppcheck:
|
|
Packit Service |
5befb9 |
$(CPPCHECK) --enable=warning,portability,performance,unusedFunction,missingInclude \
|
|
Packit Service |
5befb9 |
--std=c99 -I$(LIBDIR) --template=gcc \
|
|
Packit Service |
5befb9 |
main.c main.h alloc.c alloc.h monitor.c monitor.h profiles.c profiles.h \
|
|
Packit Service |
8a4b7a |
cap.h cap.c common.h common.c
|
|
Packit Service |
5befb9 |
|
|
Packit Service |
5befb9 |
# if target not clean then make dependencies
|
|
Packit Service |
5befb9 |
ifneq ($(MAKECMDGOALS),clean)
|
|
Packit Service |
5befb9 |
-include $(DEPFILES)
|
|
Packit Service |
5befb9 |
endif
|