Commit ac91a7f3 authored by Alessandro Rubini's avatar Alessandro Rubini

build and doc: use pp_printf and better conventions

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 5a8b8d50
......@@ -25,7 +25,13 @@ CFLAGS += -Wall -O2 -ggdb -Iinclude
# to avoid ifdef as much as possible, I use the kernel trick for OBJ variables
OBJ-y := fsm.o
# include diagnostic objects
# include pp_printf code, by default the "full" version. Please
# set CONFIG_PRINTF_NONE or CONFIG_PRINTF_XINT if needed.
OBJ-y += pp_printf/pp-printf.o
pp_printf/pp-printf.o: $(wildcard pp_printf/*.[ch])
$(MAKE) -C pp_printf pp-printf.o
include diag/Makefile
# Update 2012-07-10
......
# Alessandro Rubini for CERN, 2011 -- public domain
# Diagnostics: we have tree levels: none, full and limited
# This changed in 2013-02, and it's incompatible with what we had
# full: use a complete printf and the diag code
OBJ-$(HAS_FULL_DIAG) += diag/diag-yes.o
ifdef INTERNAL_PRINTF
OBJ-$(HAS_FULL_DIAG) += diag/diag-printf.o diag/printf-full.o
ifdef PPSI_NO_DIAG
OBJ-y += diag/diag-no.o
else
OBJ-y += diag/diag-yes.o
endif
# limited: use a minimal printf (can't coexist with FULL_DIAG)
ifndef HAS_FULL_DIAG
OBJ-$(HAS_DIAG) += diag/diag-yes.o diag/diag-printf.o diag/printf-mini.o
ifdef HAS_DIAG
SAY := $(shell echo "WARNING: ppsi doesn't use \$$HAS_DIAG any more" >&2)
endif
# no diagnostics: the diag-no.c file includes weak aliases to an empty func
OBJ-y += diag/diag-no.o
ifdef HAS_FULL_DIAG
SAY := $(shell echo "WARNING: ppsi doesn't use \$$HAS_FULL_DIAG any more" >&2)
endif
\ No newline at end of file
......@@ -66,22 +66,13 @@ environment:
CROSS_COMPILE prefix, like "arm-linux-", or empty
PROTO_EXT "whiterabbit" or empty
ARCH name of you arch (default: gnu-linux)
HAS_DIAG set to "y" or leave unset
HAS_FULL_DIAG set to "y" or leave unset
PPSI_NO_DIAG if set, prevents diagnostics from being there
WRMODE (spec only) set to "master" for m/s autodetect; set to
"slave" for slave only configuration
NOTE: The default has no diagnostics, so you most likely will want to run
make HAS_FULL_DIAG=y
or just "make" after running
export HAS_FULL_DIAG=y
If none of the variables are specified, the default Makefile compiles
with standard gcc, over gnu-linux architecture, with no protocol
extension and no diagnostic.
extension and full diagnostic conde (relying on pp_printf).
Implementation Details
......@@ -100,8 +91,9 @@ is LGPL-2.1 or later.
All the rest of the package is built as libraries. The link order
of libraries selects which object files are picked up and which are not.
Additionally, "HAS_DIAG" and "HAS_FULL_DIAG" select by Makefile rules
which diagnostic implementation (if any) is part of the diag library.
Additionally, "CONFIG_PRINTF_XINT" or one of the other pp_printf
configurations can be set to override the default (which selects the
most complete printf implementation from the package).
This state-machine source has three undefined symbols: two for
diagnostics and the "pp_state_table". The table is picked by a
......@@ -158,24 +150,17 @@ similar to what you already see for `arch-'.
Diagnostics
===========
Diagnostic functions may call printf(). If you select HAS_DIAG, the
daemon is built with a minimal printf implementation.
HAS_FULL_DIAG Selects a complete printf implementation
HAS_DIAG Selects a smaller printf
-- By default a no-op printf is selected
The complete implementation comes from an older Linux implementation
(we pulled it from U-boot) as the kernel has currently extra stuff like
%-rules for printing IPV4/IPV6 addresses, symbol tables and so on.
The small implementation receives and parses the complete % formats
but only obeys %c and %s; everything else is printed as 32-bit hex
numbers. So you can use "%-10s %3i" and the output will still make some
sense, saving some kilobytes in code. The code is derived from the full
printf by stripping out code, so the same parsing applies for sure.
With no diagnostics, the printf does nothing and only puts() is available.
Diagnostic functions may call pp_printf(). They should not call
printf() because it is not available when building from freestanding
environments. You can use the Kconfig-like environment variables
to choose which pp_printf implementation to build. The default is
the full function and should be good for everyone. If you have
size problems, please check pp_printf/README about the options.
ppsi up to 2013-01 had no diagnostics by default and used the
environment variables HAS_DIAG and HAS_FULL_DIAG. They are not
used any more and the Makefile warns about them, to ease previous
users.
Command Line
============
......
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