diff options
Diffstat (limited to 'mrbgems/Makefile4gem')
| -rw-r--r-- | mrbgems/Makefile4gem | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/mrbgems/Makefile4gem b/mrbgems/Makefile4gem new file mode 100644 index 000000000..763210659 --- /dev/null +++ b/mrbgems/Makefile4gem @@ -0,0 +1,91 @@ +# This is the default Makefile integrated +# by each Gem. It integrates important constants +# for usage inside of a Gem. + +ifeq ($(strip $(MRUBY_ROOT)),) + # mruby src root + MRUBY_ROOT := $(realpath ../../..) +endif + +# Tools +CC := gcc +RM := rm -f +AR := ar + +SRC_DIR := src +MRB_DIR := mrblib + +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 +endif + +GEM_PACKAGE := mrb-$(GEM)-gem.a + +ifeq ($(strip $(ACTIVE_GEMS)),) + # the default file which contains the active GEMs + ACTIVE_GEMS = GEMS.active +endif + +# Default rules which are calling the +# gem specific gem-all and gem-clean +# implementations of a gem + +.PHONY : all +all : gem-info gem-all + +gem-info: + @echo "Building Gem '$(GEM)'" + +# Building target for C and Ruby files +gem-c-and-rb-files : gem_mixlib.o + $(AR) rs $(GEM_PACKAGE) $(GEM_OBJECTS) $^ + +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)" > $@ + +# 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)" > $@ + +# Building target for Ruby Files +gem-rb-files : gem_mrblib.o + $(AR) rs $(GEM_PACKAGE) $< + +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)" > $@ + +gem_mrblib_init.ctmp : + $(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$@ $< + +gem_mrblib.rbtmp : + cat $(GEM_RB_FILES) > $@ + +gem-clean-c-and-rb-files : + -$(RM) $(GEM_PACKAGE) gem_mixlib.o gem_mixlib.c gem_mrblib_header.ctmp gem_mrblib_irep.ctmp gem_mixlib_init.ctmp gem_mrblib.rbtmp + +gem-clean-c-files : + -$(RM) $(GEM_PACKAGE) gem_srclib.c gem_srclib.o $(GEM_OBJECTS) + +gem-clean-rb-files : + -$(RM) $(GEM_PACKAGE) gem_mrblib.o gem_mrblib.c gem_mrblib_header.ctmp gem_mrblib_init.ctmp gem_mrblib_irep.ctmp gem_mrblib.rbtmp + +.PHONY : clean +clean : gem-clean + @echo "Gem '$(GEM)' is clean" |
