]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - apps/tidep0084.git/blob - scripts/front_matter.mak
Updated TI Linux Sensor To Cloud to the latest TI 15.4-Stack v2.4, now with CC13x2...
[apps/tidep0084.git] / scripts / front_matter.mak
1 #############################################################
2 # @file front_matter.mak
3 #
4 # @brief TIMAC 2.0 Front/Boilerplate Makefile fragment
5 #
6 # Group: WCS LPC
7 # $Target Devices: Linux: AM335x, Embedded Devices: CC1310, CC1350$
8 #
9 #############################################################
10 # $License: BSD3 2016 $
11 #  
12 #   Copyright (c) 2015, Texas Instruments Incorporated
13 #   All rights reserved.
14 #  
15 #   Redistribution and use in source and binary forms, with or without
16 #   modification, are permitted provided that the following conditions
17 #   are met:
18 #  
19 #   *  Redistributions of source code must retain the above copyright
20 #      notice, this list of conditions and the following disclaimer.
21 #  
22 #   *  Redistributions in binary form must reproduce the above copyright
23 #      notice, this list of conditions and the following disclaimer in the
24 #      documentation and/or other materials provided with the distribution.
25 #  
26 #   *  Neither the name of Texas Instruments Incorporated nor the names of
27 #      its contributors may be used to endorse or promote products derived
28 #      from this software without specific prior written permission.
29 #  
30 #   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31 #   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
32 #   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33 #   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
34 #   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35 #   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36 #   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
37 #   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38 #   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
39 #   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
40 #   EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 #############################################################
42 # $Release Name: TI-15.4Stack Linux x64 SDK$
43 # $Release Date: July 14, 2016 (2.00.00.30)$
44 #############################################################
46 #========================================
47 #
48 # ===================
49 # Theory of Operation
50 # ===================
51 #
52 # This is a *makefile* fragment that works with two other files
53 # If you are creating a library, you use "library.mak"
54 # If you are creating an application, you use "app.mak"
55 #
56 # In total there are 5 parts to the complete makefile.
57 #
58 # Part #1 
59 #     The local makefile local to the application.
60 #     Another name for this is the "Primary Makefile"
61 #     When you invoke "make" the filename is "Makefile"
62 #     If you invoke "make -f FooBar" the filename is FooBar
63 #
64 #     That makefile must define APP_NAME, the name of the app.
65 #     Likewise LIB_NAME for a library
66 #
67 #     Early in that makefile, it does "include front_matter.mak"
68 #
69 #     APP Example: ${root}/example/collector/Makefile
70 #     LIB Example: ${root}/components/common/Makefile
71 #
72 # Part #2
73 #     Is exactly *THIS* makefile, the front or starting common stuff.
74 #     These are various rules, common macros etc
75 #
76 #     For example the macro: OBJDIR is set in front_matter.mak
77
78 #     Another example: this file defines how to compile C to OBJ files.
79 #
80 # Part #3
81 #     Is not a seperate makefile, is the *middle* section of the 
82 #     primary makefile, it is between the two statements:
83 #          'include front_matter.mak'
84 #     and: 'include app.mak'
85 #      or: 'include library.mak'
86 #  
87 #     This part lists the various source filenames
88 #     Possibly other things that are specific to the app or library
89 #     
90 #     For example the collector makefile has rules to compile protobuf files.
91 #
92 # Part #4
93 #     Is one of the "app.mak" or "library.mak" file.
94 #     If you build an app, you include app.mak
95 #     if you build a library, you include library.mak
96 #
97 #     The "app.mak" file defines how to link object files into an appliation.
98 #     Likewise, the "library.mak" combines multiple object files into a library 
99 #
100 # Part #5
101 #     Is the final portion of the primary Makefile
102 #     Specifically this is the part after the 'include app.mak' or 'include library.mak'
104 #     In this area, the library or application creates any additional rules
107 #========================================
108 # if HIDE is not defined then define it.
109 # to use this:
110 #     bash$  make  HIDE= -f Makefile
111 # or  bash$  make  HIDE= -f foo_test.mak
113 HIDE ?= @
114 #========================================
116 # Forcably use BASH, do not use /bin/dash
117 SHELL=/bin/bash
118 export SHELL
120 #========================================
121 # Help recursion, determine main makefilename
122 #----------------------------------------
123 # Determine the name of the 'main' makefile
124 main_MAKEFILE := ${firstword ${MAKEFILE_LIST}}
125 # If we call make recursively, we use name of the first makefile
126 recursive_MAKE := ${MAKE} -f ${main_MAKEFILE}
128 #========================================
129 # These *MAY* need to be adjusted to fit your SDK install.
130 # NOTE: The Boot loader also has a macro that may need updating.
131 # SEE: ${root}/example/cc13xx-sbl/app/linux/Makefile
132 #----------------------------------------
133 # What is the Processor SDK Root directory
134 #----------------------------------------
135 #bbb_TI_PROC_SDK_DIR=${HOME}/ti-processor-sdk-linux-am335x-evm-03.00.00.01
136 #bbb_TI_PROC_SDK_DIR=${HOME}/ti-processor-sdk-linux-am335x-evm-02.00.02.11
137 #bbb_TI_PROC_SDK_DIR=${HOME}/ti-processor-sdk-linux-am335x-evm-03.01.00.06
138 bbb_TI_PROC_SDK_DIR=${HOME}/ti-processor-sdk-linux-am335x-evm-04.02.00.09
140 #----------------------------------------
141 # Hint/Example: Make a symbolic link like this:
142 #      bash$ cd $HOME
143 #      bash$ rm -f cur_sdk
144 #      bash$ ln -s ti-processor-sdk-linux-am335x-evm-02.00.10.01 cur_sdk
145 # Thus:
146 #    $HOME/cur_sdk -> $HOME/ti-processor-sdk-linux-am335x-evm-02.00.10.01
147 #----------------------------------------
148 # Within the Processor SDK, we find the "bin" directory
149 # this is where all the GNU tools are located
150 bbb_BIN_DIR=${bbb_TI_PROC_SDK_DIR}/linux-devkit/sysroots/x86_64-arago-linux/usr/bin
151 # And we use this prefix to build the target.
152 bbb_PREFIX=${bbb_BIN_DIR}/arm-linux-gnueabihf-
155 # Note you could add others here if required..
157 #========================================
158 # Handle various ARCH configurations
159 #----------------------------------------
160 ALL_ARCHES        += bbb
161 bbb_ARCH          := bbb
162 bbb_GCC_EXE       := ${bbb_PREFIX}gcc 
163 bbb_ARCH_CFLAGS   += -mcpu=cortex-a8 -march=armv7-a -ffunction-sections
164 bbb_AR_EXE        := ${bbb_PREFIX}ar
165 bbb_OBJDUMP_EXE   := ${bbb_PREFIX}objdump
166 bbb_ARCH_LDFLAGS  += -Wl,--gc-sections
168 # Sanity check, is the compiler present? Y or N?
169 bbb_compiler_check:
170         @if [ "x${ARCH}x" == "xbbbx" ] ; \
171         then \
172                 if [ ! -x ${bbb_GCC_EXE} ] ; \
173                 then \
174                         echo "Cannot find BBB Compiler: ${bbb_GCC_EXE}" ; \
175                         echo "Please update variable: bbb_TI_PROC_SDK_DIR" ; \
176                         echo "in the file SDK_ROOT/scripts/front_matter.mak" ; \
177                         echo "ERROR: Cannot continue" ; \
178                         exit 1 ; \
179                 fi ; \
180         fi
182 .PHONY:: bbb_compiler_check
184 ALL_ARCHES         += host
185 host_ARCH          := host
186 host_GCC_EXE       := gcc
187 host_AR_EXE        := ar
188 host_OBJDUMP_EXE   := objdump
189 host_ARCH_LDFLAGS  += -Wl,--gc-sections
190 host_ARCH_CFLAGS   += -ffunction-sections
192 ALL_ARCHES         += klockwork
193 klockwork_ARCH     := klockwork
194 KWRAP_OUTPUT       ?= `pwd`/objs/klockwork/kwrap.output
197 klockwork_GCC_EXE       := kwwrap -o ${KWRAP_OUTPUT} gcc
198 klockwork_AR_EXE        := kwwrap -o ${KWRAP_OUTPUT} ar
199 klockwork_OBJDUMP_EXE   := objdump
200 klockwork_ARCH_LDFLAGS  += -Wl,--gc-sections
201 klockwork_ARCH_CFLAGS   += -ffunction-sections
203 # Add others here if required
205 #========================================
206 # Command line goals, the main make target
207 #---------------------------------------
208 # What is the first target word on the cmdline?
209 _word_zero  := $(firstword $(MAKECMDGOALS))
210 # What is the rest of the command line goals?
211 _word_rest  := $(wordlist 2,999,$(MAKECMDGOALS))
213 #========================================
214 # Do we build the default ARCH?
215 # If so... the target is the host version only!
216 #----------------------------------------
217 ifeq (${_word_zero},)
218 _word_zero := host
219 endif
221 ARCH      := ${${_word_zero}_ARCH}
223 #----------------------------------------
224 # if ARCH is blank.. define to all arches
225 ifeq (x${ARCH}x,xx)
226 ARCH      = all_arches
227 endif
229 #----------------------------------------
230 # Select GCC for the all arch situation
231 # We use /bin/false because these will
232 # simulate an error
233 all_arches_GCC_EXE      := /bin/false
234 all_arches_AR_EXE       := /bin/false
235 all_arches_ARCH_CFLAGS  :=
238 #========================================
239 # Where do we put things? & Select final names.
240 #----------------------------------------
241 OBJDIR       := objs/${ARCH}
242 GCC_EXE      := ${${ARCH}_GCC_EXE}
243 AR_EXE       := ${${ARCH}_AR_EXE}
244 OBJDUMP_EXE  := ${${ARCH}_OBJDUMP_EXE}
245 ARCH_CFLAGS  := ${${ARCH}_ARCH_CFLAGS}
246 ARCH_LDFLAGS := ${${ARCH}_ARCH_LDFLAGS}
248 #========================================
249 # Default targets for bbb and host targets
251 host:
252         ${recursive_MAKE} ARCH=host ${_word_rest}
254 bbb:
255         ${recursive_MAKE} ARCH=bbb ${_word_rest}
257 klockwork:
258         ${recursive_MAKE} ARCH=klockwork ${_word_rest}
260 # Clean and rebuild.
261 remake:
262         ${recursive_MAKE} ARCH=${ARCH} clean
263         ${recursive_MAKE} 
265 ${OBJDIR}:
266         mkdir -p $@
268 #========================================
269 # Compliation rules
270 #----------------------------------------
271 # FUTURE: Add C++ rules, and ASM rules
273 CFLAGS_STRICT= -Wshadow -Wpointer-arith -Wcast-qual 
274 CFLAGS +=-Wall -Wmissing-prototypes -Wstrict-prototypes -Iinc 
276 # Compile
277 #  NOTE: "-MMD" and "-MF" create compiler dependancy files
278 #        Which we load below with an include statement.
279 ${OBJDIR}/%.o: %.c
280         ${HIDE}mkdir -p ${OBJDIR}
281         ${HIDE}echo "Compling: $<"
282         ${HIDE}${GCC_EXE} -g -c ${CFLAGS} ${ARCH_CFLAGS} -MP -MMD -MF ${OBJDIR}/${*F}.d -o ${OBJDIR}/${@F} $<
284 ${OBJDIR}/%.o: linux/%.c
285         ${HIDE}mkdir -p ${OBJDIR}
286         ${HIDE}echo "Compling: $<"
287         ${HIDE}${GCC_EXE} -g -c ${CFLAGS} ${ARCH_CFLAGS} -MP -MMD -MF ${OBJDIR}/${*F}.d -o ${OBJDIR}/${@F} $<
290 ${OBJDIR}/%.o: src/%.c
291         ${HIDE}mkdir -p ${OBJDIR}
292         ${HIDE}echo "Compling: $<"
293         ${HIDE}${GCC_EXE} -g -c ${CFLAGS} ${ARCH_CFLAGS} -MP -MMD -MF ${OBJDIR}/${*F}.d -o ${OBJDIR}/${@F} $<
295 # Preprocess only
296 ${OBJDIR}/%.i: %.c
297         ${HIDE}mkdir -p ${OBJDIR}
298         ${HIDE}echo "Compling: $<"
299         ${HIDE}${GCC_EXE} -g -E ${CFLAGS} ${ARCH_CFLAGS} -o ${@D} $<
301 # Preprocess only
302 ${OBJDIR}/%.i: linux/%.c
303         ${HIDE}mkdir -p ${OBJDIR}
304         ${HIDE}echo "Compling: $<"
305         ${HIDE}${GCC_EXE} -g -E ${CFLAGS} ${ARCH_CFLAGS} -o ${@D} $<
307 # Preprocess only
308 ${OBJDIR}/%.i: src/%.c
309         ${HIDE}mkdir -p ${OBJDIR}
310         ${HIDE}echo "Compling: $<"
311         ${HIDE}${GCC_EXE} -g -E ${CFLAGS} ${ARCH_CFLAGS} -o ${@D} $<
314 # Generate assembler
315 ${OBJDIR}/%.s: %.c
316         ${HIDE}mkdir -p ${OBJDIR}
317         ${HIDE}echo "Compling: $<"
318         ${HIDE}${GCC_EXE} -g -S ${CFLAGS} ${ARCH_CFLAGS} -o ${@D} $<
320 ${OBJDIR}/%.s: linux/%.c
321         ${HIDE}mkdir -p ${OBJDIR}
322         ${HIDE}echo "Compling: $<"
323         ${HIDE}${GCC_EXE} -g -S ${CFLAGS} ${ARCH_CFLAGS} -o ${@D} $<
325 ${OBJDIR}/%.s: src/%.c
326         ${HIDE}mkdir -p ${OBJDIR}
327         ${HIDE}echo "Compling: $<"
328         ${HIDE}${GCC_EXE} -g -S ${CFLAGS} ${ARCH_CFLAGS} -o ${@D} $<
331 #========================================
332 # Load any generated dependancies
333 -include ${OBJDIR}/*.d
335 generated_files::
337 .PHONY:: generated_files
339 #========================================
340 # Debug, determine the value of macro like this:
341
342 #  bash$  make  whatis_OBJDIR
343 #  bash$  make  whatis_GCC_EXE
345 whatis_%:
346         @echo ""
347         @echo "Var:  $*  => ${${*}}"
348         @echo ""
350 #========================================
351 # Simple target to force somethings to happen
352 force:
354 .PHONY:: force
356 #========================================
357 # How do we cleanup or mess?
358 #----------------------------------------
359 ifeq (${ARCH},all_arches)
360 clean:: ${ALL_ARCHES:%=clean.%}
361         ${HIDE}rm -f *.bak
362         ${HIDE}rm -f *~
363         ${HIDE}echo "Clean done"
365 clean.%:
366         ${recursive_MAKE} ARCH=$* clean
367 else
368 clean::
369         ${HIDE}echo "Cleaning: ${OBJDIR} ..."
370         ${HIDE}rm -rf ${OBJDIR}
372 endif
374 #  ========================================
375 #  Texas Instruments Micro Controller Style
376 #  ========================================
377 #  Local Variables:
378 #  mode: makefile-gmake
379 #  End:
380 #  vim:set  filetype=make