makefile.tmplt 11 KB
Newer Older
1
2
3
@@-- The up to date list of tags available for this template is available here:
@@-- https://taste.tuxfamily.org/wiki/index.php?title=Kazoo_Templates_Documentation#templates.2Fskeletons.2Fmakefile.tmplt
@@-- If you are using vim, go over the URL and pres gx in to follow the link
4
@@--
5
6
# MAKEFILE_PATH   := $(abspath $(lastword $(MAKEFILE_LIST)))
MAKEFILE_PATH   := $(lastword $(MAKEFILE_LIST))
Maxime Perrotin's avatar
Maxime Perrotin committed
7
OUTDIR          := $(dir $(MAKEFILE_PATH))
8
9
ASN1_FILES      := @_REPLACE_ALL(,/):ASN1_Files_@
CP_FILES        := @_REPLACE_ALL(,/):CP_Files_@      # Context parameters
Maxime Perrotin's avatar
Maxime Perrotin committed
10
11
DATAVIEW_PATH   := ${OUTDIR}/dataview
DATAVIEW_UNIQ   := ${DATAVIEW_PATH}/dataview-uniq.asn
12
13
@@IF@@ @_ACN_Files'Length_@ > 0
DATAVIEW_ACN    := ${DATAVIEW_PATH}/dataview-uniq.acn
Maxime Perrotin's avatar
Maxime Perrotin committed
14
15
@@ELSE@@
DATAVIEW_ACN    :=
16
@@END_IF@@
Maxime Perrotin's avatar
Maxime Perrotin committed
17
DATAVIEW_AADLV1 := ${DATAVIEW_PATH}/dataview_aadlv1.aadl
18
DATAVIEW_AADLV2 := ${DATAVIEW_PATH}/dataview_aadlv2.aadl
Maxime Perrotin's avatar
Maxime Perrotin committed
19

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

23
all:	build-default
Maxime Perrotin's avatar
Maxime Perrotin committed
24

25
26
27
28
# Build a simulator of the system
simu:	aadl2glueC build/system_config.h ${DATAVIEW_PATH}/built build/deploymentview_final/Makefile
	$(MAKE) -j -C build -f Makefile.taste simu

29
@@-- global check to check which dataviews are neeeded
Maxime Perrotin's avatar
Maxime Perrotin committed
30
@@TABLE@@
31
  @@IF@@ @_Unique_Languages_@ = Ada or @_Unique_Languages_@ = SDL
Maxime Perrotin's avatar
Maxime Perrotin committed
32
     @@SET@@ Need_Ada=TRUE
33
  @@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
34
35
36
     @@SET@@ Other_DataViews=TRUE
  @@ELSIF@@ @_Unique_Languages_@ = GUI
     @@SET@@ Has_GUI=TRUE
Maxime Perrotin's avatar
Maxime Perrotin committed
37
38
  @@END_IF@@
@@END_TABLE@@
Maxime Perrotin's avatar
Maxime Perrotin committed
39

40
# Generate the language-specific data view needed before editing user code
Maxime Perrotin's avatar
Maxime Perrotin committed
41
42
43
@@IF@@ not @_Need_Ada_@ and not @_Other_DataViews_@
dataview:	dataview/C/built
@@END_IF@@
44
@@INLINE(dataview:	dataview/C/built )( )()@@
Maxime Perrotin's avatar
Maxime Perrotin committed
45
46
47
   @@IF@@ @_Need_Ada_@ = TRUE
      dataview/Ada/built
   @@END_IF@@
48
   @@TABLE@@  @@-- Exclude Python because it depends on information from the deployment view and it is not needed for the skeletons
49
      @@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
50
51
52
53
54
55
         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
56
57
58
59
60
@@IF@@ @_Has_GUI_@
${DATAVIEW_PATH}/built:	dataview dataview/Python/built
@@ELSE@@
${DATAVIEW_PATH}/built:	dataview
@@END_IF@@
Maxime Perrotin's avatar
Maxime Perrotin committed
61
62
	touch $@

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

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

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

