makefile.tmplt 9.86 KB
Newer Older
1
2
3
4
@@-- The following tags are available in this template:
@@--
@@-- @_Function_Names_@      : Combined table: list of fuction names...
@@-- @_Language_@            : ... and corresponding implementation language
5
6
@@-- @_Is_Type_@             : ... and flag if it is a function type
@@-- @_CP_Files_@            : List of all context parameters ASN.1 files
7
@@-- @_Unique_Languages_@    : List of all languages used in the system
8
@@-- @_ASN1_Files_@          : List of all ASN.1 files
9
@@-- @_ACN_Files_@           : List of all ACN files
10
@@-- @_ASN1_Modules_@        : List of all ASN.1 modules
11
12
# MAKEFILE_PATH   := $(abspath $(lastword $(MAKEFILE_LIST)))
MAKEFILE_PATH   := $(lastword $(MAKEFILE_LIST))
Maxime Perrotin's avatar
Maxime Perrotin committed
13
OUTDIR          := $(dir $(MAKEFILE_PATH))
14
15
ASN1_FILES      := @_REPLACE_ALL(,/):ASN1_Files_@
CP_FILES        := @_REPLACE_ALL(,/):CP_Files_@      # Context parameters
Maxime Perrotin's avatar
Maxime Perrotin committed
16
17
DATAVIEW_PATH   := ${OUTDIR}/dataview
DATAVIEW_UNIQ   := ${DATAVIEW_PATH}/dataview-uniq.asn
18
19
@@IF@@ @_ACN_Files'Length_@ > 0
DATAVIEW_ACN    := ${DATAVIEW_PATH}/dataview-uniq.acn
Maxime Perrotin's avatar
Maxime Perrotin committed
20
21
@@ELSE@@
DATAVIEW_ACN    :=
22
@@END_IF@@
Maxime Perrotin's avatar
Maxime Perrotin committed
23
DATAVIEW_AADLV1 := ${DATAVIEW_PATH}/dataview_aadlv1.aadl
24
DATAVIEW_AADLV2 := ${DATAVIEW_PATH}/dataview_aadlv2.aadl
Maxime Perrotin's avatar
Maxime Perrotin committed
25

Maxime Perrotin's avatar
Maxime Perrotin committed
26
27
# Project cache folder is used to speed up all ASN.1-related processing
export PROJECT_CACHE=${HOME}/.taste_AST_cache
28

29
all:	build-default
Maxime Perrotin's avatar
Maxime Perrotin committed
30

31
@@-- global check to check which dataviews are neeeded
Maxime Perrotin's avatar
Maxime Perrotin committed
32
@@TABLE@@
33
  @@IF@@ @_Unique_Languages_@ = Ada or @_Unique_Languages_@ = SDL
Maxime Perrotin's avatar
Maxime Perrotin committed
34
     @@SET@@ Need_Ada=TRUE
35
  @@ELSIF@@ @_Unique_Languages_@ /= C and @_Unique_Languages_@ /= CPP and @_Unique_Languages_@ /= Blackbox_C and @_Unique_Languages_@ /= GUI and @_Unique_Languages_@ /= Timer_Manager
Maxime Perrotin's avatar
Maxime Perrotin committed
36
37
38
     @@SET@@ Other_DataViews=TRUE
  @@ELSIF@@ @_Unique_Languages_@ = GUI
     @@SET@@ Has_GUI=TRUE
Maxime Perrotin's avatar
Maxime Perrotin committed
39
40
  @@END_IF@@
@@END_TABLE@@
Maxime Perrotin's avatar
Maxime Perrotin committed
41

42
# Generate the language-specific data view needed before editing user code
Maxime Perrotin's avatar
Maxime Perrotin committed
43
44
45
@@IF@@ not @_Need_Ada_@ and not @_Other_DataViews_@
dataview:	dataview/C/built
@@END_IF@@
46
@@INLINE(dataview:	dataview/C/built )( )()@@
Maxime Perrotin's avatar
Maxime Perrotin committed
47
48
49
   @@IF@@ @_Need_Ada_@ = TRUE
      dataview/Ada/built
   @@END_IF@@
50
   @@TABLE@@  @@-- Exclude Python because it depends on information from the deployment view and it is not needed for the skeletons
51
      @@IF@@ @_Unique_Languages_@ /= "Ada" and @_Unique_Languages_@ /= "SDL" and @_Unique_Languages_@ /= C and @_Unique_Languages_@ /= CPP and @_Unique_Languages_@ /= Blackbox_C and @_Unique_Languages_@ /= GUI and @_Unique_Languages_@ /= Timer_Manager
52
53
54
55
56
57
         dataview/@_Unique_Languages_@/built
      @@END_IF@@
   @@END_TABLE@@
@@END_INLINE@@

