Commit d0e08ae1 authored by Alessandro Rubini's avatar Alessandro Rubini

Kconfig: added configurations; fixed Makefiles accordingly

This adds the needed configuration items: architectures, extension,
cross_compile and wrpc_root.  So, what we passed on environment and
command line is now in the configuration file.

This changes the priorities of such options, so the Makefile is
changed to force $(CC), $(LD) and $(CROSS_COMPILE) down to subprojects
(i.e. pp_printf and arch-wrs/mini-rpc).  Also, we need to remove
quotes from .config items, and this is ugly linesin ./Makefile
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 085ac6f1
mainmenu "PPSi configuration"
choice
prompt "Architecture to build for"
config ARCH_UNIX
bool "Unix (Linux and likely other systems)"
help
ARCH=unix supports standard Unix system calls, although
the code most likely includes some Linux dependencies.
Choose this architecture if you build for a Linux PC
or embedded system
config ARCH_BARE_I386
bool "Bare i386"
help
This architecture builds a Linux-i386 executable that
does not rely on the standard C library, but makes
system calls directly. This architecture is a test case
to ensure the code can run in freestanding environments
(microcontrollers or other contexts with no operating system)
config ARCH_BARE_X86_64
bool "Bare x86-64"
help
This architecture builds a Linux-x86-64 executable that
does not rely on the standard C library, but makes
system calls directly. This architecture is a test case
to ensure the code can run in freestanding environments
(microcontrollers or other contexts with no operating system)
config ARCH_WRPC
bool "White Rabbit PTP Core (WR Node)"
select CONFIG_EXT_WR
help
Build PPSi for use in the WRPC environment (SPEC card or similar
one). This is a freestanding build, without operating system.
The configuration selects the "White Rabbit" protocol extension.
config ARCH_WRS
bool "White Rabbit Switch"
select CONFIG_EXT_WR
help
Build PPSi for use in the WR switch. The computer is a standard
ARM-Linux host with hardware timestamping and internal PLLs
needed to achieve sub-ns synchnonization.
The configuration selects the "White Rabbit" protocol extension.
endchoice
config ARCH
string
default "unix" if ARCH_UNIX
default "bare-i386" if ARCH_BARE_I386
default "bare-x86-64" if ARCH_BARE_X86_64
default "wrpc" if ARCH_WRPC
default "wrs" if ARCH_WRS
choice EXTENSION
prompt "Protocol Extension"
config EXT_WR
bool "White Rabbit" if ARCH_WRS || ARCH_WRPC
help
Build WR-PTP (which is able to works as a standard PTP agent,
when the peer is not WR-aware).
config EXT_NONE
bool "None"
default y
help
Select not protocol extension (build standard PTP-V2 daemon).
endchoice
config EXTENSION
string
default "whiterabbit" if EXT_WR
default "" if EXT_NONE
config CROSS_COMPILE
string "Cross compiler prefix"
default "/opt/gcc-lm32/bin/lm32-elf-" if ARCH_WRPC
default "/opt/arm-wrswitch/bin/arm-linux-" if ARCH_WRS
default ""
config ARCH_CFLAGS
string
default "-m32" if ARCH_BARE_I386
default "-m64" if ARCH_BARE_X86_64
default ""
config ARCH_LDFLAGS
string
default "-m elf_i386" if ARCH_BARE_I386
default "-m elf_x86_64" if ARCH_BARE_X86_64
default ""
config WRPCSW_ROOT
string "Source location of wrpc-sw"
depends on ARCH_WRPC
default "../wrpc-sw"
#
# Alessandro Rubini for CERN, 2011 -- public domain
# Alessandro Rubini for CERN, 2011,2013 -- public domain
#
# The default is not extension. Uncomment here or set on the command line
# PROTO_EXT ?= whiterabbit
# We are now Kconfig-based
-include $(CURDIR)/.config
# The default architecture is hosted GNU/Linux stuff
ARCH ?= unix
# We still accept command-line choices like we used to do.
# Also, we must remove the quotes from these Kconfig values
PROTO_EXT ?= $(patsubst "%",%,$(CONFIG_EXTENSION))
ARCH ?= $(patsubst "%",%,$(CONFIG_ARCH))
CROSS_COMPILE ?= $(patsubst "%",%,$(CONFIG_CROSS_COMPILE))
WRPCSW_ROOT ?= $(patsubst "%",%,$(CONFIG_WRPCSW_ROOT))
# For "make config" to work, we need a valid ARCH
ifeq ($(ARCH),)
ARCH = unix
endif
# Also, you can set USER_CFLAGS, like this (or on the command line)
# USER_CFLAGS = -DVERB_LOG_MSGS
......@@ -24,6 +33,11 @@ STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
# To cross-build bare stuff (x86-64 under i386 and vice versa). We need this:
LD := $(LD) $(shell echo $(CONFIG_ARCH_LDFLAGS))
CC := $(CC) $(shell echo $(CONFIG_ARCH_CFLAGS))
# (I apologize, but I couldn't find another way to remove quotes)
# Instead of repeating "ppsi" over and over, bless it TARGET
TARGET = ppsi
......@@ -50,7 +64,7 @@ ifndef CONFIG_NO_PRINTF
OBJ-y += pp_printf/pp-printf.o
pp_printf/pp-printf.o: $(wildcard pp_printf/*.[ch])
$(MAKE) -C pp_printf pp-printf.o
$(MAKE) -C pp_printf pp-printf.o CC="$(CC)" LD="$(LD)"
endif
# We need this -I so <arch/arch.h> can be found
......@@ -58,7 +72,7 @@ CFLAGS += -Iarch-$(ARCH)/include
# proto-standard is always included, as it provides default function
# so the extension can avoid duplication of code.
ifdef PROTO_EXT
ifneq ($(PROTO_EXT),)
include proto-ext-$(PROTO_EXT)/Makefile
endif
include proto-standard/Makefile
......
......@@ -5,7 +5,7 @@ CFLAGS += -ffreestanding -Os \
-Itools
# Root of wrpc-sw project
WRPCSW_ROOT ?= ..
WRPCSW_ROOT ?= $(CONFIG_WRPCSW_ROOT)
CFLAGS += -I$(WRPCSW_ROOT)/include -I$(WRPCSW_ROOT)/include/std -I$(WRPCSW_ROOT)/softpll
......
......@@ -28,6 +28,7 @@ include time-unix/Makefile
CFLAGS += -Iproto-ext-whiterabbit
# mini-rpc directory contains minipc library
export CROSS_COMPILE
MINIPC_DIR := $A/mini-rpc
MINIPC_LIB := $(MINIPC_DIR)/libminipc.a
CFLAGS += -I$(MINIPC_DIR)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment