Skip to content

Commit d3e40e3

Browse files
examples/Makefile: handle CFLAGS, LDFLAGS and CPPFLAGS correctly
1 parent 212b71b commit d3e40e3

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

examples/Makefile

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1-
CFLAGS=-Wall -Wextra -Werror -pedantic -std=c89
2-
LDFLAGS=-lsuinput
3-
PROGRAMS=keyboard mouse
1+
CFLAGS = -Wall -Wextra -Werror -pedantic -std=c89
2+
CFLAGS_ALL = $(CFLAGS)
3+
4+
LDFLAGS =
5+
LDFLAGS_ALL = $(LDFLAGS) -lsuinput
6+
7+
CPPFLAGS =
8+
CPPFLAGS_ALL = $(CPPFLAGS)
9+
10+
PROGRAMS = keyboard mouse
411

512
.PHONY: all clean
613

714
all: $(PROGRAMS)
815

9-
%: %.c
10-
gcc -o$@ $(CFLAGS) $^ $(LDFLAGS)
16+
%.o : %.c
17+
$(CC) $(CPPFLAGS_ALL) $(CFLAGS_ALL) -c -o $@ $<
18+
19+
$(PROGRAMS) : % : %.o
20+
$(CC) $(LDFLAGS_ALL) $(CFLAGS_ALL) -o $@ $<
1121

1222
clean:
1323
rm -f $(PROGRAMS)
24+
rm -f *.o

0 commit comments

Comments
 (0)