# Generate the complete dataview, including Python bindings if there is a GUI
Maxime Perrotin's avatar
Maxime Perrotin committed
58
59
60
61
62
@@IF@@ @_Has_GUI_@
${DATAVIEW_PATH}/built:	dataview dataview/Python/built
@@ELSE@@
${DATAVIEW_PATH}/built:	dataview
@@END_IF@@
Maxime Perrotin's avatar
Maxime Perrotin committed
63
64
	touch $@

65
# Build based on the deployment view
66
build-default:	aadl2glueC build/system_config.h ${DATAVIEW_PATH}/built build/deploymentview_final/Makefile
Maxime Perrotin's avatar
Maxime Perrotin committed
67
	$(MAKE) -j -C build -f Makefile.taste
Maxime Perrotin's avatar
Maxime Perrotin committed
68

69
# Force build with RTEMS/Leon, even if deployment view does not specify it
70
build-rtems-ada:	aadl2glueC build/system_config.h ${DATAVIEW_PATH}/built build/deploymentview_final/Makefile
Maxime Perrotin's avatar
Maxime Perrotin committed
71
	$(MAKE) -j -C build -f Makefile.taste rtems_ada
Maxime Perrotin's avatar
Maxime Perrotin committed
72

73
# Force build with AIR (TSP), even if deployment view does not specify it
74
air:	aadl2glueC build/system_config.h ${DATAVIEW_PATH}/built build/deploymentview_final/Makefile
Maxime Perrotin's avatar
Maxime Perrotin committed
75
	$(MAKE) -j -C build -f Makefile.taste air
76

77
# Rule to invoke Ocarina (generation of POHI middleware code)
78
79
build/deploymentview_final/Makefile:	build/main.aadl ${DATAVIEW_AADLV2} ../ConcurrencyView_Properties.aadl
	taste-patch-cv-properties.py build/system.aadl ../ConcurrencyView_Properties.aadl
80
81
	cd build && ocarina -x main.aadl

82
83
@@-- ConcurrencyView_Properties is normally always present (even if empty) as
@@-- it is generated by the GUIs... Just in case it is not there, create it.
84
# Optionally hold thread priorities, offeset, stack size. Create if not present
85
86
87
../ConcurrencyView_Properties.aadl:
	touch $@

88
# Create dataview-uniq.asn by concatenating all asn1 input files
89
${DATAVIEW_UNIQ}:	${ASN1_FILES}
Maxime Perrotin's avatar
Maxime Perrotin committed
90
	mkdir -p ${PROJECT_CACHE} && mkdir -p ${DATAVIEW_PATH}
Maxime Perrotin's avatar
Maxime Perrotin committed
91
	@@-- Don't use cat, because files need newlines in between
Maxime Perrotin's avatar
Maxime Perrotin committed
92
93
94
95
96
97
98
99
100
	sed -e '$$s/$$/\n/' -s $^ > $@

@@IF@@ @_ACN_Files'Length_@ > 0
# Create dataview-uniq.acn by concatenating all input files
${DATAVIEW_ACN}:	@_REPLACE_ALL(,/):ACN_Files_@
	mkdir -p ${DATAVIEW_PATH}
	@@-- Don't use cat, because files need newlines in between
	sed -e '$$s/$$/\n/' -s $^ > $@
@@END_IF@@
Maxime Perrotin's avatar
Maxime Perrotin committed
101

