lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | # |
| 2 | # (C) Copyright 2000 |
| 3 | # Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | # |
| 5 | # See file CREDITS for list of people who contributed to this |
| 6 | # project. |
| 7 | # |
| 8 | # This program is free software; you can redistribute it and/or |
| 9 | # modify it under the terms of the GNU General Public License as |
| 10 | # published by the Free Software Foundation; either version 2 of |
| 11 | # the License, or (at your option) any later version. |
| 12 | # |
| 13 | # This program is distributed in the hope that it will be useful, |
| 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | # GNU General Public License for more details. |
| 17 | # |
| 18 | # You should have received a copy of the GNU General Public License |
| 19 | # along with this program; if not, write to the Free Software |
| 20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | # MA 02111-1307 USA |
| 22 | # |
| 23 | |
| 24 | ######################################################################### |
| 25 | |
| 26 | # clean the slate ... |
| 27 | PLATFORM_RELFLAGS = |
| 28 | PLATFORM_CPPFLAGS = |
| 29 | PLATFORM_LDFLAGS = |
| 30 | |
| 31 | # |
| 32 | # When cross-compiling on NetBSD, we have to define __PPC__ or else we |
| 33 | # will pick up a va_list declaration that is incompatible with the |
| 34 | # actual argument lists emitted by the compiler. |
| 35 | # |
| 36 | # [Tested on NetBSD/i386 1.5 + cross-powerpc-netbsd-1.3] |
| 37 | |
| 38 | ifeq ($(ARCH),ppc) |
| 39 | ifeq ($(CROSS_COMPILE),powerpc-netbsd-) |
| 40 | PLATFORM_CPPFLAGS+= -D__PPC__ |
| 41 | endif |
| 42 | ifeq ($(CROSS_COMPILE),powerpc-openbsd-) |
| 43 | PLATFORM_CPPFLAGS+= -D__PPC__ |
| 44 | endif |
| 45 | endif |
| 46 | |
| 47 | ifeq ($(ARCH),arm) |
| 48 | ifeq ($(CROSS_COMPILE),powerpc-netbsd-) |
| 49 | PLATFORM_CPPFLAGS+= -D__ARM__ |
| 50 | endif |
| 51 | ifeq ($(CROSS_COMPILE),powerpc-openbsd-) |
| 52 | PLATFORM_CPPFLAGS+= -D__ARM__ |
| 53 | endif |
| 54 | endif |
| 55 | |
| 56 | ifeq ($(strip $(board)),$(filter $(board),mdl_mini mifi_mini)) |
| 57 | PLATFORM_CPPFLAGS+= -DV3E_NOR_FLASH |
| 58 | endif |
| 59 | |
| 60 | ifeq ($(strip $(board)),$(filter $(board),cpe)) |
| 61 | PLATFORM_CPPFLAGS+= -DCONFIG_ZX297520V3E_CPE |
| 62 | endif |
| 63 | |
| 64 | ifeq ($(strip $(board)),$(filter $(board),ufi_mini)) |
| 65 | PLATFORM_CPPFLAGS+= -DCONFIG_ZX297520V3_UFI_MINI_32K_NOR |
| 66 | endif |
| 67 | |
| 68 | ifeq ($(strip $(board)),$(filter $(board),mdl_ab)) |
| 69 | PLATFORM_CPPFLAGS+= -DCONFIG_ZX297520V3E_MDL_AB |
| 70 | endif |
| 71 | |
| 72 | ifeq ($(strip $(board)),$(filter $(board),vehicle_dc)) |
| 73 | PLATFORM_CPPFLAGS+= -DCONFIG_ZX297520V3E_VEHICLE_DC |
| 74 | endif |
| 75 | |
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 76 | ifeq ($(strip $(board)),$(filter $(board),vehicle_dc_ref)) |
| 77 | PLATFORM_CPPFLAGS+= -DCONFIG_ZX297520V3E_VEHICLE_DC_REF |
| 78 | endif |
| 79 | |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 80 | ifdef ARCH |
| 81 | sinclude $(TOPDIR)/$(ARCH)_config.mk # include architecture dependend rules |
| 82 | endif |
| 83 | ifdef CPU |
| 84 | sinclude $(TOPDIR)/cpu/$(CPU)/config.mk # include CPU specific rules |
| 85 | endif |
| 86 | ifdef VENDOR |
| 87 | BOARDDIR = $(VENDOR)/$(BOARD) |
| 88 | else |
| 89 | BOARDDIR = $(BOARD) |
| 90 | endif |
| 91 | ifdef BOARD |
| 92 | sinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk # include board specific rules |
| 93 | endif |
| 94 | |
| 95 | ######################################################################### |
| 96 | |
| 97 | CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ |
| 98 | else if [ -x /bin/bash ]; then echo /bin/bash; \ |
| 99 | else echo sh; fi ; fi) |
| 100 | |
| 101 | ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc) |
| 102 | HOSTCC = cc |
| 103 | else |
| 104 | HOSTCC = gcc |
| 105 | endif |
| 106 | HOSTCFLAGS = -Wall -Wstrict-prototypes -O0 -fomit-frame-pointer #zhouqi |
| 107 | HOSTSTRIP = strip |
| 108 | |
| 109 | ######################################################################### |
| 110 | # |
| 111 | # Option checker (courtesy linux kernel) to ensure |
| 112 | # only supported compiler options are used |
| 113 | # |
| 114 | cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \ |
| 115 | > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;) |
| 116 | |
| 117 | # |
| 118 | # Include the make variables (CC, etc...) |
| 119 | # |
| 120 | AS = $(CROSS_COMPILE)as |
| 121 | LD = $(CROSS_COMPILE)ld |
| 122 | CC = $(CROSS_COMPILE)gcc |
| 123 | CPP = $(CC) -E |
| 124 | AR = $(CROSS_COMPILE)ar |
| 125 | NM = $(CROSS_COMPILE)nm |
| 126 | STRIP = $(CROSS_COMPILE)strip |
| 127 | OBJCOPY = $(CROSS_COMPILE)objcopy |
| 128 | OBJDUMP = $(CROSS_COMPILE)objdump |
| 129 | RANLIB = $(CROSS_COMPILE)RANLIB |
| 130 | |
| 131 | RELFLAGS= $(PLATFORM_RELFLAGS) |
| 132 | DBGFLAGS= -g # -DDEBUG |
| 133 | OPTFLAGS= -Os #-fomit-frame-pointer |
| 134 | ifndef LDSCRIPT |
| 135 | #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/z-load.lds.debug |
| 136 | LDSCRIPT := $(TOPDIR)/cpu/$(CPU)/z-load.lds |
| 137 | endif |
| 138 | OBJCFLAGS += --gap-fill=0xff |
| 139 | |
| 140 | gccincdir := $(shell $(CC) -print-file-name=include) |
| 141 | |
| 142 | CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS) \ |
| 143 | -D__KERNEL__ -DTEXT_BASE=$(TEXT_BASE) \ |
| 144 | -D _CHIP_ZX297520V3 \ |
| 145 | -I$(TOPDIR)/include \ |
| 146 | -I$(TOPDIR)/../../../../pub/project/zx297520v3/include/drv \ |
| 147 | -I$(TOPDIR)/../../../../pub/project/zx297520v3/include/infra \ |
| 148 | -I$(TOPDIR)/../../../../pub/project/zx297520v3/include/psm \ |
| 149 | -I$(TOPDIR)/../../../../pub/include/infra \ |
| 150 | -fno-builtin -ffreestanding -nostdinc -isystem \ |
| 151 | $(gccincdir) -pipe $(PLATFORM_CPPFLAGS) |
| 152 | |
| 153 | ifdef BUILD_TAG |
| 154 | CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes \ |
| 155 | -DBUILD_TAG='"$(BUILD_TAG)"' |
| 156 | else |
| 157 | CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes |
| 158 | endif |
| 159 | |
| 160 | AFLAGS_DEBUG := -Wa,-gstabs |
| 161 | AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS) |
| 162 | |
| 163 | LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS) -nostdlib |
| 164 | |
| 165 | # Location of a usable BFD library, where we define "usable" as |
| 166 | # "built for ${HOST}, supports ${TARGET}". Sensible values are |
| 167 | # - When cross-compiling: the root of the cross-environment |
| 168 | # - Linux/ppc (native): /usr |
| 169 | # - NetBSD/ppc (native): you lose ... (must extract these from the |
| 170 | # binutils build directory, plus the native and U-Boot include |
| 171 | # files don't like each other) |
| 172 | # |
| 173 | # So far, this is used only by tools/gdb/Makefile. |
| 174 | |
| 175 | ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc) |
| 176 | BFD_ROOT_DIR = /usr/local/tools |
| 177 | else |
| 178 | ifeq ($(HOSTARCH),$(ARCH)) |
| 179 | # native |
| 180 | BFD_ROOT_DIR = /usr |
| 181 | else |
| 182 | #BFD_ROOT_DIR = /LinuxPPC/CDK # Linux/i386 |
| 183 | #BFD_ROOT_DIR = /usr/pkg/cross # NetBSD/i386 |
| 184 | BFD_ROOT_DIR = /opt/powerpc |
| 185 | endif |
| 186 | endif |
| 187 | |
| 188 | ######################################################################### |
| 189 | |
| 190 | export CONFIG_SHELL HPATH HOSTCC HOSTCFLAGS CROSS_COMPILE \ |
| 191 | AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP \ |
| 192 | MAKE |
| 193 | export TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS |
| 194 | |
| 195 | ######################################################################### |
| 196 | |
| 197 | %.s: %.S |
| 198 | $(CPP) $(AFLAGS) -o $@ $(CURDIR)/$< |
| 199 | %.o: %.S |
| 200 | $(CC) $(AFLAGS) -c -o $@ $(CURDIR)/$< |
| 201 | %.o: %.c |
| 202 | $(CC) $(CFLAGS) -c -o $@ $< |
| 203 | |
| 204 | .depend: Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c) $(AOBJS:.o=.S) $(START:.o=.S) $(COBJS:.o=.c) |
| 205 | $(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) | \ |
| 206 | sed -e "s/\:/\\\:/g"|sed -e "s/\\\: /\: /g"> $@ |
| 207 | |
| 208 | ######################################################################### |