-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathremake.sh
537 lines (432 loc) · 12.9 KB
/
remake.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
#!/bin/bash
#
# this script is used to
# - enable / disable the build of particular modules
# - create and update Makefiles
# set following variables depending on which module you want to build.
# if unset, the module is not built.
# Build Curses plug-in
USE_CURSES=1
# Build OLED screen plug-in
# USE_OLED=1
# Build LCD1602 plug-in
USE_LCD=1
# Build DRMCairo plug-in
# USE_DRMCAIRO=1
# include fall-back to stock frame buffer
# DRMC_WITH_FB=1
# Build directFB plug-in
# As of v7, this plug-in in deprecated and won't compile anymore.
#USE_DIRECTFB=1
# DEBUG - Add debuging messages
# DEBUG=1
# MCHECK - check memory consistency (see glibc's mcheck())
# notez-bien : not compatible with multithreading. Consequently it may (or not)
# create false report with Detach() function
# MCHECK=1
# end of customisation area
# build configuration
# ----------------
# where to install plugins
# production
PLUGIN_DIR=/usr/local/lib
# for development
# PLUGIN_DIR=$( pwd )/lib
if [ ${PLUGIN_DIR+x} ]
then
USE_PLUGDIR="-DPLUGIN_DIR='\"$PLUGIN_DIR\"' -L$PLUGIN_DIR"
fi
# -------------------------------------
# END OF CONFIGURATION AREA
# DON'T MODIFY ANYTHING AFTER THIS LINE
# DON'T MODIFY ANYTHING AFTER THIS LINE
# DON'T MODIFY ANYTHING AFTER THIS LINE
# DON'T MODIFY ANYTHING AFTER THIS LINE
# -------------------------------------
# Error is fatal
set -e
# =================
# Rebuild Makefiles
# =================
echo -e "\nBuild Makefiles\n===============\n"
echo "# global Makefile that is calling sub directories ones" > Makefile
echo >> Makefile
echo "gotoall: all" >> Makefile
echo >> Makefile
echo "# Clean previous builds sequels" >> Makefile
echo "clean:" >> Makefile
echo -e "\t-rm -f Selene src/testSelene/testSelene" >> Makefile
echo -e "\t-rm -f lib/Selene/*.so" >> Makefile
echo -e "\t-rm -f lib/*.so.2" >> Makefile
echo -e "\t-rm -f src/*/*.o" >> Makefile
echo >> Makefile
echo "# Build everything" >> Makefile
echo "all:" >> Makefile
# =============================
# Configure external components
# =============================
echo -e "\nSet build options\n=================\n"
CFLAGS="-Wall -O2 -fPIC -Wno-unused-result"
# Lua version
if true; then # OS Version
if ! command -v lua &> /dev/null
then
echo "No Lua found"
exit 1
fi
VERLUA=$( lua -v 2>&1 | grep -o -E '[0-9]\.[0-9]' )
echo -n "Lua's version :" $VERLUA
if pkg-config --cflags lua$VERLUA > /dev/null 2>&1; then
echo " (Packaged)"
LUA="\$(shell pkg-config --cflags lua$VERLUA ) -DLUA"
LUALIB="\$(shell pkg-config --libs lua$VERLUA )"
elif pkg-config --cflags lua > /dev/null 2>&1; then
echo " (unpackaged)"
LUA="\$(shell pkg-config --cflags lua ) -DLUA"
LUALIB="\$(shell pkg-config --libs lua )"
else
echo " - No package found"
echo "Workaround : edit this remake file to hardcode where Lua is installed."
echo
exit 1
fi
else
# Force custom 5.3.4 version
LUA_DIR=/home/laurent/Projets/lua-5.3.4/install
LUA="-isystem $LUA_DIR/include"
LUALIB="-L$LUA_DIR/lib"
fi
# Let's go
echo
echo "Global settings"
echo "==============="
echo
if [ ${DEBUG+x} ]; then
DEBUG="-DDEBUG"
else
echo "DEBUG not defined"
fi
if [ ${MCHECK+x} ]; then
echo "Memory checking activated"
MCHECK='-DMCHECK="mcheck(NULL)"'
MCHECK_LIB="-lmcheck"
else
echo "No memory checking"
fi
echo
echo "Plug-ins settings"
echo "================="
echo
echo
echo "Curses plug-in"
echo "--------------"
if [ ${USE_CURSES+x} ]; then
if which ncursesw6-config > /dev/null 2>&1; then
echo "Found ncurses v6"
NCURSES=ncursesw6-config
elif which ncursesw5-config > /dev/null 2>&1; then
echo "Found ncurses v5"
NCURSES=ncursesw5-config
else
echo "Curse not found : Failing ..."
exit 20
fi
USE_CURSES="-DUSE_CURSES \$(shell $NCURSES --cflags )"
USE_CURSES_LIB="\$(shell $NCURSES --libs )"
cd src/SelPlugins/Curses/
LFMakeMaker -v +f=Makefile --opts="-I../../include $CFLAGS $DEBUG $MCHECK $LUA $USE_CURSES $USE_CURSES_LIB" *.c -so=../../../lib/Selene/SelCurses.so > Makefile
cd ../../..
echo -e '\t$(MAKE) -C src/SelPlugins/Curses' >> Makefile
else
echo "Curse not used."
fi
echo
echo "OLED plug-in"
echo "------------"
if [ ${USE_OLED+x} ]; then
echo "OLED used"
USE_OLED="-DUSE_OLED"
USE_OLED_LIB="-lArduiPi_OLED"
cd src/SelPlugins/OLED/
LFMakeMaker -v +f=Makefile --opts="-I../../include $CFLAGS $DEBUG $MCHECK $LUA $USE_OLED $USE_OLED_LIB" *.c -so=../../../lib/Selene/SelOLED.so > Makefile
cd ../../..
echo -e '\t$(MAKE) -C src/SelPlugins/OLED' >> Makefile
else
echo "OLED not used"
fi
echo
echo "LCD plug-in"
echo "-----------"
if [ ${USE_LCD+x} ]; then
echo "LCD used"
USE_LCD="-DUSE_LCD"
USE_L2C_LIB="-li2c"
cd src/SelPlugins/LCD/
LFMakeMaker -v +f=Makefile --opts="-I../../include $CFLAGS $DEBUG $MCHECK $LUA $USE_LCD $USE_L2C_LIB" *.c -so=../../../lib/Selene/SelLCD.so > Makefile
cd ../../..
echo -e '\t$(MAKE) -C src/SelPlugins/LCD' >> Makefile
else
echo "LCD not used"
fi
echo
echo "DRMCairo plugin"
echo "---------------"
if [ ${USE_DRMCAIRO+x} ]; then
USE_DRMCAIRO="-DUSE_DRMCAIRO \$(shell pkg-config --cflags libdrm cairo freetype2 )"
USE_DRMCAIRO_LIB="\$(shell pkg-config --libs libdrm cairo freetype2 )"
echo "DRMCairo used"
if pkg-config --cflags libkms; then
USE_DRMCAIRO="$USE_DRMCAIRO \$(shell pkg-config --cflags libkms )"
USE_DRMCAIRO_LIB="$USE_DRMCAIRO_LIB \$(shell pkg-config --libs libkms )"
else
USE_DRMCAIRO="$USE_DRMCAIRO -DKMS_MISSING"
echo "WARNING : Kms is missing"
fi
if [ ${DRMC_WITH_FB+x} ]; then
USE_DRMCAIRO="-DDRMC_WITH_FB $USE_DRMCAIRO"
echo "with Framebuffer fallback"
fi
cd src/SelPlugins/DRMCairo/
LFMakeMaker -v +f=Makefile --opts="-I../../include $CFLAGS $DEBUG $MCHECK $LUA $USE_DRMCAIRO $USE_DRMCAIRO_LIB" *.c -so=../../../lib/Selene/SelDRMCairo.so > Makefile
cd ../../..
echo -e '\t$(MAKE) -C src/SelPlugins/DRMCairo' >> Makefile
else
echo "DRMCairo not used"
fi
echo
echo "DirectFB source"
echo "-----------"
if [ ${USE_DIRECTFB+x} ]; then
USE_DIRECTFB="-DUSE_DIRECTFB \$(shell directfb-config --cflags )"
USE_DIRECTFB_LIB="\$(shell directfb-config --libs )"
echo "DirectFB used"
cd src/SelPlugins/DirectFB/
LFMakeMaker -v +f=Makefile --opts="$CFLAGS $DEBUG $MCHECK $LUA $USE_DIRECTFB $USE_DIRECTFB_LIB" *.c -so=../../../lib/Selene/SelDirectFB.so > Makefile
cd ../../..
echo -e '\t$(MAKE) -C src/SelPlugins/DirectFB' >> Makefile
else
echo "DirectFB not used"
fi
echo
echo "Selene Library"
echo "=============="
echo
cd src/libSelene
LFMakeMaker -v -I../include/ +f=Makefile --opts="-I../include $CFLAGS $DEBUG $MCHECK $USE_PLUGDIR" *.c -so=../../lib/libSelene.so.2 > Makefile
cd ../..
echo -e '\t$(MAKE) -C src/libSelene' >> Makefile
echo
echo "SeleneCore"
echo "=========="
echo
cd src/SeleneCore
LFMakeMaker -v -I../include/ +f=Makefile \
--opts="-I../include $CFLAGS $DEBUG $MCHECK $LUA $USE_PLUGDIR" \
*.c -so=../../lib/Selene/SeleneCore.so > Makefile
cd ../..
echo -e '\t$(MAKE) -C src/SeleneCore' >> Makefile
echo
echo "SelLog"
echo "======"
echo
cd src/SelLog
LFMakeMaker -v -I../include/ +f=Makefile \
--opts="-I../include $CFLAGS $DEBUG $MCHECK $LUA $USE_PLUGDIR" \
*.c -so=../../lib/Selene/SelLog.so > Makefile
cd ../..
echo -e '\t$(MAKE) -C src/SelLog' >> Makefile
echo
echo "SelLua"
echo "======="
echo
cd src/SelLua
LFMakeMaker -v -I../include/ +f=Makefile -I../include \
--opts="-I../include $CFLAGS $DEBUG $MCHECK $LUA $USE_PLUGDIR" \
*.c -so=../../lib/Selene/SelLua.so > Makefile
cd ../..
echo -e '\t$(MAKE) -C src/SelLua' >> Makefile
echo
echo "SelScripting"
echo "============"
echo
cd src/SelScripting
LFMakeMaker -v -I../include/ +f=Makefile -I../include \
--opts="-I../include $CFLAGS $DEBUG $MCHECK $LUA $USE_PLUGDIR" \
*.c -so=../../lib/Selene/SelScripting.so > Makefile
cd ../..
echo -e '\t$(MAKE) -C src/SelScripting' >> Makefile
echo
echo "SelElasticStorage"
echo "================="
echo
cd src/SelElasticStorage
LFMakeMaker -v -I../include/ +f=Makefile -I../include \
--opts="-I../include $CFLAGS $DEBUG $MCHECK $LUA $USE_PLUGDIR" \
*.c -so=../../lib/Selene/SelElasticStorage.so > Makefile
cd ../..
echo -e '\t$(MAKE) -C src/SelElasticStorage' >> Makefile
echo
echo "SelMultitasking"
echo "==============="
echo
cd src/SelMultitasking
LFMakeMaker -v -I../include/ +f=Makefile -I../include \
--opts="-I../include $CFLAGS $DEBUG $MCHECK $LUA $USE_PLUGDIR" \
*.c -so=../../lib/Selene/SelMultitasking.so > Makefile
cd ../..
echo -e '\t$(MAKE) -C src/SelMultitasking' >> Makefile
echo
echo "SelSharedFunction"
echo "================="
echo
cd src/SelSharedFunction
LFMakeMaker -v -I../include/ +f=Makefile -I../include \
--opts="-I../include $CFLAGS $DEBUG $MCHECK $LUA $USE_PLUGDIR" \
*.c -so=../../lib/Selene/SelSharedFunction.so > Makefile
cd ../..
echo -e '\t$(MAKE) -C src/SelSharedFunction' >> Makefile
echo
echo "SelSharedRef"
echo "============"
echo
cd src/SelSharedRef
LFMakeMaker -v -I../include/ +f=Makefile -I../include \
--opts="-I../include $CFLAGS $DEBUG $MCHECK $LUA $USE_PLUGDIR" \
*.c -so=../../lib/Selene/SelSharedRef.so > Makefile
cd ../..
echo -e '\t$(MAKE) -C src/SelSharedRef' >> Makefile
echo
echo "SelSharedVar"
echo "============"
echo
cd src/SelSharedVar
LFMakeMaker -v -I../include/ +f=Makefile -I../include \
--opts="-I../include $CFLAGS $DEBUG $MCHECK $LUA $USE_PLUGDIR" \
*.c -so=../../lib/Selene/SelSharedVar.so > Makefile
cd ../..
echo -e '\t$(MAKE) -C src/SelSharedVar' >> Makefile
echo
echo "SelMQTT"
echo "======="
echo
cd src/SelMQTT
LFMakeMaker -v -I../include/ +f=Makefile -I../include \
--opts="-I../include $CFLAGS $DEBUG $MCHECK $LUA $USE_PLUGDIR" \
*.c -so=../../lib/Selene/SelMQTT.so > Makefile
cd ../..
echo -e '\t$(MAKE) -C src/SelMQTT' >> Makefile
echo
echo "SelError"
echo "========"
echo
cd src/SelError
LFMakeMaker -v -I../include/ +f=Makefile -I../include \
--opts="-I../include $CFLAGS $DEBUG $MCHECK $LUA $USE_PLUGDIR" \
*.c -so=../../lib/Selene/SelError.so > Makefile
cd ../..
echo -e '\t$(MAKE) -C src/SelError' >> Makefile
echo
echo "SelTimer"
echo "========"
echo
cd src/SelTimer
LFMakeMaker -v -I../include/ +f=Makefile -I../include \
--opts="-I../include $CFLAGS $DEBUG $MCHECK $LUA $USE_PLUGDIR" \
*.c -so=../../lib/Selene/SelTimer.so > Makefile
cd ../..
echo -e '\t$(MAKE) -C src/SelTimer' >> Makefile
echo
echo "SelFIFO"
echo "======="
echo
cd src/SelFIFO
LFMakeMaker -v -I../include/ +f=Makefile -I../include \
--opts="-I../include $CFLAGS $DEBUG $MCHECK $LUA $USE_PLUGDIR" \
*.c -so=../../lib/Selene/SelFIFO.so > Makefile
cd ../..
echo -e '\t$(MAKE) -C src/SelFIFO' >> Makefile
echo
echo "SelEvent"
echo "========"
echo
cd src/SelEvent
LFMakeMaker -v -I../include/ +f=Makefile -I../include \
--opts="-I../include $CFLAGS $DEBUG $MCHECK $LUA $USE_PLUGDIR" \
*.c -so=../../lib/Selene/SelEvent.so > Makefile
cd ../..
echo -e '\t$(MAKE) -C src/SelEvent' >> Makefile
echo
echo "SelCollection"
echo "============="
echo
cd src/SelCollection
LFMakeMaker -v -I../include/ +f=Makefile -I../include \
--opts="-I../include $CFLAGS $DEBUG $MCHECK $LUA $USE_PLUGDIR" \
*.c -so=../../lib/Selene/SelCollection.so > Makefile
cd ../..
echo -e '\t$(MAKE) -C src/SelCollection' >> Makefile
echo
echo "SelAverageCollection"
echo "===================="
echo
cd src/SelAverageCollection
LFMakeMaker -v -I../include/ +f=Makefile -I../include \
--opts="-I../include $CFLAGS $DEBUG $MCHECK $LUA $USE_PLUGDIR" \
*.c -so=../../lib/Selene/SelAverageCollection.so > Makefile
cd ../..
echo -e '\t$(MAKE) -C src/SelAverageCollection' >> Makefile
echo
echo "SelTimedCollection"
echo "=================="
echo
cd src/SelTimedCollection
LFMakeMaker -v -I../include/ +f=Makefile -I../include \
--opts="-I../include $CFLAGS $DEBUG $MCHECK $LUA $USE_PLUGDIR" \
*.c -so=../../lib/Selene/SelTimedCollection.so > Makefile
cd ../..
echo -e '\t$(MAKE) -C src/SelTimedCollection' >> Makefile
echo
echo "SelTimedWindowCollection"
echo "========================"
echo
cd src/SelTimedWindowCollection
LFMakeMaker -v -I../include/ +f=Makefile -I../include \
--opts="-I../include $CFLAGS $DEBUG $MCHECK $LUA $USE_PLUGDIR" \
*.c -so=../../lib/Selene/SelTimedWindowCollection.so > Makefile
cd ../..
echo -e '\t$(MAKE) -C src/SelTimedWindowCollection' >> Makefile
echo
echo "Selene"
echo "======"
echo
cd src/Selene
LFMakeMaker -g -v -I../include/ +f=Makefile --opts="-I../include $CFLAGS $DEBUG $MCHECK \
$LUA $LUALIB \
$USE_DRMCAIRO \
$USE_DIRECTFB \
$USE_CURSES \
$USE_OLED \
$MCHECK_LIB \
$USE_PLUGDIR \
-lpaho-mqtt3c $LUA -lm -ldl -Wl,--export-dynamic -lpthread \
-L../../lib -l:libSelene.so.2" \
*.c -t=../../Selene > Makefile
cd ../..
echo -e '\t$(MAKE) -C src/Selene' >> Makefile
echo
echo "C examples"
echo "=========="
echo
cd Clenites
rm -f make.sh
for f in *.c
do
echo "cc -I../src/include/ $CFLAGS $DEBUG $MCHECK $MCHECK_LIB $USE_PLUGDIR -L../lib -l:libSelene.so.2 -lpaho-mqtt3c -lm -ldl -Wl,--export-dynamic -lpthread $f -o $( basename $f .c )" >> make.sh
done
cd ../..
if [ ${PLUGIN_DIR+x} ]
then
echo
echo "Don't forget if you want to run it without installing first"
echo export LD_LIBRARY_PATH=$PLUGIN_DIR:$LD_LIBRARY_PATH
fi