Makefile.common 5.98 KB
Newer Older
1
2
3
# It detect if networking functions have to be compiled
# With the generated code.

4
5
6
7
8
all: build-node

all-with-tweak: 
	$(MAKE) all ENABLE_DYNAMIC_CONFIGURATION=1

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

12
13
build-node: compile-c-files compile-ada-files compile-node

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
################################################################################
# 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

35

36
GCC=$(CC)
julien.delange's avatar
julien.delange committed
37
CFLAGS=-Wall $(USER_CFLAGS) $(TARGET_CFLAGS) -g
38
39
40
CPPFLAGS=$(CFLAGS) $(USER_CPPFLAGS)
LDFLAGS=$(TARGET_LDFLAGS) $(USER_LDFLAGS)

41
42
43
ifdef USE_GPROF
CFLAGS+=-D__PO_HI_USE_GPROF -pg
endif
44
45
46
47
48

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

49
ifdef TARGET_INCLUDE
50
INCLUDE=-I. -I$(RUNTIME_PATH)/include/ $(TARGET_INCLUDE)
51
52
53
54
else
INCLUDE=-I. -I$(RUNTIME_PATH)/include/
endif

55
56
57
58
ifdef USER_SOURCES_DIRS
INCLUDE+=-I$(USER_SOURCES_DIRS) 
endif

59
60
INCLUDE+=$(USER_INCLUDE)

61
62
63
64
65
66
ifndef $(TARGET_NAME)
TARGET_NAME=$(TARGET)
endif

INCLUDE+=-DTARGET=$(TARGET_NAME)

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
################################################################################
# Files to be compiled

ifeq ($(NEED_TRANSPORT), yes)
   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 \
82
   drivers/po_hi_driver_linux_serial.o \
83
   drivers/po_hi_driver_sockets.o \
84
85
   drivers/po_hi_driver_sockets_common.o \
   drivers/po_hi_driver_sockets_asn1.o \
86
   drivers/po_hi_driver_rasta_serial.o \
julien.delange's avatar
julien.delange committed
87
   drivers/po_hi_driver_rasta_1553.o \
88
   drivers/po_hi_driver_rasta_1553_brmlib.o \
89
   drivers/po_hi_driver_rasta_spacewire.o \
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
	$(ACTUAL_TRANSPORT) \
	po_hi_transport.o $(TARGET_TRANSPORT_SOURCES)

   GENERATED_OBJS = \
	activity.o \
	subprograms.o \
	types.o \
	request.o \
	deployment.o \
	marshallers.o \
	naming.o \
	main.o
else
   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 \
	types.o \
	main.o
endif

117
118
ifdef USE_ASN1_DEPLOYMENT
generate-asn1-deployment:
119
	asn1.exe -c -uPER ../asn1_deployment.asn1
120
121
122
123
	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
124
125
126

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

129
130
131
132
133
else
generate-asn1-deployment:

endif

134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
################################################################################
# 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

################################################################################
# General RTEMS STUFF

check-rtems:
	if [ ! -d $$RTEMS_MAKEFILE_PATH/make ]; then \
		echo "Please define the RTEMS_MAKEFILE_PATH variable" && exit 2 ; \
	fi

################################################################################
# General compilation rules

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

176
177
178
179
180
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"; \
181
182
183
184
185
186
187
	   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 ; \
188
189
190
191
192
	done

compile-node: $(BINARY)

ifeq ($(TARGET), leon.rtems)
193
OBJS = $(USER_OBJS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(EXTERNAL_OBJECTS) 
194
$(BINARY): generate-asn1-deployment target-objects check-rtems compile-po-hi $(USER_OBJS) $(GENERATED_OBJS)
195
	$(make-exe)
julien.delange's avatar
julien.delange committed
196
197
endif

198
199
200
201
202
203
204
205
206
207
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

run: $(BINARY)
	qemu -fda $(RUNTIME_PATH)/utils/x86-rtems-boot.img -hda fat:. -boot a
endif

julien.delange's avatar
julien.delange committed
208
209
210
211
212
213
214
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

ifeq ($(TARGET), native)
215
$(BINARY): generate-asn1-deployment target-objects compile-po-hi $(USER_OBJS) $(GENERATED_OBJS) $(TARGET_OBJECTS)
216
	$(CC) -o $(BINARY) $(EXTERNAL_OBJECTS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(USER_OBJS) $(LDFLAGS) 
217
218
219
220
221
222
223
224
225
226
endif

%.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
227
	@-rm -rf drivers
228
229
230
	if test ! "$(CLEANDIRS)" = "";  then \
	  rm -rf $(CLEANDIRS); \
	fi
231
232
233
234
235
236

ifdef USE_GPROF
gprof:
	./$(BINARY)
	gprof ./$(BINARY) > gprof.out
endif