makefile: Cleanup to move host executable to board specific
[processor-sdk/big-data-ipc-examples.git] / host_bios / simple_buffer_example / host / makefile
1 #
2 #  Copyright (c) 2012-2014 Texas Instruments Incorporated - http://www.ti.com
3 #  All rights reserved.
4 #
5 #  Redistribution and use in source and binary forms, with or without
6 #  modification, are permitted provided that the following conditions
7 #  are met:
8 #
9 #  *  Redistributions of source code must retain the above copyright
10 #     notice, this list of conditions and the following disclaimer.
11 #
12 #  *  Redistributions in binary form must reproduce the above copyright
13 #     notice, this list of conditions and the following disclaimer in the
14 #     documentation and/or other materials provided with the distribution.
15 #
16 #  *  Neither the name of Texas Instruments Incorporated nor the names of
17 #     its contributors may be used to endorse or promote products derived
18 #     from this software without specific prior written permission.
19 #
20 #  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 #  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 #  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 #  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 #  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 #  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 #  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 #  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 #  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 #  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 #  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #
33 #
34 #  ======== makefile ========
35 #
37 EXBASE = ..
38 include $(EXBASE)/products.mak
40 srcs = MainHost.c App.c
41 objs = $(addprefix bin/$(BOARD_NAME)/$(PROFILE)/obj/,$(patsubst %.c,%.oa15fg,$(srcs)))
42 CONFIG = bin/$(BOARD_NAME)/$(PROFILE)/configuro
44 HOSTOS = bios
45 locallibsrcs = shared/bigdataxlat/$(HOSTOS)/bigdataxlat.c
46 locallibobjs = $(addprefix bin/shared/$(PLATFORM)/$(PROFILE)/obj/,$(patsubst %.c,%.oa15fg,$(locallibsrcs)))
48 -include $(addprefix bin/$(BOARD_NAME)/$(PROFILE)/obj/,$(patsubst %.c,%.oa15fg.dep,$(srcs)))
49 -include $(addprefix bin/shared/$(PLATFORM)/$(PROFILE)/obj/,$(patsubst %.c,%.oa15fg.dep,$(locallibsrcs)))
51 .PRECIOUS: %/compiler.opt %/linker.cmd
53 all: release
54 #all: debug
56 release:
57         $(MAKE) PROFILE=release app_host.x
59 debug:
60         $(MAKE) PROFILE=debug app_host.x
62 app_host.x: bin/$(BOARD_NAME)/$(PROFILE)/app_host.xa15fg
63 bin/$(BOARD_NAME)/$(PROFILE)/app_host.xa15fg: $(objs) $(locallibobjs) $(libs) $(CONFIG)/linker.cmd
64         @$(ECHO) "#"
65         @$(ECHO) "# Making $@ ..."
66         $(LD) -o $@ $(LDFLAGS) $(objs) $(locallibobjs) $(libs) -Wl,-T,$(CONFIG)/linker.cmd \
67                 -lgcc -lc -lm -lnosys $(LDLIBS)
69 bin/$(BOARD_NAME)/$(PROFILE)/obj/%.oa15fg: %.c $(CONFIG)/compiler.opt
70         @$(ECHO) "#"
71         @$(ECHO) "# Making $@ ..."
72         $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $<
74 bin/shared/$(PLATFORM)/$(PROFILE)/obj/%.oa15fg: ../%.c $(CONFIG)/compiler.opt
75         @$(ECHO) "#"
76         @$(ECHO) "# Making $@ ..."
77         $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $<
79 %/compiler.opt: %/linker.cmd ;
80 %/linker.cmd: Host.cfg ../shared/$(PLATFORM)/config.bld
81         @$(ECHO) "#"
82         @$(ECHO) "# Making $@ ..."
83         $(XDC_INSTALL_DIR)/xs --xdcpath="$(subst +,;,$(PKGPATH))" \
84             xdc.tools.configuro -o $(CONFIG) \
85             -t gnu.targets.arm.A15F \
86             -c $(gnu.targets.arm.A15F) \
87             -p $(HOST_PLATFORM) \
88             -b ../shared/$(PLATFORM)/config.bld -r release \
89             --cfgArgs "{ \
90                 procnamelist: [$(PROC_NAME_LIST)], \
91                 procname: \"$(PROC_HOST_NAME)\", \
92                 boardname: \"$(BOARD_NAME)\", \
93                 profile: \"$(PROFILE)\" \
94             }" \
95             Host.cfg
97 install:
98         @$(ECHO) "#"
99         @$(ECHO) "# Making $@ ..."
100 #       @$(MKDIR) $(EXEC_DIR)/debug
101 #       $(CP) bin/$(PLATFORM)/debug/app_host.xa15fg $(EXEC_DIR)/debug
102         @$(MKDIR) $(EXEC_DIR)/release
103         $(CP) bin/$(BOARD_NAME)/release/app_host.xa15fg $(EXEC_DIR)/release
105 help:
106         @$(ECHO) "make                   # build executable"
107         @$(ECHO) "make clean             # clean everything"
109 clean::
110         $(RMDIR) bin
112 PKGPATH := $(BIOS_INSTALL_DIR)/packages
113 PKGPATH := $(PKGPATH)+$(IPC_INSTALL_DIR)/packages
114 PKGPATH := $(PKGPATH)+$(XDC_INSTALL_DIR)/packages
115 PKGPATH := $(PKGPATH)+$(PDK_INSTALL_DIR)
118 #  ======== install validation ========
119 ifeq (install,$(MAKECMDGOALS))
120 ifeq (,$(EXEC_DIR))
121 $(error must specify EXEC_DIR)
122 endif
123 endif
125 #  ======== toolchain macros ========
126 CC = $(gnu.targets.arm.A15F)/bin/arm-none-eabi-gcc -c -MD -MF $@.dep
127 LD = $(gnu.targets.arm.A15F)/bin/arm-none-eabi-gcc
129 CPPFLAGS = -Dfar= -D__DYNAMIC_REENT__
130 CFLAGS = -Wall -Wunused -Wunknown-pragmas -ffunction-sections -fdata-sections $(CCPROFILE_$(PROFILE)) @$(CONFIG)/compiler.opt -I.
131 CFLAGS += -I../shared/bigdataxlat/bios
132 CFLAGS += -DSERVER=\"$(SERVER)\" -DPLATFORM_$(PLATFORM)
134 LDFLAGS = $(LDPROFILE_$(PROFILE)) -mfloat-abi=hard -nostartfiles -Wl,-static -Wl,--gc-sections -Wl,-Map=$(@D)/obj/$(@F).map
135 LDLIBS = -L$(BIOS_INSTALL_DIR)/packages/gnu/targets/arm/libs/install-native/arm-none-eabi/lib/fpu
137 CCPROFILE_debug = -g -ggdb -D_DEBUG_=1
138 CCPROFILE_release = -O2
140 LDPROFILE_debug = -g -ggdb
141 LDPROFILE_release =
143 #  ======== standard macros ========
144 ifneq (,$(wildcard $(XDC_INSTALL_DIR)/bin/echo.exe))
145     # use these on Windows
146     CP      = $(XDC_INSTALL_DIR)/bin/cp
147     ECHO    = $(XDC_INSTALL_DIR)/bin/echo
148     MKDIR   = $(XDC_INSTALL_DIR)/bin/mkdir -p
149     RM      = $(XDC_INSTALL_DIR)/bin/rm -f
150     RMDIR   = $(XDC_INSTALL_DIR)/bin/rm -rf
151 else
152     # use these on Linux
153     CP      = cp
154     ECHO    = echo
155     MKDIR   = mkdir -p
156     RM      = rm -f
157     RMDIR   = rm -rf
158 endif
160 #  ======== create output directories ========
161 ifneq (clean,$(MAKECMDGOALS))
162 ifneq (,$(PROFILE))
163 ifeq (,$(wildcard bin/$(BOARD_NAME)/$(PROFILE)/obj))
164     $(shell $(MKDIR) -p bin/$(BOARD_NAME)/$(PROFILE)/obj)
165 endif
166 ifeq (,$(wildcard bin/shared/$(PLATFORM)/$(PROFILE)/obj/shared/bigdataxlat/bios))
167     $(shell $(MKDIR) -p bin/shared/$(PLATFORM)/$(PROFILE)/obj/shared/bigdataxlat/bios)
168 endif
169 endif
170 endif