]> rtime.felk.cvut.cz Git - omk.git/blob - snippets/vxworks
VxWorks rules are working now.
[omk.git] / snippets / vxworks
1 #                   Version for vxWorks builds.
2 #
3 #
4 # input variables
5 # lib_LIBRARIES    .. list of the user-space libraries
6 # include_HEADERS  .. list of the user-space public header files
7 # nobase_include_HEADERS .. public headers copied even with directory part
8 # renamed_include_HEADERS .. public headers copied to the different target name
9 # bin_PROGRAMS     .. list of the require binary programs
10 # utils_PROGRAMS   .. list of the development utility programs
11 # xxx_SOURCES      .. list of specific target sources
12 # INCLUDES         .. additional include directories and defines for user-space
13
14 # Some support to serialize some targets for parallel make
15 ifneq ($(OMK_SERIALIZE_INCLUDED),y)
16 include-pass: $(check-dir)
17 library-pass: include-pass
18 binary-pass: library-pass
19 kernel-lib-pass: include-pass
20 kernel-mod-pass: kernel-lib-pass
21 kernel-modpost-pass: kernel-mod-pass
22 kernel-pass: kernel-mod-pass kernel-modpost-pass
23
24 OMK_SERIALIZE_INCLUDED = y
25 endif
26
27
28 # Export some variables to VxWorks makefiles
29 CPPFLAGS  += -I $(USER_INCLUDE_DIR)
30
31 ADDED_CFLAGS = $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
32         $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -DOMK_FOR_VXWORKS -DOMK_FOR_USER
33
34 ADDED_C++FLAGS = $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
35         $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -DOMK_FOR_VXWORKS -DOMK_FOR_USER
36
37 export ADDED_CFLAGS ADDED_C++FLAGS
38
39
40 USER_SOURCES2OBJS = .o/.c .o/.cc .o/.cxx .o/.o
41
42 # Syntax: $(call PROGRAM_template,<executable-name>,<dir>,<link-variant>)
43 define PROGRAM_template
44
45 USER_IDLS  += $$($(1)_SERVER_IDL) $$($(1)_CLIENT_IDL) $$($(1)_IDL)
46 $(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-skels.c))
47 $(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-common.c))
48 $(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_CLIENT_IDL:%.idl=%-stubs.c))
49 $(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_CLIENT_IDL:%.idl=%-common.c))
50 $(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_IDL:%.idl=%.c))
51 USER_GEN_SOURCES += $$($(1)_GEN_SOURCES)
52
53 $(foreach x, $(USER_SOURCES2OBJS),
54 $(1)_OBJS += $$(patsubst %$(notdir $(x)),%$(dir $(x)),$$(filter %$(notdir $(x)),\
55                 $$($(1)_SOURCES) $$($(1)_GEN_SOURCES)))
56 )
57 $(1)_OBJS := $$(sort $$($(1)_OBJS:%/=%))
58
59 USER_OBJS  += $$($(1)_OBJS)
60 USER_SOURCES += $$($(1)_SOURCES)
61
62 # I hope dependedcies are solved in vxWorks makefiles
63 .PHONY: $(2)/$(1).vxe
64 $(2)/$(1).vxe:
65         @$(QUIET_CMD_ECHO) "  LINK    $$@"
66 # In rules.rtp (on line 265), dep generation depends on Makefile so we must create one
67 #       @[ ! -f Makefile ] && touch Makefile 
68         @touch Makefile
69         @echo 'EXE = $(1).vxe' > Makefile.vxe.$(1); \
70         echo 'OBJS = $$($(1)_OBJS)' >> Makefile.vxe.$(1); \
71         echo 'VXE_DIR = $(2)' >> Makefile.vxe.$(1); \
72         echo 'OBJ_DIR = $(USER_OBJS_DIR)' >> Makefile.vxe.$(1); \
73         echo 'LIB_ROOT = $(USER_LIB_DIR)' >> Makefile.vxe.$(1); \
74         echo 'OMK_LIB_PATH = $$$$(LIB_ROOT)/$$$$(VX_CPU_FAMILY)/$$$$(CPU)/$$$$(TOOL_COMMON_DIR)$$$$(LIB_DIR_TAG)/' >> Makefile.vxe.$(1); \
75         echo 'ADDED_LIBS = -L$$$$(OMK_LIB_PATH) $(lib_LOADLIBES:%=-l%) $$($(1)_LIBS:%=-l%)' >> Makefile.vxe.$(1); \
76         echo 'VPATH = $(SOURCES_DIR)' >> Makefile.vxe.$(1); \
77         echo 'include $$$$(WIND_USR)/make/rules.rtp' >> Makefile.vxe.$(1); \
78         $(WRENV) -p $(WRPACKAGE) $(MAKE)  CPU=$(CPU) TOOL=$(TOOL) -f Makefile.vxe.$(1)
79 #       echo 'ADDED_C++FLAGS += -L$(USER_LIB_DIR)' >> Makefile.vxe.$(1); \
80 #       echo 'ADDED_CFLAGS += -L$(USER_LIB_DIR)' >> Makefile.vxe.$(1); \
81 #       $(Q) $$(shell if [ -z "$$(filter %.cc,$$($(1)_SOURCES:%.cxx=%.cc))" ] ; then echo $$(CC) ; else echo $$(CXX) ; fi) \
82 #         $$($(1)_OBJS) $$($(1)_LIBS:%=-l%) $$(LOADLIBES) $$(LDFLAGS) -Wl,-Map,$(USER_OBJS_DIR)/$(1).exe.map -o $(2)/$(1)
83 #       @echo "$(2)/$(1): \\" >$(USER_OBJS_DIR)/$(1).exe.d
84 #       @sed -n -e 's/^LOAD \(.*\)$$$$/  \1  \\/p' $(USER_OBJS_DIR)/$(1).exe.map  >>$(USER_OBJS_DIR)/$(1).exe.d
85 #       @echo >>$(USER_OBJS_DIR)/$(1).exe.d
86 endef
87
88
89 # Syntax: $(call LIBRARY_template,<library-name>)
90 define LIBRARY_template
91
92 USER_IDLS  += $$($(1)_SERVER_IDL) $$($(1)_CLIENT_IDL) $$($(1)_IDL)
93 $(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-skels.c))
94 $(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-common.c))
95 $(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_CLIENT_IDL:%.idl=%-stubs.c))
96 $(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_CLIENT_IDL:%.idl=%-common.c))
97 $(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_IDL:%.idl=%.c))
98 USER_GEN_SOURCES += $$($(1)_GEN_SOURCES)
99
100 $(foreach x, $(USER_SOURCES2OBJS),
101 $(1)_OBJS += $$(patsubst %$(notdir $(x)),%$(dir $(x)),$$(filter %$(notdir $(x)),\
102                 $$($(1)_SOURCES) $$($(1)_GEN_SOURCES)))
103 )
104 $(1)_OBJS := $$(sort $$($(1)_OBJS:%/=%))
105 USER_OBJS  += $$($(1)_OBJS)
106 USER_SOURCES += $$($(1)_SOURCES)
107
108 # I hope dependedcies are solved in vxWorks makefiles
109 .PHONY: $(USER_LIB_DIR)/lib$(1).a
110 $(USER_LIB_DIR)/lib$(1).a: #$$($(1)_OBJS)
111         @$(QUIET_CMD_ECHO) "  LIB     $$@"
112         @echo 'LIB_BASE_NAME = $(1)' > Makefile.lib.$(1); \
113         echo 'OBJS = $$($(1)_OBJS)' >> Makefile.lib.$(1); \
114         echo 'OBJ_DIR = $(USER_OBJS_DIR)' >> Makefile.lib.$(1); \
115         echo 'LIB_ROOT = $(USER_LIB_DIR)' >> Makefile.lib.$(1); \
116         echo 'VPATH = $(SOURCES_DIR)' >> Makefile.lib.$(1); \
117         echo 'include $$$$(WIND_USR)/make/rules.library' >> Makefile.lib.$(1); 
118         $(WRENV) -p $(WRPACKAGE) $(MAKE) CPU=$(CPU) TOOL=$(TOOL) -f Makefile.lib.$(1)
119 endef
120
121
122
123
124 # Generate rules for compilation of programs and libraries
125
126 $(foreach prog,$(utils_PROGRAMS),$(eval $(call PROGRAM_template,$(prog),$(USER_UTILS_DIR))))
127
128 $(foreach prog,$(bin_PROGRAMS),$(eval $(call PROGRAM_template,$(prog),$(USER_BIN_DIR))))
129
130 $(foreach lib,$(lib_LIBRARIES),$(eval $(call LIBRARY_template,$(lib))))
131
132 $(foreach lib,$(shared_LIBRARIES),$(eval $(call SOLIB_template,$(lib))))
133
134 OTHER_PASSES = clean install include-pass
135 $(eval $(call omk_pass_template,$(OTHER_PASSES),$(USER_OBJS_DIR),,always))
136
137 include-pass-local:
138         $(call include-pass-template,$(USER_INCLUDE_DIR),include)
139
140 library-pass-local: $(addprefix $(USER_INCLUDE_DIR)/,$(cmetric_include_HEADERS)) \
141                     $(lib_LIBRARIES:%=$(USER_LIB_DIR)/lib%.a) $(shared_LIBRARIES:%=$(USER_LIB_DIR)/lib%.$(SOLIB_EXT))
142
143 binary-pass-local: $(bin_PROGRAMS:%=$(USER_BIN_DIR)/%.vxe) $(utils_PROGRAMS:%=$(USER_UTILS_DIR)/%.vxe)
144
145 clean-local:
146         @echo Cleaning in $(USER_OBJS_DIR)
147         @rm -f $(USER_OBJS_DIR)/*.o $(USER_OBJS_DIR)/*.lo \
148                $(USER_OBJS_DIR)/*.d \
149                $(USER_OBJS_DIR)/*.map \
150                $(LOCAL_CONFIG_H:%=$(USER_OBJS_DIR)/%)
151
152 $(eval $(call omk_pass_template, library-pass,$(USER_OBJS_DIR),USER_RULE_TEMPLATES=y,$(lib_LIBRARIES)$(shared_LIBRARIES)))
153 $(eval $(call omk_pass_template, binary-pass, $(USER_OBJS_DIR),USER_RULE_TEMPLATES=y,$(bin_PROGRAMS)$(utils_PROGRAMS)))
154
155
156 # Create directories only for the first time
157 ifndef CHECK_DIR_DONE
158 check-dir = check-dir
159 CHECK_DIR_DONE = y
160 endif
161 export CHECK_DIR_DONE
162
163 check-dir:
164         @$(call mkdir_def,$(USER_BUILD_DIR))
165         @$(call mkdir_def,$(USER_INCLUDE_DIR))
166         @$(call mkdir_def,$(USER_LIB_DIR))
167         @$(call mkdir_def,$(USER_BIN_DIR))
168         @$(call mkdir_def,$(USER_UTILS_DIR))
169
170
171 default: $(check-dir) include-pass library-pass binary-pass
172
173 # Local Variables:
174 # mode:makefile
175 # End: