Commit e3ae5bb9 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #188 from thecodeshop/makefile-mods

Makefile mods
parents 265ff670 105c11b7
# makefile discription. # makefile discription.
# basic build file for mruby # basic build file for mruby
# compiler, linker (gcc) # compiler, linker (gcc), archiver, parser generator
CC = gcc export CC = gcc
LL = gcc export LL = gcc
export AR = ar
export YACC = bison
DEBUG_MODE = 1 DEBUG_MODE = 1
ifeq ($(DEBUG_MODE),1) ifeq ($(DEBUG_MODE),1)
CFLAGS = -g -O3 CFLAGS = -g -O3
...@@ -17,6 +20,16 @@ else ...@@ -17,6 +20,16 @@ else
MAKE_FLAGS = --no-print-directory CC='$(CC)' LL='$(LL)' ALL_CFLAGS='$(ALL_CFLAGS)' MAKE_FLAGS = --no-print-directory CC='$(CC)' LL='$(LL)' ALL_CFLAGS='$(ALL_CFLAGS)'
endif 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 # generic build targets, rules
...@@ -39,3 +52,29 @@ clean : ...@@ -39,3 +52,29 @@ clean :
@$(MAKE) clean -C tools/mruby $(MAKE_FLAGS) @$(MAKE) clean -C tools/mruby $(MAKE_FLAGS)
@$(MAKE) clean -C tools/mirb $(MAKE_FLAGS) @$(MAKE) clean -C tools/mirb $(MAKE_FLAGS)
@$(MAKE) clean -C test $(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)
...@@ -15,17 +15,15 @@ MRBS := $(MRB1) ...@@ -15,17 +15,15 @@ MRBS := $(MRB1)
LIBR0 := ../lib/libmruby_core.a LIBR0 := ../lib/libmruby_core.a
LIBR := ../lib/libmruby.a LIBR := ../lib/libmruby.a
# C compiler (gcc) # libraries, includes
CC = gcc INCLUDES = -I../src -I../include
LL = gcc
AR = ar
DEBUG_MODE = 1 DEBUG_MODE = 1
ifeq ($(DEBUG_MODE),1) ifeq ($(DEBUG_MODE),1)
CFLAGS = -g CFLAGS = -g
else else
CFLAGS = -O3 CFLAGS = -O3
endif endif
INCLUDES = -I../src -I../include
ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS) ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS)
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
MAKE_FLAGS = CC=$(CC) LL=$(LL) ALL_CFLAGS="$(ALL_CFLAGS)" MAKE_FLAGS = CC=$(CC) LL=$(LL) ALL_CFLAGS="$(ALL_CFLAGS)"
...@@ -40,6 +38,7 @@ else ...@@ -40,6 +38,7 @@ else
MRBC = ../bin/mrbc MRBC = ../bin/mrbc
endif endif
############################## ##############################
# generic build targets, rules # generic build targets, rules
...@@ -48,7 +47,7 @@ all : $(LIBR) ...@@ -48,7 +47,7 @@ all : $(LIBR)
# update libmruby.a # update libmruby.a
$(LIBR) : $(MLIB) $(LIBR0) $(LIBR) : $(MLIB) $(LIBR0)
cp $(LIBR0) $(LIBR) $(CP) $(LIBR0) $(LIBR)
$(AR) r $(LIBR) $(MLIB) $(AR) r $(LIBR) $(MLIB)
# Compile mrblib source # Compile mrblib source
...@@ -57,17 +56,17 @@ $(MLIB) : $(CLIB) ...@@ -57,17 +56,17 @@ $(MLIB) : $(CLIB)
# Compile C source from merged mruby source # Compile C source from merged mruby source
$(CLIB) : $(RLIB) $(MRBC) $(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 $(MRBC) : ../src/opcode.h ../src/codegen.c ../src/parse.y
$(MAKE) -C ../tools/mrbc $(MAKE_FLAGS) $(MAKE) -C ../tools/mrbc $(MAKE_FLAGS)
# merge mruby sources # merge mruby sources
$(RLIB) : $(MRBS) $(RLIB) : $(MRBS)
cat $? > $@ $(CAT) $? > $@
# clean up # clean up
.PHONY : clean .PHONY : clean
clean : clean :
@echo "make: removing targets, objects and depend files of `pwd`" @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)
...@@ -19,12 +19,6 @@ OBJS := $(OBJ1) $(OBJ2) $(OBJ3) ...@@ -19,12 +19,6 @@ OBJS := $(OBJ1) $(OBJ2) $(OBJ3)
# libraries, includes # libraries, includes
INCLUDES = -I$(BASEDIR) -I$(BASEDIR)/../include INCLUDES = -I$(BASEDIR) -I$(BASEDIR)/../include
# compiler, linker (gcc)
CC = gcc
LL = gcc
AR = ar
YACC = bison
DEBUG_MODE = 1 DEBUG_MODE = 1
ifeq ($(DEBUG_MODE),1) ifeq ($(DEBUG_MODE),1)
CFLAGS = -g -O3 CFLAGS = -g -O3
...@@ -33,6 +27,7 @@ CFLAGS = -O3 ...@@ -33,6 +27,7 @@ CFLAGS = -O3
endif endif
ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS) ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS)
############################## ##############################
# generic build targets, rules # generic build targets, rules
...@@ -64,6 +59,6 @@ $(LDEF) : $(KWD) ...@@ -64,6 +59,6 @@ $(LDEF) : $(KWD)
.PHONY : clean #cleandep .PHONY : clean #cleandep
clean : clean :
@echo "make: removing targets, objects and depend files of `pwd`" @echo "make: removing targets, objects and depend files of `pwd`"
-rm -f $(TARGET) $(OBJS) $(OBJY) $(YC) -$(RM_F) $(TARGET) $(OBJS) $(OBJY) $(YC)
-rm -f $(OBJS:.o=.d) $(OBJY:.o=.d) -$(RM_F) $(OBJS:.o=.d) $(OBJY:.o=.d)
-rm -f $(patsubst %.c,%.o,$(EXCEPT1)) $(patsubst %.c,%.d,$(EXCEPT1)) -$(RM_F) $(patsubst %.c,%.o,$(EXCEPT1)) $(patsubst %.c,%.d,$(EXCEPT1))
...@@ -16,17 +16,16 @@ ASSLIB := $(BASEDIR)/assert.rb ...@@ -16,17 +16,16 @@ ASSLIB := $(BASEDIR)/assert.rb
MRBS := $(BASEDIR)/t/*.rb MRBS := $(BASEDIR)/t/*.rb
OBJS := driver.o $(MLIB) OBJS := driver.o $(MLIB)
# C compiler (gcc) # libraries, includes
CC = gcc LIBS = -lm
LL = gcc INCLUDES = -I$(BASEDIR)/../src -I$(BASEDIR)/../include
AR = ar
DEBUG_MODE = 1 DEBUG_MODE = 1
ifeq ($(DEBUG_MODE),1) ifeq ($(DEBUG_MODE),1)
CFLAGS = -g CFLAGS = -g
else else
CFLAGS = -O3 CFLAGS = -O3
endif endif
INCLUDES = -I../src -I../include
ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS) ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS)
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
MAKE_FLAGS = CC=$(CC) LL=$(LL) ALL_CFLAGS="$(ALL_CFLAGS)" MAKE_FLAGS = CC=$(CC) LL=$(LL) ALL_CFLAGS="$(ALL_CFLAGS)"
...@@ -43,20 +42,6 @@ MRBC = ../bin/mrbc ...@@ -43,20 +42,6 @@ MRBC = ../bin/mrbc
EXE := $(TARGET) EXE := $(TARGET)
endif 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 # generic build targets, rules
...@@ -77,14 +62,14 @@ $(OBJS) : %.o : %.c ...@@ -77,14 +62,14 @@ $(OBJS) : %.o : %.c
# Compile C source from merged mruby source # Compile C source from merged mruby source
$(CLIB) : $(RLIB) $(MRBC) $(INIT) $(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 # merge mruby sources
$(RLIB) : $(ASSLIB) $(MRBS) $(RLIB) : $(ASSLIB) $(MRBS)
cat $(ASSLIB) $(MRBS) > $@ $(CAT) $(ASSLIB) $(MRBS) > $@
# clean up # clean up
.PHONY : clean .PHONY : clean
clean : clean :
@echo "make: removing targets, objects and depend files of `pwd`" @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)
...@@ -21,10 +21,6 @@ EXTS := $(EXT1) ...@@ -21,10 +21,6 @@ EXTS := $(EXT1)
LIBS = -lm LIBS = -lm
INCLUDES = -I$(BASEDIR) -I$(BASEDIR)/../include INCLUDES = -I$(BASEDIR) -I$(BASEDIR)/../include
# compiler, linker (gcc)
CC = gcc
LL = gcc
YACC = bison
DEBUG_MODE = 1 DEBUG_MODE = 1
ifeq ($(DEBUG_MODE),1) ifeq ($(DEBUG_MODE),1)
CFLAGS = -g -O3 CFLAGS = -g -O3
...@@ -69,5 +65,5 @@ clean : ...@@ -69,5 +65,5 @@ clean :
$(MAKE) clean -C ../../mrblib $(MAKE_FLAGS) $(MAKE) clean -C ../../mrblib $(MAKE_FLAGS)
$(MAKE) clean -C ../mrbc $(MAKE_FLAGS) $(MAKE) clean -C ../mrbc $(MAKE_FLAGS)
@echo "make: removing targets, objects and depend files of `pwd`" @echo "make: removing targets, objects and depend files of `pwd`"
-rm -f $(EXE) $(OBJS) -$(RM_F) $(EXE) $(OBJS)
-rm -f $(OBJS:.o=.d) -$(RM_F) $(OBJS:.o=.d)
...@@ -23,9 +23,6 @@ LIBS = -lm ...@@ -23,9 +23,6 @@ LIBS = -lm
INCLUDES = -I$(BASEDIR) -I$(BASEDIR)/../include INCLUDES = -I$(BASEDIR) -I$(BASEDIR)/../include
# compiler, linker (gcc) # compiler, linker (gcc)
CC = gcc
LL = gcc
YACC = bison
DEBUG_MODE = 1 DEBUG_MODE = 1
ifeq ($(DEBUG_MODE),1) ifeq ($(DEBUG_MODE),1)
CFLAGS = -g -O3 CFLAGS = -g -O3
...@@ -39,6 +36,7 @@ else ...@@ -39,6 +36,7 @@ else
MAKE_FLAGS = CC='$(CC)' LL='$(LL)' ALL_CFLAGS='$(ALL_CFLAGS)' MAKE_FLAGS = CC='$(CC)' LL='$(LL)' ALL_CFLAGS='$(ALL_CFLAGS)'
endif endif
############################## ##############################
# generic build targets, rules # generic build targets, rules
...@@ -63,5 +61,5 @@ $(LIBR) : ...@@ -63,5 +61,5 @@ $(LIBR) :
.PHONY : clean .PHONY : clean
clean : clean :
@echo "make: removing targets, objects and depend files of `pwd`" @echo "make: removing targets, objects and depend files of `pwd`"
-rm -f $(EXE) $(OBJS) -$(RM_F) $(EXE) $(OBJS)
-rm -f $(OBJS:.o=.d) -$(RM_F) $(OBJS:.o=.d)
...@@ -26,9 +26,6 @@ LIBS = -lm ...@@ -26,9 +26,6 @@ LIBS = -lm
INCLUDES = -I$(BASEDIR) -I$(BASEDIR)/../include INCLUDES = -I$(BASEDIR) -I$(BASEDIR)/../include
# compiler, linker (gcc) # compiler, linker (gcc)
CC = gcc
LL = gcc
YACC = bison
DEBUG_MODE = 1 DEBUG_MODE = 1
ifeq ($(DEBUG_MODE),1) ifeq ($(DEBUG_MODE),1)
CFLAGS = -g -O3 CFLAGS = -g -O3
...@@ -73,5 +70,5 @@ clean : ...@@ -73,5 +70,5 @@ clean :
$(MAKE) clean -C ../../mrblib $(MAKE_FLAGS) $(MAKE) clean -C ../../mrblib $(MAKE_FLAGS)
$(MAKE) clean -C ../mrbc $(MAKE_FLAGS) $(MAKE) clean -C ../mrbc $(MAKE_FLAGS)
@echo "make: removing targets, objects and depend files of `pwd`" @echo "make: removing targets, objects and depend files of `pwd`"
-rm -f $(EXE) $(OBJS) -$(RM_F) $(EXE) $(OBJS)
-rm -f $(OBJS:.o=.d) -$(RM_F) $(OBJS:.o=.d)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment