Niranjan Yadla | 19336af | 2018-04-19 12:19:27 -0700 | [diff] [blame] | 1 | # |
| 2 | # Copyright (C) 2018 Cadence Design Systems, Inc. |
| 3 | # |
| 4 | # Permission is hereby granted, free of charge, to any person obtaining |
| 5 | # a copy of this software and associated documentation files (the |
| 6 | # "Software"), to use this Software with Cadence processor cores only and |
| 7 | # not with any other processors and platforms, subject to |
| 8 | # the following conditions: |
| 9 | # |
| 10 | # The above copyright notice and this permission notice shall be included |
| 11 | # in all copies or substantial portions of the Software. |
| 12 | # |
| 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 14 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 15 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 16 | # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 17 | # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 18 | # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 19 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 20 | # |
| 21 | |
| 22 | QUIET = |
| 23 | MAPFILE = map_$(CODEC_NAME).txt |
| 24 | LDSCRIPT = ldscript_$(CODEC_NAME).txt |
| 25 | SYMFILE = symbols_$(CODEC_NAME).txt |
| 26 | ELFTOBIN = $(ROOTDIR)/build_hikey/tools/elftobin.sh |
| 27 | |
| 28 | ifeq ($(CPU), gcc) |
| 29 | S = / |
| 30 | AR = ar |
| 31 | OBJCOPY = objcopy |
| 32 | CC = gcc |
| 33 | CXX = g++ |
| 34 | CFLAGS += -fno-exceptions -DCSTUB=1 |
| 35 | CFLAGS += -ffloat-store |
| 36 | CFLAGS += -DHIFI3_CSTUB |
| 37 | RM = rm -f |
| 38 | RM_R = rm -rf |
| 39 | MKPATH = mkdir -p |
| 40 | CP = cp -f |
| 41 | INCLUDES += \ |
| 42 | -I$(ROOTDIR)/test/include |
| 43 | else |
| 44 | AR = xt-ar $(XTCORE) |
| 45 | OBJCOPY = xt-objcopy $(XTCORE) |
| 46 | CC = xt-xcc $(XTCORE) |
| 47 | CXX = xt-xc++ $(XTCORE) |
| 48 | ISS = xt-run $(XTCORE) |
| 49 | CONFIGDIR := $(shell $(ISS) --show-config=config) |
| 50 | include $(CONFIGDIR)/misc/hostenv.mk |
| 51 | #CFLAGS += -Wall |
| 52 | #CFLAGS += -Werror |
| 53 | #CFLAGS += -mno-mul16 -mno-mul32 -mno-div32 -fsigned-char -fno-exceptions -mlongcalls -INLINE:requested -mcoproc -fno-zero-initialized-in-bss |
| 54 | CFLAGS += -mlongcalls -mtext-section-literals |
| 55 | ASMFLAGS += -mlongcalls |
| 56 | endif |
| 57 | |
| 58 | OBJDIR = objs$(S)$(CODEC_NAME) |
| 59 | LIBDIR = $(ROOTDIR)$(S)lib |
| 60 | |
| 61 | OBJ_LIBO2OBJS = $(addprefix $(OBJDIR)/,$(LIBO2OBJS)) |
| 62 | OBJ_LIBOSOBJS = $(addprefix $(OBJDIR)/,$(LIBOSOBJS)) |
| 63 | OBJ_LIBO2CPPOBJS = $(addprefix $(OBJDIR)/,$(LIBO2CPPOBJS)) |
| 64 | OBJ_LIBOSCPPOBJS = $(addprefix $(OBJDIR)/,$(LIBOSCPPOBJS)) |
| 65 | OBJ_LIBASMOBJS = $(addprefix $(OBJDIR)/,$(LIBASMOBJS)) |
| 66 | |
| 67 | TEMPOBJ = temp.o |
| 68 | |
| 69 | ifeq ($(CPU), gcc) |
| 70 | LIBOBJ = $(OBJDIR)/xgcc_$(CODEC_NAME).o |
| 71 | LIB = xgcc_$(CODEC_NAME).img |
| 72 | else |
| 73 | LIBOBJ = $(OBJDIR)/xa_$(CODEC_NAME).o |
| 74 | LIB = xa_$(CODEC_NAME).img |
| 75 | endif |
| 76 | |
| 77 | CFLAGS += \ |
| 78 | $(EXTRA_CFLAGS) $(EXTRA_CFLAGS2) |
| 79 | |
| 80 | |
| 81 | ifeq ($(DEBUG),1) |
| 82 | NOSTRIP = 1 |
| 83 | OPT_O2 = -O0 -g |
| 84 | OPT_OS = -O0 -g |
| 85 | CFLAGS += -DDEBUG |
| 86 | else |
| 87 | ifeq ($(CPU), gcc) |
| 88 | OPT_O2 = -O2 -g |
| 89 | OPT_OS = -O2 -g |
| 90 | else |
| 91 | #OPT_O2 = -O3 -LNO:simd |
| 92 | OPT_O2 = -g -O2 |
| 93 | OPT_OS = -Os |
| 94 | endif |
| 95 | endif |
| 96 | |
| 97 | OPT_ASM = -g -Wa,--gdwarf-2 |
| 98 | |
| 99 | |
| 100 | all: $(OBJDIR) $(LIB) |
| 101 | $(CODEC_NAME): $(OBJDIR) $(LIB) |
| 102 | |
| 103 | install: $(LIB) |
| 104 | @echo "Installing $(LIB)" |
| 105 | $(QUIET) -$(MKPATH) "$(LIBDIR)" |
| 106 | $(QUIET) $(CP) $(LIB) "$(LIBDIR)" |
| 107 | |
| 108 | $(OBJDIR): |
| 109 | $(QUIET) -$(MKPATH) $@ |
| 110 | |
| 111 | ifeq ($(NOSTRIP), 1) |
| 112 | $(LIBOBJ): $(OBJ_LIBO2OBJS) $(OBJ_LIBOSOBJS) $(OBJ_LIBO2CPPOBJS) $(OBJ_LIBOSCPPOBJS) $(OBJ_LIBASMOBJS) $(PLUGINLIBS) |
| 113 | @echo "Linking Objects" |
| 114 | $(QUIET) $(CXX) -c $(OPT_O2) $(CFLAGS) -o $@ $^ \ |
| 115 | -Wl,-Map,$(MAPFILE) --no-standard-libraries \ |
| 116 | $(LDFLAGS) $(EXTRA_LDFLAGS) |
| 117 | else |
| 118 | $(LIBOBJ): $(OBJ_LIBO2OBJS) $(OBJ_LIBOSOBJS) $(OBJ_LIBO2CPPOBJS) $(OBJ_LIBOSCPPOBJS) $(OBJ_LIBASMOBJS) $(PLUGINLIBS) |
| 119 | @echo "Linking Objects" |
| 120 | $(QUIET) $(CXX) -c $(OPT_O2) $(CFLAGS) -o $@ $^ \ |
| 121 | -Wl,-Map,$(MAPFILE) --no-standard-libraries \ |
| 122 | -Wl,--retain-symbols-file,$(SYMFILE) \ |
| 123 | $(IPA_FLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) |
| 124 | $(QUIET) $(OBJCOPY) --keep-global-symbols=$(SYMFILE) $@ $(TEMPOBJ) |
| 125 | $(QUIET) $(OBJCOPY) --strip-unneeded $(TEMPOBJ) $@ |
| 126 | $(QUIET) -$(RM) $(TEMPOBJ) |
| 127 | endif |
| 128 | |
| 129 | |
| 130 | $(OBJ_LIBO2OBJS): $(OBJDIR)/%.o: %.c |
| 131 | @echo "Compiling $<" |
| 132 | $(QUIET) $(CC) -o $@ $(OPT_O2) $(CFLAGS) $(INCLUDES) -c $< |
| 133 | |
| 134 | $(OBJ_LIBOSOBJS): $(OBJDIR)/%.o: %.c |
| 135 | @echo "Compiling $<" |
| 136 | $(QUIET) $(CC) -o $@ $(OPT_OS) $(CFLAGS) $(INCLUDES) -c $< |
| 137 | |
| 138 | $(OBJ_LIBO2CPPOBJS): $(OBJDIR)/%.o: %.cpp |
| 139 | @echo "Compiling $<" |
| 140 | $(QUIET) $(CXX) -o $@ $(OPT_O2) $(CFLAGS) $(INCLUDES) -c $< |
| 141 | |
| 142 | $(OBJ_LIBOSCPPOBJS): $(OBJDIR)/%.o: %.cpp |
| 143 | @echo "Compiling $<" |
| 144 | $(QUIET) $(CXX) -o $@ $(OPT_OS) $(CFLAGS) $(INCLUDES) -c $< |
| 145 | |
| 146 | $(OBJ_LIBASMOBJS): $(OBJDIR)/%.o: %.S |
| 147 | @echo "Compiling $<" |
| 148 | $(QUIET) $(CC) -o $@ $(OPT_ASM) $(ASMFLAGS) $(INCLUDES) -c $< |
| 149 | |
| 150 | $(LIB): %.img: $(OBJDIR)/%.o |
| 151 | @echo "Creating Library $@" |
| 152 | $(ELFTOBIN) $< $@ |
| 153 | |
| 154 | clean: |
| 155 | -$(RM) $(LIB) $(MAPFILE) |
| 156 | -$(RM_R) $(OBJDIR) $(LIBDIR) |