Commit 60f708fd authored by Tristan Gingold's avatar Tristan Gingold

Add ppsi.mk to avoid recursive makefile

Preliminary work to build ppsi as object files of wrc
instead of building an intermediate archive.
This simplifies the definition of flags.

Also adjust some include directives
parent 39fc1f24
......@@ -62,43 +62,16 @@ CFLAGS += -I$(MAINSW_ROOT)/include
CFLAGS += -Iinclude -fno-common
CFLAGS += -DPPSI_VERSION=\"$(VERSION)\"
# to avoid ifdef as much as possible, I use the kernel trick for OBJ variables
OBJ-y := fsm.o diag.o timeout.o msgtype.o
# ppsi directory (can be relative).
PPSI=.
# Include arch code. Each arch chooses its own time directory..
include arch-$(ARCH)/Makefile
# Declare the variable as a simply expanded variable
OBJ-y :=
# include pp_printf code, by default the "full" version. Please
# set CONFIG_PRINTF_NONE or CONFIG_PRINTF_XINT if needed.
ifndef CONFIG_NO_PRINTF
OBJ-y += pp_printf/pp-printf.o
include $(PPSI)/arch-$(ARCH)/Makefile
pp_printf/pp-printf.o: $(wildcard pp_printf/*.[ch])
CFLAGS="$(ARCH_PP_PRINTF_CFLAGS)" \
$(MAKE) -C pp_printf pp-printf.o CC="$(CC)" LD="$(LD)" \
CONFIG_PRINTF_64BIT=y CFLAGS_OPTIMIZATION="$(CFLAGS_OPTIMIZATION)"
endif
# We need this -I so <arch/arch.h> can be found
CFLAGS += -Iarch-$(ARCH)/include
# proto-standard is always included, as it provides default function
# so the extension can avoid duplication of code.
ifeq ($(CONFIG_HAS_EXT_WR),1)
include proto-ext-whiterabbit/Makefile
endif
ifeq ($(CONFIG_HAS_EXT_L1SYNC),1)
include proto-ext-l1sync/Makefile
endif
include proto-ext-common/Makefile
include proto-standard/Makefile
# ...and the TIME choice sets the default operations
CFLAGS += -DDEFAULT_TIME_OPS=$(TIME)_time_ops
CFLAGS += -DDEFAULT_NET_OPS=$(TIME)_net_ops
include $(PPSI)/ppsi.mk
CFLAGS-$(CONFIG_ABSCAL) += -DCONFIG_ABSCAL=1
CFLAGS += $(CFLAGS-y)
export CFLAGS
# And this is the rule to build our target.o file. The architecture may
......
......@@ -12,38 +12,15 @@ CFLAGS += -ffreestanding \
-Itools -Iproto-standard \
$(CFLAGS-CPU-$(CPU_ARCH))
# WRPCSW_ROOT shall be defined in the env by WRPC's Makefile
CFLAGS += -I$(WRPCSW_ROOT)/include -I$(WRPCSW_ROOT)/include/std -I$(WRPCSW_ROOT)/softpll
include arch.mk
# TODOA: remove --no-gc-sections
PPSI_O_LDFLAGS = --no-gc-sections -u wrc_ptp_init
# Let's use the pp_printf we already have in wrpc-sw
CONFIG_NO_PRINTF = y
# All files are under A (short for ARCH): I'm lazy
A := arch-$(ARCH)
OBJ-y += \
$A/wrpc-io.o \
$A/wrpc-spll.o \
$A/wrpc-calibration.o \
$A/wrc_ptp_ppsi.o \
lib/dump-funcs.o \
lib/drop.o \
lib/div64.o \
lib/time-arith.o \
OBJ-$(CONFIG_WRPC_FAULTS) += $A/faults.o
# wrpc/Makefile invokes this makefile with the ppsi.a target,
# if you can also call it directly.
all: $(TARGET).a
# We only support "wrpc" time operations
TIME := wrpc
include time-wrpc/Makefile
fsm.o: wrpcsw_root_check
wrpcsw_root_check:
......
# WRPCSW_ROOT shall be defined in the env by WRPC's Makefile
CFLAGS += -I$(WRPCSW_ROOT)/include -I$(WRPCSW_ROOT)/include/std -I$(WRPCSW_ROOT)/softpll
# Let's use the pp_printf we already have in wrpc-sw
CONFIG_NO_PRINTF = y
# All files are under A (short for ARCH): I'm lazy
A := $(PPSI)/arch-$(ARCH)
OBJ-y += \
$A/wrpc-io.o \
$A/wrpc-spll.o \
$A/wrpc-calibration.o \
$A/wrc_ptp_ppsi.o \
$(PPSI)/lib/dump-funcs.o \
$(PPSI)/lib/drop.o \
$(PPSI)/lib/div64.o \
$(PPSI)/lib/time-arith.o \
OBJ-$(CONFIG_WRPC_FAULTS) += $A/faults.o
# We only support "wrpc" time operations
TIME := wrpc
include $(PPSI)/time-wrpc/Makefile
......@@ -8,9 +8,9 @@
*/
#include <stdint.h>
#include <errno.h>
#include <ppsi/ppsi.h>
#include "ppsi/ppsi.h"
#include "wrpc.h"
#include <common-fun.h>
#include "../proto-standard/common-fun.h"
/* All of these live in wrpc-sw/include */
#include "dev/minic.h"
......
# to avoid ifdef as much as possible, I use the kernel trick for OBJ variables
OBJ-y += $(PPSI)/fsm.o $(PPSI)/diag.o $(PPSI)/timeout.o $(PPSI)/msgtype.o
# Include arch code. Each arch chooses its own time directory..
-include $(PPSI)/arch-$(ARCH)/arch.mk
# include pp_printf code, by default the "full" version. Please
# set CONFIG_PRINTF_NONE or CONFIG_PRINTF_XINT if needed.
ifndef CONFIG_NO_PRINTF
OBJ-y += pp_printf/pp-printf.o
pp_printf/pp-printf.o: $(wildcard pp_printf/*.[ch])
CFLAGS="$(ARCH_PP_PRINTF_CFLAGS)" \
$(MAKE) -C pp_printf pp-printf.o CC="$(CC)" LD="$(LD)" \
CONFIG_PRINTF_64BIT=y CFLAGS_OPTIMIZATION="$(CFLAGS_OPTIMIZATION)"
endif
# We need this -I so <arch/arch.h> can be found
CFLAGS += -Iarch-$(ARCH)/include
# proto-standard is always included, as it provides default function
# so the extension can avoid duplication of code.
ifeq ($(CONFIG_HAS_EXT_WR),1)
include $(PPSI)/proto-ext-whiterabbit/Makefile
endif
ifeq ($(CONFIG_HAS_EXT_L1SYNC),1)
include $(PPSI)/proto-ext-l1sync/Makefile
endif
include $(PPSI)/proto-ext-common/Makefile
include $(PPSI)/proto-standard/Makefile
# ...and the TIME choice sets the default operations
CFLAGS += -DDEFAULT_TIME_OPS=$(TIME)_time_ops
CFLAGS += -DDEFAULT_NET_OPS=$(TIME)_net_ops
CFLAGS-$(CONFIG_ABSCAL) += -DCONFIG_ABSCAL=1
CFLAGS += $(CFLAGS-y)
D := proto-ext-common
D := $(PPSI)/proto-ext-common
INC_WRH_SERVO=$(shell test ".$(CONFIG_HAS_EXT_WR)" = ".1" -o \
".$(CONFIG_HAS_EXT_L1SYNC)" = ".1" \
&& echo -n "true")
ifeq ($(INC_WRH_SERVO),true)
ifeq ($(CONFIG_HAS_EXT_WR),1)
INC_WRH_SERVO=y
endif
ifeq ($(CONFIG_HAS_EXT_L1SYNC),1)
INC_WRH_SERVO=y
endif
ifdef INC_WRH_SERVO
OBJ-y += $D/wrh-servo.o
endif
# All files are under directory D: I'm lazy
D := proto-ext-whiterabbit
D := $(PPSI)/proto-ext-whiterabbit
OBJ-y += $D/hooks.o \
$D/common-fun.o \
......
......@@ -5,10 +5,9 @@
* Released according to the GNU LGPL, version 2.1 or any later version.
*/
#include <ppsi/ppsi.h>
#include <common-fun.h>
#include "ppsi/ppsi.h"
#include "../proto-standard/common-fun.h"
#include "wr-constants.h"
#include <math.h>
typedef int (*wr_state_action_t)(struct pp_instance *ppi, void *buf, int len, int new_state);
......
# Hosted environment: build the final exectuable
# All files are under D: I'm lazy
D := proto-standard
D := $(PPSI)/proto-standard
OBJ-y += $D/fsm-table.o \
$D/fsm-lib.o \
......
......@@ -2,5 +2,5 @@
# Object files are added to libarch, so they are picked on demand.
OBJ-y += \
time-wrpc/wrpc-time.o \
time-wrpc/wrpc-socket.o
$(PPSI)/time-wrpc/wrpc-time.o \
$(PPSI)/time-wrpc/wrpc-socket.o
......@@ -4,12 +4,12 @@
*
* Released according to the GNU LGPL, version 2.1 or any later version.
*/
#include <ppsi/ppsi.h>
#include "ptpdump.h"
#include "ppsi/ppsi.h"
#include "../tools/ptpdump.h"
#include "../arch-wrpc/wrpc.h"
#include <dev/syscon.h> /* wrpc-sw */
#include <dev/endpoint.h> /* wrpc-sw */
#include "dev/syscon.h" /* wrpc-sw */
#include "dev/endpoint.h" /* wrpc-sw */
#include "net.h"
#include "board.h"
......
......@@ -6,11 +6,11 @@
*/
#include <stdio.h>
#include <string.h>
#include "ptpdump.h"
#include <ppsi/ieee1588_types.h> /* from ../include */
#include "../tools/ptpdump.h"
#include "ppsi/ieee1588_types.h" /* from ../include */
#include "../proto-ext-whiterabbit/wr-constants.h"
#include "decent_types.h"
#include <ppsi/lib.h>
#include "../tools/decent_types.h"
#include "ppsi/lib.h"
#define WR_MODE_ON_MASK 0x8
#define CALIBRATED_MASK 0x4
......
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