From f93572c531c1e69dc0c5d2c2bfd03fc83044158c Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Thu, 20 Sep 2012 18:41:16 +0800 Subject: Optimize Makefile --- mrbgems/Makefile | 2 +- mrbgems/gem_helper.c | 31 ++++++++++++++++++++++++------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/mrbgems/Makefile b/mrbgems/Makefile index 6fde97128..0f2908ab9 100644 --- a/mrbgems/Makefile +++ b/mrbgems/Makefile @@ -42,7 +42,7 @@ all_gems : $(MMAKER_BIN) g/Makefile $(MAKE) -C g test : - $(MAKE) test -C g + @$(MAKE) test -C g # clean driver and all gems .PHONY : clean diff --git a/mrbgems/gem_helper.c b/mrbgems/gem_helper.c index 01daef364..dd19ea2d0 100644 --- a/mrbgems/gem_helper.c +++ b/mrbgems/gem_helper.c @@ -69,14 +69,31 @@ make_gem_makefile() dir_list("\t@$(MAKE) -C ", " $(MAKE_FLAGS)\n", "", ""); puts(".PHONY : test"); - puts("test :"); - dir_list("", "/test/*.rb ", "\tcat ../../test/assert.rb ", "> mrbtest.rbtmp"); - puts("\t../../bin/mrbc -Bmrbtest_irep -omrbtest.ctmp mrbtest.rbtmp"); + puts("test : mrbtest"); + puts("\t@./mrbtest"); + puts(""); + + puts("mrbtest : driver.o mrbtest.o"); + puts("\t$(CC) $(CFLAGS) -o ./mrbtest ./mrbtest.o ../../lib/libmruby.a ./driver.o"); + puts(""); + + puts("driver.o : ../../test/driver.c"); + puts("\t$(CC) $(CFLAGS) -o $@ -c $<"); + puts(""); + + puts("mrbtest.o : mrbtest.c"); + puts(""); + + puts("mrbtest.c : mrbtest.ctmp"); puts("\tcat ../../test/init_mrbtest.c mrbtest.ctmp > mrbtest.c"); - puts("\t$(CC) -c ../../test/driver.c -o ./driver.o $(CFLAGS)"); - puts("\t$(CC) -c ./mrbtest.c -o ./mrbtest.o $(CFLAGS)"); - puts("\t$(CC) -o ./mrbtest ./mrbtest.o ../../lib/libmruby.a ./driver.o $(CFLAGS) -lm"); - puts("\t./mrbtest"); + puts(""); + + puts("mrbtest.ctmp : mrbtest.rbtmp"); + puts("\t../../bin/mrbc -Bmrbtest_irep -omrbtest.ctmp mrbtest.rbtmp"); + puts(""); + + puts("mrbtest.rbtmp :"); + dir_list("", "/test/*.rb ", "\tcat ../../test/assert.rb ", "> mrbtest.rbtmp"); puts(""); puts(".PHONY : clean"); -- cgit v1.2.3