build: export build system to external modules

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
This commit is contained in:
Philippe Gerum 2019-01-20 13:13:28 +01:00
parent 240f0babe1
commit 6205a1eac6
8 changed files with 38 additions and 33 deletions

View File

@ -1,18 +1,14 @@
include scripts/config.mk
# SPDX-License-Identifier: MIT
include config.mk
GOALS := all clean clobber mrproper install
TARGETS := include lib tests utils commands
$(GOALS):
$(MAIN_GOALS):
@for target in $(TARGETS); do \
$(MAKE) -C $$target O=$(O_DIR)/$$target V=$(V) $@; \
done
$(TARGETS):
$(Q)$(MAKE) -C $@ O=$(O_DIR)/$@ V=$(V)
lib: include
tests utils: lib
.PHONY: $(GOALS) $(TARGETS)

View File

@ -1,4 +1,6 @@
include ../scripts/config.mk
# SPDX-License-Identifier: MIT
include ../config.mk
CMDFILES := $(wildcard *.c)
BINARIES = $(CMDFILES:%.c=%)
@ -22,6 +24,4 @@ clean clobber mrproper:
$(O_DIR)/%: %.c
$(call ccld-cmd,$@,$(Q)$(CC) -o $(@) $< $(CFLAGS) $(LDFLAGS))
.PHONY: all install clean clobber mrproper
-include $(DEPFILES)

View File

@ -1,10 +1,7 @@
# SPDX-License-Identifier: MIT
LIBSERIAL := 0
LIBIVERSION := 0
ARCH ?= $(shell uname -m | sed \
-e s/arm.*/arm/ \
-e s/arm.*/arm/ \
-e s/aarch64.*/arm64/ )
CROSS_COMPILE ?=
CC = $(CROSS_COMPILE)gcc
@ -85,5 +82,12 @@ ccld-cmd = $(call run-cc,CCLD,$(1),$(2))
ld-cmd = $(call run-cmd,LD,$(notdir $(1)),$(2))
ar-cmd = $(call run-cmd,AR,$(notdir $(1)),$(2) $(if $(Q),2>/dev/null))
MAIN_GOALS := all clean clobber mrproper install
$(TARGETS):
$(Q)$(MAKE) -C $@ O=$(O_DIR)/$@ V=$(V)
$(O_DIR)/%.d: %.c
$(call dep-cmd,$@,@$(CC) -MM $(CFLAGS) $< | sed 's$(comma)\($*\)\.o[ :]*$(comma)$(O_DIR)/\1.o $@: $(comma)g' > $@ || rm -f $@)
.PHONY: $(MAIN_GOALS) $(TARGETS)

View File

@ -1,6 +1,6 @@
# SPDX-License-Identifier: MIT
include ../scripts/config.mk
include ../config.mk
O_UAPI = $(O_DIR)/uapi
@ -29,5 +29,3 @@ install: all
$(Q)$(MKDIR_P) $(DESTDIR)/$(includedir)/uapi
$(Q)(cd $(O_UAPI) && find -L evenless \! \( -name '*~' \) -type f | $(CPIO) -Lpdum $(DESTDIR)/$(includedir)/uapi)
$(Q)(find evenless \! \( -name '*~' \) -type f | $(CPIO) -Lpdum $(DESTDIR)/$(includedir))
.PHONY: clean clobber mrproper install

View File

