Skip to content

Commit 353fca1

Browse files
committed
Honor external toolchain environment variables
If the compiler/CFLAGS were set in the environment, do not override them. Signed-off-by: Vincent Palatin <[email protected]>
1 parent 37f5581 commit 353fca1

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

u2f-tests/HID/Makefile

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,58 +6,61 @@
66

77
all: list HIDTest U2FTest
88

9+
CC ?= gcc
10+
CXX ?= g++
11+
912
UNAME := $(shell uname)
1013

1114
ifeq ($(UNAME), Linux)
1215

13-
CFLAGS=-Ihidapi/hidapi -D__OS_LINUX -Icore/include
14-
LDFLAGS=-lrt -ludev
16+
CPPFLAGS+=-Ihidapi/hidapi -D__OS_LINUX -Icore/include
17+
LDLIBS+=-lrt -ludev
1518
HIDAPI=hid.o
1619
hid.o: hidapi/linux/hid.c
17-
gcc -c $(CFLAGS) -o hid.o hidapi/linux/hid.c
20+
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o hid.o hidapi/linux/hid.c
1821

1922
endif # Linux
2023

2124
ifeq ($(UNAME), Darwin)
2225

23-
CFLAGS=-Ihidapi/hidapi -Icore/include -D__OS_MAC
24-
LDFLAGS=-framework IOKit -framework CoreFoundation
26+
CPPFLAGS+=-Ihidapi/hidapi -Icore/include -D__OS_MAC
27+
LDLIBS+=-framework IOKit -framework CoreFoundation
2528
HIDAPI=hid.o
2629
hid.o: hidapi/mac/hid.c
27-
gcc -c $(CFLAGS) -o hid.o hidapi/mac/hid.c
30+
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o hid.o hidapi/mac/hid.c
2831

2932
endif # Darwin
3033

3134
# Crypto code.
3235
LIBMINCRYPT=dsa_sig.o p256.o p256_ec.o p256_ecdsa.o sha256.o
3336

3437
dsa_sig.o: core/libmincrypt/dsa_sig.c
35-
gcc -c $(CFLAGS) -Wall $^
38+
$(CC) -c $(CPPFLAGS) $(CFLAGS) -Wall $^
3639

3740
p256.o: core/libmincrypt/p256.c
38-
gcc -c $(CFLAGS) -Wall $^
41+
$(CC) -c $(CPPFLAGS) $(CFLAGS) -Wall $^
3942

4043
p256_ec.o: core/libmincrypt/p256_ec.c
41-
gcc -c $(CFLAGS) -Wall $^
44+
$(CC) -c $(CPPFLAGS) $(CFLAGS) -Wall $^
4245

4346
p256_ecdsa.o: core/libmincrypt/p256_ecdsa.c
44-
gcc -c $(CFLAGS) -Wall $^
47+
$(CC) -c $(CPPFLAGS) $(CFLAGS) -Wall $^
4548

4649
sha256.o: core/libmincrypt/sha256.c
47-
gcc -c $(CFLAGS) -Wall $^
50+
$(CC) -c $(CPPFLAGS) $(CFLAGS) -Wall $^
4851

4952
# utility tools.
5053
u2f_util.o: u2f_util.cc u2f_util.h u2f.h u2f_hid.h
51-
g++ -c $(CFLAGS) -Wall -o u2f_util.o u2f_util.cc
54+
$(CXX) -c $(CPPFLAGS) $(CFLAGS) -Wall -o u2f_util.o u2f_util.cc
5255

5356
# simple hidapi tool to list devices to see paths.
5457
list: list.c $(HIDAPI)
55-
gcc $(CFLAGS) -Wall -o $@ $^ $(LDFLAGS)
58+
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -Wall -o $@ $^ $(LDLIBS)
5659

5760
# Low-level HID framing test.
5861
HIDTest: HIDTest.cc u2f_util.o $(HIDAPI)
59-
g++ $(CFLAGS) -Wall -o $@ $^ $(LDFLAGS)
62+
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -Wall -o $@ $^ $(LDLIBS)
6063

6164
# U2F messaging crypto test.
6265
U2FTest: U2FTest.cc u2f_util.o $(HIDAPI) $(LIBMINCRYPT)
63-
g++ $(CFLAGS) -Wall -o $@ $^ $(LDFLAGS)
66+
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -Wall -o $@ $^ $(LDLIBS)

0 commit comments

Comments
 (0)