diff options
author | Ed Warnicke <eaw@cisco.com> | 2015-12-08 15:45:58 -0700 |
---|---|---|
committer | Ed Warnicke <eaw@cisco.com> | 2015-12-08 15:47:27 -0700 |
commit | cb9cadad578297ffd78fa8a33670bdf1ab669e7e (patch) | |
tree | 6ac2be912482cc7849a26f0ab845561c3d7f4e26 /vppinfra/Make.defs | |
parent | fb0815d4ae4bb0fe27bd9313f34b45c8593b907e (diff) |
Initial commit of vpp code.v1.0.0
Change-Id: Ib246f1fbfce93274020ee93ce461e3d8bd8b9f17
Signed-off-by: Ed Warnicke <eaw@cisco.com>
Diffstat (limited to 'vppinfra/Make.defs')
-rw-r--r-- | vppinfra/Make.defs | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/vppinfra/Make.defs b/vppinfra/Make.defs new file mode 100644 index 00000000000..dcb51e16ab7 --- /dev/null +++ b/vppinfra/Make.defs @@ -0,0 +1,129 @@ +# Copyright (c) 2001, 2002 Eliot Dresselhaus +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +# Basic toolchain defines. +CC = $(CROSS_COMPILE)gcc +LD = $(CROSS_COMPILE)ld +AR = $(CROSS_COMPILE)ar +RANLIB = $(CROSS_COMPILE)ranlib +INSTALL = install + +ifneq ($(origin CROSS_COMPILE), undefined) + IS_CROSS_COMPILE=yes +endif + +CLIB_ARCH = $(shell $(CC) -dumpmachine) + +# Where to get linux kernel includes. +# By default get linux includes from /usr/include/linux... +KERNEL_PREFIX ?= /usr + +# Where to find compiler include directory (since we may +# be using -nostdinc). +CC_PREFIX = $(shell dirname `$(CC) --print-libgcc-file-name`) + +# Where to get LIBC includes for cross compiles +LIBC_PREFIX ?= $(CC_PREFIX)/../../../../$(CLIB_ARCH) + +# Where to find CLIB includes/libraries for cross compiles +CLIB_PREFIX ?= /usr/local/$(CLIB_ARCH) + +OBJ = $(CLIB_ARCH).o +SHARED_OBJ = shared.$(OBJ) +KERNEL_OBJ = kernel.$(OBJ) +MODULE_OBJ = module.$(OBJ) + +DEP = $(CLIB_ARCH).d +SHARED_DEP = shared.$(DEP) +KERNEL_DEP = kernel.$(DEP) + +STATIC_LIB = $(CLIB_ARCH).a +SHARED_LIB = $(CLIB_ARCH).so +KERNEL_LIB = kernel.$(CLIB_ARCH).a + +STATIC_CFLAGS = $(DEFAULT_CFLAGS) +SHARED_CFLAGS = $(STATIC_CFLAGS) -fPIC + +# Compile flags common to user/kernel +CLIB_COMMON_CFLAGS += -Wall + +DEBUG ?= no +ifeq ($(DEBUG),yes) + COPTS ?= -g -O0 + CLIB_COMMON_CFLAGS += -DDEBUG +else + COPTS ?= -O2 +endif + +CLIB_COMMON_CFLAGS += $(COPTS) + +CLIB_USER_CFLAGS = $(CLIB_COMMON_CFLAGS) + +ifeq ($(IS_CROSS_COMPILE),yes) + CLIB_USER_CFLAGS += -nostdinc + CLIB_USER_CFLAGS += -idirafter $(CC_PREFIX)/include + CLIB_USER_CFLAGS += -idirafter $(KERNEL_PREFIX)/include + CLIB_USER_CFLAGS += -idirafter $(LIBC_PREFIX)/include + CLIB_COMMON_CFLAGS += -idirafter $(CLIB_PREFIX)/include +endif + +STATIC_CFLAGS = $(CLIB_USER_CFLAGS) +SHARED_CFLAGS = $(STATIC_CFLAGS) -fPIC + +%.$(SHARED_OBJ): %.c + $(CC) -c $(SHARED_CFLAGS) -o $@ $< + +%.$(OBJ): %.c + $(CC) -c $(STATIC_CFLAGS) -o $@ $< + +# Kernel version of clib + +CLIB_KERNEL_CFLAGS = $(CLIB_COMMON_CFLAGS) + +CLIB_KERNEL_CFLAGS += -nostdinc +CLIB_KERNEL_CFLAGS += -idirafter $(CC_PREFIX)/include +CLIB_KERNEL_CFLAGS += -idirafter $(KERNEL_PREFIX)/include + +# Kernel always uses mheap allocator (no malloc) +CLIB_KERNEL_CFLAGS += -DCLIB_MEM_MHEAP + +CLIB_KERNEL_CFLAGS += -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB + +CLIB_KERNEL_CFLAGS += -fno-common -fomit-frame-pointer -fno-strict-aliasing + +ifeq ($(findstring mips,$(CLIB_ARCH)),mips) + CLIB_KERNEL_CFLAGS += -G0 \ + -mno-abicalls -fno-pic -mlong-calls \ + -mcpu=r8000 -mips2 -Wa,--trap +endif + +%.$(KERNEL_OBJ): %.c + $(CC) $(CLIB_KERNEL_CFLAGS) -c -o $@ $< + +# Dependencies +%.$(DEP): %.c + $(CC) $(CLIB_USER_CFLAGS) -c -M $< | sed -e s/.o:/.$(OBJ):/ > $@ + +%.$(SHARED_DEP): %.c + $(CC) $(CLIB_USER_CFLAGS) -c -M $< | sed -e s/.o:/.$(SHARED_OBJ):/ > $@ + +%.$(KERNEL_DEP): %.c + $(CC) $(CLIB_KERNEL_CFLAGS) -c -M $< | sed -e s/.o:/.$(KERNEL_OBJ):/ > $@ |