Skip to content

Commit

Permalink
Merge branch 'enhancement-install-uninstall' into unstable
Browse files Browse the repository at this point in the history
  • Loading branch information
ppenna committed May 5, 2019
2 parents a962f25 + c1045f2 commit 214f266
Show file tree
Hide file tree
Showing 9 changed files with 197 additions and 35 deletions.
File renamed without changes.
31 changes: 31 additions & 0 deletions build/makefile.contrib
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# MIT License
#
# Copyright(c) 2018 Pedro Henrique Penna <pedrohenriquepenna@gmail.com>
#
# 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)
84 changes: 84 additions & 0 deletions build/makefile.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#
# MIT License
#
# Copyright(c) 2018 Pedro Henrique Penna <pedrohenriquepenna@gmail.com>
#
# 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 := $(<F))
$(eval dir := $(<D))
@echo [CP] $(dir)/$(file)
@mkdir -p $(PREFIX)/$(dir)
@cp -f $< $(PREFIX)/$(dir)/$(file)
@chmod 444 $(PREFIX)/$(dir)/$(file)

# Deletes All Artifacts
delete-artifacts: $(patsubst $(CURDIR)/%, delete/%, $(ARTIFACTS))

# Deletes a Single Artifact
delete/%:
$(eval file := $(patsubst delete/%, %, $@))
@echo [RM] $(file)
@rm -f $(PREFIX)/$(file)
47 changes: 47 additions & 0 deletions build/makefile.run
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#
# MIT License
#
# Copyright(c) 2018 Pedro Henrique Penna <pedrohenriquepenna@gmail.com>
#
# 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
3 changes: 3 additions & 0 deletions build/optimsoc/make/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ export CFLAGS += -nostdlib -nostdinc

# Linker Options
export LDFLAGS += -nostdlib -nostdinc

# Suffix for Objects
export OBJ_SUFFIX=optimsoc
3 changes: 3 additions & 0 deletions build/qemu-openrisc/make/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
#===============================================================================
Expand Down
3 changes: 3 additions & 0 deletions build/qemu-riscv32/make/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
#===============================================================================
Expand Down
3 changes: 3 additions & 0 deletions build/qemu-x86/make/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export CFLAGS += -nostdlib -nostdinc
# Linker Options
export LDFLAGS += -nostdlib -nostdinc

# Suffix for Objects
export OBJ_SUFFIX=qemu-x86

#===============================================================================
# Libraries
#===============================================================================
Expand Down
58 changes: 23 additions & 35 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
# Verbose Build?
export VERBOSE ?= no

# Object suffix for heterogeneous architectures.
export OBJ_SUFFIX :=
# Installation Prefix
export PREFIX ?= $(HOME)

#===============================================================================
# Directories
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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

0 comments on commit 214f266

Please sign in to comment.