Makefile.common 9.9 KB
Newer Older
1
2
3
4
5
6
7
8
9
# 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.
#
# For more informations, please visit http://ocarina.enst.fr
#
# Copyright (C) 2010-2011, European Space Agency (ESA).
#

jdelange's avatar
jdelange committed
10
GCC_GENERIC_CFLAGS=-Wall -g
11
12

all: build-node
13

14
15
16
include $(RUNTIME_PATH)/make/Makefile.$(TARGET)
-include ../../userdefined.mk

jdelange's avatar
jdelange committed
17
build-node: compile-c-files compile-ada-files compile-node generate-doc
18

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
################################################################################
# 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

40

41
GCC=$(CC)
jdelange's avatar
jdelange committed
42
CFLAGS=$(USER_CFLAGS) $(TARGET_CFLAGS)
43
CPPFLAGS=$(CFLAGS) $(USER_CPPFLAGS)
44
LDFLAGS=$(USER_LDFLAGS) $(TARGET_LDFLAGS)
45

46
47
48
ifdef USE_GPROF
CFLAGS+=-D__PO_HI_USE_GPROF -pg
endif
49
50
51
52
53

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

54
55
56
57
ifeq ($(NEED_TRANSPORT),yes)
CFLAGS+=-D__PO_HI_USE_TRANSPORT
endif

58
ifdef TARGET_INCLUDE
59
INCLUDE=-I. -I$(RUNTIME_PATH)/include/ $(TARGET_INCLUDE)
60
61
62
63
else
INCLUDE=-I. -I$(RUNTIME_PATH)/include/
endif

64
ifdef USER_SOURCES_DIRS
65
INCLUDE+=$(USER_SOURCES_DIRS) 
66
67
endif

68
69
INCLUDE+=$(USER_INCLUDE)

70
71
72
73
74
75
ifndef $(TARGET_NAME)
TARGET_NAME=$(TARGET)
endif

INCLUDE+=-DTARGET=$(TARGET_NAME)

76
77
78
79
################################################################################
# Files to be compiled

ifeq ($(NEED_TRANSPORT), yes)
julien.delange's avatar
julien.delange committed
80
81
82
83
84
85
86
87
88
89
90
91
   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                             \
	po_hi_gqueue.o                            \
   drivers/po_hi_driver_exarm.o              \
julien.delange's avatar
julien.delange committed
92
   drivers/po_hi_driver_keyboard.o           \
93
94
   drivers/po_hi_driver_exarm_ni_6071e_analog.o \
   drivers/po_hi_driver_exarm_ni_6071e_digital.o \
95
   drivers/po_hi_driver_usbbrick_spacewire.o \
julien.delange's avatar
julien.delange committed
96
   drivers/po_hi_driver_linux_serial.o       \
97
   drivers/po_hi_driver_leon_serial.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
125
126
127
128
129
   PO_HI_OBJS =                     \
	po_hi_task.o                     \
	po_hi_time.o                     \
	po_hi_utils.o                    \
	po_hi_protected.o                \
	po_hi_main.o                     

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

135
136
ifdef USE_ASN1_DEPLOYMENT
generate-asn1-deployment:
137
	asn1.exe -c -uPER ../asn1_deployment.asn1
138
139
140
141
	for f in real.o asn1_deployment.o asn1crt.o; do \
	   c_file="`basename $$f .o`.c"; \
	      $(CC) $(INCLUDE) $(CFLAGS) -c -o $$f $$c_file || exit 1 ; \
	done
142
143
144

GENERATED_OBJS += real.o  asn1_deployment.o asn1crt.o
LDFLAGS += -lm
julien.delange's avatar
julien.delange committed
145
CFLAGS+=-DPO_HI_USE_ASN1 -I../../
146

147
148
149
150
151
else
generate-asn1-deployment:

endif

152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
################################################################################
# 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 \
              -I$(SIMULINK_DIRECTORY)/rtw/c/libsrc 
   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
179
# General RTEMS stuff
180
181
182

check-rtems:
	if [ ! -d $$RTEMS_MAKEFILE_PATH/make ]; then \
183
		echo "Please define the RTEMS_MAKEFILE_PATH variable [currently set to \"$(RTEMS_MAKEFILE_PATH)\"]" && exit 2 ; \
184
185
	fi

julien.delange's avatar
julien.delange committed
186
187
188
189
190
191
192
193
194
195
196
197

################################################################################
# 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




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

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

206
207
208
209
210
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"; \
211
212
213
214
215
216
217
	   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 ; \
218
219
220
221
222
	done

compile-node: $(BINARY)