102
# system_config.h is used to filter out non-needed ASN.1 encoder/decoders
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
103
104
build/system_config.h:	$(wildcard */*/wrappers/*_system_config.h)
	cat $^ > $@
Maxime Perrotin's avatar
Maxime Perrotin committed
105

106
#  Call DMT/aadl2glueC to generate glue code from the mini-cv.aadl files
Maxime Perrotin's avatar
Maxime Perrotin committed
107
108
109
110
111
112
113
114
@@INLINE(aadl2glueC:	)( )()@@
        @@TABLE@@
	@@IF@@ not @_Is_Type_@
            @_LOWER:Function_Names_@/@_Language_@/wrappers/aadl2glueC_built
	@@END_IF@@
	@@END_TABLE@@
@@END_INLINE@@

115
# Build dataview.aadl in AADLv1 format, used by DMT to generate glue code
Maxime Perrotin's avatar
Maxime Perrotin committed
116
${DATAVIEW_AADLV1}: ${DATAVIEW_UNIQ}
117
	@@-- Generate DataView.aadl in AADLV1 as this is needed by aadl2glueC
118
	asn2aadlPlus  $< $@
Maxime Perrotin's avatar
Maxime Perrotin committed
119

120
# Build dataview.aadl in AADLv2 format, used by Ocarina to generate glue code
121
122
${DATAVIEW_AADLV2}: ${DATAVIEW_UNIQ}
	@@-- Generate DataView.aadl in AADLV2 without -f flag
Maxime Perrotin's avatar
Maxime Perrotin committed
123
	asn2aadlPlus --aadlv2  $< $@
124

Maxime Perrotin's avatar
Maxime Perrotin committed
125
@@-- For each function generate the glue code from DMT based on the dataview
126
	@@TABLE@@
Maxime Perrotin's avatar
Maxime Perrotin committed
127
	@@IF@@ not @_Is_Type_@
Maxime Perrotin's avatar
Maxime Perrotin committed
128
@_LOWER:Function_Names_@/@_Language_@/wrappers/aadl2glueC_built: @_LOWER:Function_Names_@/@_Language_@/wrappers/@_LOWER:Function_Names_@_mini_cv.aadl ${DATAVIEW_AADLV1}
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
129
	aadl2glueC -o $(dir $@) $^
Maxime Perrotin's avatar
Maxime Perrotin committed
130
131
	touch $@

Maxime Perrotin's avatar
Maxime Perrotin committed
132
	@@END_IF@@
133
	@@END_TABLE@@
Maxime Perrotin's avatar
Maxime Perrotin committed
134
135

@@-- Then generate Dataviews once per target language - first for C, it is needed in any case
136
137
# Compile the ASN.1 models in C
dataview/C/built: ${DATAVIEW_UNIQ} ${DATAVIEW_ACN} ${CP_FILES}
138
	mkdir -p $(dir $@)
Maxime Perrotin's avatar
Maxime Perrotin committed
139
140
	# asn2dataModel does not take the ACN files, and only calls asn1.exe
	# asn2dataModel -o $(dir $@) -toC ${DATAVIEW_UNIQ} ${DATAVIEW_ACN}
141
	asn1.exe -typePrefix asn1Scc -equal -fp AUTO -o $(dir $@) -c -uPER -ACN $^
Maxime Perrotin's avatar
Maxime Perrotin committed
142
143
	cp $(shell taste-config --prefix)/share/AutoGUI/debug_messages.? dataview/C
	cp $(shell taste-config --prefix)/share/AutoGUI/timeInMS.? dataview/C
144
145
	cd dataview/C && msgPrinter ../dataview-uniq.asn
	cd dataview/C && msgPrinterASN1  ../dataview-uniq.asn
Maxime Perrotin's avatar
Maxime Perrotin committed
146
	touch $@
147

Maxime Perrotin's avatar
Maxime Perrotin committed
148
        @@TABLE@@
149
	   @@IF@@ @_Unique_Languages_@ = Ada or @_Unique_Languages_@ = SDL
Maxime Perrotin's avatar
Maxime Perrotin committed
150
              @@SET@@ Need_Ada=TRUE
151
	   @@ELSIF@@ @_Unique_Languages_@ = C or @_Unique_Languages_@ = CPP or @_Unique_Languages_@ = Blackbox_C or @_Unique_Languages_@ = Timer_Manager
152
           @@--  do nothing, C is always done, only once
153
	   @@ELSIF@@ @_Unique_Languages_@ = GUI
154
           @@--  for DMT, GUI means Python
155
# Compile the ASN.1 models in Python for the autogenerated GUIs
156
157
158
159
160
161
162
163
164
@@INLINE(dataview/Python/built:	dataview/C/built )( )()@@
        @@--  aadl2glueC has to be called before the python mapper is built
        @@--  because it depends on gui_api.c/etc.
        @@TABLE@@
          @@IF@@ @_Language_@ = GUI
             @_LOWER:Function_Names_@/GUI/wrappers/aadl2glueC_built
          @@END_IF@@
        @@END_TABLE@@
@@END_INLINE@@
165
166
	mkdir -p $(dir $@)
	asn2dataModel -o $(dir $@) -toPython ${DATAVIEW_UNIQ}  @@-- Ignore context parameters for python interface
167
	$(MAKE) -C dataview/Python -f Makefile.python
168
169
        @@TABLE@@
        @@IF@@ @_Language_@ = GUI
170
171
	cp dataview/Python/* @_LOWER:Function_Names_@/GUI/wrappers/python
	cp dataview/C/timeInMS.[ch] dataview/C/debug_messages.c @_LOWER:Function_Names_@/GUI/wrappers/python
172
173
	cd @_LOWER:Function_Names_@/GUI/wrappers/python && \
	   gcc -g -fPIC -c `python-config --cflags`  gui_api.c ../../src/queue_manager.c timeInMS.c debug_messages.c -I. -I../../src && \
Maxime Perrotin's avatar
Maxime Perrotin committed
174
175
176
177
178
	   gcc -g -shared -o PythonAccess.so gui_api.o queue_manager.o timeInMS.o debug_messages.o `python-config --ldflags` -lrt
	mkdir -p binaries/@_LOWER:Function_Names_@_GUI 
	cp -f @_LOWER:Function_Names_@/GUI/wrappers/python/* binaries/@_LOWER:Function_Names_@_GUI
	cp -f @_LOWER:Function_Names_@/GUI/wrappers/*.py binaries/@_LOWER:Function_Names_@_GUI
	cp -f @_LOWER:Function_Names_@/GUI/wrappers/*.ui binaries/@_LOWER:Function_Names_@_GUI
179
180
181
182
183
184
185
186
        @@-- If system contains the PeekPoke component, copy the relevant code in the gui folder
        @@IF@@ @_LOWER:Function_Names_@ = taste_probe_console
	@# Peek-Poke function is placed in the gui folder
	cp $(shell taste-config --prefix)/bin/taste-gnuplot-streams binaries/@_LOWER:Function_Names_@_GUI/driveGnuPlotsStreams.pl
	cp $(shell taste-config --prefix)/share/peekpoke/peekpoke.py binaries/@_LOWER:Function_Names_@_GUI
	cp $(shell taste-config --prefix)/share/peekpoke/PeekPoke.glade binaries/@_LOWER:Function_Names_@_GUI
        @@END_IF@@
        @@-- End of PeekPoke-specifics
187
188
189
        @@END_IF@@
        @@END_TABLE@@
	touch $@
Maxime Perrotin's avatar
Maxime Perrotin committed
190
	   @@ELSE@@
191
192
dataview/@_Unique_Languages_@/built: ${DATAVIEW_UNIQ} # no context parameters except for C and Ada
	mkdir -p $(dir $@) && asn2dataModel -o $(dir $@) -to@_Unique_Languages_@ $^
Maxime Perrotin's avatar
Maxime Perrotin committed
193
	touch $@
Maxime Perrotin's avatar
Maxime Perrotin committed
194
195
	   @@END_IF@@
	@@END_TABLE@@
Maxime Perrotin's avatar
Maxime Perrotin committed
196

Maxime Perrotin's avatar
Maxime Perrotin committed
197
	@@IF@@ @_Need_Ada_@=TRUE
198
dataview/Ada/built: ${DATAVIEW_UNIQ} ${CP_FILES}
199
	mkdir -p $(dir $@)
200
	asn2dataModel -o $(dir $@) -toAda $^
Maxime Perrotin's avatar
Maxime Perrotin committed
201
	touch $@
202
203
	cd dataview/Ada
	rm -f gnat.cfg GPS_project.gpr IgnoredExaminerWarnings.wrn runSpark.sh
Maxime Perrotin's avatar
Maxime Perrotin committed
204
        @@END_IF@@
205
206
	@@-- Then symlink the files for each function
	@@TABLE@@
Maxime Perrotin's avatar
Maxime Perrotin committed
207
	@@IF@@ @_Language_@ = "SDL"
208
	ln -fs ../../../$^ @_LOWER:Function_Names_@/@_Language_@/src
209
	@@END_IF@@
210
	@@END_TABLE@@
211

Maxime Perrotin's avatar
Maxime Perrotin committed
212
function-types-linux:
Maxime Perrotin's avatar
Maxime Perrotin committed
213
	@@TABLE@@
Maxime Perrotin's avatar
Maxime Perrotin committed
214
	@@IF@@ @_Is_Type_@
215
	$(MAKE) -j -C @_LOWER:Function_Names_@/@_Language_@ compile-linux
Maxime Perrotin's avatar
Maxime Perrotin committed
216
	@@END_IF@@
Maxime Perrotin's avatar
Maxime Perrotin committed
217
	@@END_TABLE@@
Maxime Perrotin's avatar
Maxime Perrotin committed
218

Maxime Perrotin's avatar
Maxime Perrotin committed
219
function-instances-linux:	function-types-linux
Maxime Perrotin's avatar
Maxime Perrotin committed
220
221
	@@TABLE@@
	@@IF@@ not @_Is_Type_@
222
	$(MAKE) -C @_LOWER:Function_Names_@/@_Language_@ -j compile-linux
Maxime Perrotin's avatar
Maxime Perrotin committed
223
224
225
	@@END_IF@@
	@@END_TABLE@@

Maxime Perrotin's avatar
Maxime Perrotin committed
226
compile-all-linux:	dataviews function-instances-linux
Maxime Perrotin's avatar
Maxime Perrotin committed
227
228

clean:
229
	rm -rf binaries dataview
Maxime Perrotin's avatar
Maxime Perrotin committed
230
	$(MAKE) -C build -f Makefile.taste clean
Maxime Perrotin's avatar
Maxime Perrotin committed
231

232
.PHONY: clean compile-all-linux function-instances-linux function-types-linux build-default dataview build-rtems-ada dataview