75
# Rule to invoke Ocarina (generation of POHI middleware code)
76
build/deploymentview_final/Makefile:	build/main.aadl ${DATAVIEW_AADLV2} ../ConcurrencyView_Properties.aadl
77
	cd build ; ocarina -x main.aadl
78

79
80
@@-- 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.
81
# Optionally hold thread priorities, offset, stack size. Create if not present
82
83
84
../ConcurrencyView_Properties.aadl:
	touch $@

85
86
87
88
89
90
91
@@-- SQL Database: can be created by taste-create-database
@@-- Add a dependency to make sure that if is is modified, the GUIs
@@-- Using it are properly updated
# Optionally manage SQL Database (run taste-create-database to enable)
sql_db/DV.py:
	mkdir -p sql_db && touch $@

92
# Create dataview-uniq.asn by concatenating all asn1 input files
93
${DATAVIEW_UNIQ}:	${ASN1_FILES}
Maxime Perrotin's avatar
Maxime Perrotin committed
94
	mkdir -p ${PROJECT_CACHE} && mkdir -p ${DATAVIEW_PATH}
Maxime Perrotin's avatar
Maxime Perrotin committed
95
	@@-- Don't use cat, because files need newlines in between
Maxime Perrotin's avatar
Maxime Perrotin committed
96
97
98
99
100
101
102
103
104
	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
105

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

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

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

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

Maxime Perrotin's avatar
Maxime Perrotin committed
129
@@-- For each function generate the glue code from DMT based on the dataview
130
	@@TABLE@@
Maxime Perrotin's avatar
Maxime Perrotin committed
131
	@@IF@@ not @_Is_Type_@
Maxime Perrotin's avatar
Maxime Perrotin committed
132
@_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
133
	aadl2glueC -o $(dir $@) $^
Maxime Perrotin's avatar
Maxime Perrotin committed
134
135
	touch $@

Maxime Perrotin's avatar
Maxime Perrotin committed
136
	@@END_IF@@
137
	@@END_TABLE@@
Maxime Perrotin's avatar
Maxime Perrotin committed
138
139

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

Maxime Perrotin's avatar
Maxime Perrotin committed
152
        @@TABLE@@
153
	   @@IF@@ @_Unique_Languages_@ = Ada or @_Unique_Languages_@ = SDL
Maxime Perrotin's avatar
Maxime Perrotin committed
154
              @@SET@@ Need_Ada=TRUE
155
	   @@ELSIF@@ @_Unique_Languages_@ = C or @_Unique_Languages_@ = CPP or @_Unique_Languages_@ = Blackbox_C or @_Unique_Languages_@ = Timer_Manager
156
           @@--  do nothing, C is always done, only once
157
	   @@ELSIF@@ @_Unique_Languages_@ = GUI
158
           @@--  for DMT, GUI means Python
159
# Compile the ASN.1 models in Python for the autogenerated GUIs
160
161
162
163
164
165
166
167
@@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@@
168
        sql_db/DV.py
169
@@END_INLINE@@
170
171
	mkdir -p $(dir $@)
	asn2dataModel -o $(dir $@) -toPython ${DATAVIEW_UNIQ}  @@-- Ignore context parameters for python interface
172
	$(MAKE) -C dataview/Python -f Makefile.python
173
174
        @@TABLE@@
        @@IF@@ @_Language_@ = GUI
175
176
	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
177
178
	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
179
	   gcc -g -shared -o PythonAccess.so gui_api.o queue_manager.o timeInMS.o debug_messages.o `python-config --ldflags` -lrt
180
	mkdir -p binaries/@_LOWER:Function_Names_@_GUI
Maxime Perrotin's avatar
Maxime Perrotin committed
181
182
183
	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
184
185
186
187
188
189
        @@-- 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
190
191
192
        @@END_IF@@  @@-- End of PeekPoke-specifics
        @@-- Add symbolic link to the SQL Database interface for the GUIs, if needed
	if [ -f sql_db/db.info ]; then cd binaries/@_LOWER:Function_Names_@_GUI && ln -fs ../../sql_db; fi
