1 # Common definitions and functions. 2 # 3 # Copyright (C) 2020, 2022 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 # Functions to generate filenames for individual interfaces. 23 24 export_includes = $(patsubst %,$(IDL_EXPORT_DIR)/%,$(1)) 25 26 interfaces_to_idl = $(patsubst %,$(IDL_DIR)/%.idl,$(1)) 27 28 interfaces_to_client_c = \ 29 $(patsubst %,%_client.c,$(1)) \ 30 31 interfaces_to_client_c_h = \ 32 $(patsubst %,%_client.c,$(1)) \ 33 $(patsubst %,%_client.h,$(1)) \ 34 35 interfaces_to_client_cc = \ 36 $(patsubst %,%_client.cc,$(1)) \ 37 38 interfaces_to_client_cc_h = \ 39 $(patsubst %,%_client.cc,$(1)) \ 40 $(patsubst %,%_client.h,$(1)) \ 41 42 interfaces_to_interface_h = \ 43 $(patsubst %,%_interface.h,$(1)) \ 44 45 interfaces_to_interfaces_h = \ 46 $(patsubst %,%_interface.h,$(1)) \ 47 $(patsubst %,%_interfaces.h,$(1)) \ 48 49 _interfaces_to_server_c = \ 50 $(patsubst %,%_server.c,$(1)) \ 51 52 _interfaces_to_server_c_h = \ 53 $(patsubst %,%_server.c,$(1)) \ 54 $(patsubst %,%_server.h,$(1)) \ 55 56 _interfaces_to_server_cc = \ 57 $(patsubst %,%_server.cc,$(1)) \ 58 59 _interfaces_to_server_cc_h = \ 60 $(patsubst %,%_server.cc,$(1)) \ 61 $(patsubst %,%_server.h,$(1)) \ 62 63 # For each interface file basename, obtain basenames of all other files needed 64 # to complete the interfaces in the given file. The resulting list is sorted and 65 # without duplicate words. This function is used to support the indication of 66 # compound interfaces, providing the constituent interfaces. 67 68 needed_interfaces = $(sort $(foreach BASENAME,$(call interfaces_to_idl,$(1)),$(shell $(IDL_PROG) -f $(BASENAME)))) 69 70 # File generation for all needed interfaces. 71 72 interfaces_to_server_c = $(call _interfaces_to_server_c,$(call needed_interfaces,$(1))) 73 interfaces_to_server_c_h = $(call _interfaces_to_server_c_h,$(call needed_interfaces,$(1))) 74 interfaces_to_server_cc = $(call _interfaces_to_server_cc,$(call needed_interfaces,$(1))) 75 interfaces_to_server_cc_h = $(call _interfaces_to_server_cc_h,$(call needed_interfaces,$(1))) 76 77 # Generation of exported interface header file locations. 78 79 exported_interfaces_h = $(foreach INTERFACE,$(call interfaces_to_interface_h,$(1)),$(call export_includes,$(INTERFACE)))