Skip to content

Commit 21ddb98

Browse files
committed
Makefile: Simplify it
Rather than doing fancy stuff with shell if/then just specify recipes for the few binaries that need different stuff. This should also fix problems on systems with strictly POSIX conforming /bin/sh's like on Debian. Signed-off-by: Andrew Clayton <[email protected]>
1 parent 19b2590 commit 21ddb98

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

Makefile

+18-5
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,33 @@ srctmp = $(wildcard *.c)
2323
sources = $(filter-out common.c,$(srctmp))
2424
elfs = $(patsubst %.c,%,$(sources))
2525

26-
.ONESHELL:
26+
v = @
27+
ifeq ($V,1)
28+
v =
29+
endif
2730

2831
.PHONY: all
2932
all: common.o $(elfs)
3033

3134
common.o: common.c common.h
3235
@echo " CC $@"
33-
$(CC) $(CFLAGS) -c $<
36+
$(v)$(CC) $(CFLAGS) -c $<
37+
38+
gen-ula: gen-ula.c
39+
@echo " CCLNK $@"
40+
$(v)$(CC) $(CFLAGS) -o $@ $< -luuid -lmhash
41+
42+
ipv6-gen-slaac: ipv6-gen-slaac.c common.o
43+
@echo " CCLNK $@"
44+
$(v)$(CC) $(CFLAGS) -o $@ $< common.o
45+
46+
mac-to-eui64: mac-to-eui64.c common.o
47+
@echo " CCLNK $@"
48+
$(v)$(CC) $(CFLAGS) -o $@ $< common.o
3449

3550
%: %.c
3651
@echo " CCLNK $@"
37-
@if [ "$@" == "gen-ula" ]; then LIBS="$(LIBS_FOR_GEN_ULA)"; else LIBS=; fi
38-
@if [ "$@" == "ipv6-gen-slaac" ] || [ "$@" == "mac-to-eui64" ]; then OBJS="common.o"; else OBJS=; fi
39-
$(CC) $(CFLAGS) -o $@ $$OBJS $$LIBS $<
52+
$(v)$(CC) $(CFLAGS) -o $@ $<
4053

4154
clean:
4255
rm -f $(elfs) *.o

0 commit comments

Comments
 (0)