summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--mrbgems/Makefile4gem37
-rw-r--r--mrbgems/g/hello_world/Makefile29
-rw-r--r--mrbgems/g/hello_world/README.md6
3 files changed, 47 insertions, 25 deletions
diff --git a/mrbgems/Makefile4gem b/mrbgems/Makefile4gem
new file mode 100644
index 000000000..a4fa3f3c9
--- /dev/null
+++ b/mrbgems/Makefile4gem
@@ -0,0 +1,37 @@
+# This is the default Makefile integrated
+# by each Gem. It integrates important constants
+# for usage inside of a Gem.
+
+# mruby src root
+MRUBY_ROOT := ../../../
+
+# Tools
+CC := gcc
+RM := rm -f
+AR := ar
+
+SRC_DIR := src
+
+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
+
+# Default rules which are calling the
+# gem specific gem-all and gem-clean
+# implementations of a gem
+
+.PHONY : all
+all : gem-info gem-all
+ @echo "Gem '$(GEM)' is done"
+
+gem-info:
+ @echo "Building Gem '$(GEM)'"
+
+.PHONY : clean
+clean : gem-clean
+ @echo "Gem '$(GEM)' is clean"
diff --git a/mrbgems/g/hello_world/Makefile b/mrbgems/g/hello_world/Makefile
index 50a92f03a..c03910bf6 100644
--- a/mrbgems/g/hello_world/Makefile
+++ b/mrbgems/g/hello_world/Makefile
@@ -1,25 +1,12 @@
-GEMNAME := hello_world
-MRUBY_ROOT = ../../../
+include ../../Makefile4gem
-INCLUDES = -I$(MRUBY_ROOT)include -I$(MRUBY_ROOT)src -I.
-CFLAGS = $(INCLUDES) -O3 -g -Wall -Werror-implicit-function-declaration
-RM_F := rm -f
-AR := ar
+GEM := hello_world
-ifeq ($(strip $(LIBR)),)
- # default mruby library
- LIBR = $(MRUBY_ROOT)lib/libmruby.a
-endif
+GEM_C_FILES := $(wildcard $(SRC_DIR)/*.c)
+GEM_OBJECTS := $(patsubst %.c, %.o, $(GEM_C_FILES))
-.PHONY : all
-all : src/hello_world.o
- @$(AR) rs $(LIBR) src/hello_world.o
- @echo "Gem '$(GEMNAME)' is done"
+gem-all : $(GEM_OBJECTS)
+ $(AR) rs $(LIBR) $<
-src/hello_world.o : src/hello_world.c
- @gcc -c $(CFLAGS) src/hello_world.c -o src/hello_world.o
-
-.PHONY : clean
-clean :
- -$(RM_F) src/*.o
- @echo "Gem '$(GEMNAME)' is clean"
+gem-clean :
+ -$(RM) $(GEM_OBJECTS)
diff --git a/mrbgems/g/hello_world/README.md b/mrbgems/g/hello_world/README.md
index d84bb9941..42792567f 100644
--- a/mrbgems/g/hello_world/README.md
+++ b/mrbgems/g/hello_world/README.md
@@ -1,6 +1,4 @@
-mruby-md5
+hello world
=========
-MD5 digest function.
-
-This library comes original from mattn (http://github.com/mattn/mruby-md5)
+This is an example gem which implements just one method +HW.say+ in a C extension.