summaryrefslogtreecommitdiffhomepage
path: root/test/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'test/Makefile')
-rw-r--r--test/Makefile65
1 files changed, 50 insertions, 15 deletions
diff --git a/test/Makefile b/test/Makefile
index b7a6572c8..26c898704 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -4,15 +4,16 @@
# project-specific macros
# extension of the executable-file is modifiable(.exe .out ...)
BASEDIR = .
-TARGET := mritlib
+TARGET := mrbtest
+LIBR := ../lib/libmruby.a
MLIB := $(TARGET).o
CLIB := $(TARGET).c
+INIT := init_$(TARGET).c
DLIB := $(TARGET).ctmp
RLIB := $(TARGET).rbtmp
-DEPLIB := $(TARGET).d
-MRB1 := $(BASEDIR)/*.rb
-MRBS := $(MRB1)
-LIBR := ../lib/libmrit.a
+DEPLIB := $(TARGET).d driver.d
+MRBS := $(BASEDIR)/t/*.rb
+OBJS := driver.o $(MLIB)
# C compiler (gcc)
CC = gcc
@@ -32,28 +33,63 @@ else
MAKE_FLAGS = CC='$(CC)' LL='$(LL)' ALL_CFLAGS='$(ALL_CFLAGS)'
endif
-# mruby compiler
+# mruby compiler and test driver
ifeq ($(OS),Windows_NT)
MRBC = ../bin/mrbc.exe
+EXE := $(TARGET).exe
else
MRBC = ../bin/mrbc
+EXE := $(TARGET)
+endif
+
+# libraries, includes
+LIBS = -lm
+
+# compiler, linker (gcc)
+CC = gcc
+LL = gcc
+YACC = bison
+DEBUG_MODE = 1
+ifeq ($(DEBUG_MODE),1)
+CFLAGS = -g -O3
+else
+CFLAGS = -O3
+endif
+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
##############################
# generic build targets, rules
.PHONY : all
-all : $(MRBC) $(MLIB)
- $(AR) r $(LIBR) $(MLIB)
+all : $(LIBR) $(EXE)
@echo "make: built targets of `pwd`"
-# Compile mrblib source
-$(MLIB) : $(CLIB)
- $(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $(CLIB) -o $(MLIB)
+.PHONY : test
+all : $(LIBR) $(EXE)
+ ./$(EXE)
+
+# executable constructed using linker from object files
+$(EXE) : $(LIBR) $(OBJS)
+ $(LL) -o $@ $(CFLAGS) $(OBJS) $(LIBR) $(LIBS)
+
+-include $(OBJS:.o=.d)
+
+# objects compiled from source
+$(OBJS) : %.o : %.c
+ $(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $< -o $@
+
+# C library compile
+$(LIBR) :
+ @$(MAKE) -C $(BASEDIR) $(MAKE_FLAGS)
# Compile C source from merged mruby source
-$(CLIB) : $(RLIB) $(MRBC)
- $(MRBC) -Bmritlib_irep -o$(DLIB) $(RLIB); cat init_$(TARGET).c $(DLIB) > $@
+$(CLIB) : $(RLIB) $(MRBC) $(INIT)
+ $(MRBC) -Bmrbtest_irep -o$(DLIB) $(RLIB); cat $(INIT) $(DLIB) > $@
$(MRBC) : ../src/opcode.h ../src/codegen.c ../src/parse.y
$(MAKE) -C ../tools/mrbc $(MAKE_FLAGS)
@@ -66,5 +102,4 @@ $(RLIB) : $(MRBS)
.PHONY : clean
clean :
@echo "make: removing targets, objects and depend files of `pwd`"
- -rm -f $(MRBC) $(MLIB) $(CLIB) $(RLIB) $(DLIB) $(DEPLIB) $(LIBR)
-
+ -rm -f $(MRBC) $(MLIB) $(CLIB) $(RLIB) $(DLIB) $(DEPLIB) $(OBJS) $(EXE)