From dd6f0e3f6e80b43a92000908676947c4b06c22e6 Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 5 Jan 2019 20:08:10 -0500 Subject: project: added config bits and rules for alltypes.h and syscall.h. --- config.project | 1 + project/config/cfgdefs.in | 6 ++++++ project/config/cfgdefs.sh | 23 +++++++++++++++++++++++ project/headers.mk | 48 ++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 75 insertions(+), 3 deletions(-) diff --git a/config.project b/config.project index 051f38d..b9e01d6 100644 --- a/config.project +++ b/config.project @@ -33,6 +33,7 @@ mb_ccenv_skip_native= mb_default_cflags_common="-std=c99 -pipe -D_XOPEN_SOURCE=700" mb_default_cflags_common="$mb_default_cflags_common -ffreestanding -nostdinc" mb_default_cflags_common="$mb_default_cflags_common -fomit-frame-pointer" +mb_default_cflags_common="$mb_default_cflags_common -Ibuild/include" mb_default_cflags_common="$mb_default_cflags_common -I\$(SOURCE_DIR)/arch/\$(ARCH)" mb_default_cflags_common="$mb_default_cflags_common -I\$(PROJECT_DIR)/arch/\$(ARCH)" mb_default_cflags_common="$mb_default_cflags_common -I\$(SOURCE_DIR)/arch/\$(ARCH)/generic" diff --git a/project/config/cfgdefs.in b/project/config/cfgdefs.in index 4299d59..a846390 100644 --- a/project/config/cfgdefs.in +++ b/project/config/cfgdefs.in @@ -4,3 +4,9 @@ LIBC_MAJOR = @libc_major@ LIBC_MINOR = @libc_minor@ LIBC_MICRO = @libc_micro@ +# port source directory +PORT_DIR = @port_dir@ + +# syscall.h +syscall-arch: @libc_syscall_arch@ + diff --git a/project/config/cfgdefs.sh b/project/config/cfgdefs.sh index 20daffc..02e54b1 100644 --- a/project/config/cfgdefs.sh +++ b/project/config/cfgdefs.sh @@ -60,13 +60,33 @@ cfgdefs_detect_libc_version() } +cfgdefs_set_libc_options() +{ + if [ -d $mb_project_dir/arch/$mb_arch ]; then + port_dir='$(PROJECT_DIR)' + arch_dir=$mb_project_dir + else + port_dir='$(SOURCE_DIR)' + arch_dir=$mb_source_dir + fi + + if [ -f $arch_dir/arch/$mb_arch/bits/syscall.h.in ]; then + libc_syscall_arch='syscall-gen' + else + libc_syscall_arch='syscall-copy' + fi +} + + cfgdefs_output_custom_defs() { sed \ + -e 's/@port_dir@/'"$port_dir"'/g' \ -e 's/@libc_ver@/'"$libc_ver"'/g' \ -e 's/@libc_major@/'"$libc_major"'/g' \ -e 's/@libc_minor@/'"$libc_minor"'/g' \ -e 's/@libc_micro@/'"$libc_micro"'/g' \ + -e 's/@libc_syscall_arch@/'"$libc_syscall_arch"'/g' \ "$mb_project_dir/project/config/cfgdefs.in" \ | sed -e 's/[ \t]*$//g' \ >> "$mb_pwd/cfgdefs.mk" @@ -79,6 +99,9 @@ cfgdefs_set_arch # libc version info cfgdefs_detect_libc_version +# libc (variant-specific) options +cfgdefs_set_libc_options + # cfgdefs.in --> cfgdefs.mk cfgdefs_output_custom_defs diff --git a/project/headers.mk b/project/headers.mk index 9d50ee3..ea8bea4 100644 --- a/project/headers.mk +++ b/project/headers.mk @@ -1,5 +1,47 @@ -API_HEADERS = \ +# alltypes.h, syscall.h +ALLTYPES_H = build/include/bits/alltypes.h +SYSCALL_H = build/include/bits/syscall.h -INTERNAL_HEADERS = \ +ARCH_GEN_H = $(ALLTYPES_H) $(SYSCALL_H) -ALL_HEADERS = $(API_HEADERS) $(INTERNAL_HEADERS) +ALLTYPES_DEPS = \ + $(PORT_DIR)/arch/$(ARCH)/bits/alltypes.h.in \ + $(SOURCE_DIR)/include/alltypes.h.in \ + $(SOURCE_DIR)/tools/mkalltypes.sed + +$(ALLTYPES_H): build/headers.tag $(ALLTYPES_DEPS) + sed -f $(SOURCE_DIR)/tools/mkalltypes.sed \ + $(PORT_DIR)/arch/$(ARCH)/bits/alltypes.h.in \ + $(SOURCE_DIR)/include/alltypes.h.in > $@ + +syscall-copy: $(PORT_DIR)/arch/$(ARCH)/bits/syscall.h build/headers.tag + cp $< $(SYSCALL_H) + +syscall-gen: $(PORT_DIR)/arch/$(ARCH)/bits/syscall.h.in build/headers.tag + cp $< $(SYSCALL_H).tmp + sed -n -e 's/__NR_/SYS_/p' < $< >> $(SYSCALL_H).tmp + mv $(SYSCALL_H).tmp $(SYSCALL_H) + +$(SYSCALL_H): syscall-arch + + + +# build/include +build/headers.tag: + mkdir -p build/include + mkdir -p build/include/bits + touch $@ + +clean-headers: + rm -f $(ARCH_GEN_H) + rm -f $(SYSCALL_H).tmp + rmdir build/include/bits 2>/dev/null || true + rmdir build/include 2>/dev/null || true + rm -f build/headers.tag + +clean: clean-headers + +.PHONY: syscall-arch +.PHONY: syscall-copy +.PHONY: syscall-gen +.PHONY: clean-headers -- cgit v1.2.3