1
0
Fork 0
mirror of https://github.com/tailix/mrubyvisor.git synced 2024-11-11 13:50:47 -05:00
mrubyvisor/Makefile

121 lines
2.8 KiB
Makefile
Raw Normal View History

2022-11-30 20:51:35 -05:00
include config.mk
2022-11-30 17:15:34 -05:00
############
# Programs #
############
2022-11-30 17:20:10 -05:00
# Toolchain
2022-11-27 06:21:26 -05:00
AR = $(CCPREFIX)ar
AS = $(CCPREFIX)as
CC = $(CCPREFIX)gcc
LD = $(CCPREFIX)ld
RANLIB = $(CCPREFIX)ranlib
2022-11-30 16:23:08 -05:00
2022-11-30 17:20:10 -05:00
# Common programs
2022-11-30 17:25:54 -05:00
CP = cp
2022-11-30 17:20:10 -05:00
MKDIR = mkdir
PWD = pwd
# Additional programs
2022-11-30 16:23:08 -05:00
GRUB_MKRESCUE = grub-mkrescue
RAKE = rake
QEMU = qemu-system-i386
2022-11-27 06:21:26 -05:00
2022-11-30 17:25:54 -05:00
#########
# Paths #
#########
2022-11-30 17:15:34 -05:00
2022-11-30 17:20:10 -05:00
ABS_REPO = $(shell $(PWD))
2022-11-27 06:21:26 -05:00
2022-11-29 08:44:28 -05:00
# Basic paths
MRUBY_CONF = build_config.rb
DEST_DIR = dest
IMAGE = image.iso
ROOTFS_DIR = rootfs
SRC_DIR = src
LIBKERNAUX_DIR = vendor/libkernaux
MRUBY_DIR = vendor/mruby
# Deeper paths
INCLUDE_DIR = $(DEST_DIR)/include
LIB_DIR = $(DEST_DIR)/lib
2022-11-28 16:56:25 -05:00
LIBKERNAUX = $(LIB_DIR)/libkernaux.a
LIBMRUBY = $(LIB_DIR)/libmruby.a
2022-11-29 08:44:28 -05:00
GRUBCFG = $(ROOTFS_DIR)/boot/grub/grub.cfg
MRUBYVISOR = $(ROOTFS_DIR)/boot/mrubyvisor.multiboot2
2022-11-27 06:21:26 -05:00
2022-11-30 17:15:34 -05:00
##############
# libkernaux #
##############
2022-11-28 16:29:06 -05:00
LIBKERNAUX_ARGS = \
--enable-freestanding \
--enable-split-libc \
2022-11-28 16:32:05 -05:00
--enable-debug \
--disable-float \
2022-11-28 16:29:06 -05:00
--with-drivers \
--with-libc
2022-11-30 17:15:34 -05:00
#########
# mruby #
#########
2022-11-30 17:20:10 -05:00
MRUBY_BUILD_NAME = mrubyvisor
2022-11-28 16:48:14 -05:00
MRUBY_FLAGS = \
-DMRB_NO_BOXING \
-DMRB_NO_FLOAT \
-DMRB_NO_STDIO
2022-11-30 17:15:34 -05:00
#########
# Tasks #
#########
2022-11-27 07:10:32 -05:00
.PHONY: $(IMAGE) $(MRUBYVISOR)
2022-11-27 06:54:45 -05:00
all: runc
runc: $(IMAGE)
2022-11-27 07:10:32 -05:00
$(QEMU) -cdrom $< -serial stdio -display none
2022-11-27 06:54:45 -05:00
runw: $(IMAGE)
2022-11-27 07:10:32 -05:00
$(QEMU) -cdrom $< -serial stdio
2022-11-27 06:54:45 -05:00
2022-11-30 17:25:54 -05:00
clean: clean-src clean-dest clean-mruby clean-libkernaux
2022-11-28 16:18:01 -05:00
clean-src:
2022-11-29 08:44:28 -05:00
$(MAKE) -C $(SRC_DIR) clean
2022-11-28 16:18:01 -05:00
clean-dest:
2022-11-29 08:44:28 -05:00
rm -rf $(MRUBYVISOR) $(DEST_DIR)/*
2022-11-28 16:18:01 -05:00
clean-mruby:
2022-11-29 08:44:28 -05:00
cd $(MRUBY_DIR) && $(RAKE) clean
2022-11-28 16:18:01 -05:00
clean-libkernaux:
2022-11-29 08:44:28 -05:00
$(MAKE) -C $(LIBKERNAUX_DIR) distclean || true
2022-11-27 06:54:45 -05:00
2022-11-30 17:15:34 -05:00
##############
# File tasks #
##############
2022-11-27 06:54:45 -05:00
$(IMAGE): $(GRUBCFG) $(MRUBYVISOR)
2022-11-30 16:23:08 -05:00
$(GRUB_MKRESCUE) $(ROOTFS_DIR) -o $@
2022-11-27 06:54:45 -05:00
$(MRUBYVISOR): $(LIBKERNAUX) $(LIBMRUBY)
2022-11-29 08:44:28 -05:00
$(MAKE) -C $(SRC_DIR) mrubyvisor.multiboot2 CCPREFIX='$(CCPREFIX)' DEST='$(ABS_REPO)/$(DEST_DIR)' MRUBY_FLAGS='$(MRUBY_FLAGS)'
2022-11-30 17:25:54 -05:00
$(CP) $(SRC_DIR)/mrubyvisor.multiboot2 $@
2022-11-27 06:21:26 -05:00
2022-11-27 06:54:45 -05:00
$(LIBKERNAUX):
2022-11-29 08:44:28 -05:00
cd $(LIBKERNAUX_DIR) && ./autogen.sh
cd $(LIBKERNAUX_DIR) && ./configure --host='i386-elf' --prefix='$(ABS_REPO)/$(DEST_DIR)' $(LIBKERNAUX_ARGS) AR='$(AR)' AS='$(AS)' CC='$(CC)' LD='$(LD)' RANLIB='$(RANLIB)'
cd $(LIBKERNAUX_DIR) && $(MAKE)
cd $(LIBKERNAUX_DIR) && $(MAKE) install
2022-11-27 06:21:26 -05:00
2022-11-28 15:20:42 -05:00
$(LIBMRUBY): $(LIBKERNAUX) $(MRUBY_CONF)
2022-11-28 16:21:10 -05:00
$(MAKE) clean-mruby
2022-11-30 17:15:34 -05:00
$(MKDIR) -p $(INCLUDE_DIR) $(LIB_DIR)
2022-11-29 08:44:28 -05:00
cd $(MRUBY_DIR) && $(RAKE) MRUBY_CONFIG='$(ABS_REPO)/$(MRUBY_CONF)' CROSS_AR='$(AR)' CROSS_CC='$(CC)' CROSS_LD='$(LD)' FLAGS='$(MRUBY_FLAGS)' BUILD_NAME='$(MRUBY_BUILD_NAME)' INCLUDE_DIR='$(ABS_REPO)/$(INCLUDE_DIR)' LIB_DIR='$(ABS_REPO)/$(LIB_DIR)'
2022-11-30 17:25:54 -05:00
$(CP) -r $(MRUBY_DIR)/include/* $(INCLUDE_DIR)
$(CP) -r $(MRUBY_DIR)/build/$(MRUBY_BUILD_NAME)/include/* $(INCLUDE_DIR)
$(CP) $(MRUBY_DIR)/build/$(MRUBY_BUILD_NAME)/lib/libmruby.a $(LIB_DIR)