forked from ciaa/firmware_v1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
668 lines (596 loc) · 27.5 KB
/
Makefile
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
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
###############################################################################
#
# Copyright 2014, Mariano Cerdeiro
# Copyright 2014, Juan Cecconi (UTN-FRBA)
#
# This file is part of CIAA Firmware.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
###############################################################################
######################## DO NOT CHANGE THIS FILE ##############################
###############################################################################
# You dont have to change this file, never.
#
# Copy Makefile.config to Makefile.mine and set the variables.
#
# Makefile.mine will be included by this root Makefile and your configurations
# in Makefile.mine will be ignored due to .gitignore.
#
# Please take into account to check and compare your Makefile.mine every time
# that Makefile.config is updated, you may have to adapt your Makefile.mine
# if Makefile.config is changed.
#
###############################################################################
-include Makefile.mine
###############################################################################
# ARCH, CPUTYPE and CPU following are supported
# +--------------+---------------+----------------+--------------+
# | ARCH | CPUTYPE | CPU | COMPILER |
# +--------------+---------------+----------------+--------------+
# | x86 | ia32 | | gcc |
# | | ia64 | | |
# +--------------+---------------+----------------+--------------+
# | cortexM4 | lpc43xx | lpc4337 | gcc |
# | | k60_120 | mk60fx512vlq15 | gcc |
# +--------------+---------------+----------------+--------------+
#
ARCH ?= x86
CPUTYPE ?= ia64
CPU ?= none
COMPILER ?= gcc
DS ?= /
# Project
#
# Available projects are:
# examples/blinking (example with rtos and posix)
# examples/blinking_base (example without rtos and without posix)
# examples/blinking_wo_rtos (example with posix without rtos)
# examples/blinking_wo_posix (example with rtos without rtos)
# examples/blinking_modbus (example with rtos, posix and using modbus)
#
PROJECT ?= examples$(DS)blinking
# rtostests options
#
RTOSTESTS_DEBUG_CTESTS ?= 0
RTOSTESTS_CLEAN_GENERATE ?= 1
RTOSTESTS_CTEST ?=
RTOSTESTS_SUBTEST ?=
# dependencies options
#
# Compile and make dependencies, or compile only and skip dependencies
MAKE_DEPENDENCIES ?= 1
#
# tools
WIN_TOOL_PATH ?=
LINUX_TOOLS_PATH ?= $(DS)opt$(DS)ciaa_tools
kconfig ?= $(LINUX_TOOLS_PATH)$(DS)kconfig$(DS)kconfig-qtconf
###############################################################################
# get OS
#
# This part of the makefile is used to detect your OS. Depending on the OS
ifeq ($(OS),Windows_NT)
# WINDOWS
# Command line separator
CS = ;
# Command for multiline echo
MULTILINE_ECHO = echo -e
# Libraries group linker parameters
START_GROUP = -Xlinker --start-group
END_GROUP = -Xlinker --end-group
else
# NON WINDOWS OS
# Command line separator
CS = ;
# Comand for multiline echo
MULTILINE_ECHO = echo -n
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
# LINUX
# Libraries group linker parameters
START_GROUP = -Xlinker --start-group
END_GROUP = -Xlinker --end-group
endif
ifeq ($(UNAME_S),Darwin)
# MACOS
# Compile in 32 bits mode
CFLAGS += -m32 -Wno-typedef-redefinition
# 32 bits non relocable excutable image
LFLAGS += -m32 -Xlinker -no_pie
# Libraries group linker parameters
START_GROUP = -all_load
END_GROUP =
endif
endif
###############################################################################
# get root dir
ROOT_DIR := .
# out dir
OUT_DIR = $(ROOT_DIR)$(DS)out
# object dir
OBJ_DIR = $(OUT_DIR)$(DS)obj
# lib dir
LIB_DIR = $(OUT_DIR)$(DS)lib
# bin dir
BIN_DIR = $(OUT_DIR)$(DS)bin
# rtos gen dir
GEN_DIR = $(OUT_DIR)$(DS)gen
# rtos test gen dir
RTOS_TEST_GEN_DIR = $(OUT_DIR)$(DS)rtos
# include needed project
include $(PROJECT)$(DS)mak$(DS)Makefile
# include needed modules
include $(foreach module, $(MODS), $(module)$(DS)mak$(DS)Makefile)
.DEFAULT_GOAL := $(project)
# add include files
INCLUDE += $(foreach LIB, $(LIBS), $($(LIB)_INC_PATH))
CFLAGS += $(foreach inc, $(INCLUDE), -I$(inc))
CFLAGS += -DARCH=$(ARCH) -DCPUTYPE=$(CPUTYPE) -DCPU=$(CPU)
TARGET_NAME ?= $(BIN_DIR)$(DS)$(project)
LD_TARGET = $(TARGET_NAME).$(LD_EXTENSION)
# create list of object files for a Lib (without DIR), based on source file %.c and %.s
$(foreach LIB, $(LIBS), $(eval $(LIB)_OBJ_FILES = $(notdir $(patsubst %.c,%.o,$(patsubst %.s,%.o,$(patsubst %.cpp,%.o,$($(LIB)_SRC_FILES)))))))
# Complete list of object files (without DIR), based on source file %.c and %.s
$(foreach LIB, $(LIBS), $(eval LIBS_OBJ_FILES += $($(LIB)_OBJ_FILES)))
# Complete Libs Source Files for debug Info
$(foreach LIB, $(LIBS), $(eval LIBS_SRC_FILES += $($(LIB)_SRC_FILES)))
# Complete Libs Source Dirs for vpath search (duplicates removed by sort)
$(foreach LIB, $(LIBS), $(eval LIBS_SRC_DIRS += $(sort $(dir $($(LIB)_SRC_FILES)))))
# Add the search patterns
vpath %.c $($(project)_SRC_PATH)
vpath %.c $(LIBS_SRC_DIRS)
vpath %.s $(LIBS_SRC_DIRS)
vpath %.cpp $(LIBS_SRC_DIRS)
vpath %.o $(OBJ_DIR)
#rule for library
define librule
$(LIB_DIR)$(DS)$(strip $(1)).a : $(2)
@echo ' '
@echo ===============================================================================
@echo Creating library $(1)
$(AR) -crs $(LIB_DIR)$(DS)$(strip $(1)).a $(foreach obj,$(2),$(OBJ_DIR)$(DS)$(obj))
@echo ' '
endef
OBJ_FILES = $(notdir $(patsubst %.c,%.o,$(patsubst %.s,%.o,$(SRC_FILES))))
# create rule for library
# lib.a : lib_OBJ_FILES.o
$(foreach LIB, $(LIBS), $(eval $(call librule, $(LIB), $($(LIB)_OBJ_FILES))) )
$(foreach LIB, $(LIBS), $(eval $(LIB) : $(LIB_DIR)$(DS)$(LIB).a ) )
###################### START UNIT TEST PART OF MAKE FILE ######################
# Gets all Modules Names
DIRS := $(sort $(dir $(wildcard modules$(DS)*$(DS))))
ALL_MODS := $(subst modules, , $(DIRS))
ALL_MODS := $(subst $(DS), , $(ALL_MODS))
MOCKS_OUT_DIR = $(OUT_DIR)$(DS)ceedling$(DS)mocks
RUNNERS_OUT_DIR = $(OUT_DIR)$(DS)ceedling$(DS)runners
FILES_TO_MOCK = $(foreach DIR, $(DIRS), $(wildcard $(DIR)inc$(DS)*.h))
FILES_MOCKED = $(foreach MOCKED, $(FILES_TO_MOCK), $(MOCKS_OUT_DIR)$(DS)mock_$(notdir $(MOCKED)))
###############################################################################
# rule for tst_<mod>[_file]
ifeq ($(findstring tst_, $(MAKECMDGOALS)),tst_)
# get module to be tested and store it in tst_mod variable
tst_mod = $(firstword $(filter-out tst,$(subst _, ,$(MAKECMDGOALS))))
# get file to be tested (if present) and store it in tst_file
tst_file := $(word 2,$(filter-out tst,$(subst _, ,$(MAKECMDGOALS))))
ifneq ($(word 3,$(filter-out tst,$(subst _, ,$(MAKECMDGOALS)))),)
tst_file := $(join $(tst_file),_$(word 3,$(filter-out tst,$(subst _, ,$(MAKECMDGOALS)))))
endif
# if tst_file is all the variable shall be reset and all tests shall be executed
ifeq ($(tst_file),all)
tst_file :=
endif
# include corresponding makefile
include modules$(DS)$(tst_mod)$(DS)mak$(DS)Makefile
# include test makefile
include modules$(DS)$(tst_mod)$(DS)test$(DS)utest$(DS)mak$(DS)Makefile
# get list of unit test sources
ifneq ($(tst_file),)
# definitions if to run only a specific unit test
# include modules needed for this module
include $(foreach mod,$($(tst_mod)_TST_MOD),modules$(DS)$(mod)$(DS)mak$(DS)Makefile)
MTEST_SRC_FILES = $($(tst_mod)_PATH)$(DS)test$(DS)utest$(DS)src$(DS)test_$(tst_file).c
UNITY_INC = externals$(DS)ceedling$(DS)vendor$(DS)unity$(DS)src \
externals$(DS)ceedling$(DS)vendor$(DS)cmock$(DS)src \
out$(DS)ceedling$(DS)mocks \
$(foreach mod,$($(tst_mod)_TST_MOD),$($(mod)_INC_PATH)) \
$($(tst_mod)_TST_INC_PATH) \
$($(tst_mod)_INC_PATH)
UNITY_SRC = modules$(DS)$(tst_mod)$(DS)test$(DS)utest$(DS)src$(DS)test_$(tst_file).c \
$(RUNNERS_OUT_DIR)$(DS)test_$(tst_file)_Runner.c \
modules$(DS)$(tst_mod)$(DS)src$(DS)$(tst_file).c \
externals$(DS)ceedling$(DS)vendor$(DS)unity$(DS)src$(DS)unity.c \
externals$(DS)ceedling$(DS)vendor$(DS)cmock$(DS)src$(DS)cmock.c \
$(foreach file,$(filter-out $(tst_file).c,$(notdir $($(tst_mod)_SRC_FILES))), out$(DS)ceedling$(DS)mocks$(DS)mock_$(file)) \
$(foreach mods,$($(tst_mod)_TST_MOD), $(foreach files, $(notdir $($(mods)_SRC_FILES)), out$(DS)ceedling$(DS)mocks$(DS)mock_$(files))) \
$(foreach tst_mocks, $($(tst_mod)_TST_MOCKS), out$(DS)ceedling$(DS)mocks$(DS)mock_$(tst_mocks))
# Needed Unity Obj files
UNITY_OBJ = $(notdir $(UNITY_SRC:.c=.o))
# Add the search patterns
$(foreach U_SRC, $(sort $(dir $(UNITY_SRC))), $(eval vpath %.c $(U_SRC)))
CFLAGS += -ggdb -c #-Wall -Werror #see issue #28
CFLAGS += $(foreach inc, $(UNITY_INC), -I$(inc))
CFLAGS += -DARCH=$(ARCH) -DCPUTYPE=$(CPUTYPE) -DCPU=$(CPU) -DUNITY_EXCLUDE_STDINT_H --coverage
else
# get all test target for the selected module
MTEST := $(notdir $(wildcard $($(tst_mod)_PATH)$(DS)test$(DS)utest$(DS)src$(DS)test_*.c))
MTEST := $(subst test_,,$(MTEST))
MTEST := $(subst .c,,$(MTEST))
MTEST := $(foreach tst, $(MTEST),tst_$(tst_mod)_$(tst))
endif
tst_link: $(UNITY_OBJ)
@echo ' '
@echo ===============================================================================
@echo Linking Test
gcc $(addprefix $(OBJ_DIR)$(DS),$(UNITY_OBJ)) -lgcov -o out/bin/$(tst_file).bin
# rule for tst_<mod>_<file>
tst_$(tst_mod)_$(tst_file): $(RUNNERS_OUT_DIR)$(DS)$(notdir $(MTEST_SRC_FILES:.c=_Runner.c)) tst_link
@echo ' '
@echo ===============================================================================
@echo Testing from module $(tst_mod) the file $(tst_file)
@echo === CEEDLING START ====
$(BIN_DIR)$(DS)$(tst_file).bin
@echo === CEEDLING END ===
gcov -abclu modules$(DS)$(tst_mod)$(DS)src$(DS)$(tst_file).c -o out$(DS)obj$(DS)
# rule for tst_<mod>
tst_$(tst_mod)_all:
@echo ' '
@echo ===============================================================================
@echo Testing the module $(tst_mod)
@echo Testing $(MTEST)
$(foreach tst,$(MTEST),make $(tst) $(CS))
tst_$(tst_mod):
@echo ' '
@echo ===============================================================================
@echo For the module $(tst_mod) following units can be tested:
@$(MULTILINE_ECHO) " $(foreach unit, $(MTEST), $(unit)\n)"
#tst_$(tst_mod): $(MTEST_SRC_FILES:.c=_Runner.c) tst_link
# @echo ===============================================================================
# @echo Testing the module $(tst_mod)
# @$(MULTILINE_ECHO) "Testing following .c Files: \n $(foreach src, $($(tst_mod)_SRC_FILES), $(src)\n)"
# @$(MULTILINE_ECHO) "Following Unity Test found: \n $(foreach src, $(MTEST_SRC_FILES), $(src)\n)"
# out/bin/test.bin
endif
results:
externals$(DS)lcov$(DS)bin$(DS)lcov -c -d . -o coverage.info -b .
externals$(DS)lcov$(DS)bin$(DS)genhtml coverage.info --output-directory $(OUT_DIR)$(DS)coverage
###############################################################################
# rule to generate the mocks
mocks:
@echo ' '
@echo ===============================================================================
@$(MULTILINE_ECHO) "Creating Mocks for: \n $(foreach mock, $(FILES_TO_MOCK), $(mock)\n)"
ruby externals/ceedling/vendor/cmock/lib/cmock.rb -omodules/tools/ceedling/project.yml $(FILES_TO_MOCK)
###############################################################################
# rule to inform about all available tests
tst:
@echo "+-----------------------------------------------------------------------------+"
@echo "| Unit Tests |"
@echo "+-----------------------------------------------------------------------------+"
@$(MULTILINE_ECHO) "Following tst rules have been created:\n $(foreach TST,$(ALL_MODS), tst_$(TST): run unit tests of $(TST)\n)"
$(RUNNERS_OUT_DIR)$(DS)test_%_Runner.c : test_%.c
@echo ' '
@echo ===============================================================================
@echo Creating Runner for $<
@echo " in $(RUNNERS_OUT_DIR)$(DS)$(notdir $@)"
ruby externals$(DS)ceedling$(DS)vendor$(DS)unity$(DS)auto$(DS)generate_test_runner.rb $< $(RUNNERS_OUT_DIR)$(DS)$(notdir $@) modules$(DS)tools$(DS)ceedling$(DS)project.yml
###################### ENDS UNIT TEST PART OF MAKE FILE #######################
# Rule to compile
%.o : %.c
@echo ' '
@echo ===============================================================================
@echo Compiling 'c' file: $<
@echo ' '
$(CC) $(CFLAGS) $< -o $(OBJ_DIR)$(DS)$@
ifeq ($(MAKE_DEPENDENCIES),1)
@echo ' '
@echo Generating dependencies...
$(CC) -MM $(CFLAGS) $< > $(OBJ_DIR)$(DS)$(@:.o=.d)
else
@echo ' '
@echo Skipping make dependencies...
endif
%.o : %.cpp
@echo ' '
@echo ===============================================================================
@echo Compiling 'c++' file: $<
@echo ' '
$(CPP) $(CFLAGS) $< -o $(OBJ_DIR)$(DS)$@
%.o : %.s
@echo ' '
@echo ===============================================================================
@echo Compiling 'asm' file: $<
@echo ' '
$(AS) $(AFLAGS) $< -o $(OBJ_DIR)$(DS)$@
###############################################################################
# Incremental Build (IDE: Build)
# link rule
# New rules for LIBS dependencies
$(foreach LIB, $(LIBS), $(eval -include $(addprefix $(OBJ_DIR)$(DS),$($(LIB)_OBJ_FILES:.o=.d))))
# New rules for project dependencies
$(foreach LIB, $(LIBS), $(eval -include $(addprefix $(OBJ_DIR)$(DS),$(OBJ_FILES:.o=.d))))
# libs with contains sources
LIBS_WITH_SRC = $(foreach LIB, $(LIBS), $(if $(filter %.c,$($(LIB)_SRC_FILES)),$(LIB)))
$(project) : $(LIBS_WITH_SRC) $(OBJ_FILES)
@echo ' '
@echo ===============================================================================
@echo Linking file: $(LD_TARGET)
@echo ' '
$(CC) $(foreach obj,$(OBJ_FILES),$(OBJ_DIR)$(DS)$(obj)) $(START_GROUP) $(foreach lib, $(LIBS_WITH_SRC), $(LIB_DIR)$(DS)$(lib).a) $(END_GROUP) -o $(LD_TARGET) $(LFLAGS)
@echo ' '
@echo ===============================================================================
@echo Post Building $(project)
@echo ' '
$(POST_BUILD)
# debug rule
debug : $(BIN_DIR)$(DS)$(project).bin
$(GDB) $(BIN_DIR)$(DS)$(project).bin
###############################################################################
# rtos OSEK generation
generate : $(OIL_FILES)
php modules$(DS)rtos$(DS)generator$(DS)generator.php --cmdline -l -v -c \
$(OIL_FILES) -f $(foreach TMP, $(rtos_GEN_FILES), $(TMP)) -o $(GEN_DIR)
###############################################################################
# doxygen
doxygen:
@echo running doxygen
doxygen modules/tools/doxygen/doxygen.cnf
###############################################################################
# openocd
include modules$(DS)tools$(DS)openocd$(DS)mak$(DS)Makefile
openocd:
# if windows or posix shows an error
ifeq ($(subst win,yes,$(subst posix,yes,$(ARCH))),yes)
@echo ERROR: You can not start openocd in Windows nor Linux
else
# if CPU is not entered shows an error
ifeq ($(CPU),)
@echo ERROR: The CPU variable of your makefile is empty.
else
ifeq ($(OPENOCD_CFG),)
@echo ERROR: Your CPU: $(CPU) may not be supported...
else
@echo ===============================================================================
@echo Starting OpenOCD...
@echo ' '
$(OPENOCD_BIN) $(OPENOCD_FLAGS)
endif
endif
endif
###############################################################################
# Download to target
download:
# if windows or posix shows an error
ifeq ($(subst win,yes,$(subst posix,yes,$(ARCH))),yes)
@echo ERROR: You can not download to target in Windows nor Linux
else
# if CPU is not entered shows an error
ifeq ($(CPU),)
@echo ERROR: The CPU variable of your makefile is empty.
else
ifeq ($(OPENOCD_CFG),)
@echo ERROR: Your CPU: $(CPU) may not be supported...
else
@echo ===============================================================================
@echo Starting GDB...be sure to run 'make openocd' in another console previously
@echo ' '
$(GDB) $(GDB_DOWNLOAD_TO_TARGET)
endif
endif
endif
###############################################################################
# help
help:
@echo "+-----------------------------------------------------------------------------+"
@echo "| General Help |"
@echo "+-----------------------------------------------------------------------------+"
@echo menuconfig.......: starts the CIAA Firmware configurator
@echo info.............: general information about the make environment
@echo info_\<mod\>.......: same as info but reporting information of a library
@echo info_ext_\<mod\>...: same as info_\<mod\> but for an external library
@echo "+-----------------------------------------------------------------------------+"
@echo "| FreeOSEK (CIAA RTOS based on OSEK Standard) |"
@echo "+-----------------------------------------------------------------------------+"
@echo generate.........: generates the ciaaRTOS
@echo rtostests........: run FreeOSEK conformace tests
@echo "+-----------------------------------------------------------------------------+"
@echo "| Unit Tests |"
@echo "+-----------------------------------------------------------------------------+"
@echo mocks............: generate the mocks for all header files
@echo tst..............: displays possible tests
@echo tst_\<mod\>........: shows all unit test of a specific module
@echo tst_\<mod\>_\<unit\>.: runs the specific unit test
@echo tst_\<mod\>_all....: runs all unit tests of a specific module
@echo results..........: create results report
@echo ci...............: run the continuous integration
@echo "+-----------------------------------------------------------------------------+"
@echo "| Debugging / Running / Programming |"
@echo "+-----------------------------------------------------------------------------+"
@echo run..............: execute the binary file (Win/Posix only)
@echo openocd..........: starts openocd for $(ARCH)
@echo download.........: download firmware to the target
@echo "+-----------------------------------------------------------------------------+"
@echo "| Bulding |"
@echo "+-----------------------------------------------------------------------------+"
@echo clean............: cleans generated, object, binary, etc. files
@echo clean_generate...: performs make clean and make generate
@echo all..............: performs make clean, make generate and make
@echo generate_make....: performs make generate and make
###############################################################################
# menuconfig
menuconfig:
@echo Starting Configurator
$(kconfig) modules$(DS)ciaak$(DS)etc$(DS)ciaaconfig.cfg
###############################################################################
# info for aspecific module
ifeq ($(findstring info_, $(MAKECMDGOALS)),info_)
info_mod = $(subst info_,,$(MAKECMDGOALS))
ext = 0
ifeq ($(findstring info_ext_, $(MAKECMDGOALS)),info_ext_)
info_mod = $(subst info_ext_,,$(MAKECMDGOALS))
ext = 1
endif
ifeq ($(ext),1)
# include corresponding makefile
include externals$(DS)$(info_mod)$(DS)mak$(DS)Makefile
else
# include corresponding makefile
include modules$(DS)$(info_mod)$(DS)mak$(DS)Makefile
endif
# create the corresponding info_<mod> rule
info_ext_$(info_mod) :
@echo ===============================================================================
@echo Info of ext_$(info_mod)
@echo Path........: $(ext_$(info_mod)_PATH)
@$(MULTILINE_ECHO) "Include path: \n $(foreach inc, $(ext_$(info_mod)_INC_PATH), $(inc)\n)"
@echo Source path.: $(ext_$(info_mod)_SRC_PATH)
@$(MULTILINE_ECHO) "Source files:\n $(foreach src, $(ext_$(info_mod)_SRC_FILES), $(src)\n)"
# create the corresponding info_<mod> rule
info_$(info_mod) :
@echo ===============================================================================
@echo Info of $(info_mod)
@echo Path........: $($(info_mod)_PATH)
@$(MULTILINE_ECHO) "Include path: \n $(foreach inc, $($(info_mod)_INC_PATH), $(inc)\n)"
@echo Source path.: $($(info_mod)_SRC_PATH)
@$(MULTILINE_ECHO) "Source files:\n $(foreach src, $($(info_mod)_SRC_FILES), $(src)\n)"
endif
###############################################################################
# information
info:
@echo "+-----------------------------------------------------------------------------+"
@echo "| Enable Config Info |"
@echo "+-----------------------------------------------------------------------------+"
@echo PROJECT............: $(PROJECT)
@echo ARCH/CPUTYPE/CPU...: $(ARCH)/$(CPUTYPE)/$(CPU)
@echo enable modules.....: $(MODS)
@echo libraries..........: $(LIBS)
@echo libraris with srcs.: $(LIBS_WITH_SRC)
# @echo Lib Src dirs.......: $(LIBS_SRC_DIRS)
# @echo Lib Src Files......: $(LIBS_SRC_FILES)
# @echo Lib Obj Files......: $(LIBS_OBJ_FILES)
# @echo Project Src Path...: $($(project)_SRC_PATH)
@echo Includes...........: $(INCLUDE)
@echo use make info_\<mod\>: to get information of a specific module. eg: make info_posix
@echo "+-----------------------------------------------------------------------------+"
@echo "| All available modules |"
@echo "+-----------------------------------------------------------------------------+"
@echo modules............: $(ALL_MODS)
@echo "+-----------------------------------------------------------------------------+"
@echo "| Compiler Info |"
@echo "+-----------------------------------------------------------------------------+"
@echo Compiler...........: $(COMPILER)
@echo CC.................: $(CC)
@echo AR.................: $(AR)
@echo LD.................: $(LD)
@echo Compile C Flags....: $(CFLAGS)
@echo Compile ASM Flags..: $(AFLAGS)
@echo Target Name........: $(TARGET_NAME)
@echo Src Files..........: $(SRC_FILES)
@echo Obj Files..........: $(OBJ_FILES)
@echo Linker Flags.......: $(LFLAGS)
@echo Linker Extension...: $(LD_EXTENSION)
@echo Linker Target......: $(LD_TARGET)
###############################################################################
# clean
.PHONY: clean generate all run
clean:
@echo Removing libraries
@rm -rf $(LIB_DIR)$(DS)*
@echo Removing bin files
@rm -rf $(BIN_DIR)$(DS)*
@echo Removing RTOS generated files
@rm -rf $(GEN_DIR)$(DS)*
@echo Removing mocks
@rm -rf $(MOCKS_OUT_DIR)$(DS)*
@echo Removing Unity Runners files
@rm -rf $(RUNNERS_OUT_DIR)$(DS)*
@echo Removing doxygen files
@rm -rf $(OUT_DIR)$(DS)doc$(DS)*
@echo Removing ci outputs
@rm -rf $(OUT_DIR)$(DS)ci$(DS)*
@echo Removing coverage
@rm -rf $(OUT_DIR)$(DS)coverage$(DS)*
@echo Removing object files
@rm -rf $(OBJ_DIR)$(DS)*
clean_rtostests:
@echo Removing RTOS Test generated project files
@rm -rf $(RTOS_TEST_GEN_DIR)$(DS)*
###############################################################################
# Generates docbook documentation
docbook:
xsltproc /usr/share/xml/docbook/stylesheet/docbook-xsl/fo/docbook.xsl doc/documentation.xml > out/docbook/documentation.fo
fop -fo out/docbook/documentation.fo -pdf out/docbook/documentation.pdf
###############################################################################
# clean and generate (IDE: Build Clean)
clean_generate: clean generate
###############################################################################
# Incremental Build (IDE: Build)
all: clean generate
make
###############################################################################
# generate and make (IDE: Generate and Make)
generate_make: generate
make
###############################################################################
# Run the bin file
run:
# if windows or posix shows an error
ifeq ($(subst win,yes,$(subst posix,yes,$(ARCH))),yes)
@echo ' '
@echo ===============================================================================
@echo Running the file: $(LD_TARGET)
$(LD_TARGET)
else
@echo ERROR: You can not run this binary due to you are not in Windows nor Linux ARCH
endif
###############################################################################
# Run all FreeOSEK Tests
rtostests:
mkdir -p $(OUT_DIR)$(DS)doc$(DS)ctest
@echo GDB:$(GDB) $(GFLAGS) > $(OUT_DIR)$(DS)doc$(DS)ctest$(DS)ctest.cnf
@echo CLEAN_GENERATE:$(RTOSTESTS_CLEAN_GENERATE) >> $(OUT_DIR)$(DS)doc$(DS)ctest$(DS)ctest.cnf
@echo BINDIR:$(BIN_DIR)>> $(OUT_DIR)$(DS)doc$(DS)ctest$(DS)ctest.cnf
@echo DEBUG_CTESTS:$(RTOSTESTS_DEBUG_CTESTS)>> $(OUT_DIR)$(DS)doc$(DS)ctest$(DS)ctest.cnf
@echo DIR:$(DS)>> $(OUT_DIR)$(DS)doc$(DS)ctest$(DS)ctest.cnf
@echo ARCH:$(ARCH)>> $(OUT_DIR)$(DS)doc$(DS)ctest$(DS)ctest.cnf
@echo CPUTYPE:$(CPUTYPE)>> $(OUT_DIR)$(DS)doc$(DS)ctest$(DS)ctest.cnf
@echo CPU:$(CPU)>> $(OUT_DIR)$(DS)doc$(DS)ctest$(DS)ctest.cnf
@echo RES:$(OUT_DIR)$(DS)rtos$(DS)doc$(DS)ctest$(DS)ctestresults.log>>$(OUT_DIR)$(DS)doc$(DS)ctest$(DS)ctest.cnf
@echo LOG:$(OUT_DIR)$(DS)rtos$(DS)doc$(DS)ctest$(DS)ctest.log>>$(OUT_DIR)$(DS)doc$(DS)ctest$(DS)ctest.cnf
@echo LOGFULL:$(OUT_DIR)$(DS)rtos$(DS)doc$(DS)ctest$(DS)ctestfull.log>>$(OUT_DIR)$(DS)doc$(DS)ctest$(DS)ctest.cnf
@echo TESTS:$(ROOT_DIR)$(DS)modules$(DS)rtos$(DS)tst$(DS)ctest$(DS)cfg$(DS)ctestcases.cfg>>$(OUT_DIR)$(DS)doc$(DS)ctest$(DS)ctest.cnf
@echo TESTCASES:$(ROOT_DIR)$(DS)modules$(DS)rtos$(DS)tst$(DS)ctest$(DS)cfg$(DS)testcases.cfg>>$(OUT_DIR)$(DS)doc$(DS)ctest$(DS)ctest.cnf
$(ROOT_DIR)$(DS)modules$(DS)rtos$(DS)tst$(DS)ctest$(DS)bin$(DS)ctest.pl -f $(OUT_DIR)$(DS)doc$(DS)ctest$(DS)ctest.cnf $(RTOSTESTS_CTEST) $(RTOSTESTS_SUBTEST)
###############################################################################
# run continuous integration
ci:
perl modules$(DS)tools$(DS)scripts$(DS)ci.pl
###############################################################################
# doc -> documentation
doc: doxygen
@echo Generating CIAA Firmware documentation
@echo This rule is still not implemented see: https://github.com/ciaa/Firmware/issues/10
@exit 1