1PKGDIR ?= 	..
2L4DIR  ?= 	$(PKGDIR)/../../..
3
4STDCXX_PKG_DIR ?= $(PKGDIR_ABS)/../libstdc++-v3
5
6CONTRIB_HEADERS = y
7PKGNAME         = libstdc++-v3
8INCSRC_DIR      = $(STDCXX_CONTRIB_DIR)/include
9TARGET          = $(shell (cd $(INCSRC_DIR) && find . -type f -not -name 'Make*' -print))
10
11LIBSUPC_H            := exception new typeinfo cxxabi.h \
12                        bits/exception_defines.h bits/cxxabi_forced.h \
13                        cxxabi_forced.h bits/hash_bytes.h \
14                        bits/atomic_lockfree_defines.h
15LIBSUPC_H-7_PLUS-y   += bits/exception.h bits/cxxabi_init_exception.h
16LIBSUPC_H-10_PLUS-y  += compare
17
18ALLOCATOR_H        := config/allocator/new_allocator_base.h
19CLOCALE_H          := config/locale/generic/c_locale.h
20ATOMIC_WORD_H      := atomic_word.h
21CPU_DEFINES_H      := cpu_defines.h
22TIME_MEMBERS_H     := config/locale/generic/time_members.h
23MESSAGES_MEMBERS_H := config/locale/generic/messages_members.h
24BASIC_FILE_H       := config/io/basic_file_stdio.h
25CSTDIO_H           := config/io/c_io_stdio.h
26
27include $(L4DIR)/mk/include.mk
28include $(STDCXX_PKG_DIR)/contrib.inc
29
30LIBSUPC_H           += initializer_list bits/exception_ptr.h bits/nested_exception.h
31
32STDCXX_CSTD_HEADERS := \
33  cassert cctype cerrno cfloat ciso646 climits clocale cmath csetjmp csignal \
34  cstdarg cstddef cstdio cstdlib cstring ctime cwchar cwctype cstdint
35
36
37STDCXX_CSTD_HEADERS += $(patsubst std_%.h,%,$(notdir $(wildcard $(INCSRC_DIR)/std/*)))
38
39STDCXX_STD_DIRS     := std c_global c_std tr1
40
41
42INSTALL_INCDIR_X = $(INSTALLDIR_LOCAL)/$(INSTALL_INC_PREFIX)
43SRCDIR_X         = $(STDCXX_CONTRIB_DIR)
44
45CTYPE_HEADERS := $(filter-out %/os_defines.h,$(wildcard $(SRCDIR_X)/config/os/generic/*))
46
47install_header_x = $(MKDIR) $(dir $(INSTALL_INCDIR_X)/$(strip $(2))) && $(LN) -sf $(call absfilename,$(strip $(1)) $(INSTALL_INCDIR_X)/$(strip $(2)))
48install_header   = $(MKDIR) $(dir $(INSTALL_INCDIR_X)/$(strip $(2))) && $(LN) -sf $(SRCDIR_X)/$(strip $(1)) $(INSTALL_INCDIR_X)/$(strip $(2))
49
50install_config_header = $(call install_header, $(1), bits/$(strip $(2)))
51
52cpu_header = $(word 1,$(wildcard $(SRCDIR_X)/$(CPU_H_arch)/$(strip $(1)) $(SRCDIR_X)/$(CPU_H_generic)/$(strip $(1))))
53
54install_cpu_header = $(VERBOSE)$(if $(call cpu_header,$(1)),$(LN) -sf $(call cpu_header,$(1)) $(INSTALL_INCDIR_X)/bits/$(strip $(notdir $(1))))
55
56LIBSUPC_H += $(foreach V,$(STDCXX_AVAILABLE_VERSIONS),$(LIBSUPC_H-$(V)_PLUS-$(STDCXX_CONTRIB_VERSION_$(V)_PLUS)))
57
58LIBSUPC_HI = $(addprefix $(INSTALL_INCDIR_X)/, $(LIBSUPC_H))
59STDCXX_CSTD_HEADERS_ABS = $(addprefix $(INSTALL_INCDIR_X)/, $(STDCXX_CSTD_HEADERS))
60
61
62std_header_list = $(strip $(1)) std_$(strip $(1)).h
63
64choose_std_header = $(word 1, $(wildcard $(foreach DIR,$(STDCXX_STD_DIRS),$(addprefix $(INCSRC_DIR)/$(DIR)/, $(call std_header_list, $(1))))))
65
66$(STDCXX_CSTD_HEADERS_ABS): %: $(BID_ROOT_CONF) | $(INSTALL_INCDIR_X)
67	@$(INSTALL_LINK_MESSAGE) $@
68	$(VERBOSE)$(LN) -sf $(call choose_std_header,$(notdir $@)) $@
69
70$(LIBSUPC_HI): %: $(BID_ROOT_CONF) | $(INSTALL_INCDIR_X)
71	@$(INSTALL_LINK_MESSAGE) $@
72	$(VERBOSE)$(call install_header, libsupc++/$(notdir $@), $(patsubst $(INSTALL_INCDIR_X)/%,%,$@))
73
74$(INSTALL_INCDIR_X):
75	@$(INSTALL_LINK_MESSAGE) $(INSTALL_INCDIR_X)
76	$(VERBOSE)$(INSTALL) -d $(INSTALL_INCDIR_X)
77
78all:: $(LIBSUPC_HI) $(STDCXX_CSTD_HEADERS_ABS) $(BID_ROOT_CONF) | $(INSTALL_INCDIR_X)
79	@$(INSTALL_LINK_MESSAGE)
80	$(VERBOSE)$(call install_config_header, $(ALLOCATOR_H),     c++allocator.h)
81	$(VERBOSE)$(call install_config_header, $(CLOCALE_H),       c++locale.h)
82	$(call install_cpu_header, atomic_word.h)
83	$(call install_cpu_header, cpu_defines.h)
84	$(call install_cpu_header, cxxabi_tweaks.h)
85	$(call install_cpu_header, opt/bits/opt_random.h)
86	$(VERBOSE)$(foreach H,$(CTYPE_HEADERS), $(call install_header_x, $(H), bits/$(notdir $(H))); )
87	$(VERBOSE)$(call install_config_header, $(TIME_MEMBERS_H),  time_members.h)
88	$(VERBOSE)$(call install_config_header, $(MESSAGES_MEMBERS_H),  messages_members.h)
89	$(VERBOSE)$(call install_config_header, $(BASIC_FILE_H), basic_file.h)
90	$(VERBOSE)$(call install_config_header, $(CSTDIO_H), c++io.h)
91