Makefile.common 11.6 KB
Newer Older
1
2
3
4
# This is a part of PolyORB-HI-C distribution, a minimal
# middleware written for generated code from AADL models.
# You should use it with the Ocarina toolsuite.

jdelange's avatar
jdelange committed
5
GCC_GENERIC_CFLAGS=-Wall -g
6
7

all: build-node
8

9
10
11
include $(RUNTIME_PATH)/make/Makefile.$(TARGET)
-include ../../userdefined.mk

yoogx's avatar
yoogx committed
12
13
14
15
ifneq ($(USE_CPP_LINKER),)
LD=$(LD_CPP)
endif

yoogx's avatar
yoogx committed
16
build-node: compile-node
yoogx's avatar
yoogx committed
17

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
################################################################################
# Configuration
#
# In userdefined.mk, we defined the following variables
# - USER_CFLAGS   : Additional flags to compile .c files
# - USER_CPPFLAGS : Additional flags to compile .cpp files
# - USER_CC       : User overrides CC compiler
# - USER_CPP      : User ovverides CPP compiler

ifneq ($(USER_CC),)
CC=$(USER_CC)
endif

ifneq ($(USER_CPP),)
CPP=$(USER_CPP)
endif

ifneq ($(USER_LD),)
LD=$(USER_LD)
endif

jdelange's avatar
jdelange committed
39
CFLAGS=$(USER_CFLAGS) $(TARGET_CFLAGS)
40
CPPFLAGS=$(CFLAGS) $(USER_CPPFLAGS)
jdelange's avatar
jdelange committed
41
LDFLAGS=$(TARGET_LDFLAGS) $(USER_LDFLAGS)
42

43
44
45
ifdef USE_GPROF
CFLAGS+=-D__PO_HI_USE_GPROF -pg
endif
46
47
48
49
50

ifeq ($(ENABLE_DYNAMIC_CONFIGURATION),1)
CFLAGS+=-D__PO_HI_USE_DYNAMIC_CONFIGURATION
endif

51
52
53
54
ifeq ($(NEED_TRANSPORT),yes)
CFLAGS+=-D__PO_HI_USE_TRANSPORT
endif

yoogx's avatar
yoogx committed
55
56
INCLUDE=-I. -I"${shell $(CYGPATH_W) "${RUNTIME_PATH}/include"}"

57
ifdef TARGET_INCLUDE
yoogx's avatar
yoogx committed
58
INCLUDE += $(TARGET_INCLUDE)
59
60
endif

61
ifdef USER_SOURCES_DIRS
yoogx's avatar
yoogx committed
62
INCLUDE+=$(USER_SOURCES_DIRS)
63
64
endif

65
66
INCLUDE+=$(USER_INCLUDE)

67
68
69
70
71
72
ifndef $(TARGET_NAME)
TARGET_NAME=$(TARGET)
endif

INCLUDE+=-DTARGET=$(TARGET_NAME)

73
74
75
76
################################################################################
# Files to be compiled

ifeq ($(NEED_TRANSPORT), yes)
julien.delange's avatar
julien.delange committed
77
78
79
80
81
82
83
84
85
86
   PO_HI_OBJS =                              \
	po_hi_task.o                              \
	po_hi_time.o                              \
	po_hi_protected.o                         \
	po_hi_main.o                              \
	po_hi_messages.o                          \
	po_hi_marshallers.o                       \
	po_hi_giop.o                              \
	po_hi_utils.o                             \
	po_hi_types.o                             \
jdelange's avatar
jdelange committed
87
   po_hi_monitor.o                           \
jdelange's avatar
jdelange committed
88
   po_hi_storage.o                           \
julien.delange's avatar
julien.delange committed
89
90
	po_hi_gqueue.o                            \
   drivers/po_hi_driver_exarm.o              \
julien.delange's avatar
julien.delange committed
91
   drivers/po_hi_driver_keyboard.o           \
92
93
   drivers/po_hi_driver_exarm_ni_6071e_analog.o \
   drivers/po_hi_driver_exarm_ni_6071e_digital.o \
