diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-05-23 16:59:22 -0700 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-05-23 16:59:22 -0700 |
| commit | e3ae5bb9d261e174a82e318f784a8ab2aa4036ec (patch) | |
| tree | b74473538845af72be3a3104ad0d52c1b6df9324 | |
| parent | 265ff670c8545a6ebaba7c13d946fc3c70eef36f (diff) | |
| parent | 105c11b7f6570292ad0fa15c8346c038f9d2f561 (diff) | |
| download | mruby-e3ae5bb9d261e174a82e318f784a8ab2aa4036ec.tar.gz mruby-e3ae5bb9d261e174a82e318f784a8ab2aa4036ec.zip | |
Merge pull request #188 from thecodeshop/makefile-mods
Makefile mods
| -rw-r--r-- | Makefile | 45 | ||||
| -rw-r--r-- | mrblib/Makefile | 17 | ||||
| -rw-r--r-- | src/Makefile | 13 | ||||
| -rw-r--r-- | test/Makefile | 29 | ||||
| -rw-r--r-- | tools/mirb/Makefile | 8 | ||||
| -rw-r--r-- | tools/mrbc/Makefile | 8 | ||||
| -rw-r--r-- | tools/mruby/Makefile | 7 |
7 files changed, 68 insertions, 59 deletions
@@ -1,9 +1,12 @@ # makefile discription. # basic build file for mruby -# compiler, linker (gcc) -CC = gcc -LL = gcc +# compiler, linker (gcc), archiver, parser generator +export CC = gcc +export LL = gcc +export AR = ar +export YACC = bison + DEBUG_MODE = 1 ifeq ($(DEBUG_MODE),1) CFLAGS = -g -O3 @@ -18,6 +21,16 @@ else endif ############################## +# internal variables + +export MSG_BEGIN = @for line in +export MSG_END = ; do echo "$$line"; done + +export CP := cp +export RM_F := rm -f +export CAT := cat + +############################## # generic build targets, rules .PHONY : all @@ -39,3 +52,29 @@ clean : @$(MAKE) clean -C tools/mruby $(MAKE_FLAGS) @$(MAKE) clean -C tools/mirb $(MAKE_FLAGS) @$(MAKE) clean -C test $(MAKE_FLAGS) + +# display help for build configuration and interesting targets +.PHONY : showconfig +showconfig : + $(MSG_BEGIN) \ + "" \ + " CC = $(CC)" \ + " LL = $(LL)" \ + " MAKE = $(MAKE)" \ + "" \ + " CFLAGS = $(CFLAGS)" \ + " ALL_CFLAGS = $(ALL_CFLAGS)" \ + $(MSG_END) + +.PHONY : help +help : + $(MSG_BEGIN) \ + "" \ + " Basic mruby Makefile" \ + "" \ + "targets:" \ + " all (default): build all targets, install (locally) in-repo" \ + " clean: clean all built and in-repo installed artifacts" \ + " showconfig: show build config summary" \ + " test: run all mruby tests" \ + $(MSG_END) diff --git a/mrblib/Makefile b/mrblib/Makefile index d22c4509f..9a7e93596 100644 --- a/mrblib/Makefile +++ b/mrblib/Makefile @@ -15,17 +15,15 @@ MRBS := $(MRB1) LIBR0 := ../lib/libmruby_core.a LIBR := ../lib/libmruby.a -# C compiler (gcc) -CC = gcc -LL = gcc -AR = ar +# libraries, includes +INCLUDES = -I../src -I../include + 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)" @@ -40,6 +38,7 @@ else MRBC = ../bin/mrbc endif + ############################## # generic build targets, rules @@ -48,7 +47,7 @@ all : $(LIBR) # update libmruby.a $(LIBR) : $(MLIB) $(LIBR0) - cp $(LIBR0) $(LIBR) + $(CP) $(LIBR0) $(LIBR) $(AR) r $(LIBR) $(MLIB) # Compile mrblib source @@ -57,17 +56,17 @@ $(MLIB) : $(CLIB) # Compile C source from merged mruby source $(CLIB) : $(RLIB) $(MRBC) - $(MRBC) -Bmrblib_irep -o$(DLIB) $(RLIB); cat init_$(TARGET).c $(DLIB) > $@ + $(MRBC) -Bmrblib_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 $? > $@ + $(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) + -$(RM_F) $(MRBC) $(MLIB) $(CLIB) $(RLIB) $(DLIB) $(DEPLIB) $(LIBR) diff --git a/src/Makefile b/src/Makefile index 385e447e3..61012ea68 100644 --- a/src/Makefile +++ b/src/Makefile @@ -19,12 +19,6 @@ OBJS := $(OBJ1) $(OBJ2) $(OBJ3) # libraries, includes INCLUDES = -I$(BASEDIR) -I$(BASEDIR)/../include -# compiler, linker (gcc) -CC = gcc -LL = gcc -AR = ar -YACC = bison - DEBUG_MODE = 1 ifeq ($(DEBUG_MODE),1) CFLAGS = -g -O3 @@ -33,6 +27,7 @@ CFLAGS = -O3 endif ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS) + ############################## # generic build targets, rules @@ -64,6 +59,6 @@ $(LDEF) : $(KWD) .PHONY : clean #cleandep clean : @echo "make: removing targets, objects and depend files of `pwd`" - -rm -f $(TARGET) $(OBJS) $(OBJY) $(YC) - -rm -f $(OBJS:.o=.d) $(OBJY:.o=.d) - -rm -f $(patsubst %.c,%.o,$(EXCEPT1)) $(patsubst %.c,%.d,$(EXCEPT1)) + -$(RM_F) $(TARGET) $(OBJS) $(OBJY) $(YC) + -$(RM_F) $(OBJS:.o=.d) $(OBJY:.o=.d) + -$(RM_F) $(patsubst %.c,%.o,$(EXCEPT1)) $(patsubst %.c,%.d,$(EXCEPT1)) diff --git a/test/Makefile b/test/Makefile index d46fa7a3e..b2df11486 100644 --- a/test/Makefile +++ b/test/Makefile @@ -16,17 +16,16 @@ ASSLIB := $(BASEDIR)/assert.rb MRBS := $(BASEDIR)/t/*.rb OBJS := driver.o $(MLIB) -# C compiler (gcc) -CC = gcc -LL = gcc -AR = ar +# libraries, includes +LIBS = -lm +INCLUDES = -I$(BASEDIR)/../src -I$(BASEDIR)/../include + 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)" @@ -43,20 +42,6 @@ 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) ############################## # generic build targets, rules @@ -77,14 +62,14 @@ $(OBJS) : %.o : %.c # Compile C source from merged mruby source $(CLIB) : $(RLIB) $(MRBC) $(INIT) - $(MRBC) -Bmrbtest_irep -o$(DLIB) $(RLIB); cat $(INIT) $(DLIB) > $@ + $(MRBC) -Bmrbtest_irep -o$(DLIB) $(RLIB); $(CAT) $(INIT) $(DLIB) > $@ # merge mruby sources $(RLIB) : $(ASSLIB) $(MRBS) - cat $(ASSLIB) $(MRBS) > $@ + $(CAT) $(ASSLIB) $(MRBS) > $@ # clean up .PHONY : clean clean : @echo "make: removing targets, objects and depend files of `pwd`" - -rm -f $(MLIB) $(CLIB) $(RLIB) $(DLIB) $(DEPLIB) $(OBJS) $(EXE) + -$(RM_F) $(MLIB) $(CLIB) $(RLIB) $(DLIB) $(DEPLIB) $(OBJS) $(EXE) diff --git a/tools/mirb/Makefile b/tools/mirb/Makefile index 4c6ab4e62..ba307227c 100644 --- a/tools/mirb/Makefile +++ b/tools/mirb/Makefile @@ -21,10 +21,6 @@ EXTS := $(EXT1) LIBS = -lm INCLUDES = -I$(BASEDIR) -I$(BASEDIR)/../include -# compiler, linker (gcc) -CC = gcc -LL = gcc -YACC = bison DEBUG_MODE = 1 ifeq ($(DEBUG_MODE),1) CFLAGS = -g -O3 @@ -69,5 +65,5 @@ clean : $(MAKE) clean -C ../../mrblib $(MAKE_FLAGS) $(MAKE) clean -C ../mrbc $(MAKE_FLAGS) @echo "make: removing targets, objects and depend files of `pwd`" - -rm -f $(EXE) $(OBJS) - -rm -f $(OBJS:.o=.d) + -$(RM_F) $(EXE) $(OBJS) + -$(RM_F) $(OBJS:.o=.d) diff --git a/tools/mrbc/Makefile b/tools/mrbc/Makefile index 9ecda4a59..99f5830e6 100644 --- a/tools/mrbc/Makefile +++ b/tools/mrbc/Makefile @@ -23,9 +23,6 @@ LIBS = -lm INCLUDES = -I$(BASEDIR) -I$(BASEDIR)/../include # compiler, linker (gcc) -CC = gcc -LL = gcc -YACC = bison DEBUG_MODE = 1 ifeq ($(DEBUG_MODE),1) CFLAGS = -g -O3 @@ -39,6 +36,7 @@ else MAKE_FLAGS = CC='$(CC)' LL='$(LL)' ALL_CFLAGS='$(ALL_CFLAGS)' endif + ############################## # generic build targets, rules @@ -63,5 +61,5 @@ $(LIBR) : .PHONY : clean clean : @echo "make: removing targets, objects and depend files of `pwd`" - -rm -f $(EXE) $(OBJS) - -rm -f $(OBJS:.o=.d) + -$(RM_F) $(EXE) $(OBJS) + -$(RM_F) $(OBJS:.o=.d) diff --git a/tools/mruby/Makefile b/tools/mruby/Makefile index 052aa93d6..0442bd422 100644 --- a/tools/mruby/Makefile +++ b/tools/mruby/Makefile @@ -26,9 +26,6 @@ LIBS = -lm INCLUDES = -I$(BASEDIR) -I$(BASEDIR)/../include # compiler, linker (gcc) -CC = gcc -LL = gcc -YACC = bison DEBUG_MODE = 1 ifeq ($(DEBUG_MODE),1) CFLAGS = -g -O3 @@ -73,5 +70,5 @@ clean : $(MAKE) clean -C ../../mrblib $(MAKE_FLAGS) $(MAKE) clean -C ../mrbc $(MAKE_FLAGS) @echo "make: removing targets, objects and depend files of `pwd`" - -rm -f $(EXE) $(OBJS) - -rm -f $(OBJS:.o=.d) + -$(RM_F) $(EXE) $(OBJS) + -$(RM_F) $(OBJS:.o=.d) |