193
194
195
        @@-- Copy default UserWidgets.py file for user to customise the GUI widgets
	# User can edit at will the customisable user widgets python module:
	cp -u $(shell taste-config --prefix)/share/AutoGUI/UserWidgets.py binaries/@_LOWER:Function_Names_@_GUI
196
197
198
        @@-- Copy InterfaceView.aadl, it is needed to replay MSC scenarios
        #  Interface view must be placed in the gui folder to allow replaying MSCs
	cp -u ../InterfaceView.aadl binaries/@_LOWER:Function_Names_@_GUI
199
        @@END_IF@@  @@-- End of GUI-specifics
200
201
        @@END_TABLE@@
	touch $@
Maxime Perrotin's avatar
Maxime Perrotin committed
202
	   @@ELSE@@
203
204
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
205
	touch $@
Maxime Perrotin's avatar
Maxime Perrotin committed
206
207
	   @@END_IF@@
	@@END_TABLE@@
Maxime Perrotin's avatar
Maxime Perrotin committed
208

Maxime Perrotin's avatar
Maxime Perrotin committed
209
	@@IF@@ @_Need_Ada_@=TRUE
210
dataview/Ada/built: ${DATAVIEW_UNIQ} ${CP_FILES}
211
	mkdir -p $(dir $@)
212
	asn2dataModel -o $(dir $@) -toAda $^
Maxime Perrotin's avatar
Maxime Perrotin committed
213
	touch $@
214
	cd dataview/Ada && rm -f gnat.cfg GPS_project.gpr IgnoredExaminerWarnings.wrn runSpark.sh
Maxime Perrotin's avatar
Maxime Perrotin committed
215
        @@END_IF@@
216
217
	@@-- Then symlink the files for each function
	@@TABLE@@
Maxime Perrotin's avatar
Maxime Perrotin committed
218
	@@IF@@ @_Language_@ = "SDL"
219
220
221
222
223
224
225
        @@IF@@ @_Has_Context_Param_@
	# SDL function with context parameters: put them in dataview
	sed -e '$$s/$$/\n/' -s ${DATAVIEW_UNIQ} @_LOWER:Function_Names_@/SDL/Context-@_LOWER:REPLACE_ALL(_/-):Function_Names_@.asn > @_LOWER:Function_Names_@/SDL/src/dataview-uniq.asn
        @@ELSE@@
        # Copy the dataview to SDL function @_Function_Names_@ (no context parameters)
	cp -u ${DATAVIEW_UNIQ} @_LOWER:Function_Names_@/SDL/src
        @@END_IF@@
226
	@@END_IF@@
227
	@@END_TABLE@@
228

Maxime Perrotin's avatar
Maxime Perrotin committed
229
function-types-linux:
Maxime Perrotin's avatar
Maxime Perrotin committed
230
	@@TABLE@@
Maxime Perrotin's avatar
Maxime Perrotin committed
231
	@@IF@@ @_Is_Type_@
232
	$(MAKE) -j -C @_LOWER:Function_Names_@/@_Language_@ compile-linux
Maxime Perrotin's avatar
Maxime Perrotin committed
233
	@@END_IF@@
Maxime Perrotin's avatar
Maxime Perrotin committed
234
	@@END_TABLE@@
Maxime Perrotin's avatar
Maxime Perrotin committed
235

Maxime Perrotin's avatar
Maxime Perrotin committed
236
function-instances-linux:	function-types-linux
Maxime Perrotin's avatar
Maxime Perrotin committed
237
238
	@@TABLE@@
	@@IF@@ not @_Is_Type_@
239
	$(MAKE) -C @_LOWER:Function_Names_@/@_Language_@ -j compile-linux
Maxime Perrotin's avatar
Maxime Perrotin committed
240
241
242
	@@END_IF@@
	@@END_TABLE@@

Maxime Perrotin's avatar
Maxime Perrotin committed
243
compile-all-linux:	dataviews function-instances-linux
Maxime Perrotin's avatar
Maxime Perrotin committed
244
245

clean:
246
	rm -rf binaries dataview
Maxime Perrotin's avatar
Maxime Perrotin committed
247
	$(MAKE) -C build -f Makefile.taste clean
Maxime Perrotin's avatar
Maxime Perrotin committed
248

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