-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakeconfig
More file actions
76 lines (66 loc) · 2.9 KB
/
Makeconfig
File metadata and controls
76 lines (66 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Determine properties of the system and write a config.h.
#
# Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
#
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.
#
# Licensed under the GNU General Public License (GPL), version 2. See the file
# COPYING in the top level of this tree.
# The configuration header file.
CONFIG_H = $(objdir)/config.h
# Generate a makefile rule to check for the presence of SYMBOL
# in LIBRARY and emit an appropriate header file fragment into
# a file under $(objdir)/.config.
#
# The first argument must be suitable for a filename fragment,
# for a makefile rule name and for a #define.
#
# Syntax: $(call check-symbol,name,symbol,library)
define check-symbol-rule
$(objdir)/.config/config.$(1).h: $(objdir)/.config/.dir.stamp
if echo 'void $(2)(); int main(void) { $(2)(); }' | \
$(CC) $(CFLAGS) $(LDFLAGS) -o /dev/null -x c - -l$(3) >/dev/null 2>&1; then \
echo '#define HAVE_$(1) 1' > $(objdir)/.config/config.$(1).h; \
else \
echo '/* #undef HAVE_$(1) */' > $(objdir)/.config/config.$(1).h; \
fi
$(CONFIG_H): $(objdir)/.config/config.$(1).h
endef
# Generate a makefile rule to check for the presence of HEADER
# and emit an appropriate header file fragment into a file
# under $(objdir)/.config.
#
# The first argument must be suitable for a filename fragment,
# for a makefile rule name and for a #define.
#
# Syntax: $(call check-header-rule,name,header)
define check-header-rule
$(objdir)/.config/config.$(1).h: $(objdir)/.config/.dir.stamp
if echo '#include <$(2)>' | \
$(CC) $(CFLAGS) $(LDFLAGS) -c -o /dev/null -x c - >/dev/null 2>&1; then \
echo '#define HAVE_$(1)_H 1' > $(objdir)/.config/config.$(1).h; \
else \
echo '/* #undef HAVE_$(1)_H */' > $(objdir)/.config/config.$(1).h; \
fi
$(CONFIG_H): $(objdir)/.config/config.$(1).h
endef
$(objdir)/.config/config.bfd_section_size.h: $(objdir)/.config/.dir.stamp
if printf '#include <stdio.h>\n#include <bfd.h>\nint main (void) { asection *foo = NULL; printf ("%%li", bfd_section_size (foo)); }' | \
$(CC) $(CFLAGS) $(LDFLAGS) -c -o /dev/null -x c - >/dev/null 2>&1; then \
echo '#define HAVE_ONE_ARG_BFD_SECTION_SIZE 1' > $(objdir)/.config/config.bfd_section_size.h; \
else \
echo '/* #undef HAVE_ONE_ARG_BFD_SECTION_SIZE */' > $(objdir)/.config/config.bfd_section_size.h; \
fi
$(CONFIG_H): $(objdir)/.config/config.bfd_section_size.h
$(objdir)/.config/.dir.stamp:
mkdir -p $(objdir)/.config
touch $(objdir)/.config/.dir.stamp
$(CONFIG_H):
echo '/* This file is automatically generated. */' > $(objdir)/config.h
cat $(objdir)/.config/*.h >> $(objdir)/config.h 2>/dev/null || true
$(eval $(call check-symbol-rule,MMAP,mmap,c))
$(eval $(call check-symbol-rule,PREAD,pread,c))
$(eval $(call check-symbol-rule,BSEARCH_R,bsearch_r,c))
$(eval $(call check-header-rule,BYTESWAP,byteswap.h))
$(eval $(call check-header-rule,ENDIAN,endian.h))