-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
55 lines (42 loc) · 1.12 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
SHELL = /bin/sh
CC = gcc
CFLAGS = -Wall -Wextra -std=c99 -g -O2
LIBS =
GLIBC_MAJOR := $(shell ldd --version | grep -Eo '[0-9]+\.[0-9]+' | \
cut -d . -f 1)
GLIBC_MINOR := $(shell ldd --version | grep -Eo '[0-9]+\.[0-9]+' | \
cut -d . -f 2)
GLIBC_VER_OK := $(shell test $(GLIBC_MAJOR) -ge 2 && \
test $(GLIBC_MINOR) -ge 17 && \
echo 1)
LIBS_FOR_GEN_ULA = -luuid -lmhash
ifneq "$(GLIBC_VER_OK)" "1"
# clock_* functions need linking against -lrt in glibc < 2.17
LIBS := -lrt
endif
srctmp = $(wildcard *.c)
sources = $(filter-out common.c,$(srctmp))
elfs = $(patsubst %.c,%,$(sources))
v = @
ifeq ($V,1)
v =
endif
.PHONY: all
all: common.o $(elfs)
common.o: common.c common.h
@echo " CC $@"
$(v)$(CC) $(CFLAGS) -c $<
gen-ula: gen-ula.c
@echo " CCLNK $@"
$(v)$(CC) $(CFLAGS) -o $@ $< -luuid -lmhash
ipv6-gen-slaac: ipv6-gen-slaac.c common.o
@echo " CCLNK $@"
$(v)$(CC) $(CFLAGS) -o $@ $< common.o
mac-to-eui64: mac-to-eui64.c common.o
@echo " CCLNK $@"
$(v)$(CC) $(CFLAGS) -o $@ $< common.o
%: %.c
@echo " CCLNK $@"
$(v)$(CC) $(CFLAGS) -o $@ $<
clean:
rm -f $(elfs) *.o