File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ GENHTML ?= genhtml
30
30
CXXFLAGS += -std=gnu++17
31
31
CFLAGS += -std=gnu17
32
32
33
+ # 32-bit mode is prefered, but not required
33
34
ifeq ($(FORCE32 ) ,1)
34
35
SIZEOFLONG = $(shell echo 'int main() {return sizeof(long);}'|$(CXX ) -m32 -x c++ - -o sizeoflong 2>/dev/null && ./sizeoflong; echo $$? ; rm -f sizeoflong;)
35
36
ifneq ($(SIZEOFLONG ) ,4)
50
51
OUTPUT_BINARY := $(BINDIR ) /host_tests
51
52
LCOV_DIRECTORY := $(BINDIR ) /../lcov
52
53
54
+ # Core files sometimes override libc functions, check when necessary to hide them
55
+ # TODO proper configure script / other build system?
56
+ ifeq (,$(wildcard ./.have_strlcpy) )
57
+ $(shell echo -e '# include <cstring>\nint main(){char a[4]; char b[4]; strlcpy(&a[0], &b[0], sizeof(a)); return 0;}' | \
58
+ $(CXX) -x c++ - -o .have_strlcpy 2>/dev/null || { echo -e '#!/bin/sh\nexit 1' > .have_strlcpy ; chmod +x .have_strlcpy; })
59
+ endif
60
+
61
+ $(shell ./.have_strlcpy)
62
+ ifeq ($(.SHELLSTATUS ) , 0)
63
+ FLAGS += -DHAVE_STRLCPY
64
+ endif
65
+
66
+ ifeq (,$(wildcard ./.have_strlcat) )
67
+ $(shell echo -e '# include <cstring>\nint main(){char a[4]; strlcat(&a[0], "test", sizeof(a)); return 0;}' | \
68
+ $(CXX) -x c++ - -o .have_strlcat 2>/dev/null || { echo -e '#!/bin/sh\nexit 1' > .have_strlcat ; chmod +x .have_strlcat; })
69
+ endif
70
+
71
+ $(shell ./.have_strlcat)
72
+ ifeq ($(.SHELLSTATUS ) , 0)
73
+ FLAGS += -DHAVE_STRLCAT
74
+ endif
75
+
76
+ # Hide full build commands by default
53
77
ifeq ($(V ) , 0)
54
78
VERBC = @echo "C $@ ";
55
79
VERBCXX = @echo "C++ $@ ";
Original file line number Diff line number Diff line change 65
65
extern " C"
66
66
{
67
67
#endif
68
- char * utoa (unsigned value, char * result, int base);
69
- char * itoa (int value, char * result, int base);
68
+ char * utoa (unsigned value, char * result, int base);
69
+ char * itoa (int value, char * result, int base);
70
+ #ifndef HAVE_STRLCAT
70
71
size_t strlcat (char * dst, const char * src, size_t size);
72
+ #endif
73
+ #ifndef HAVE_STRLCPY
71
74
size_t strlcpy (char * dst, const char * src, size_t size);
75
+ #endif
72
76
#ifdef __cplusplus
73
77
}
74
78
#endif
You can’t perform that action at this time.
0 commit comments