94
   drivers/po_hi_driver_usbbrick_spacewire.o \
julien.delange's avatar
julien.delange committed
95
   drivers/po_hi_driver_linux_serial.o       \
96
   drivers/po_hi_driver_leon_serial.o        \
jdelange's avatar
jdelange committed
97
   drivers/po_hi_driver_leon_eth.o           \
98
   drivers/po_hi_driver_serial_common.o      \
julien.delange's avatar
julien.delange committed
99
100
101
   drivers/po_hi_driver_sockets.o            \
   drivers/po_hi_driver_rtems_ne2000.o       \
   drivers/po_hi_driver_rasta_serial.o       \
102
   drivers/po_hi_driver_rasta_common.o       \
julien.delange's avatar
julien.delange committed
103
   drivers/po_hi_driver_rasta_1553.o         \
104
   drivers/po_hi_driver_xc4v_fpga.o          \
julien.delange's avatar
julien.delange committed
105
106
   drivers/po_hi_driver_rasta_1553_brmlib.o  \
   drivers/po_hi_driver_rasta_spacewire.o    \
107
108
109
	$(ACTUAL_TRANSPORT) \
	po_hi_transport.o $(TARGET_TRANSPORT_SOURCES)

julien.delange's avatar
julien.delange committed
110
111
112
113
114
115
   GENERATED_OBJS =                 \
	activity.o                       \
	subprograms.o                    \
	types.o                          \
	request.o                        \
	marshallers.o                    \
116
	deployment.o                     \
julien.delange's avatar
julien.delange committed
117
	naming.o                         \
118
119
	main.o
else
julien.delange's avatar
julien.delange committed
120
121
122
123
124
   PO_HI_OBJS =                     \
	po_hi_task.o                     \
	po_hi_time.o                     \
	po_hi_utils.o                    \
	po_hi_protected.o                \
jdelange's avatar
jdelange committed
125
   po_hi_monitor.o                  \
jdelange's avatar
jdelange committed
126
   po_hi_storage.o                  \
127
	po_hi_main.o
julien.delange's avatar
julien.delange committed
128
129
130
131

   GENERATED_OBJS =                 \
	activity.o                       \
	subprograms.o                    \
132
	deployment.o                     \
julien.delange's avatar
julien.delange committed
133
	types.o                          \
134
135
136
	main.o
endif

jdelange's avatar
jdelange committed
137
138

ifeq ($(TARGET), $(filter $(TARGET), linux32 linux64 linux32-xenomai-posix linux32-xenomai-native))
139
PO_HI_OBJS += po_hi_lua.o
jdelange's avatar
jdelange committed
140
141
endif

jdelange's avatar
jdelange committed
142
ifeq ($(USE_ASN1_DEPLOYMENT), yes)
143
generate-asn1-deployment:
jdelange's avatar
jdelange committed
144
145
146
	if [ ! -d ../asn-types ]; then mkdir -p ../asn-types ; fi
	asn1.exe -c -uPER $(ASN_SOURCES) -o ../asn-types
	for f in real.o asn1crt.o acn.o ber.o xer.o; do \
147
	   c_file="`basename $$f .o`.c"; \
jdelange's avatar
jdelange committed
148
149
150
151
152
153
	      $(CC) $(INCLUDE) $(CFLAGS) -c -o $$f ../asn-types/$$c_file || exit 1 ; \
	done
	for f in $(ASN_SOURCES); do \
	   c_file="`basename $$f .asn`.c"; \
	   o_file="`basename $$f .asn`.o"; \
      if [ -f ../asn-types/$$c_file ]; then $(CC) $(INCLUDE) $(CFLAGS) -c -o $$o_file ../asn-types/$$c_file || exit 1 ; fi \
154
	done
155

jdelange's avatar
jdelange committed
156
GENERATED_OBJS += real.o asn1crt.o xer.o ber.o acn.o $(ASN_OBJS)
157
LDFLAGS += -lm
158
CFLAGS+=-DPO_HI_USE_ASN1 -I../../ -I../asn-types/
159

