summaryrefslogtreecommitdiffhomepage
path: root/test/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'test/Makefile')
-rw-r--r--test/Makefile70
1 files changed, 70 insertions, 0 deletions
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 000000000..b7a6572c8
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,70 @@
+# makefile discription.
+# basic build file for mruby library (Ruby part)
+
+# project-specific macros
+# extension of the executable-file is modifiable(.exe .out ...)
+BASEDIR = .
+TARGET := mritlib
+MLIB := $(TARGET).o
+CLIB := $(TARGET).c
+DLIB := $(TARGET).ctmp
+RLIB := $(TARGET).rbtmp
+DEPLIB := $(TARGET).d
+MRB1 := $(BASEDIR)/*.rb
+MRBS := $(MRB1)
+LIBR := ../lib/libmrit.a
+
+# C compiler (gcc)
+CC = gcc
+LL = gcc
+AR = ar
+DEBUG_MODE = 1
+ifeq ($(DEBUG_MODE),1)
+CFLAGS = -g
+else
+CFLAGS = -O3
+endif
+INCLUDES = -I../src -I../include
+ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS)
+ifeq ($(OS),Windows_NT)
+ MAKE_FLAGS = CC=$(CC) LL=$(LL) ALL_CFLAGS="$(ALL_CFLAGS)"
+else
+ MAKE_FLAGS = CC='$(CC)' LL='$(LL)' ALL_CFLAGS='$(ALL_CFLAGS)'
+endif
+
+# mruby compiler
+ifeq ($(OS),Windows_NT)
+MRBC = ../bin/mrbc.exe
+else
+MRBC = ../bin/mrbc
+endif
+
+##############################
+# generic build targets, rules
+
+.PHONY : all
+all : $(MRBC) $(MLIB)
+ $(AR) r $(LIBR) $(MLIB)
+ @echo "make: built targets of `pwd`"
+
+# Compile mrblib source
+$(MLIB) : $(CLIB)
+ $(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $(CLIB) -o $(MLIB)
+
+# Compile C source from merged mruby source
+$(CLIB) : $(RLIB) $(MRBC)
+ $(MRBC) -Bmritlib_irep -o$(DLIB) $(RLIB); cat init_$(TARGET).c $(DLIB) > $@
+
+$(MRBC) : ../src/opcode.h ../src/codegen.c ../src/parse.y
+ $(MAKE) -C ../tools/mrbc $(MAKE_FLAGS)
+
+# merge mruby sources
+$(RLIB) : $(MRBS)
+ cat $? > $@
+
+# clean up
+.PHONY : clean
+clean :
+ @echo "make: removing targets, objects and depend files of `pwd`"
+ -rm -f $(MRBC) $(MLIB) $(CLIB) $(RLIB) $(DLIB) $(DEPLIB) $(LIBR)
+