]> rtime.felk.cvut.cz Git - l4.git/blob - l4/mk/idl.mk
update
[l4.git] / l4 / mk / idl.mk
1 # -*- Makefile -*-
2 #
3 # DROPS (Dresden Realtime OPerating System) Component
4 #
5 # Makefile-Template for idl directories
6 #
7 # install.inc is used, see there for further documentation
8 #               - from install.inc, we use the feature to install files
9 #                 to the local install directory on 'all' target.
10 #                 Therefore, we set INSTALLDIR_LOCAL and INSTALLFILE_LOCAL.
11 #                 Note that we changed INSTALLDIR_IDL_LOCAL AND INSTALLDIR_IDL
12 # binary.inc is used, see there for further documentation
13
14 ifeq ($(origin _L4DIR_MK_IDL_MK),undefined)
15 _L4DIR_MK_IDL_MK=y
16
17 ROLE = idl.mk
18
19 DICE_REQ := --require="3.2.0"
20
21 # define LOCAL_INSTALLDIR prior to including install.inc, where the install-
22 # rules are defined. Same for INSTALLDIR.
23 INSTALLDIR_IDL          ?= $(DROPS_STDDIR)/include/$(ARCH)/$(L4API)/$(INSTALL_INC_PREFIX)
24 INSTALLDIR_IDL_LOCAL    ?= $(OBJ_BASE)/include/$(ARCH)/$(L4API)/$(INSTALL_INC_PREFIX)
25 INSTALLFILE_IDL         ?= $(INSTALL) -m 644 $(1) $(2)
26 INSTALLFILE_IDL_LOCAL   ?= $(LN) -sf $(call absfilename,$(1)) $(2)
27
28 INSTALLFILE             = $(INSTALLFILE_IDL)
29 INSTALLDIR              = $(INSTALLDIR_IDL)
30 INSTALLFILE_LOCAL       = $(INSTALLFILE_IDL_LOCAL)
31 INSTALLDIR_LOCAL        = $(INSTALLDIR_IDL_LOCAL)
32
33 INSTALL_INC_PREFIX     ?= l4/$(PKGNAME)
34
35 # our default MODE is 'static'
36 MODE                    ?= static
37
38 IDL_EXPORT_STUB ?= %
39 IDL_EXPORT_IDL  ?= %
40
41 include $(L4DIR)/mk/Makeconf
42 include $(L4DIR)/mk/binary.inc
43 $(GENERAL_D_LOC): $(L4DIR)/mk/idl.mk
44
45 ifneq ($(SYSTEM),) # if we have a system, really build
46 #######################################################
47 #
48 # SYSTEM valid, we are in an OBJ-<xxx> system subdir
49 #
50 #######################################################
51
52 IDL_EXPORT_STUB ?= %
53 IDL_TYPE        ?= dice
54
55 # C++ specific rules
56 IDL_C           = c
57 IDL_H           = h
58 IDL_CPP         = $(CC)
59 ifneq (,$(findstring BmCPP,$(IDL_FLAGS)))
60 IDL_C           = cc
61 IDL_H           = hh
62 IDL_CPP         = $(CXX)
63 else
64 ifneq (,$(findstring Bmcpp,$(IDL_FLAGS)))
65 IDL_C           = cc
66 IDL_H           = hh
67 IDL_CPP         = $(CXX)
68 endif
69 endif
70
71 IDL_DEP =               $(addprefix .,$(addsuffix .d,$(notdir $(IDL))))
72 IDL_SKELETON_C =        $(IDL:.idl=-server.$(IDL_C))
73 IDL_SKELETON_H =        $(IDL_SKELETON_C:.$(IDL_C)=.$(IDL_H))
74 IDL_STUB_C =            $(IDL:.idl=-client.$(IDL_C))
75 IDL_STUB_H =            $(IDL_STUB_C:.$(IDL_C)=.$(IDL_H))
76 IDL_OPCODE_H =          $(IDL:.idl=-sys.$(IDL_H))
77
78 IDL_FILES = $(IDL_SKELETON_C) $(IDL_SKELETON_H) $(IDL_STUB_C) $(IDL_STUB_H) \
79             $(IDL_OPCODE_H)
80
81 # Makro that expands to the list of generated files
82 # arg1 - name of the idl file. Path and extension will be stripped
83 IDL_FILES_EXPAND =      $(addprefix $(notdir $(basename $(1))),-server.$(IDL_C) -server.$(IDL_H) -client.$(IDL_C) -client.$(IDL_H) -sys.$(IDL_H))
84
85 INSTALL_TARGET = $(patsubst %.idl,%-sys.$(IDL_H),               \
86                    $(filter $(IDL_EXPORT_SKELETON) $(IDL_EXPORT_STUB),$(IDL)))\
87                  $(patsubst %.idl,%-server.$(IDL_H),            \
88                    $(filter $(IDL_EXPORT_SKELETON),$(IDL)))             \
89                  $(patsubst %.idl,%-client.$(IDL_H),            \
90                    $(filter $(IDL_EXPORT_STUB), $(IDL)))
91
92 all:: $(IDL_FILES)
93 .DELETE_ON_ERROR:
94
95 # the dependencies for the generated files
96 DEPS            += $(IDL_DEP)
97
98 ifneq (,$(filter-out corba dice, $(IDL_TYPE)))
99 $(error IDL_TYPE is neither <dice> nor <corba>)
100 endif
101
102 # the IDL file is found one directory up
103 vpath %.idl $(SRC_DIR)
104
105 # DICE mode
106 IDL_FLAGS       += $(addprefix -P,$(CPPFLAGS))
107 IDL_FLAGS       += $(IDL_FLAGS_$(<F))
108
109 ifeq ($(L4API),l4f)
110 IDL_FLAGS       += -Bifiasco
111 endif
112
113 ifeq ($(L4API),l4v4)
114 IDL_FLAGS       += -Biv4
115 endif
116
117 ifeq ($(L4API),l4x2)
118 IDL_FLAGS       += -Bix2
119 endif
120
121 ifeq ($(L4API),linux)
122 IDL_FLAGS       += -Bisock
123 endif
124
125 ifeq ($(L4API),l4secv2emu)
126 IDL_FLAGS       += -fforce-c-bindings -P-DL4API_l4f
127 endif
128
129 ifeq ($(ARCH),x86)
130 IDL_FLAGS       += -Bpia32
131 endif
132
133 ifeq ($(ARCH),arm)
134 IDL_FLAGS       += -Bparm
135 endif
136
137 ifeq ($(ARCH),amd64)
138 IDL_FLAGS       += -Bpamd64
139 endif
140
141 ifeq ($(IDL_TYPE),corba)
142 IDL_FLAGS       += --x=corba
143 endif
144
145 # We don't use gendep for generating the dependencies because gendep can only
146 # catch open() calls from _one_ applications. Here two applications, dice and
147 # the preprocessor perform open.
148 %-server.$(IDL_C) %-server.$(IDL_H) %-client.$(IDL_C) %-client.$(IDL_H) %-sys.$(IDL_H): %.idl .general.d
149         @$(GEN_MESSAGE)
150         $(VERBOSE)CC="$(IDL_CPP)" $(DICE) $(DICE_REQ) $(IDL_FLAGS) -MD $<
151         $(VERBOSE)mv $*.d .$(<F).d
152         $(DEPEND_VERBOSE)$(ECHO) "$(call IDL_FILES_EXPAND,$<): $(DICE) $<" >>.$(<F).d
153         $(DEPEND_VERBOSE)$(ECHO) "$(DICE) $<:" >>.$(<F).d
154
155
156 clean cleanall::
157         $(VERBOSE)$(RM) $(wildcard $(addprefix $(INSTALLDIR_LOCAL)/, $(IDL_FILES)))
158         $(VERBOSE)$(RM) $(wildcard $(IDL_FILES))
159
160 # include install.inc to define install rules
161 include $(L4DIR)/mk/install.inc
162
163 else
164 #####################################################
165 #
166 # No SYSTEM defined, we are in the idl directory
167 #
168 #####################################################
169
170 # we install the IDL-files specified in IDL_EXPORT_IDL
171 INSTALL_TARGET = $(filter $(IDL_EXPORT_IDL), $(IDL))
172
173 # include install.inc to define install rules
174 include $(L4DIR)/mk/install.inc
175
176 # install idl-files before going down to subdirs
177 $(foreach arch,$(TARGET_SYSTEMS), $(OBJ_DIR)/OBJ-$(arch)): $(addprefix $(INSTALLDIR_LOCAL)/,$(INSTALL_TARGET))
178
179 endif   # architecture is defined, really build
180 #####################################################
181 #
182 # Common part
183 #
184 #####################################################
185
186 -include $(DEPSVAR)
187 .PHONY: all clean cleanall config help install oldconfig txtconfig
188
189 help::
190         @echo "  all            - generate .c and .h from idl files and install locally"
191 ifneq ($(SYSTEM),)
192         @echo "                   to $(INSTALLDIR_LOCAL)"
193 endif
194         @echo "  scrub          - delete backup and temporary files"
195         @echo "  clean          - delete generated source files"
196         @echo "  cleanall       - delete all generated, backup and temporary files"
197         @echo "  help           - this help"
198         @echo
199         @echo "  idls are: $(IDL)"
200
201
202 endif   # _L4DIR_MK_IDL_MK undefined