diff options
| author | Daniel Bovensiepen <[email protected]> | 2012-09-22 02:07:15 +0800 |
|---|---|---|
| committer | Daniel Bovensiepen <[email protected]> | 2012-09-22 02:07:15 +0800 |
| commit | df91989bf760d206a3b3d035f2425caa65d35d60 (patch) | |
| tree | 7b3147bace420fc7eab141e16e325c3ed7e2e614 | |
| parent | 0e7d5a2e4bcca01a41ea00324261818440808e6f (diff) | |
| download | mruby-df91989bf760d206a3b3d035f2425caa65d35d60.tar.gz mruby-df91989bf760d206a3b3d035f2425caa65d35d60.zip | |
Optimize Makefiles
| -rw-r--r-- | mrbgems/Makefile | 35 | ||||
| -rw-r--r-- | mrbgems/generator.c | 8 | ||||
| -rw-r--r-- | test/Makefile | 22 |
3 files changed, 43 insertions, 22 deletions
diff --git a/mrbgems/Makefile b/mrbgems/Makefile index d12e85ab4..466ac18e1 100644 --- a/mrbgems/Makefile +++ b/mrbgems/Makefile @@ -5,29 +5,37 @@ LIBR := ../lib/libmruby.a INIT := init_gems RM_F := rm -f CC_FLAGS := -Wall -Werror-implicit-function-declaration -g -O3 -MMD -I. -I./../include -MMAKER := ./generator -MMAKER_BIN := $(MMAKER) + export CC = gcc export LL = gcc export AR = ar +GENERATOR := ./generator +ifeq ($(OS),Windows_NT) + GENERATOR_BIN := $(GENERATOR).exe +else + GENERATOR_BIN := $(GENERATOR) +endif +GEM_MAKEFILE := g/Makefile +GEMDLIB := g/mrbgemtest.ctmp + ############################## # generic build targets, rules .PHONY : all all : $(INIT).o all_gems -all_gems : g/Makefile +all_gems : GEM_MAKEFILE @echo "Build all gems" $(MAKE) -C g -g/Makefile : $(MMAKER_BIN) +GEM_MAKEFILE : $(GENERATOR_BIN) @echo "Generate Gem Makefile" - $(MMAKER_BIN) makefile > $@ + $(GENERATOR_BIN) makefile > $@ -$(INIT).c : $(MMAKER_BIN) +$(INIT).c : $(GENERATOR_BIN) @echo "Generate Gem driver" - $(MMAKER_BIN) $(INIT) > $@ + $(GENERATOR_BIN) $(INIT) > $@ $(INIT).o : $(INIT).c @echo "Build the driver which initializes all gems" @@ -36,21 +44,22 @@ $(INIT).o : $(INIT).c # Generator -$(MMAKER_BIN) : $(MMAKER).o +$(GENERATOR_BIN) : $(GENERATOR).o @echo "Build the generator which creates the driver and Gem Makefile" $(LL) -o $@ $(CC_FLAGS) $< -$(MMAKER).o : $(MMAKER).c +$(GENERATOR).o : $(GENERATOR).c $(CC) $(CC_FLAGS) -MMD -c $< -o $@ .PHONY : prepare-test -prepare-test : +prepare-test : $(GEMDLIB) + +$(GEMDLIB) : @$(MAKE) prepare-test -C g # clean driver and all gems .PHONY : clean -clean : $(MMAKER_BIN) +clean : GEM_MAKEFILE @echo "Cleanup Gems" - $(MMAKER_BIN) makefile > g/Makefile $(MAKE) clean -C g - -$(RM_F) $(INIT).c *.o *.d $(MMAKER_BIN) g/Makefile + -$(RM_F) $(INIT).c *.o *.d $(GENERATOR_BIN) GEM_MAKEFILE diff --git a/mrbgems/generator.c b/mrbgems/generator.c index 8d8bee0cf..7015f5a4d 100644 --- a/mrbgems/generator.c +++ b/mrbgems/generator.c @@ -102,6 +102,10 @@ for_each_gem (char before[1024], char after[1024], puts(complete_line); } +/* + * Gem Makefile Generator + * + */ void make_gem_makefile() { @@ -156,6 +160,10 @@ make_gem_makefile() for_each_gem("\t@$(MAKE) clean -C ", " $(MAKE_FLAGS)\n", "", "", ""); } +/* + * init_gems.c Generator + * + */ void make_init_gems() { diff --git a/test/Makefile b/test/Makefile index efabdc367..04722e2d1 100644 --- a/test/Makefile +++ b/test/Makefile @@ -10,6 +10,8 @@ MLIB := $(TARGET).o CLIB := $(TARGET).c INIT := init_$(TARGET).c DLIB := $(TARGET).ctmp +GEMDIR := ../mrbgems +GEMDLIB := $(GEMDIR)/g/mrbgemtest.ctmp RLIB := $(TARGET).rbtmp DEPLIB := $(TARGET).d driver.d ASSLIB := $(BASEDIR)/assert.rb @@ -42,14 +44,13 @@ endif # mruby compiler and test driver ifeq ($(OS),Windows_NT) -MRBC = ../bin/mrbc.exe -EXE := $(TARGET).exe + MRBC = ../bin/mrbc.exe + EXE := $(TARGET).exe else -MRBC = ../bin/mrbc -EXE := $(TARGET) + MRBC = ../bin/mrbc + EXE := $(TARGET) endif - ############################## # generic build targets, rules @@ -68,15 +69,18 @@ $(OBJS) : %.o : %.c $(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $< -o $@ # Compile C source from merged mruby source -$(CLIB) : ../mrbgems/g/mrbgemtest.ctmp $(RLIB) $(MRBC) $(INIT) - $(MRBC) -Bmrbtest_irep -o$(DLIB) $(RLIB); $(CAT) $(INIT) $(DLIB) ../mrbgems/g/mrbgemtest.ctmp > $@ +$(CLIB) : $(DLIB) $(GEMDLIB) $(INIT) + $(CAT) $(INIT) $(DLIB) $(GEMDLIB) > $@ + +$(DLIB) : $(RLIB) $(MRBC) + $(MRBC) -Bmrbtest_irep -o$@ $(RLIB) # merge mruby sources $(RLIB) : $(ASSLIB) $(MRBS) $(CAT) $(ASSLIB) $(MRBS) > $@ -../mrbgems/g/mrbgemtest.ctmp : - @$(MAKE) prepare-test -C ../mrbgems +$(GEMDLIB) : + @$(MAKE) prepare-test -C $(GEMDIR) # clean up .PHONY : clean |
