-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
141 lines (116 loc) · 3.57 KB
/
Makefile
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/usr/bin/make -f
# -*- makefile -*-
#
# Copyright (C) 2012-2016 B.A.T.M.A.N. contributors
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA
#
# alfred build
BINARY_NAME = alfred
OBJ = main.o server.o client.o netsock.o send.o recv.o hash.o unix_sock.o util.o debugfs.o batadv_query.o
MANPAGE = man/alfred.8
# alfred flags and options
CFLAGS += -pedantic -Wall -W -std=gnu99 -fno-strict-aliasing -MD -MP
LDLIBS += -lrt
# Turn on alfred capability dropping by default - set this to n if you don't want/need it
export CONFIG_ALFRED_CAPABILITIES=y
# disable verbose output
ifneq ($(findstring $(MAKEFLAGS),s),s)
ifndef V
Q_CC = @echo ' ' CC $@;
Q_LD = @echo ' ' LD $@;
export Q_CC
export Q_LD
endif
endif
# standard build tools
CC ?= gcc
RM ?= rm -f
INSTALL ?= install
MKDIR ?= mkdir -p
COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
LINK.o = $(Q_LD)$(CC) $(CFLAGS) $(LDFLAGS) $(TARGET_ARCH)
# standard install paths
PREFIX = /usr/local
SBINDIR = $(PREFIX)/sbin
MANDIR = $(PREFIX)/share/man
# try to generate revision
REVISION= $(shell if [ -d .git ]; then \
echo $$(git describe --always --dirty --match "v*" |sed 's/^v//' 2> /dev/null || echo "[unknown]"); \
fi)
ifneq ($(REVISION),)
CPPFLAGS += -DSOURCE_VERSION=\"$(REVISION)\"
endif
ifneq ($(CONFIG_ALFRED_VIS),n)
VIS_ALL=vis-all
VIS_CLEAN=vis-clean
VIS_INSTALL=vis-install
endif
ifneq ($(CONFIG_ALFRED_GPSD),n)
GPSD_ALL=gpsd-all
GPSD_CLEAN=gpsd-clean
GPSD_INSTALL=gpsd-install
endif
ifneq ($(CONFIG_ALFRED_CAPABILITIES),n)
ifeq ($(origin PKG_CONFIG), undefined)
PKG_CONFIG = pkg-config
ifeq ($(shell which $(PKG_CONFIG) 2>/dev/null),)
$(error $(PKG_CONFIG) not found)
endif
endif
ifeq ($(origin LIBCAP_CFLAGS) $(origin LIBCAP_LDLIBS), undefined undefined)
LIBCAP_NAME ?= libcap
ifeq ($(shell $(PKG_CONFIG) --modversion $(LIBCAP_NAME) 2>/dev/null),)
$(error No $(LIBCAP_NAME) development libraries found!)
endif
LIBCAP_CFLAGS += $(shell $(PKG_CONFIG) --cflags $(LIBCAP_NAME))
LIBCAP_LDLIBS += $(shell $(PKG_CONFIG) --libs $(LIBCAP_NAME))
endif
CFLAGS += $(LIBCAP_CFLAGS)
CPPFLAGS += -DCONFIG_ALFRED_CAPABILITIES
LDLIBS += $(LIBCAP_LDLIBS)
endif
# default target
all: $(BINARY_NAME) $(VIS_ALL) $(GPSD_ALL)
# standard build rules
.SUFFIXES: .o .c
.c.o:
$(COMPILE.c) -o $@ $<
$(BINARY_NAME): $(OBJ)
$(LINK.o) $^ $(LDLIBS) -o $@
clean: $(VIS_CLEAN) $(GPSD_CLEAN)
$(RM) $(BINARY_NAME) $(OBJ) $(DEP)
install: $(BINARY_NAME) $(VIS_INSTALL) $(GPSD_INSTALL)
$(MKDIR) $(DESTDIR)$(SBINDIR)
$(MKDIR) $(DESTDIR)$(MANDIR)/man8
$(INSTALL) -m 0755 $(BINARY_NAME) $(DESTDIR)$(SBINDIR)
$(INSTALL) -m 0644 $(MANPAGE) $(DESTDIR)$(MANDIR)/man8
vis-install:
$(MAKE) -C vis install
vis-all:
$(MAKE) -C vis all
vis-clean:
$(MAKE) -C vis clean
gpsd-install:
$(MAKE) -C gpsd install
gpsd-all:
$(MAKE) -C gpsd all
gpsd-clean:
$(MAKE) -C gpsd clean
# load dependencies
DEP = $(OBJ:.o=.d)
-include $(DEP)
.PHONY: all clean install vis-install vis-all vis-clean \
gpsd-install gpsd-all gpsd-clean