forked from DLR-SC/tasking-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
152 lines (130 loc) · 5.55 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
#
# Build tasking framework
#
# Copyright 2012-2020 German Aerospace Center (DLR) SC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
.PHONY : help doc lib clean depend test install
# Get platform specific sources for the scheduler
# IS_NONE_PLATFORM is switch for unit test checks working only on platform none
ifeq (none, $(platform))
schedulerFolder = $(wildcard arch/none)
CXXFLAGS += -Iarch/none -DIS_NONE_PLATFORM
else
ifeq (outpost, $(platform))
schedulerFolder = $(wildcard arch/outpost)
CXXFLAGS += -Iarch/outpost
CXXFLAGS += -Icontrib/outpost-core/modules/base/src
CXXFLAGS += -Icontrib/outpost-core/modules/rtos/arch/$(outpostArch)
CXXFLAGS += -Icontrib/outpost-core/modules/rtos/src
CXXFLAGS += -Icontrib/outpost-core/modules/time/src
else
ifeq (custom, $(platform))
else
platform = linux
schedulerFolder = $(wildcard arch/linux)
CXXFLAGS += -Iarch/linux
endif
endif
endif
# Find out object files of scheduler and convert to objects in build folder
schedulerSources= $(wildcard $(schedulerFolder)/*.cpp)
schedulerDependencies = $(patsubst $(schedulerFolder)/%,build/%,$(schedulerSources:.cpp=.d))
schedulerObjects = $(patsubst $(schedulerFolder)/%,build/%,$(schedulerSources:.cpp=.o))
# Find out object files of API and convert to objects in build folder
srcSources = $(wildcard src/*.cpp)
srcDependencies = $(patsubst src/%,build/%,$(srcSources:.cpp=.d))
srcObjects = $(patsubst src/%,build/%,$(srcSources:.cpp=.o))
testSource = $(wildcard test/*cpp)
testObjects = $(patsubst %,build/%,$(testSource:.cpp=.o))
# Setup includes and other flags for the build
CXXFLAGS += -Iinclude
help :
@echo "Targets for make:"
@echo " doc : Generates documentation of API"
@echo " depend : Generate dependancies for source files without platform option as"
@echo " Linux scheduler"
@echo " lib : Generates library without platform option as Linux scheduler"
@echo " Call 'make clean' if you generate for a different platform."
@echo " install : Generate the tasking directory with lib and include folder."
@echo " Platform option is necessary if it is different from Linux."
@echo " clean : Remove the build folder"
@echo " examples: Compile all examples"
@echo
@echo "Optional arguments"
@echo " platform = linux : Generate scheduler for Posix thread functionalities"
@echo " platform = none : Generate scheduler without any functionality, e.g. for"
@echo " unit tests"
@echo " platform = outpost : Generate scheduler for outpost thread functionalities"
@echo " Generating with outpost need to address the outpost architecture"
@echo " by setting outpostArch to one of freertos, none, posix, or rtems."
@echo " platform = custom : Generate without scheduler. The application software has"
@echo " to provide the scheduler interfaces and provide the"
@echo " include path in the CXXFLAGS."
# Generate lib file for the Tasking Framework
lib: $(schedulerObjects) $(srcObjects) | build/lib
@echo "<<<< Create lib for scheduler type $(platform) >>>>"
ar rcs build/lib/libtasking.a $(schedulerObjects) $(srcObjects)
# Generate an install folder to roll out
install: lib | build/tasking
@cp build/lib/libtasking.a build/tasking/lib/libtasking.a
@cp include/*.h build/tasking/include
@cp -r include/impl build/tasking/include/impl
ifneq ("$(platform)", "custom")
@cp $(schedulerFolder)/*.h build/tasking/include
endif
@cp LICENSE build/tasking
@echo "taskingVariant = $(platform)" > build/tasking/variant.mk
@echo "Tasking framework for $(platform) provided in folder build/tasking."
# Update dependencies
depend: $(srcDependencies) $(schedulerDependencies)
build/%.d: src/%.cpp | build
@$(CXX) -MM $(CXXFLAGS) $< > $@
@sed -i '1s/.*/build\/&/; $$s/.*/& | build/' $@
@echo -e "\t$(CXX) -c $(CXXFLAGS) $< -o $@" >> $@
@sed -i '$$s/\.d/.o/' $@
build/%.d: $(schedulerFolder)/%.cpp | build
@$(CXX) -MM $(CXXFLAGS) $< > $@
@sed -i '1s/.*/build\/&/; $$s/.*/& | build/' $@
@echo -e "\t$(CXX) -c $(CXXFLAGS) $< -o $@" >> $@
@sed -i '$$s/\.d/.o/' $@
# Generate unit tests (googletest required)
GOOGLE_TEST_INCLUDE = -Icontrib/googletest/include
test: build/testTasking
build/testTasking: lib $(testObjects) build/test/gtest-all.o | build/test
@echo "<<<< Generate unit tests >>>>"
$(CXX) $(CFLAGS) $(CXXFLAGS) $(GOOGLE_TEST_INCLUDE) \
$(wildcard build/test/*.o) \
-Lbuild/lib -ltasking -lpthread -o build/tasking_test
build/test/%.o: test/%.cpp | build/test
$(CXX) -c $(CFLAGS) $(CXXFLAGS) $(GOOGLE_TEST_INCLUDE) $< -o $@
build/test/gtest-all.o: contrib/googletest/src/gtest-all.cc | build/test
$(CXX) -c $(CFLAGS) $(CXXFLAGS) $(GOOGLE_TEST_INCLUDE) $< -o $@
# Generate documentation
doc : | build
@doxygen DoxyfileMake.in
# Cleaning compile results by removing build folder
clean :
@rm -r build
# Generate build folders if not existing
build/test: | build
@mkdir build/test
build/lib: | build
@mkdir build/lib
build/tasking: | build
mkdir build/tasking
mkdir build/tasking/lib
mkdir build/tasking/include
build:
@mkdir build
-include $(srcDependencies) $(schedulerDependencies)