diff --git a/Userspace/Makefile b/Userspace/Makefile index 9fd1e563..57abf78b 100644 --- a/Userspace/Makefile +++ b/Userspace/Makefile @@ -32,6 +32,7 @@ create_out: mkdir -p out/lib mkdir -p out/include/fennix mkdir -p out/usr/bin + mkdir -p out/usr/lib mkdir -p out/usr/share/doc mkdir -p out/usr/share/info mkdir -p out/usr/include @@ -46,8 +47,8 @@ build_coreutils: -DCMAKE_C_STANDARD_INCLUDE_DIRECTORIES=$(WORKSPACE_DIR)/out/include \ -DCMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES=$(WORKSPACE_DIR)/out/include \ && \ - make -j$(shell nproc) && \ - make install + $(MAKE) -j$(shell nproc) && \ + $(MAKE) install define copy_generic_header cp -f $(WORKSPACE_DIR)/../Kernel/include/interface/$(1) $(WORKSPACE_DIR)/libc/abis/fennix/generic/bits/$(1) @@ -66,22 +67,22 @@ build_libc: -DTARGET_OS=fennix \ -DTARGET_ARCH=$(OSARCH) \ && \ - make -j$(shell nproc) && \ - make install + $(MAKE) -j$(shell nproc) && \ + $(MAKE) install build: create_out $(MAKE) build_libc - make -C libs build + $(MAKE) -C libs build $(MAKE) build_coreutils - make -C apps build + $(MAKE) -C apps build prepare: - $(info Nothing to prepare) + $(MAKE) -C libs prepare clean: rm -rf out cache mkdir -p cache touch cache/.gitkeep - make -C libs clean - make -C apps clean - make -C docker clean + $(MAKE) -C libs clean + $(MAKE) -C apps clean + $(MAKE) -C docker clean diff --git a/Userspace/libs/Makefile b/Userspace/libs/Makefile index 2675176a..80586046 100644 --- a/Userspace/libs/Makefile +++ b/Userspace/libs/Makefile @@ -1,8 +1,51 @@ -build: - cp -a $(CURDIR)/include/. $(WORKSPACE_DIR)/out/include - make -C libgcc build - make -C libexample build +MAKE_TARGETS := build clean +DIRECTORIES := $(sort $(filter-out ./include/,$(dir $(wildcard ./*/)))) -clean: - make -C libgcc clean - make -C libexample clean +FFI_VERSION = 3.4.4 +XML2_VERSION = 2.12.10 +EXPAT_VERSION = 2.7.0 + +FFI_ARCHIVE = /tmp/libffi-$(FFI_VERSION).tar.gz +XML2_ARCHIVE = /tmp/libxml2-$(XML2_VERSION).tar.xz +EXPAT_ARCHIVE = /tmp/expat-$(EXPAT_VERSION).tar.gz + +.PHONY: $(MAKE_TARGETS) $(DIRECTORIES) prepare + +build: copy_includes $(DIRECTORIES) +clean: $(DIRECTORIES) + +copy_includes: + cp -a $(CURDIR)/include/. $(WORKSPACE_DIR)/out/include + +prepare: + rm -rf ffi/libffi-src xml2/libxml2-src expat/libexpat-src + + mkdir -p ffi/libffi-src + if [ ! -f $(FFI_ARCHIVE) ]; then \ + wget https://github.com/libffi/libffi/releases/download/v$(FFI_VERSION)/libffi-$(FFI_VERSION).tar.gz -O $(FFI_ARCHIVE); \ + fi + cd ffi && \ + tar xf $(FFI_ARCHIVE) && \ + cp -r libffi-$(FFI_VERSION)/* libffi-src/ && \ + rm -rf libffi-$(FFI_VERSION) + + mkdir -p xml2/libxml2-src + if [ ! -f $(XML2_ARCHIVE) ]; then \ + wget https://download.gnome.org/sources/libxml2/2.12/libxml2-$(XML2_VERSION).tar.xz -O $(XML2_ARCHIVE); \ + fi + cd xml2 && \ + tar xf $(XML2_ARCHIVE) && \ + cp -r libxml2-$(XML2_VERSION)/* libxml2-src/ && \ + rm -rf libxml2-$(XML2_VERSION) + + mkdir -p expat/libexpat-src + if [ ! -f $(EXPAT_ARCHIVE) ]; then \ + wget https://github.com/libexpat/libexpat/releases/download/R_2_7_0/expat-$(EXPAT_VERSION).tar.gz -O $(EXPAT_ARCHIVE); \ + fi + cd expat && \ + tar xf $(EXPAT_ARCHIVE) && \ + cp -r expat-$(EXPAT_VERSION)/* libexpat-src/ && \ + rm -rf expat-$(EXPAT_VERSION) + +$(DIRECTORIES): + $(MAKE) -C $@ $(MAKECMDGOALS) diff --git a/Userspace/libs/libexample/Makefile b/Userspace/libs/example/Makefile similarity index 93% rename from Userspace/libs/libexample/Makefile rename to Userspace/libs/example/Makefile index eddae0a7..711bb9df 100644 --- a/Userspace/libs/libexample/Makefile +++ b/Userspace/libs/example/Makefile @@ -1,8 +1,8 @@ default: $(error Do not run this Makefile directly!) -DYNAMIC_NAME := $(notdir $(shell pwd)).so -STATIC_NAME := $(notdir $(shell pwd)).a +DYNAMIC_NAME := lib$(notdir $(shell pwd)).so +STATIC_NAME := lib$(notdir $(shell pwd)).a OUTPUT_DIR=$(WORKSPACE_DIR)/out/lib/ SYSROOT = --sysroot=$(WORKSPACE_DIR)/out/ diff --git a/Userspace/libs/libexample/example.c b/Userspace/libs/example/example.c similarity index 100% rename from Userspace/libs/libexample/example.c rename to Userspace/libs/example/example.c diff --git a/Userspace/libs/expat/.gitignore b/Userspace/libs/expat/.gitignore new file mode 100644 index 00000000..7cb7f41e --- /dev/null +++ b/Userspace/libs/expat/.gitignore @@ -0,0 +1 @@ +libexpat-src diff --git a/Userspace/libs/expat/Makefile b/Userspace/libs/expat/Makefile new file mode 100644 index 00000000..08388392 --- /dev/null +++ b/Userspace/libs/expat/Makefile @@ -0,0 +1,29 @@ +build: + mkdir -p $(WORKSPACE_DIR)/cache/expat + if [ ! -f "$(WORKSPACE_DIR)/cache/expat/.configured" ]; then \ + cd $(WORKSPACE_DIR)/cache/expat && \ + $(CURDIR)/libexpat-src/configure \ + --host=x86_64-none-elf \ + --prefix=/usr \ + --libdir=/usr/lib \ + --enable-static \ + --disable-shared \ + --without-docbook \ + --without-xmlwf \ + --without-examples \ + --without-tests \ + CC="$(CC)" \ + CXX="$(CXX)" \ + AR="$(AR)" \ + CFLAGS="-nostdinc -I$(WORKSPACE_DIR)/out/include" \ + CXXFLAGS="-nostdinc++ -I$(WORKSPACE_DIR)/out/include" \ + LDFLAGS="-nostdlib -L$(WORKSPACE_DIR)/out/lib -lc" && \ + touch .configured; \ + fi + $(MAKE) -C $(WORKSPACE_DIR)/cache/expat -j$(shell nproc) + $(MAKE) -C $(WORKSPACE_DIR)/cache/expat install DESTDIR=$(WORKSPACE_DIR)/out + cd $(WORKSPACE_DIR)/cache/expat && \ + ./libtool --finish $(WORKSPACE_DIR)/out/usr/lib + +clean: + $(info Nothing to clean) diff --git a/Userspace/libs/ffi/.gitignore b/Userspace/libs/ffi/.gitignore new file mode 100644 index 00000000..3c925a9b --- /dev/null +++ b/Userspace/libs/ffi/.gitignore @@ -0,0 +1 @@ +libffi-src diff --git a/Userspace/libs/ffi/Makefile b/Userspace/libs/ffi/Makefile new file mode 100644 index 00000000..2ba54ef0 --- /dev/null +++ b/Userspace/libs/ffi/Makefile @@ -0,0 +1,27 @@ +build: + mkdir -p $(WORKSPACE_DIR)/cache/ffi + if [ ! -f "$(WORKSPACE_DIR)/cache/ffi/.configured" ]; then \ + cd $(WORKSPACE_DIR)/cache/ffi && \ + $(CURDIR)/libffi-src/configure \ + --host=x86_64-none-elf \ + --prefix=/usr \ + --libdir=/usr/lib \ + --enable-static \ + --disable-shared \ + --disable-docs \ + --disable-multi-os-directory \ + CC="$(CC)" \ + CXX="$(CXX)" \ + AR="$(AR)" \ + CFLAGS="-nostdinc -I$(WORKSPACE_DIR)/out/include" \ + CXXFLAGS="-nostdinc++ -I$(WORKSPACE_DIR)/out/include" \ + LDFLAGS="-nostdlib -L$(WORKSPACE_DIR)/out/lib -lc" && \ + touch .configured; \ + fi + $(MAKE) -C $(WORKSPACE_DIR)/cache/ffi -j$(shell nproc) + $(MAKE) -C $(WORKSPACE_DIR)/cache/ffi install DESTDIR=$(WORKSPACE_DIR)/out + cd $(WORKSPACE_DIR)/cache/ffi && \ + ./libtool --finish $(WORKSPACE_DIR)/out/usr/lib + +clean: + $(info Nothing to clean) diff --git a/Userspace/libs/libgcc/Makefile b/Userspace/libs/gcc/Makefile similarity index 100% rename from Userspace/libs/libgcc/Makefile rename to Userspace/libs/gcc/Makefile diff --git a/Userspace/libs/xml2/.gitignore b/Userspace/libs/xml2/.gitignore new file mode 100644 index 00000000..875a3f18 --- /dev/null +++ b/Userspace/libs/xml2/.gitignore @@ -0,0 +1,2 @@ +libxml2-src + diff --git a/Userspace/libs/xml2/Makefile b/Userspace/libs/xml2/Makefile new file mode 100644 index 00000000..62cee08e --- /dev/null +++ b/Userspace/libs/xml2/Makefile @@ -0,0 +1,47 @@ +build: + mkdir -p $(WORKSPACE_DIR)/cache/xml2 + if [ ! -f "$(WORKSPACE_DIR)/cache/xml2/.configured" ]; then \ + cd $(WORKSPACE_DIR)/cache/xml2 && \ + $(CURDIR)/libxml2-src/configure \ + --host=x86_64-none-elf \ + --prefix=/usr \ + --libdir=/usr/lib \ + --enable-static \ + --disable-shared \ + --without-python \ + --without-debug \ + --without-docbook \ + --without-ftp \ + --without-http \ + --without-html \ + --without-legacy \ + --without-pattern \ + --without-push \ + --without-regexps \ + --without-sax1 \ + --without-schemas \ + --without-schematron \ + --without-threads \ + --without-valid \ + --without-xinclude \ + --without-xpath \ + --without-xptr \ + --without-modules \ + --without-zlib \ + --without-lzma \ + --without-coverage \ + CC="$(CC)" \ + CXX="$(CXX)" \ + AR="$(AR)" \ + CFLAGS="-nostdinc -I$(WORKSPACE_DIR)/out/include" \ + CXXFLAGS="-nostdinc++ -I$(WORKSPACE_DIR)/out/include" \ + LDFLAGS="-nostdlib -L$(WORKSPACE_DIR)/out/lib -lc" && \ + touch .configured; \ + fi + $(MAKE) -C $(WORKSPACE_DIR)/cache/xml2 -j$(shell nproc) + $(MAKE) -C $(WORKSPACE_DIR)/cache/xml2 install DESTDIR=$(WORKSPACE_DIR)/out + cd $(WORKSPACE_DIR)/cache/xml2 && \ + ./libtool --finish $(WORKSPACE_DIR)/out/usr/lib + +clean: + $(info Nothing to clean)