diff --git a/build/makefile.oflags b/build/makefile.cflags similarity index 100% rename from build/makefile.oflags rename to build/makefile.cflags diff --git a/build/makefile.contrib b/build/makefile.contrib new file mode 100644 index 000000000..34be44f7c --- /dev/null +++ b/build/makefile.contrib @@ -0,0 +1,31 @@ +# +# MIT License +# +# Copyright(c) 2018 Pedro Henrique Penna +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +# Builds contrib. +contrib: make-dirs + $(MAKE) -C $(CONTRIBDIR)/hal install PREFIX=$(ROOTDIR) + +# Cleans the HAL. +contrib-uninstall: + $(MAKE) -C $(CONTRIBDIR)/hal uninstall PREFIX=$(ROOTDIR) diff --git a/build/makefile.install b/build/makefile.install new file mode 100644 index 000000000..3602d2fc4 --- /dev/null +++ b/build/makefile.install @@ -0,0 +1,84 @@ +# +# MIT License +# +# Copyright(c) 2018 Pedro Henrique Penna +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +#=============================================================================== +# Build Options +#=============================================================================== + +# Installation Prefix +export PREFIX ?= $(HOME) + +#=============================================================================== +# Artifacts +#=============================================================================== + +export ARTIFACTS := $(shell find $(INCDIR) -name *.h -type f) + +#=============================================================================== + +# Install +install: | all-target copy-artifacts + @mkdir -p $(PREFIX)/lib + @cp -f $(LIBDIR)/libhal*.a $(PREFIX)/lib + @echo [CP] $(LIBDIR)/libhal*.a + @cp -f $(LIBDIR)/libkernel*.a $(PREFIX)/lib + @echo [CP] $(LIBDIR)/libkernel*.a + @cp -f $(LIBDIR)/libnanvix*.a $(PREFIX)/lib + @echo [CP] $(LIBDIR)/libnanvix*.a + @echo "===============================================================================" + @echo "Nanvix Microkernel Successfully Installed into $(PREFIX)" + @echo "===============================================================================" + +# Uninstall +uninstall: | distclean delete-artifacts + @rm -f $(PREFIX)/lib/libhal*.a + @echo [RM] $(PREFIX)/lib/libhal*.a + @rm -f $(PREFIX)/lib/libkernel*.a + @echo [RM] $(PREFIX)/lib/libkernel*.a + @rm -f $(PREFIX)/lib/libnanvix*.a + @echo [RM] $(PREFIX)/lib/libnanvix*.a + @echo "===============================================================================" + @echo "Nanvix Microkernel Successfully Uninstalled from $(PREFIX)" + @echo "===============================================================================" + +# Copies All Artifacts +copy-artifacts: $(patsubst $(CURDIR)/%, copy/%, $(ARTIFACTS)) + +# Copy a Single Artifact +copy/%: % + $(eval file := $( +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +# Runs Unit Tests in all clusters +run: + bash $(TOOLSDIR)/utils/nanvix-run.sh $(IMAGE) $(EXEC) $(TARGET) all --no-debug + +# Runs Unit Tests in IO Cluster. +run-iocluster: + bash $(TOOLSDIR)/utils/nanvix-run.sh $(IMAGE) $(EXEC) $(TARGET) iocluster --no-debug + +# Runs Unit Tests in Compute Cluster. +run-ccluster: + bash $(TOOLSDIR)/utils/nanvix-run.sh $(IMAGE) $(EXEC) $(TARGET) ccluster --no-debug + +# Runs Unit Tests in all clusters in debug mode. +debug: + bash $(TOOLSDIR)/utils/nanvix-run.sh $(IMAGE) $(EXEC) $(TARGET) all --debug + +# Runs Unit Tests in IO Cluster in debug mode. +debug-iocluster: + bash $(TOOLSDIR)/utils/nanvix-run.sh $(IMAGE) $(EXEC) $(TARGET) iocluster --debug + +# Runs Unit Tests in Compute Cluster in debug mode. +debug-ccluster: + bash $(TOOLSDIR)/utils/nanvix-run.sh $(IMAGE) $(EXEC) $(TARGET) ccluster --debug diff --git a/build/optimsoc/make/makefile b/build/optimsoc/make/makefile index 6ebb075ee..5b0470044 100644 --- a/build/optimsoc/make/makefile +++ b/build/optimsoc/make/makefile @@ -50,3 +50,6 @@ export CFLAGS += -nostdlib -nostdinc # Linker Options export LDFLAGS += -nostdlib -nostdinc + +# Suffix for Objects +export OBJ_SUFFIX=optimsoc diff --git a/build/qemu-openrisc/make/makefile b/build/qemu-openrisc/make/makefile index 04cf704e4..2f64a0f34 100644 --- a/build/qemu-openrisc/make/makefile +++ b/build/qemu-openrisc/make/makefile @@ -53,6 +53,9 @@ export CFLAGS += -Wno-error=type-limits # Linker Options export LDFLAGS += -nostdlib -nostdinc +# Suffix for Objects +export OBJ_SUFFIX=qemu-openrisc + #=============================================================================== # Libraries #=============================================================================== diff --git a/build/qemu-riscv32/make/makefile b/build/qemu-riscv32/make/makefile index 6e56103a1..bd5cddd61 100644 --- a/build/qemu-riscv32/make/makefile +++ b/build/qemu-riscv32/make/makefile @@ -56,6 +56,9 @@ export LDFLAGS += -nostdlib -nostdinc export LDFLAGS += -march=rv32imac -mabi=ilp32 -mcmodel=medany export LDFLAGS += -Wl,--nmagic -Wl,--gc-sections +# Suffix for Objects +export OBJ_SUFFIX=qemu-riscv32 + #=============================================================================== # Libraries #=============================================================================== diff --git a/build/qemu-x86/make/makefile b/build/qemu-x86/make/makefile index 764a7738e..5d5bc2f0c 100644 --- a/build/qemu-x86/make/makefile +++ b/build/qemu-x86/make/makefile @@ -51,6 +51,9 @@ export CFLAGS += -nostdlib -nostdinc # Linker Options export LDFLAGS += -nostdlib -nostdinc +# Suffix for Objects +export OBJ_SUFFIX=qemu-x86 + #=============================================================================== # Libraries #=============================================================================== diff --git a/makefile b/makefile index dce56a27a..b744f33fc 100644 --- a/makefile +++ b/makefile @@ -29,8 +29,8 @@ # Verbose Build? export VERBOSE ?= no -# Object suffix for heterogeneous architectures. -export OBJ_SUFFIX := +# Installation Prefix +export PREFIX ?= $(HOME) #=============================================================================== # Directories @@ -72,7 +72,7 @@ include $(MAKEDIR)/makefile # Toolchain Configuration #=============================================================================== -# Compiler Options. +# Compiler Options export CFLAGS += -std=c99 -fno-builtin export CFLAGS += -pedantic-errors export CFLAGS += -Wall -Wextra -Werror -Wa,--warn @@ -82,7 +82,9 @@ export CFLAGS += -Wno-unused-function export CFLAGS += -fno-stack-protector export CFLAGS += -Wvla # -Wredundant-decls export CFLAGS += -I $(INCDIR) -include $(BUILDDIR)/makefile.oflags + +# Additional C Flags +include $(BUILDDIR)/makefile.cflags # Archiver Options export ARFLAGS = rc @@ -96,17 +98,17 @@ export IMAGE_BENCHMARKS = nanvix-benchmarks.img # Builds everything. all: image-tests image-benchmarks +# Make Directories +make-dirs: + @mkdir -p $(BINDIR) + @mkdir -p $(LIBDIR) + image-tests: | make-dirs all-target bash $(TOOLSDIR)/image/build-image.sh $(BINDIR) $(IMAGE) image-benchmarks: | make-dirs all-target bash $(TOOLSDIR)/image/build-image.sh $(BINDIR) $(IMAGE_BENCHMARKS) -# Make Directories -make-dirs: - @mkdir -p $(BINDIR) - @mkdir -p $(LIBDIR) - # Cleans builds. clean: clean-target @@ -115,34 +117,20 @@ distclean: | clean-target @rm -f $(BINDIR)/* @find $(SRCDIR) -name "*.o" -exec rm -rf {} \; -# Builds contrib. -contrib: make-dirs - $(MAKE) -C $(CONTRIBDIR)/hal install PREFIX=$(ROOTDIR) - -# Cleans the HAL. -contrib-uninstall: - $(MAKE) -C $(CONTRIBDIR)/hal uninstall PREFIX=$(ROOTDIR) - -# Runs Unit Tests in all clusters -run: - bash $(TOOLSDIR)/utils/nanvix-run.sh $(IMAGE) $(EXEC) $(TARGET) all --no-debug +#=============================================================================== +# Contrib Install and Uninstall Rules +#=============================================================================== -# Runs Unit Tests in IO Cluster. -run-iocluster: - bash $(TOOLSDIR)/utils/nanvix-run.sh $(IMAGE) $(EXEC) $(TARGET) iocluster --no-debug +include $(BUILDDIR)/makefile.contrib -# Runs Unit Tests in Compute Cluster. -run-ccluster: - bash $(TOOLSDIR)/utils/nanvix-run.sh $(IMAGE) $(EXEC) $(TARGET) ccluster --no-debug +#=============================================================================== +# Install and Uninstall Rules +#=============================================================================== -# Runs Unit Tests in all clusters in debug mode. -debug: - bash $(TOOLSDIR)/utils/nanvix-run.sh $(IMAGE) $(EXEC) $(TARGET) all --debug +include $(BUILDDIR)/makefile.install -# Runs Unit Tests in IO Cluster in debug mode. -debug-iocluster: - bash $(TOOLSDIR)/utils/nanvix-run.sh $(IMAGE) $(EXEC) $(TARGET) iocluster --debug +#=============================================================================== +# Debug and Run Rules +#=============================================================================== -# Runs Unit Tests in Compute Cluster in debug mode. -debug-ccluster: - bash $(TOOLSDIR)/utils/nanvix-run.sh $(IMAGE) $(EXEC) $(TARGET) ccluster --debug +include $(BUILDDIR)/makefile.run