@ -1,10 +1,11 @@
# SPDX-License-Identifier: MIT
include ../scripts/config.mk
include ../config.mk
include ../libversion.mk
DTSONAME := libevenless.so.$(LIBIVERSION)
SOLIBNAME := libevenless-$(LIBSERIAL).so.$(LIBIVERSION)
ARLIBNAME := libevenless-$(LIBSERIAL).a
DTSONAME := libevenless.so.$(EVL_IVERSION)
SOLIBNAME := libevenless-$(EVL_SERIAL).so.$(EVL_IVERSION)
ARLIBNAME := libevenless-$(EVL_SERIAL).a
TARGETS := $(O_DIR)/$(SOLIBNAME) $(O_DIR)/$(ARLIBNAME)
SRCFILES := $(wildcard *.c arch/$(ARCH)/*.c)
@ -46,7 +47,7 @@ $(O_DIR)/$(ARLIBNAME): $(OBJFILES)
$(O_DIR)/syscall-pic.o $(O_DIR)/syscall.o: override CFLAGS := $(CFLAGS) -fomit-frame-pointer
$(O_DIR)/version-pic.o $(O_DIR)/version.o: override CFLAGS := $(CFLAGS) -DLIBSERIAL=\"$(LIBSERIAL)\"
$(O_DIR)/version-pic.o $(O_DIR)/version.o: override CFLAGS := $(CFLAGS) -DLIBSERIAL=\"$(EVL_SERIAL)\"
version.c: $(O_DIR)/git-stamp.h
$(O_DIR)/git-stamp.h: git-stamp
@ -60,12 +61,12 @@ $(O_DIR)/git-stamp.h: git-stamp
$(RM) -f $@ && touch $@; \
fi; true
.PHONY: git-stamp
$(O_DIR)/%-pic.o: %.c
$(call cc-pic-cmd,$@,$(CC) $(CFLAGS) -fPIC -c -o $@ $<)
$(O_DIR)/%.o: %.c
$(call cc-cmd,$@,$(CC) $(CFLAGS) -c -o $@ $<)
.PHONY: all install clean clobber mrproper git-stamp
-include $(DEPFILES)

4
libversion.mk Normal file
View File

@ -0,0 +1,4 @@
# SPDX-License-Identifier: MIT
EVL_SERIAL := 0
EVL_IVERSION := 0

View File

@ -1,4 +1,7 @@
include ../scripts/config.mk
# SPDX-License-Identifier: MIT
include ../config.mk
include ../libversion.mk
TESTFILES := $(wildcard *.c)
BINARIES = $(TESTFILES:%.c=%)
@ -13,7 +16,7 @@ TEST_CPPFLAGS := $(BASE_CPPFLAGS) \
TEST_CFLAGS := $(TEST_CPPFLAGS) $(BASE_CFLAGS)
override CFLAGS := $(TEST_CFLAGS) $(CFLAGS)
TEST_LDFLAGS := $(O_DIR)/../lib/libevenless.so.$(LIBIVERSION) -lpthread -lrt
TEST_LDFLAGS := $(O_DIR)/../lib/libevenless.so.$(EVL_IVERSION) -lpthread -lrt
override LDFLAGS := $(TEST_LDFLAGS) $(LDFLAGS)
all: $(TARGETS)
@ -29,6 +32,4 @@ clean clobber mrproper:
$(O_DIR)/%: %.c
$(call ccld-cmd,$@,$(Q)$(CC) -o $(@) $< $(CFLAGS) $(LDFLAGS))
.PHONY: all install clean clobber mrproper
-include $(DEPFILES)

View File

@ -1,4 +1,7 @@
include ../scripts/config.mk
# SPDX-License-Identifier: MIT
include ../config.mk
include ../libversion.mk
UTILFILES := $(wildcard *.c)
BINARIES = $(UTILFILES:%.c=%)
@ -13,7 +16,7 @@ UTIL_CPPFLAGS := $(BASE_CPPFLAGS) \
UTIL_CFLAGS := $(UTIL_CPPFLAGS) $(BASE_CFLAGS)
override CFLAGS := $(UTIL_CFLAGS) $(CFLAGS)
UTIL_LDFLAGS := $(O_DIR)/../lib/libevenless.so.$(LIBIVERSION) -lpthread -lrt
UTIL_LDFLAGS := $(O_DIR)/../lib/libevenless.so.$(EVL_IVERSION) -lpthread -lrt
override LDFLAGS := $(UTIL_LDFLAGS) $(LDFLAGS)
all: $(TARGETS)
@ -29,6 +32,4 @@ clean clobber mrproper:
$(O_DIR)/%: %.c
$(call ccld-cmd,$@,$(Q)$(CC) -o $(@) $< $(CFLAGS) $(LDFLAGS))
.PHONY: all install clean clobber mrproper
-include $(DEPFILES)