160
161
162
163
164
else
generate-asn1-deployment:

endif

165
166
167
168
169
170
171
172
173
174
175
176
177
################################################################################
# Simulink

ifdef SIMULINK_NODE
   PO_HI_OBJS += po_hi_simulink.o
endif

ifdef SIMULINK_DIR
   INCLUDE += -I$(SIMULINK_DIR) \
              -I$(SIMULINK_DIRECTORY)/simulink/include \
              -I$(SIMULINK_DIRECTORY)/extern/include \
              -I$(SIMULINK_DIRECTORY)/rtw/c/src \
              -I$(SIMULINK_DIRECTORY)/rtw/c/src/ext_mode/common \
178
              -I$(SIMULINK_DIRECTORY)/rtw/c/libsrc
179
180
181
182
183
184
185
186
187
188
189
190
   CFLAGS += -DRT -DUSE_RTMODEL -DMODEL=$(SIMULINK_NODE) -DRT -DNUMST=2 -DTID01EQ=1 -DNCSTATES=0 -DUNIX -DMT=0 -DHAVESTDIO
   LDFLAGS += $(SIMULINK_LDFLAGS)
endif

################################################################################
# SCADE

ifdef SCADE_DIR
   INCLUDE += -I$(SCADE_DIR)
	USER_OBJS += $(SCADE_DIR)/*.o
endif

julien.delange's avatar
julien.delange committed
191
192
193
194
195
196
197
198
################################################################################
# General LINUXTASTE stuff
check-linuxtaste:
	if [ ! -d $$LINUXTASTE_PATH/output/staging ]; then \
		echo "Please define the LINUXTASTE_PATH variable" ; \
      echo "It should point to the directory where the distro was built" && exit 2 ; \
	fi

199
200
201
202
203
204
205
################################################################################
# General compilation rules

compile-po-hi:
ifdef SIMULINK_DIR
	(cd $(SIMULINK_DIR) && $(MAKE) -f $(SIMULINK_NODE).mk  && rm -f grt_main.o)
endif
206

207
208
209
210
211
ifdef SCADE_DIR
	(cd $(SCADE_DIR) && for v in `ls *.c`; do $(CC) -c $$v; done)
endif
	for f in $(PO_HI_OBJS); do \
	   c_file="`basename $$f .o`.c"; \
212
213
214
215
216
217
218
	   c_file_dirname="`dirname $$f`"; \
      if [ -n "$$c_file_dirname" ]; then \
         if [ ! -d $$c_file_dirname ]; then mkdir -p $$c_file_dirname ; fi ; \
	      $(CC) $(INCLUDE) $(CFLAGS) -c -o $$f '$(RUNTIME_PATH)/src/'$$c_file_dirname'/'$$c_file  || exit 1 ; \
      else \
	      $(CC) $(INCLUDE) $(CFLAGS) -c -o $$f '$(RUNTIME_PATH)/src/'$$c_file || exit 1 ; \
      fi ; \
219
220
221
222
	done

compile-node: $(BINARY)

jdelange's avatar
jdelange committed
223
ifeq ($(TARGET), $(filter $(TARGET), leon3-scoc3 leon.rtems leon.rtems_posix))
224
225
OBJS = $(USER_OBJS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(EXTERNAL_OBJECTS)
$(BINARY):
yoogx's avatar
yoogx committed
226
	if [  x"$$RTEMS_MAKEFILE_PATH" = x"" ]; then \
227
228
		echo "Please define the RTEMS_MAKEFILE_PATH variable, exiting" ; \
	else \
yoogx's avatar
yoogx committed
229
		$(MAKE) generate-asn1-deployment compile-c-files compile-cpp-files compile-ada-files target-objects compile-po-hi $(USER_OBJS) $(GENERATED_OBJS) ; \
230
231
		$(CC) -o $(BINARY) $(EXTERNAL_OBJECTS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(USER_OBJS) $(LDFLAGS) $(CFLAGS) ; \
	fi
julien.delange's avatar
julien.delange committed
232
233
endif

234
ifeq ($(TARGET), leon3-xm3)
235
$(BINARY):
236
OBJS = $(USER_OBJS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(EXTERNAL_OBJECTS)
237
238
239
240
241
$(BINARY): generate-asn1-deployment target-objects check-rtems compile-po-hi $(USER_OBJS) $(GENERATED_OBJS)
	$(make-exe)
endif


jrosa's avatar
jrosa committed
242
ifeq ($(TARGET), $(filter $(TARGET), x86.rtems x86.rtems_posix))
243
OBJS = $(USER_OBJS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(EXTERNAL_OBJECTS)
244
245
246
247
$(BINARY): generate-asn1-deployment target-objects check-rtems compile-po-hi $(USER_OBJS) $(GENERATED_OBJS)
	$(make-exe)
	cp $(BINARY) binary

248
249
250
ifeq ($(NEED_TRANSPORT), yes)
run: $(BINARY)
	pidof qemu >/dev/null 2>&1 ; if [ $$?  -eq 0 ]; then \
251
		( sleep 5 ; qemu -net nic,model=ne2k_pci,macaddr=52:54:00:12:34:93 -net socket,connect=127.0.0.1:12345 -fda $(RUNTIME_PATH)/utils/x86-rtems-boot.img -hda fat:. -boot a -serial /dev/stdout ; )& \
252
253
		echo "Launching QEMU in connect mode" ; \
	else \
254
		qemu -net nic,model=ne2k_pci,macaddr=52:54:00:12:34:92 -net socket,listen=:12345 -fda $(RUNTIME_PATH)/utils/x86-rtems-boot.img -hda fat:. -boot a -serial /dev/stdout; \
255
256
257
		echo "Launching QEMU in listen mode" ; \
	fi
else
258
259
run: $(BINARY)
	qemu -fda $(RUNTIME_PATH)/utils/x86-rtems-boot.img -hda fat:. -boot a
260
261
endif #NEED_TRANSPORT
endif #TARGET=x86qemu
262

julien.delange's avatar
julien.delange committed
263
ifeq ($(TARGET), nds.rtems)
264
OBJS = $(USER_OBJS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(EXTERNAL_OBJECTS)
julien.delange's avatar
julien.delange committed
265
$(BINARY): generate-asn1-deployment target-objects check-rtems compile-po-hi $(USER_OBJS) $(GENERATED_OBJS)
266
	$(CC) -o $(BINARY) $(EXTERNAL_OBJECTS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(USER_OBJS) $(LDFLAGS)
julien.delange's avatar
julien.delange committed
267
268
endif

julien.delange's avatar
julien.delange committed
269
270

ifeq ($(TARGET), gumstix.rtems)
271
OBJS = $(USER_OBJS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(EXTERNAL_OBJECTS)
julien.delange's avatar
julien.delange committed
272
273
274
275
$(BINARY): generate-asn1-deployment target-objects check-rtems compile-po-hi $(USER_OBJS) $(GENERATED_OBJS)
	$(make-exe)
endif

jdelange's avatar
jdelange committed
276
ifeq ($(TARGET), compcert)
277
278
279
280
$(BINARY):
	@if [ ! -f ccomp ]; then \
		echo "Compcert not installed, exiting" ; \
	else \
yoogx's avatar
yoogx committed
281
		$(MAKE) generate-asn1-deployment compile-c-files compile-cpp-files compile-ada-files target-objects compile-po-hi $(GENERATED_OBJS) $(TARGET_OBJECTS); \
282
283
284
285
286
		for v in $(USER_OBJS); do mv ../../$$v . ; done ; \
 		mkdir -p drivers; \
		for v in $(PO_HI_OBJS); do mv $(RUNTIME_PATH)/src/$$v $$v ; done; \
		$(CC) -o $(BINARY) $(EXTERNAL_OBJECTS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(USER_OBJS) $(LDFLAGS); \
	fi
jdelange's avatar
jdelange committed
287
endif
julien.delange's avatar
julien.delange committed
288

289
ifeq ($(TARGET), $(filter $(TARGET), native bench linux32 linux64))
jdelange's avatar
jdelange committed
290
EXE=$(BINARY)
291
$(BINARY):
yoogx's avatar
yoogx committed
292
	$(MAKE) generate-asn1-deployment target-objects compile-c-files compile-cpp-files compile-ada-files compile-po-hi $(USER_OBJS) $(GENERATED_OBJS) $(TARGET_OBJECTS)
293
	$(LD) -o $(EXE) $(EXTERNAL_OBJECTS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(USER_OBJS) $(LDFLAGS)
jdelange's avatar
jdelange committed
294
endif
295
296
297
298

ifeq ($(TARGET), $(filter $(TARGET), win32))
EXE=$(BINARY).exe
$(BINARY):
299
	@if [ x"$(which i686-w64-mingw32-gcc)" = x ]; then \
300
301
302
303
304
305
306
307
308
309
		echo "Windows compiler is not installed in your system, exiting" ; \
	else \
		$(MAKE) generate-asn1-deployment target-objects compile-po-hi $(USER_OBJS) $(GENERATED_OBJS) $(TARGET_OBJECTS) ; \
		$(LD) -o $(EXE) $(EXTERNAL_OBJECTS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(USER_OBJS) $(LDFLAGS) ; \
	fi
endif

ifeq ($(TARGET), $(filter $(TARGET), linux32-xenomai-posix linux32-xenomai-native))
EXE=$(BINARY)
$(BINARY):
310
	@if [ x"$(which xeno-config)" = x ]; then \
311
312
313
314
315
		echo "Xenomai is not installed in your system, exiting" ; \
	else \
		$(MAKE) generate-asn1-deployment target-objects compile-po-hi $(USER_OBJS) $(GENERATED_OBJS) $(TARGET_OBJECTS) ; \
		$(LD) -o $(EXE) $(EXTERNAL_OBJECTS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(USER_OBJS) $(LDFLAGS) ; \
	fi
316
317
endif

julien.delange's avatar
julien.delange committed
318
319
ifeq ($(TARGET), arm.dslinux)
$(BINARY): generate-asn1-deployment target-objects compile-po-hi $(USER_OBJS) $(GENERATED_OBJS) $(TARGET_OBJECTS)
320
	$(CC) -o $(BINARY) $(EXTERNAL_OBJECTS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(USER_OBJS) $(LDFLAGS)
julien.delange's avatar
julien.delange committed
321
322
endif

julien.delange's avatar
julien.delange committed
323
324
ifeq ($(TARGET), x86.linuxtaste)
$(BINARY): check-linuxtaste generate-asn1-deployment target-objects compile-po-hi $(USER_OBJS) $(GENERATED_OBJS) $(TARGET_OBJECTS)
325
	$(CC) -o $(BINARY) $(EXTERNAL_OBJECTS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(USER_OBJS) $(LDFLAGS)
julien.delange's avatar
julien.delange committed
326
327
endif

328
329
330
331
332
333
334
%.o: %.cpp
	$(CPP) $(INCLUDE) $(CPPFLAGS) -c -o $@ $<

%.o: %.c
	$(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $<

clean: target-clean
335
	@-rm -f *~ *.o *.al temp.* *.metrix $(BINARY) $(BINARY).bin $(BINARY).bt $(BINARY).num $(BINARY).nxe b~*.* *.ali
336
	@-rm -rf drivers
337
338
339
	if test ! "$(CLEANDIRS)" = "";  then \
	  rm -rf $(CLEANDIRS); \
	fi
340

jdelange's avatar
jdelange committed
341
generate-doc:
342
343
	@if [ -d generated-documentation ]; then rm  -rf generated-documentation ; fi
	@( DOXYBIN=`which doxygen 2>/dev/null` && if [ -x "$$DOXYBIN" ]; then ` which doxygen` doxygen.cfg ; fi ) || exit 0
jdelange's avatar
jdelange committed
344
345


346
347
348
349
350
ifdef USE_GPROF
gprof:
	./$(BINARY)
	gprof ./$(BINARY) > gprof.out
endif
yoogx's avatar
yoogx committed
351