Commit 84df8890 authored by Alessandro Rubini's avatar Alessandro Rubini

build: avoid libraries: arch and protocols include OBJ-y instead

This simplifies the build system, by relying in weak symbols instead
of the link order. We need weak symbols anyways for configuration, so
we can get rid of the libraries.  The size of binaries returned at
build time is increased, because arch/ and lib/ stuff is not part of
ppsi.o (as it actually should).
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent c2dd5980
......@@ -91,8 +91,8 @@ export CFLAGS
# libraries: see proto-standard/Makefile as an example.
$(TARGET).o: silentoldconfig $(OBJ-y)
$(LD) -Map $(TARGET).map1 -r -o $@ $(OBJ-y) $(PPSI_O_LDFLAGS) \
--start-group $(LIBS) --end-group
$(LD) -Map $(TARGET).map1 -r -o $@ $(PPSI_O_LDFLAGS) \
--start-group $(OBJ-y) --end-group
# Finally, "make clean" is expected to work
clean:
......
CFLAGS += -ffreestanding -Os -fno-stack-protector -Itools
ARCH_LDFLAGS = -nostdlib -static -T $(ARCH).lds
ARCH_LDFLAGS = -nostdlib -static -T $A/$(ARCH).lds
# We need to undefine _FORTIFY_SOURCE, to prevent picking up external
# symbols in the inline versions of strcpy etc. This is documented in
......@@ -13,9 +13,8 @@ L := lib-bare
CFLAGS += -Ilib-bare
LIBARCH := $A/libarch.a
OBJ-libarch := $L/bare-startup.o \
OBJ-y += $A/crt0.o \
$L/bare-startup.o \
$L/main-loop.o \
$L/bare-io.o \
$A/syscalls.o \
......@@ -28,14 +27,10 @@ OBJ-libarch := $L/bare-startup.o \
TIME := bare
include time-bare/Makefile
$(LIBARCH): $(OBJ-libarch)
$(AR) r $@ $^
all: $(TARGET)
# to build the target, we need -lstd again, in case we call functions that
# were not selected yet (e.g., pp_open_globals() ).
$(TARGET): $(TARGET).o $A/crt0.o $(LIBARCH)
$(CC) -Wl,-Map,$(TARGET).map2 $(ARCH_LDFLAGS) -o $@ $A/crt0.o \
$(TARGET).o -L$A -larch -L$D -lstd
$(TARGET): $(TARGET).o
$(CC) -Wl,-Map,$(TARGET).map2 $(ARCH_LDFLAGS) -o $@ $(TARGET).o
CFLAGS += -ffreestanding -Os -fno-stack-protector -Itools
ARCH_LDFLAGS = -nostdlib -static -T $(ARCH).lds
ARCH_LDFLAGS = -nostdlib -static -T $A/$(ARCH).lds
# We need to undefine _FORTIFY_SOURCE, to prevent picking up external
# symbols in the inline versions of strcpy etc. This is documented in
......@@ -13,9 +13,8 @@ L := lib-bare
CFLAGS += -Ilib-bare
LIBARCH := $A/libarch.a
OBJ-libarch := $L/bare-startup.o \
OBJ-y += $A/crt0.o \
$L/bare-startup.o \
$L/main-loop.o \
$L/bare-io.o \
$A/syscall.o \
......@@ -36,7 +35,6 @@ all: $(TARGET)
# to build the target, we need -lstd again, in case we call functions that
# were not selected yet (e.g., pp_open_globals() ).
$(TARGET): $(TARGET).o $A/crt0.o $(LIBARCH)
$(CC) -Wl,-Map,$(TARGET).map2 $(ARCH_LDFLAGS) -o $@ $A/crt0.o \
$(TARGET).o -L$A -larch -L$D -lstd
$(TARGET): $(TARGET).o
$(CC) -Wl,-Map,$(TARGET).map2 $(ARCH_LDFLAGS) -o $@ $(TARGET).o
......@@ -4,10 +4,7 @@ A := arch-$(ARCH)
CFLAGS += -Itools
LIBARCH := $A/libarch.a
OBJ-libarch := $A/unix-startup.o \
OBJ-y += $A/unix-startup.o \
$A/main-loop.o \
$A/unix-io.o \
lib/cmdline.o \
......@@ -22,17 +19,15 @@ TIME ?= unix
include time-$(TIME)/Makefile
# Unix time operations are always included as a fallback
ifneq ($(TIME),unix)
include time-unix/Makefile
endif
CFLAGS += -Itime-unix
$(LIBARCH): $(OBJ-libarch)
$(AR) r $@ $^
all: $(TARGET)
# to build the target, we need -lstd again, in case we call functions that
# were not selected yet (e.g., pp_open_globals() ).
$(TARGET): $(TARGET).o $(LIBARCH)
$(CC) -Wl,-Map,$(TARGET).map2 -o $@ $(TARGET).o \
-L$A -larch -L$D -lstd -lrt
$(TARGET): $(TARGET).o
$(CC) -Wl,-Map,$(TARGET).map2 -o $@ $(TARGET).o -lrt
......@@ -17,12 +17,7 @@ CONFIG_NO_PRINTF = y
# All files are under A (short for ARCH): I'm lazy
A := arch-$(ARCH)
LIBARCH := $A/libarch.a
LIBS += -L$A -larch
OBJ-libarch := \
OBJ-y += \
$A/wrpc-io.o \
$A/wrpc-spll.o \
$A/wrpc-calibration.o \
......@@ -34,7 +29,4 @@ OBJ-libarch := \
TIME := wrpc
include time-wrpc/Makefile
$(LIBARCH): $(OBJ-libarch)
$(AR) r $@ $^
$(TARGET).o: $(LIBARCH)
......@@ -3,10 +3,7 @@ A := arch-$(ARCH)
CFLAGS += -Itools
LIBARCH := $A/libarch.a
OBJ-libarch := $A/wrs-startup.o \
OBJ-y += $A/wrs-startup.o \
$A/main-loop.o \
$A/wrs-io.o \
$A/wrs-calibration.o \
......@@ -36,14 +33,12 @@ CFLAGS += -I$(MINIPC_DIR)
$(MINIPC_LIB):
$(MAKE) -C $(MINIPC_DIR)
$(LIBARCH): $(OBJ-libarch) $(MINIPC_LIB)
$(AR) r $@ $^
OBJ-y += $(MINIPC_LIB)
all: $(TARGET)
# to build the target, we need -lstd again, in case we call functions that
# were not selected yet (e.g., pp_open_globals() ).
$(TARGET): $(TARGET).o $(LIBARCH)
$(CC) -Wl,-Map,$(TARGET).map2 -o $@ $(TARGET).o \
-L$A -larch -L$D -L$(MINIPC_DIR) -lminipc -lstd -lrt
$(TARGET): $(TARGET).o
$(CC) -Wl,-Map,$(TARGET).map2 -o $@ $(TARGET).o -lrt
......@@ -2,11 +2,7 @@
# All files are under directory D: I'm lazy
D := proto-ext-whiterabbit
# don't link as a library, but as a big object. Otherwise we loose open/close
LIBWRO := $D/libwr.o
LIBS += $(LIBWRO)
OBJ-libwr := $D/fsm-table.o \
OBJ-y += $D/fsm-table.o \
$D/hooks.o \
$D/state-wr-present.o \
$D/state-wr-m-lock.o \
......@@ -18,8 +14,3 @@ OBJ-libwr := $D/fsm-table.o \
$D/state-wr-link-on.o \
$D/wr-msg.o \
$D/wr-servo.o
$(TARGET).o: $(LIBWRO)
$(LIBWRO): $(OBJ-libwr)
$(LD) -r $^ -o $@
......@@ -3,11 +3,7 @@
# All files are under D: I'm lazy
D := proto-standard
LIBSTD := $D/libstd.a
LIBS += -L$D -lstd
OBJ-libstd := $D/fsm-table.o \
OBJ-y += $D/fsm-table.o \
$D/state-initializing.o \
$D/state-faulty.o \
$D/state-disabled.o \
......@@ -25,8 +21,3 @@ OBJ-libstd := $D/fsm-table.o \
$D/hooks.o \
$D/timeout.o \
$D/open-close.o
$(TARGET).o: $(LIBSTD)
$(LIBSTD): $(OBJ-libstd)
$(AR) r $@ $^
......@@ -13,7 +13,7 @@
* the linker can avoid pulling this data space if another table is there.
*/
struct pp_state_table_item pp_state_table[] = {
struct pp_state_table_item pp_state_table[] __attribute__((weak)) = {
{ PPS_INITIALIZING, "initializing", pp_initializing,},
{ PPS_FAULTY, "faulty", pp_faulty,},
{ PPS_DISABLED, "disabled", pp_disabled,},
......
#include <ppsi/ppsi.h>
/* proto-standard offers all-null hooks as a default extension */
struct pp_ext_hooks pp_hooks;
struct pp_ext_hooks __attribute__((weak)) pp_hooks;
# This Makefile in included by architectures that select time-bare
# Object files are added to libarch, so they are picked on demand.
# Object files are added straight, as they are always needed
OBJ-libarch += \
OBJ-y += \
time-bare/bare-time.o \
time-bare/bare-socket.o
# This Makefile in included by architectures that select time-unix
# as a default, or by builds with explicit TIME=unix.
# Object files are added to libarch, so they are picked on demand.
# Object files are added straight, as they are always needed
OBJ-libarch += \
OBJ-y += \
time-unix/unix-time.o \
time-unix/unix-socket.o
OBJ-libarch += \
OBJ-y += \
time-wrs/wrs-time.o \
time-wrs/wrs-socket.o
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