| 1 |
# Be quiet and do not echo the cmd |
| 2 |
Q = @ |
| 3 |
|
| 4 |
# Try to use bash as shell for make |
| 5 |
SHELL := $(shell if [ -x /bin/bash ]; then echo /bin/bash; else echo /bin/sh; fi) |
| 6 |
|
| 7 |
# Compiler related stuff |
| 8 |
CCNQ = $(CCACHE) $(CC) |
| 9 |
ifeq ($(Q),) |
| 10 |
LDQ = $(CCACHE) $(CC) |
| 11 |
CCQ = $(CCNQ) |
| 12 |
else |
| 13 |
LDQ = $(Q)echo -e " LD\t$@" && $(CCACHE) $(CC) |
| 14 |
CCQ = $(Q)echo -e " CC\t$<" && $(CCNQ) |
| 15 |
endif |
| 16 |
|
| 17 |
# sparse related |
| 18 |
C = |
| 19 |
ifeq ($(C), 1) |
| 20 |
CHECK = $(Q)echo -e " CHECK\t$<" && sparse |
| 21 |
else |
| 22 |
CHECK = @true |
| 23 |
endif |
| 24 |
|
| 25 |
# Flex/bison related |
| 26 |
LEX = flex |
| 27 |
YACC = bison |
| 28 |
ifeq ($(Q),) |
| 29 |
LEXQ = $(LEX) |
| 30 |
YACCQ = $(YACC) |
| 31 |
else |
| 32 |
LEXQ = $(Q)echo -e " LEX\t$<" && $(LEX) |
| 33 |
YACCQ = $(Q)echo -e " YAAC\t$<" && $(YACC) |
| 34 |
endif |
| 35 |
|
| 36 |
# Installation related |
| 37 |
INST = echo -e " INST\t$(1)" && install -d $(2) && \ |
| 38 |
install --mode=644 -DC $(1) $(2)/$(shell basename $(1)) |
| 39 |
|
| 40 |
INSTD = echo -e " INSTD\t$(1)" && install -d $(1) |
| 41 |
|
| 42 |
# Determine wheter origin of PREFIX is "file" or "command line" |
| 43 |
ifeq ("$(origin PREFIX)", "$(filter $(origin PREFIX), file command line)") |
| 44 |
INSTX = echo -e " INST\t$(1)" && install -d $(2) && \ |
| 45 |
install -C $(1) $(2)/$(shell basename $(1)) |
| 46 |
else |
| 47 |
INSTX = echo -e " INST\t$(1)" && install -d $(2) && \ |
| 48 |
install -C $(1) $(2)/$(shell basename $(1)) |
| 49 |
endif |
| 50 |
|
| 51 |
MKDIR = echo -e " MKDIR\t$(1)" && mkdir -p $(1) |
| 52 |
|
| 53 |
RM = echo -e " RM\t$(1)" && rm -rf $(1) |
| 54 |
RMDIR = echo -e " RM\t$(1)" && rmdir --ignore-fail-on-non-empty $(1) 2> /dev/null || true |
| 55 |
|
| 56 |
GZIP_ENV = -9 -c |
| 57 |
|
| 58 |
# Git related |
| 59 |
GIT_LAST_TAG = git describe --abbrev=0 v$(VERSION_SHORT)^ |
| 60 |
GIT_ARCHIVE = git archive --prefix=netsniff-ng-$(VERSION_SHORT)/ v$(VERSION_SHORT) | \ |
| 61 |
$(1) > ../netsniff-ng-$(VERSION_SHORT).tar.$(2) |
| 62 |
GIT_TAG = git tag -a v$(VERSION_SHORT) -s -m "$(VERSION_SHORT) release" |
| 63 |
GIT_LOG = git shortlog -n $(shell $(GIT_LAST_TAG))..HEAD |
| 64 |
GIT_REM = git ls-files -o | xargs rm -rf |
| 65 |
GIT_PEOPLE = git log --no-merges $(shell $(GIT_LAST_TAG))..HEAD | grep Author: | cut -d: -f2 | \ |
| 66 |
cut -d\< -f1 | sort | uniq -c | sort -nr |
| 67 |
GIT_VERSION = git describe --always |
| 68 |
|
| 69 |
# GPG related |
| 70 |
GPG_SIGN = gpg -a --output ../netsniff-ng-$(VERSION_SHORT).tar.$(1).sign --detach-sig \ |
| 71 |
../netsniff-ng-$(VERSION_SHORT).tar.$(1) |