forked from nerves-networking/vintage_net_wifi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
126 lines (108 loc) · 3.39 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
# Makefile for building port binaries
#
# Makefile targets:
#
# all/install build and install the port binary
# clean clean build products and intermediates
#
# Variables to override:
#
# MIX_APP_PATH path to the build directory
#
# CC C compiler
# CROSSCOMPILE crosscompiler prefix, if any
# CFLAGS compiler flags for compiling all C files
# LDFLAGS linker flags for linking all binaries
# PKG_CONFIG_SYSROOT_DIR sysroot for pkg-config (for finding libnl-3)
# PKG_CONFIG_PATH pkg-config metadata
#
ifeq ($(MIX_APP_PATH),)
calling_from_make:
mix compile
endif
PREFIX = $(MIX_APP_PATH)/priv
BUILD = $(MIX_APP_PATH)/obj
CFLAGS ?= -O2 -Wall -Wextra -Wno-unused-parameter -pedantic
# Check that we're on a supported build platform
ifeq ($(CROSSCOMPILE),)
# Not crosscompiling, so check that we're on Linux.
ifeq ($(shell uname -s),Linux)
CFLAGS += $(shell pkg-config --cflags libnl-genl-3.0)
else
$(warning vintage_net_wifi only works on Linux, but crosscompilation)
$(warning is supported by defining $$CROSSCOMPILE.)
$(warning See Makefile for details. If using Nerves,)
$(warning this should be done automatically.)
$(warning .)
$(warning Skipping C compilation unless targets explicitly passed to make.)
DEFAULT_TARGETS ?= $(PREFIX)
endif
else
# Crosscompiling
ifeq ($(PKG_CONFIG_SYSROOT_DIR),)
# If pkg-config sysroot isn't set, then assume Nerves
CFLAGS += -I$(NERVES_SDK_SYSROOT)/usr/include/libnl3
else
# Use pkg-config to find libnl
PKG_CONFIG = $(shell which pkg-config)
ifeq ($(PKG_CONFIG),)
$(error pkg-config required to build. Install by running "brew install pkg-config")
endif
CFLAGS += $(shell $(PKG_CONFIG) --cflags libnl-genl-3.0)
endif
endif
DEFAULT_TARGETS ?= $(PREFIX) \
$(PREFIX)/force_ap_scan \
$(PREFIX)/mesh_mode \
$(PREFIX)/mesh_param
# Enable for debug messages
# CFLAGS += -DDEBUG
# Unfortunately, depending on the system we're on, we need
# to specify -std=c99 or -std=gnu99. The later is more correct,
# but it fails to build on many setups.
# NOTE: Need to call sh here since file permissions are not preserved
# in hex packages.
ifeq ($(shell CC=$(CC) sh src/test-c99.sh),yes)
CFLAGS += -std=c99 -D_XOPEN_SOURCE=600
else
CFLAGS += -std=gnu99
endif
all: install
install: $(BUILD) $(PREFIX) $(DEFAULT_TARGETS)
$(BUILD)/%.o: src/%.c
@echo " CC $(notdir $@)"
$(CC) -c $(CFLAGS) -o $@ $<
$(PREFIX)/force_ap_scan: $(BUILD)/force_ap_scan.o
@echo " LD $(notdir $@)"
$(CC) $^ $(LDFLAGS) -lnl-3 -lnl-genl-3 -o $@
$(PREFIX)/mesh_mode: $(BUILD)/mesh_mode.o
@echo " LD $(notdir $@)"
$(CC) $^ $(LDFLAGS) -lnl-3 -lnl-genl-3 -o $@
$(PREFIX)/mesh_param: $(BUILD)/mesh_param.o
@echo " LD $(notdir $@)"
$(CC) $^ $(LDFLAGS) -lnl-3 -lnl-genl-3 -o $@
$(PREFIX) $(BUILD):
mkdir -p $@
mix_clean:
$(RM) $(PREFIX)/force_ap_scan \
$(PREFIX)/mesh_mode \
$(PREFIX)/mesh_param \
$(BUILD)/*.o
clean:
mix clean
format:
astyle \
--style=kr \
--indent=spaces=4 \
--align-pointer=name \
--align-reference=name \
--convert-tabs \
--attach-namespaces \
--max-code-length=100 \
--max-instatement-indent=120 \
--pad-header \
--pad-oper \
src/*.c
.PHONY: all clean mix_clean calling_from_make install format
# Don't echo commands unless the caller exports "V=1"
${V}.SILENT: