mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Add the usage of MRUBY_ROOT to the mrbgems build system, so that we can easily build everywhere
This commit is contained in:
@@ -7,6 +7,8 @@ export LL = gcc
|
||||
export AR = ar
|
||||
export YACC = bison
|
||||
|
||||
MRUBY_ROOT := $(realpath .)
|
||||
|
||||
ifeq ($(strip $(ENABLE_GEMS)),)
|
||||
# by default GEMs are deactivated
|
||||
ENABLE_GEMS = false
|
||||
@@ -32,9 +34,9 @@ endif
|
||||
|
||||
ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS)
|
||||
ifeq ($(OS),Windows_NT)
|
||||
MAKE_FLAGS = --no-print-directory CC=$(CC) LL=$(LL) ALL_CFLAGS='$(ALL_CFLAGS)' ENABLE_GEMS='$(ENABLE_GEMS)' ACTIVE_GEMS='$(ACTIVE_GEMS)'
|
||||
MAKE_FLAGS = --no-print-directory CC=$(CC) LL=$(LL) ALL_CFLAGS='$(ALL_CFLAGS)' ENABLE_GEMS='$(ENABLE_GEMS)' ACTIVE_GEMS='$(ACTIVE_GEMS)' MRUBY_ROOT='$(MRUBY_ROOT)'
|
||||
else
|
||||
MAKE_FLAGS = --no-print-directory CC='$(CC)' LL='$(LL)' ALL_CFLAGS='$(ALL_CFLAGS)' ENABLE_GEMS='$(ENABLE_GEMS)' ACTIVE_GEMS='$(ACTIVE_GEMS)'
|
||||
MAKE_FLAGS = --no-print-directory CC='$(CC)' LL='$(LL)' ALL_CFLAGS='$(ALL_CFLAGS)' ENABLE_GEMS='$(ENABLE_GEMS)' ACTIVE_GEMS='$(ACTIVE_GEMS)' MRUBY_ROOT='$(MRUBY_ROOT)'
|
||||
endif
|
||||
|
||||
##############################
|
||||
|
||||
+8
-4
@@ -1,6 +1,10 @@
|
||||
# makefile description.
|
||||
# add gems to the ruby library
|
||||
|
||||
ifeq ($(strip $(MRUBY_ROOT)),)
|
||||
MRUBY_ROOT := $(realpath ..)
|
||||
endif
|
||||
|
||||
LIBR := ../lib/libmruby.a
|
||||
RM_F := rm -f
|
||||
CC_FLAGS := -Wall -Werror-implicit-function-declaration -g -O3 -MMD -I. -I./../include
|
||||
@@ -9,7 +13,7 @@ export CC = gcc
|
||||
export LL = gcc
|
||||
export AR = ar
|
||||
|
||||
GENERATOR := ./generator
|
||||
GENERATOR := $(MRUBY_ROOT)/mrbgems/generator
|
||||
ifeq ($(OS),Windows_NT)
|
||||
GENERATOR_BIN := $(GENERATOR).exe
|
||||
else
|
||||
@@ -40,7 +44,7 @@ all_gems : $(GENERATOR_BIN)
|
||||
@echo "Generate Gem Makefile"
|
||||
$(GENERATOR_BIN) makefile "$(ACTIVE_GEMS)" > $(GEM_MAKEFILE)
|
||||
@echo "Build all gems"
|
||||
$(MAKE) -C g
|
||||
$(MAKE) -C g MRUBY_ROOT='$(MRUBY_ROOT)' ACTIVE_GEMS="$(ACTIVE_GEMS)"
|
||||
|
||||
$(GEM_INIT).c : $(GENERATOR_BIN)
|
||||
@echo "Generate Gem driver"
|
||||
@@ -61,12 +65,12 @@ $(GENERATOR).o : $(GENERATOR).c
|
||||
|
||||
.PHONY : prepare-test
|
||||
prepare-test :
|
||||
@$(MAKE) prepare-test -C g ACTIVE_GEMS="$(ACTIVE_GEMS)"
|
||||
@$(MAKE) prepare-test -C g ACTIVE_GEMS="$(ACTIVE_GEMS)" MRUBY_ROOT='$(MRUBY_ROOT)'
|
||||
|
||||
# clean driver and all gems
|
||||
.PHONY : clean
|
||||
clean : $(GENERATOR_BIN)
|
||||
@echo "Cleanup Gems"
|
||||
$(GENERATOR_BIN) makefile "$(ACTIVE_GEMS)" > $(GEM_MAKEFILE)
|
||||
$(MAKE) clean -C g
|
||||
$(MAKE) clean -C g ACTIVE_GEMS="$(ACTIVE_GEMS)" MRUBY_ROOT='$(MRUBY_ROOT)'
|
||||
-$(RM_F) $(GEM_INIT).c *.o *.d $(GENERATOR_BIN) $(GEM_MAKEFILE) $(GEM_MAKEFILE_LIST) gem_init.a
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
ifeq ($(strip $(MRUBY_ROOT)),)
|
||||
# mruby src root
|
||||
MRUBY_ROOT := ../../../
|
||||
MRUBY_ROOT := $(realpath ../../..)
|
||||
endif
|
||||
|
||||
# Tools
|
||||
@@ -15,13 +15,13 @@ AR := ar
|
||||
SRC_DIR := src
|
||||
MRB_DIR := mrblib
|
||||
|
||||
INCLUDES := -I$(SRC_DIR) -I$(MRUBY_ROOT)include -I$(MRUBY_ROOT)src -I.
|
||||
INCLUDES := -I$(SRC_DIR) -I$(MRUBY_ROOT)/include -I$(MRUBY_ROOT)/src -I.
|
||||
CFLAGS := $(INCLUDES) -O3 -g -Wall -Werror-implicit-function-declaration
|
||||
|
||||
# LIBR can be manipulated with command line arguments
|
||||
ifeq ($(strip $(LIBR)),)
|
||||
# default mruby library
|
||||
LIBR := $(MRUBY_ROOT)lib/libmruby.a
|
||||
LIBR := $(MRUBY_ROOT)/lib/libmruby.a
|
||||
endif
|
||||
|
||||
GEM_PACKAGE := mrb-$(GEM)-gem.a
|
||||
@@ -49,14 +49,14 @@ gem_mixlib.c : gem_mrblib_header.ctmp gem_mrblib_irep.ctmp gem_mixlib_init.ctmp
|
||||
cat $^ > $@
|
||||
|
||||
gem_mixlib_init.ctmp :
|
||||
$(MRUBY_ROOT)mrbgems/generator gem_mixlib $(GEM) "$(ACTIVE_GEMS)" > $@
|
||||
$(MRUBY_ROOT)/mrbgems/generator gem_mixlib $(GEM) "$(ACTIVE_GEMS)" > $@
|
||||
|
||||
# Building target for C files
|
||||
gem-c-files : gem_srclib.o
|
||||
$(AR) rs $(GEM_PACKAGE) $(GEM_OBJECTS) $<
|
||||
|
||||
gem_srclib.c :
|
||||
$(MRUBY_ROOT)mrbgems/generator gem_srclib $(GEM) "$(ACTIVE_GEMS)" > $@
|
||||
$(MRUBY_ROOT)/mrbgems/generator gem_srclib $(GEM) "$(ACTIVE_GEMS)" > $@
|
||||
|
||||
# Building target for Ruby Files
|
||||
gem-rb-files : gem_mrblib.o
|
||||
@@ -66,13 +66,13 @@ gem_mrblib.c : gem_mrblib_header.ctmp gem_mrblib_irep.ctmp gem_mrblib_init.ctmp
|
||||
cat $^ > $@
|
||||
|
||||
gem_mrblib_header.ctmp :
|
||||
$(MRUBY_ROOT)mrbgems/generator gem_mrblib "$(ACTIVE_GEMS)" > $@
|
||||
$(MRUBY_ROOT)/mrbgems/generator gem_mrblib "$(ACTIVE_GEMS)" > $@
|
||||
|
||||
gem_mrblib_init.ctmp :
|
||||
$(MRUBY_ROOT)mrbgems/generator gem_mrblib $(GEM) "$(ACTIVE_GEMS)" > $@
|
||||
$(MRUBY_ROOT)/mrbgems/generator gem_mrblib $(GEM) "$(ACTIVE_GEMS)" > $@
|
||||
|
||||
gem_mrblib_irep.ctmp : gem_mrblib.rbtmp
|
||||
$(MRUBY_ROOT)bin/mrbc -Bgem_mrblib_irep_$(GEM) -o$@ $<
|
||||
$(MRUBY_ROOT)/bin/mrbc -Bgem_mrblib_irep_$(GEM) -o$@ $<
|
||||
|
||||
gem_mrblib.rbtmp :
|
||||
cat $(GEM_RB_FILES) > $@
|
||||
|
||||
+9
-5
@@ -129,11 +129,15 @@ make_gem_makefile(char active_gems[1024])
|
||||
char *gem_check = { 0 };
|
||||
int gem_empty;
|
||||
|
||||
printf("CFLAGS := -I. -I../../include -I../../src\n\n"
|
||||
printf("ifeq ($(strip $(MRUBY_ROOT)),)\n"
|
||||
" MRUBY_ROOT := $(realpath ../../..)\n"
|
||||
"endif\n\n"
|
||||
"MAKEFILE_4_GEM := $(MRUBY_ROOT)/mrbgems/Makefile4gem\n\n"
|
||||
"CFLAGS := -I. -I$(MRUBY_ROOT)/include -I$(MRUBY_ROOT)/src\n\n"
|
||||
"ifeq ($(OS),Windows_NT)\n"
|
||||
"MAKE_FLAGS = --no-print-directory CC=$(CC) LL=$(LL) ALL_CFLAGS='$(ALL_CFLAGS)'\n"
|
||||
" MAKE_FLAGS = --no-print-directory CC=$(CC) LL=$(LL) ALL_CFLAGS='$(ALL_CFLAGS)' MRUBY_ROOT='$(MRUBY_ROOT)' MAKEFILE_4_GEM='$(MAKEFILE_4_GEM)'\n"
|
||||
"else\n"
|
||||
"MAKE_FLAGS = --no-print-directory CC='$(CC)' LL='$(LL)' ALL_CFLAGS='$(ALL_CFLAGS)'\n"
|
||||
" MAKE_FLAGS = --no-print-directory CC='$(CC)' LL='$(LL)' ALL_CFLAGS='$(ALL_CFLAGS)' MRUBY_ROOT='$(MRUBY_ROOT)' MAKEFILE_4_GEM='$(MAKEFILE_4_GEM)'\n"
|
||||
"endif\n\n");
|
||||
|
||||
/* is there any GEM available? */
|
||||
@@ -168,9 +172,9 @@ make_gem_makefile(char active_gems[1024])
|
||||
for_each_gem(" ", "/test/*.rb ", "\tcat", " > mrbgemtest.rbtmp", TRUE, active_gems)
|
||||
);
|
||||
else
|
||||
printf("\t../generator rbtmp \"%s\"> mrbgemtest.rbtmp", active_gems);
|
||||
printf("\t$(MRUBY_ROOT)/mrbgems/generator rbtmp \"%s\"> mrbgemtest.rbtmp", active_gems);
|
||||
|
||||
printf("\n\t../../bin/mrbc -Bmrbgemtest_irep -omrbgemtest.ctmp mrbgemtest.rbtmp\n\n");
|
||||
printf("\n\t$(MRUBY_ROOT)/bin/mrbc -Bmrbgemtest_irep -omrbgemtest.ctmp mrbgemtest.rbtmp\n\n");
|
||||
|
||||
/* Makefile Rules to Clean GEMs */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user