Skip to content

Commit b198df9

Browse files
committed
Makefile: Streamline it
Rather than list out the individual targets for the different programs, just a single target that can handle them all. We also streamline the output a little, so rather than printing the gcc command line we get CCLNK <target> for each program. Signed-off-by: Andrew Clayton <[email protected]>
1 parent 96ecc5c commit b198df9

File tree

1 file changed

+11
-35
lines changed

1 file changed

+11
-35
lines changed

Makefile

+11-35
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,23 @@ GLIBC_VER_OK := $(shell test $(GLIBC_MAJOR) -ge 2 && \
1212
test $(GLIBC_MINOR) -ge 17 && \
1313
echo 1)
1414

15+
LIBS_FOR_GEN_ULA = -luuid -lmhash
16+
1517
ifneq "$(GLIBC_VER_OK)" "1"
1618
# clock_* functions need linking against -lrt in glibc < 2.17
1719
LIBS := -lrt
1820
endif
1921

20-
all: ipv6-range ipv6-arpa ipv6-isin gen-ula mac-to-eui64 mac-type \
21-
ipv6-extract-mac prefix-to-mask mask-to-prefix ipv6-fmt ipv6-gen-slaac
22-
23-
ipv6-range: ipv6-range.c
24-
$(CC) $(CFLAGS) -o $@ $<
25-
26-
ipv6-arpa: ipv6-arpa.c
27-
$(CC) $(CFLAGS) -o $@ $<
28-
29-
ipv6-isin: ipv6-isin.c
30-
$(CC) $(CFLAGS) -o $@ $<
31-
32-
gen-ula: gen-ula.c
33-
$(CC) $(CFLAGS) -o $@ $< -luuid -lmhash $(LIBS)
34-
35-
mac-to-eui64: mac-to-eui64.c
36-
$(CC) $(CFLAGS) -o $@ $<
37-
38-
mac-type: mac-type.c
39-
$(CC) $(CFLAGS) -o $@ $<
40-
41-
ipv6-extract-mac: ipv6-extract-mac.c
42-
$(CC) $(CFLAGS) -o $@ $<
43-
44-
prefix-to-mask: prefix-to-mask.c
45-
$(CC) $(CFLAGS) -o $@ $<
46-
47-
mask-to-prefix: mask-to-prefix.c
48-
$(CC) $(CFLAGS) -o $@ $<
22+
sources = $(wildcard *.c)
4923

50-
ipv6-fmt: ipv6-fmt.c
51-
$(CC) $(CFLAGS) -o $@ $<
24+
.ONESHELL:
5225

53-
ipv6-gen-slaac: ipv6-gen-slaac.c
54-
$(CC) $(CFLAGS) -o $@ $<
26+
.PHONY: all
27+
all: $(patsubst %.c,%,$(sources))
28+
%: %.c
29+
@echo -e " CCLNK\t$@"
30+
@if [[ "$@" == "gen-ula" ]]; then libs="-luuid -lmhash"; fi
31+
$(CC) $(CFLAGS) -o $@ $$libs $<
5532

5633
clean:
57-
rm -f ipv6-range ipv6-arpa ipv6-isin gen-ula mac-to-eui64 mac-type \
58-
ipv6-extract-mac prefix-to-mask mask-to-prefix ipv6-fmt ipv6-gen-slaac
34+
rm -f $(patsubst %.c,%,$(sources))

0 commit comments

Comments
 (0)