]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blob - packages/ti/sdo/utils/makefile_gccArmLto.xdt
ipc: Remove compiler warnings
[ipc/ipcdev.git] / packages / ti / sdo / utils / makefile_gccArmLto.xdt
1 %%{
2 /*
3  * Copyright (c) 2013-2016, Texas Instruments Incorporated
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * *  Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  *
13  * *  Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * *  Neither the name of Texas Instruments Incorporated nor the names of
18  *    its contributors may be used to endorse or promote products derived
19  *    from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
25  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 %%}
34 %%{
35     var File = xdc.module("xdc.services.io.File");
37     var BIOS = xdc.module("ti.sysbios.BIOS");
39     var Build = xdc.module("ti.sdo.utils.Build");
41     var TARGET = $args[0];
43     var XDCROOT = String(environment['xdc.rootDir'] + '/packages/').replace(/\\/g, "/");
45     var XOPTS = '-I "' + XDCROOT + '"'
46         + " -Dxdc_target_types__=" + File.getDOSPath(TARGET.$package.packageRepository) + TARGET.stdInclude
47         + " -Dxdc_target_name__=" + TARGET.name;
49     var CGEN = TARGET.rootDir.replace(/\\/g, "/");
51     function baseName(path) {
52         return path.substr(path.lastIndexOf('/') + 1).replace(/\.[^\.]+$/, "");
53     }
55     function packageName(path) {
56         var dirpath = path.substring(0, path.lastIndexOf('/'));
57         return dirpath.substr(dirpath.lastIndexOf('/') + 1);
58     }
59     var OBJS = [];
60 %%}
61 vpath % `File.getDOSPath(this.$package.packageRepository) + "ti/sdo/"`
62 vpath %.c `XDCROOT`
64 CCOPTS    = `BIOS.getCCOpts(TARGET.$name)`
66 XDC_ROOT  = `XDCROOT`
68 BUILD_DEFS = `Build.getDefs()`
70 BIOS_INC  = -I"`xdc.getPackageRepository("ti.sysbios")`"
72 UTILS_INC    = -I"`xdc.getPackageRepository("ti.sdo.utils")`"
75 CC = `CGEN`/`TARGET.ccBin.cmd` $(CCOPTS) -I `CGEN`/arm-none-eabi/include
76 ASM = `CGEN`/`TARGET.asmBin.cmd` $(CCOPTS) -I `CGEN`/arm-none-eabi/include
77 AR = `CGEN`/`TARGET.arBin.cmd` `TARGET.ar.opts`
79 %if (environment["os.name"].match(/Windows.*/i)) {
80 %if (BIOS.buildingAppLib == false) {
81 %    Build.$private.libDir = Build.$private.libDir.replace(/\//g,'\\');
82 %}
83 DEL = cmd.exe /q /c del /f
84 CP = cmd.exe /q /c copy /Y
85 MKDIR = mkdir
86 %}
87 %else {
88 DEL = rm -f
89 CP = cp -f
90 MKDIR = mkdir -p
91 %}
93 define RM
94         $(if $(wildcard $1),$(DEL) $1,:)
95 endef
97 define ASSEMBLE
98         @echo asm`TARGET.suffix` $< ...
99         @$(ASM) $(BUILD_DEFS) `XOPTS` $(BIOS_INC) $<
100 endef
102 define COMPILE
103         @echo cl`TARGET.suffix` $< ...
104         @$(CC) $(BUILD_DEFS) `XOPTS` $(BIOS_INC) $(UTILS_INC) $<
105 endef
107 %var LIB = "utils.a" + TARGET.suffix;
109 %if (BIOS.buildingAppLib == false) {
110 all: `Build.$private.libDir``LIB`
111 %}
112 %else {
113 all: `LIB`
114 %}
116 %var sources = Build.getAsmFiles(TARGET.$name);
117 %for each (var s in sources) {
118 %    var obj = packageName(s) + "_" + baseName(s) + ".o";
119 %    OBJS.push(obj)
120 `obj`: `s` makefile
121         @-$(call RM, $@)
122         $(ASSEMBLE) -o `obj`
124 %}
126 %var sources = Build.getCFiles(TARGET.$name).split(' ');
127 %for each (var s in sources) {
128 %    var obj = packageName(s) + "_" + baseName(s) + ".o";
129 %    OBJS.push(obj)
130 `obj`: `s` makefile
131         @-$(call RM, `obj`)
132         $(COMPILE) -o `obj`
133 %}
135 `LIB`: `OBJS.join(" ")`
136         @echo ar`TARGET.suffix` $^ ...
137         @-$(call RM, $@)
138         @$(AR) $@ $^
140 %if (BIOS.buildingAppLib == false) {
141 `Build.$private.libDir``LIB`: `LIB`
142         @echo cp `LIB`
143         @-$(call RM, "`Build.$private.libDir``LIB`")
144         @$(CP) `LIB` "`Build.$private.libDir``LIB`"
145 %}
147 clean:
148         @-$(call RM, `LIB`)
149 %if (BIOS.buildingAppLib == false) {
150         @-$(call RM, "`Build.$private.libDir``LIB`")
151 %}
152 %if (TARGET.$name.match(/gnu/)) {
153         @-$(call RM, BIOS.o)
154 %}
155 %else {
156         @-$(call RM, BIOS.obj)
157 %}
158 %for (var i = 0; i < OBJS.length; i++) {
159         @-$(call RM, `OBJS[i]`)
160 %}
161 %if (Build.$private.libDir != null) {
163 # create output directories
164 ifneq ($(MAKECMDGOALS),clean)
165 ifeq ($(wildcard `Build.$private.libDir`),)
166     $(shell $(MKDIR) `Build.$private.libDir`)
167 endif
168 endif
169 %}