1 # Common definitions and functions. 2 # 3 # Copyright (C) 2020, 2022, 2023 Paul Boddie <paul@boddie.org.uk> 4 # 5 # This program is free software; you can redistribute it and/or 6 # modify it under the terms of the GNU General Public License as 7 # published by the Free Software Foundation; either version 2 of 8 # the License, or (at your option) any later version. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program; if not, write to the Free Software 17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 # Boston, MA 02110-1301, USA 19 20 IDL_PROG = $(L4DIR)/idl4re/idl 21 22 # Alignment could be overridden by testing for a particular architecture. 23 # For example: 24 # 25 # ifeq ($(ARCH),x86) 26 # IDL_ARGS = -A 8 27 # else 28 # ... 29 # endif 30 31 IDL_ARGS = 32 33 # Functions to generate filenames for individual interfaces. 34 35 export_includes = $(patsubst %,$(IDL_EXPORT_DIR)/%,$(1)) 36 37 interfaces_to_idl = $(patsubst %,$(IDL_DIR)/%.idl,$(1)) 38 39 interfaces_to_client_c = \ 40 $(patsubst %,%_client.c,$(1)) \ 41 42 interfaces_to_client_c_h = \ 43 $(patsubst %,%_client.c,$(1)) \ 44 $(patsubst %,%_client.h,$(1)) \ 45 46 interfaces_to_client_cc = \ 47 $(patsubst %,%_client.cc,$(1)) \ 48 49 interfaces_to_client_cc_h = \ 50 $(patsubst %,%_client.cc,$(1)) \ 51 $(patsubst %,%_client.h,$(1)) \ 52 53 interfaces_to_interface_h = \ 54 $(patsubst %,%_interface.h,$(1)) \ 55 56 interfaces_to_interfaces_h = \ 57 $(patsubst %,%_interface.h,$(1)) \ 58 $(patsubst %,%_interfaces.h,$(1)) \ 59 60 _interfaces_to_server_c = \ 61 $(patsubst %,%_server.c,$(1)) \ 62 63 _interfaces_to_server_c_h = \ 64 $(patsubst %,%_server.c,$(1)) \ 65 $(patsubst %,%_server.h,$(1)) \ 66 67 _interfaces_to_server_cc = \ 68 $(patsubst %,%_server.cc,$(1)) \ 69 70 _interfaces_to_server_cc_h = \ 71 $(patsubst %,%_server.cc,$(1)) \ 72 $(patsubst %,%_server.h,$(1)) \ 73 74 # For each interface file basename, obtain basenames of all other files needed 75 # to complete the interfaces in the given file. The resulting list is sorted and 76 # without duplicate words. This function is used to support the indication of 77 # compound interfaces, providing the constituent interfaces. 78 79 needed_interfaces = $(sort $(foreach BASENAME,$(call interfaces_to_idl,$(1)),$(shell $(IDL_PROG) -f $(BASENAME)))) 80 81 # File generation for all needed interfaces. 82 83 interfaces_to_server_c = $(call _interfaces_to_server_c,$(call needed_interfaces,$(1))) 84 interfaces_to_server_c_h = $(call _interfaces_to_server_c_h,$(call needed_interfaces,$(1))) 85 interfaces_to_server_cc = $(call _interfaces_to_server_cc,$(call needed_interfaces,$(1))) 86 interfaces_to_server_cc_h = $(call _interfaces_to_server_cc_h,$(call needed_interfaces,$(1))) 87 88 # Generation of exported interface header file locations. 89 90 exported_interfaces_h = $(foreach INTERFACE,$(call interfaces_to_interface_h,$(1)),$(call export_includes,$(INTERFACE)))