ifeq ($(TARGET), leon.rtems)
223
OBJS = $(USER_OBJS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(EXTERNAL_OBJECTS) 
224
$(BINARY): generate-asn1-deployment target-objects check-rtems compile-po-hi $(USER_OBJS) $(GENERATED_OBJS)
225
	$(make-exe)
julien.delange's avatar
julien.delange committed
226
227
endif

228
ifeq ($(TARGET), leon3-xm3)
229
$(BINARY):
230
231
232
233
234
235
OBJS = $(USER_OBJS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(EXTERNAL_OBJECTS) 
$(BINARY): generate-asn1-deployment target-objects check-rtems compile-po-hi $(USER_OBJS) $(GENERATED_OBJS)
	$(make-exe)
endif


236
237
238
239
240
241
ifeq ($(TARGET), x86.rtems)
OBJS = $(USER_OBJS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(EXTERNAL_OBJECTS) 
$(BINARY): generate-asn1-deployment target-objects check-rtems compile-po-hi $(USER_OBJS) $(GENERATED_OBJS)
	$(make-exe)
	cp $(BINARY) binary

242
243
244
ifeq ($(NEED_TRANSPORT), yes)
run: $(BINARY)
	pidof qemu >/dev/null 2>&1 ; if [ $$?  -eq 0 ]; then \
245
		( 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 ; )& \
246
247
		echo "Launching QEMU in connect mode" ; \
	else \
248
		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; \
249
250
251
		echo "Launching QEMU in listen mode" ; \
	fi
else
252
253
run: $(BINARY)
	qemu -fda $(RUNTIME_PATH)/utils/x86-rtems-boot.img -hda fat:. -boot a
254
255
endif #NEED_TRANSPORT
endif #TARGET=x86qemu
256

julien.delange's avatar
julien.delange committed
257
258
259
260
261
262
ifeq ($(TARGET), nds.rtems)
OBJS = $(USER_OBJS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(EXTERNAL_OBJECTS) 
$(BINARY): generate-asn1-deployment target-objects check-rtems compile-po-hi $(USER_OBJS) $(GENERATED_OBJS)
	$(make-exe)
endif

julien.delange's avatar
julien.delange committed
263
264
265
266
267
268
269

ifeq ($(TARGET), gumstix.rtems)
OBJS = $(USER_OBJS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(EXTERNAL_OBJECTS) 
$(BINARY): generate-asn1-deployment target-objects check-rtems compile-po-hi $(USER_OBJS) $(GENERATED_OBJS)
	$(make-exe)
endif

jdelange's avatar
jdelange committed
270
271
272
ifeq ($(TARGET), compcert)
$(BINARY): generate-asn1-deployment target-objects compile-po-hi $(GENERATED_OBJS) $(TARGET_OBJECTS)
	for v in $(USER_OBJS); do mv ../../$$v . ; done
273
274
	mkdir -p drivers
	for v in $(PO_HI_OBJS); do mv $(RUNTIME_PATH)/src/$$v $$v ; done
jdelange's avatar
jdelange committed
275
276
	$(CC) -o $(BINARY) $(EXTERNAL_OBJECTS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(USER_OBJS) $(LDFLAGS) 
endif
julien.delange's avatar
julien.delange committed
277

278
ifeq ($(TARGET), $(filter $(TARGET), native bench linux32 linux64 linux32-xenomai-posix linux32-xenomai-native))
279
$(BINARY): generate-asn1-deployment target-objects compile-po-hi $(USER_OBJS) $(GENERATED_OBJS) $(TARGET_OBJECTS)
280
	$(CC) -o $(BINARY) $(EXTERNAL_OBJECTS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(USER_OBJS) $(LDFLAGS) 
281
282
endif

julien.delange's avatar
julien.delange committed
283
284
285
286
287
ifeq ($(TARGET), arm.dslinux)
$(BINARY): generate-asn1-deployment target-objects compile-po-hi $(USER_OBJS) $(GENERATED_OBJS) $(TARGET_OBJECTS)
	$(CC) -o $(BINARY) $(EXTERNAL_OBJECTS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(USER_OBJS) $(LDFLAGS) 
endif

julien.delange's avatar
julien.delange committed
288
289
290
291
292
293
ifeq ($(TARGET), x86.linuxtaste)
$(BINARY): check-linuxtaste generate-asn1-deployment target-objects compile-po-hi $(USER_OBJS) $(GENERATED_OBJS) $(TARGET_OBJECTS)
	$(CC) -o $(BINARY) $(EXTERNAL_OBJECTS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(USER_OBJS) $(LDFLAGS) 
endif


294
295
296
297
298
299
300
301
%.o: %.cpp
	$(CPP) $(INCLUDE) $(CPPFLAGS) -c -o $@ $<

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

clean: target-clean
	@-rm -f *~ *.o *.al temp.* *.metrix $(BINARY) $(BINARY).bin $(BINARY).bt $(BINARY).num $(BINARY).nxe
302
	@-rm -rf drivers
303
304
305
	if test ! "$(CLEANDIRS)" = "";  then \
	  rm -rf $(CLEANDIRS); \
	fi
306

jdelange's avatar
jdelange committed
307
308
generate-doc:
	if [ -d generated-documentation ]; then rm  -rf generated-documentation ; fi
309
	( DOXYBIN=`which doxygen 2>/dev/null` && if [ -x "$$DOXYBIN" ]; then ` which doxygen` doxygen.cfg ; fi ) || exit 0
jdelange's avatar
jdelange committed
310
311


312
313
314
315
316
ifdef USE_GPROF
gprof:
	./$(BINARY)
	gprof ./$(BINARY) > gprof.out
endif