Makefile.unix-user (4337B)
1 # 2 # This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 3 # 4 # Copyright 2007-2019 Broadcom Inc. All rights reserved. 5 # 6 # Build rules for Linux user mode support 7 8 # When using GDB on Linux, you may want to use "setenv GDB 1" to disable 9 # editline. For best results put "set environment GDB 1" in your .gdbinit. 10 11 # Get cross tools and platform specific settings 12 13 ifneq (,$(platform)) 14 include ${SDK}/make/Makefile.linux-$(platform) 15 endif 16 17 18 # Filter out features that cannot or should not be supported in Linux 19 ifdef ESW_CHIPS 20 _FEATURE_EXCLUDE_LIST += OOB_RCPU 21 endif 22 FEATURE_EXCLUDE_LIST = $(sort $(_FEATURE_EXCLUDE_LIST)) 23 24 # User-Linux Configuration Flags 25 26 CC = $(LSRUN) $(CROSS_COMPILE)gcc 27 CXX = $(CROSS_COMPILE)g++ 28 LD = $(CROSS_COMPILE)ld 29 ARFLAGS = -rc 30 STRIP = $(CROSS_COMPILE)strip 31 OBJCOPY = $(CROSS_COMPILE)objcopy 32 #From version ~4.7 of gcc, it has its ownar, ranlib, nm tools that should be used 33 ifeq (1,$(USE_GCC_TOOLS)) 34 AR = $(CROSS_COMPILE)gcc-ar 35 RANLIB = $(CROSS_COMPILE)gcc-ranlib 36 else 37 AR = $(CROSS_COMPILE)ar 38 RANLIB = $(CROSS_COMPILE)ranlib 39 endif 40 41 OPTFLAGS_DEFAULT = -O2 42 43 # Configuration Variable 44 # OSType Defines: This defines the type of RTOS or microkernel which you 45 # are compiling the SAL (and its associated driver) for. New platforms 46 # can be created by porting the routines (system.c) to your platform and 47 # adding the define in this Makefile. 48 49 OSTYPE = LINUX 50 51 # Linux 52 LIBS =-lnsl -pthread -lm -lrt 53 54 # 55 # ORIGIN is used to Optionally select different CFLAGS. It is used to import 56 # source from other vendors. If SOURCE=Broadcom, then the BCM_ flags are added 57 # to those passed to the compiler. If SOURCE != Broadcom, BCM_ flags are NOT 58 # added. 59 # 60 # Default specifies Broadcom 61 # 62 ifndef ORIGIN 63 ORIGIN = Broadcom 64 endif 65 66 # 67 # STD_{C|CPP|CXX}FLAGS - Standard flags used by ALL compilations 68 # BCM_{C|CPP|CXX}FLAGS - Flags used for Broadcom source files 69 # OPT_{C|CPP|CXX}FLAGS - Defined in local make files BEFORE inclusion of 70 # this Makefile, to define local "Extra" flags. 71 # 72 73 STD_CFLAGS = $(OPTFLAGS) -D_REENTRANT -D${OSTYPE} ${CFGFLAGS} \ 74 -D$(ENDIAN) -D__BSD_SOURCE -DUNIX 75 ifeq ($(LINUX_MAKE_SHARED_LIB),1) 76 STD_CFLAGS += -fPIC 77 endif 78 STD_CPPFLAGS = ${STD_CFLAGS} 79 STD_CXXFLAGS = ${STD_CFLAGS} 80 81 BCM_CFLAGS ?= -Wall -Werror -fno-strict-aliasing 82 ifeq ($(platform), iproc-3_6) 83 ifeq (BE,$(ENDIAN_MODE)) 84 BCM_CFLAGS += -Werror=format-security 85 endif 86 endif 87 88 ifeq ($(BCM_SIM_PATH_SUPPORT),1) 89 BCM_CFLAGS += -DLINUX_PLI_COMBO_BDE 90 BCM_CFLAGS += -DPLISIM 91 BCM_CFLAGS += -DPLISIM_DIRECT_SCHAN 92 endif 93 94 95 # Check for redundant declarations in pedantic build 96 ifeq ($(DEBUG_PEDANTIC),TRUE) 97 ifneq (,$(LOCALDIR)) 98 SKIP_LOCALDIR_LIST = \ 99 src/bcm \ 100 src/appl/cint \ 101 src/appl/diag/cint \ 102 src/appl/tcl8.3.3/broadcom \ 103 src/appl/tcl8.3.3/generic \ 104 src/appl/tcl8.3.3/unix \ 105 src/sal/appl/editline 106 ifeq (,$(findstring $(LOCALDIR),$(SKIP_LOCALDIR_LIST))) 107 BCM_CFLAGS += -Wredundant-decls 108 endif 109 endif 110 endif 111 112 BCM_CPPFLAGS = ${BCM_CFLAGS} 113 BCM_CXXFLAGS = ${BCM_CFLAGS} 114 115 ifeq (${ORIGIN}, Broadcom) 116 CFLAGS += ${STD_CFLAGS} ${BCM_CFLAGS} ${OPT_CFLAGS} 117 CPPFLAGS += ${STD_CPPFLAGS} ${BCM_CPPFLAGS} ${OPT_CPPFLAGS} 118 CXXFLAGS += ${STD_CXXFLAGS} ${BCM_CXXFLAGS} ${OPT_CXXFLAGS} 119 else 120 CFLAGS += ${STD_CFLAGS} ${OPT_CFLAGS} 121 CPPFLAGS += ${STD_CPPFLAGS} ${OPT_CPPFLAGS} 122 CXXFLAGS += ${STD_CXXFLAGS} ${OPT_CXXFLAGS} 123 endif 124 125 # 126 # Add flags required for running on linux. 127 # 128 129 ifneq ($(LINUX_MAKE_SHARED_LIB),1) 130 ifndef LINK_STATIC 131 LINK_STATIC = 1 132 endif 133 endif 134 135 ifeq (${LINK_STATIC},1) 136 LDFLAGS += -static 137 endif 138 139 LDFLAGS += ${LIBS} 140 141 # 142 # DEPEND is used as a command to generate the list of dependencies. 143 # The format of the output must be 144 # "file.o : file.c a/b/c.h d/e/f.h ...", 145 # if it is on multiple lines, each line must end in a backslash. 146 # The output MUST be on standard out. 147 # 148 DEPEND = ${CC} -M $(CFLAGS) $< 149 150 # 151 # Optionally link against different library versions. 152 # 153 ifneq (,${LIB_OVERRIDE}) 154 CFLAGS += -B${LIB_OVERRIDE} -nostdinc -I`$(CC) --print-file-name=include` -I${LIB_OVERRIDE}/../usr/include 155 LDFLAGS += -Wl,-rpath-link,${LIB_OVERRIDE} 156 endif 157 # 158 # Optionally use the linker --relax flag to enable linking larger 159 # images on the GTO platform 160 # 161 ifneq (,${LINKER_RELAX}) 162 LDFLAGS += -Wl,--relax 163 endif