Permalink
Browse files

build process restructured

  • Loading branch information...
1 parent f8fb947 commit db999237bc0f9d8e9aed5f22f41b780884ceb6b8 @matz matz committed Apr 30, 2012
Showing with 71 additions and 163 deletions.
  1. +11 −78 Makefile
  2. +8 −6 mrblib/Makefile
  3. +6 −27 src/Makefile
  4. +20 −24 tools/mrbc/Makefile
  5. +26 −28 tools/mruby/Makefile
View
@@ -1,42 +1,5 @@
# makefile discription.
-# basic build file for Rite-VM(mruby)
-# 11.Apr.2011 coded by Kenji Yoshimoto.
-# 17.Jan.2012 coded by Hiroshi Mimaki.
-
-# project-specific macros
-# extension of the executable-file is modifiable(.exe .out ...)
-TARGET := bin/mrubysample
-RITEVM := lib/ritevm
-MRUBY := tools/mruby/mruby
-ifeq ($(OS),Windows_NT)
-EXE := $(TARGET).exe
-LIB := $(RITEVM).lib
-MRB := $(MRUBY).exe
-else
-EXE := $(TARGET)
-LIB := $(RITEVM).a
-MRB := $(MRUBY)
-endif
-MSRC := src/minimain.c
-YSRC := src/parse.y
-YC := src/y.tab.c
-EXCEPT1 := $(YC) $(MSRC)
-OBJM := $(patsubst %.c,%.o,$(MSRC))
-OBJY := $(patsubst %.c,%.o,$(YC))
-OBJ1 := $(patsubst %.c,%.o,$(filter-out $(EXCEPT1),$(wildcard src/*.c)))
-#OBJ2 := $(patsubst %.c,%.o,$(wildcard ext/regex/*.c))
-#OBJ3 := $(patsubst %.c,%.o,$(wildcard ext/enc/*.c))
-OBJS := $(OBJ1) $(OBJ2) $(OBJ3)
-# mruby libraries
-EXTC := mrblib/mrblib.c
-EXTRB := $(wildcard mrblib/*.rb)
-EXT0 := $(patsubst %.c,%.o,src/$(EXTC))
-# ext libraries
-EXTS := $(EXT0)
-
-# libraries, includes
-LIBS = $(LIB) -lm
-INCLUDES = -I./src -I./include
+# basic build file for mruby
# library for iOS
IOSLIB := $(RITEVM)-ios.a
@@ -48,24 +11,26 @@ IOSDEVCC := xcrun -sdk iphoneos llvm-gcc-4.2 -arch armv7 -isysroot "/Developer/P
# compiler, linker (gcc)
CC = gcc
LL = gcc
-YACC = bison
DEBUG_MODE = 1
ifeq ($(DEBUG_MODE),1)
-CFLAGS = -g
+CFLAGS = -g -O3
else
CFLAGS = -O3
endif
ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS)
-MAKE_FLAGS = --no-print-directory CC=$(CC) LL=$(LL)
+ifeq ($(OS),Windows_NT)
+ MAKE_FLAGS = --no-print-directory CC=$(CC) LL=$(LL) ALL_CFLAGS='$(ALL_CFLAGS)'
+else
+ MAKE_FLAGS = --no-print-directory CC='$(CC)' LL='$(LL)' ALL_CFLAGS='$(ALL_CFLAGS)'
+endif
##############################
# generic build targets, rules
.PHONY : all
-all : $(LIB) $(MRB) $(EXE)
- @echo "make: built targets of `pwd`"
+all :
+ @$(MAKE) -C tools/mruby $(MAKE_FLAGS)
-##############################
# make library for iOS
.PHONY : ios
ios : $(IOSLIB)
@@ -83,40 +48,8 @@ $(IOSDEVLIB) :
$(MAKE) -C src $(MAKE_FLAGS) CC="$(IOSDEVCC)" LL="$(IOSDEVCC)"
cp $(LIB) $(IOSDEVLIB)
-# executable constructed using linker from object files
-$(EXE) : $(OBJM) $(LIB)
- $(LL) -o $@ $(OBJM) $(LIBS)
-
--include $(OBJS:.o=.d)
-
-# src compile
-$(LIB) : $(EXTS) $(OBJS) $(OBJY)
- $(MAKE) -C src $(MAKE_FLAGS)
-
-# mruby interpreter compile
-$(MRB) : $(EXTS) $(OBJS) $(OBJY)
- $(MAKE) -C tools/mruby $(MAKE_FLAGS)
-
-# objects compiled from source
-$(OBJS) :
- $(MAKE) -C src $(MAKE_FLAGS) && $(MAKE) -C tools/mruby $(MAKE_FLAGS)
-
-# extend libraries complile
-$(EXTS) : $(EXTRB)
- $(MAKE) -C mrblib $(MAKE_FLAGS)
-
-# test module compile
-$(OBJM) : $(MSRC)
- $(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $(MSRC) -o $(OBJM)
-
# clean up
.PHONY : clean
clean :
- $(MAKE) clean -C src $(MAKE_FLAGS)
- $(MAKE) clean -C tools/mrbc $(MAKE_FLAGS)
- $(MAKE) clean -C tools/mruby $(MAKE_FLAGS)
- -rm -f $(EXE) $(OBJM)
- -rm -f $(OBJM:.o=.d)
- -rm -f $(patsubst %.c,%.o,$(EXCEPT1)) $(patsubst %.c,%.d,$(EXCEPT1))
- -rm -f $(IOSLIB) $(IOSSIMLIB) $(IOSDEVLIB)
- @echo "make: removing targets, objects and depend files of `pwd`"
+ @$(MAKE) clean -C src $(MAKE_FLAGS)
+ @$(MAKE) clean -C tools/mruby $(MAKE_FLAGS)
View
@@ -1,6 +1,5 @@
# makefile discription.
-# basic build file for RiteVM library
-# 11.Oct.2011 coded by Hiroshi Mimaki.
+# basic build file for mruby library (Ruby part)
# project-specific macros
# extension of the executable-file is modifiable(.exe .out ...)
@@ -24,7 +23,11 @@ CFLAGS = -O3
endif
INCLUDES = -I../src -I../include
ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS)
-MAKE_FLAGS = --no-print-directory CC=$(CC) LL=$(LL)
+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
# mruby compiler
ifeq ($(OS),Windows_NT)
@@ -58,8 +61,7 @@ $(RLIB) : $(MRBS)
# clean up
.PHONY : clean
clean :
- -rm -f $(MRBC) $(MLIB) $(CLIB) $(RLIB) $(DLIB)
- -rm -f $(patsubst %.c,%.d,$(CLIB))
- -rm -f $(patsubst %.c,%.o,$(EXCEPT1)) $(patsubst %.c,%.d,$(EXCEPT1))
@echo "make: removing targets, objects and depend files of `pwd`"
+ -rm -f $(MRBC) $(MLIB) $(CLIB) $(RLIB) $(DLIB)
+ -rm -f $(OBJS:.o=.d)
View
@@ -1,7 +1,5 @@
# makefile discription.
-# basic build file for RiteVM library
-# 11.Apr.2011 coded by Kenji Yoshimoto.
-# 31.Aug.2011 coded by Hiroshi Mimaki.
+# basic build file for mruby library
# project-specific macros
# extension of the executable-file is modifiable(.exe .out ...)
@@ -14,23 +12,15 @@ LIB := $(TARGET).a
endif
YSRC := $(BASEDIR)/parse.y
YC := $(BASEDIR)/y.tab.c
-EXCEPT1 := $(YC) $(BASEDIR)/minimain.c $(BASEDIR)/compile.c $(BASEDIR)/dump.c $(BASEDIR)/cdump.c
+EXCEPT1 := $(YC) $(BASEDIR)/minimain.c
OBJY := $(patsubst %.c,%.o,$(YC))
OBJ1 := $(patsubst %.c,%.o,$(filter-out $(EXCEPT1),$(wildcard $(BASEDIR)/*.c)))
#OBJ2 := $(patsubst %.c,%.o,$(wildcard $(BASEDIR)/ext/regex/*.c))
#OBJ3 := $(patsubst %.c,%.o,$(wildcard $(BASEDIR)/ext/enc/*.c))
OBJS := $(OBJ1) $(OBJ2) $(OBJ3)
-# mruby libraries
-EXTC := $(BASEDIR)/../mrblib/mrblib.c
-EXTRB := $(wildcard $(BASEDIR)/../mrblib/*.rb)
-EXTM := $(patsubst %.c,%.o,$(EXTC))
-# extend libraries
-#EXT1 := $(patsubst %.c,%.o,$(wildcard $(BASEDIR)/ext/socket/*.c))
-EXTS := $(EXT1)
# libraries, includes
INCLUDES = -I$(BASEDIR) -I$(BASEDIR)/../include
-#INCLUDES = -I$(RITEVM_ROOT)
# compiler, linker (gcc)
CC = gcc
@@ -45,33 +35,24 @@ else
CFLAGS = -O3
endif
ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS)
-MAKE_FLAGS = --no-print-directory CC=$(CC) LL=$(LL)
##############################
# generic build targets, rules
.PHONY : all
-all : $(EXTM) $(LIB)
+all : $(LIB)
@echo "make: built targets of `pwd`"
# executable constructed using linker from object files
-$(LIB) : $(OBJS) $(OBJY) $(EXTM) $(EXTS)
- $(AR) r $@ $(OBJS) $(OBJY) $(EXTM) $(EXTS)
+$(LIB) : $(OBJS) $(OBJY)
+ $(AR) r $@ $(OBJS) $(OBJY)
-include $(OBJS:.o=.d) $(OBJY:.o=.d)
# objects compiled from source
$(OBJS) : %.o : %.c
$(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $< -o $@
-# mruby library compile
-$(EXTM) : $(EXTRB) $(OBJS) $(OBJY)
- $(MAKE) -C ../mrblib $(MAKE_FLAGS)
-
-# extend libraries complile
-$(EXTS) : %.o : %.c
- $(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $< -o $@
-
# parser complie
$(OBJY) : $(YC)
$(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $(YC) -o $(OBJY)
@@ -83,9 +64,7 @@ $(YC) : $(YSRC)
# clean up
.PHONY : clean #cleandep
clean :
- $(MAKE) clean -C ../mrblib $(MAKE_FLAGS)
+ @echo "make: removing targets, objects and depend files of `pwd`"
-rm -f $(LIB) $(OBJS) $(OBJY) $(YC)
-rm -f $(OBJS:.o=.d) $(OBJY:.o=.d)
-rm -f $(patsubst %.c,%.o,$(EXCEPT1)) $(patsubst %.c,%.d,$(EXCEPT1))
- @echo "make: removing targets, objects and depend files of `pwd`"
-
View
@@ -1,26 +1,24 @@
# makefile discription.
-# basic build file for Rite-Compiler
-# 11.Apr.2011 coded by Kenji Yoshimoto.
-# 31.Aug.2011 coded by Hiroshi Mimaki.
+# basic build file for mruby-compiler
# project-specific macros
# extension of the executable-file is modifiable(.exe .out ...)
BASEDIR := ../../src
TARGET := ../../bin/mrbc
+LIB := ../../lib/ritevm
ifeq ($(OS),Windows_NT)
EXE := $(TARGET).exe
+LIBR := $(LIB).lib
else
EXE := $(TARGET)
+LIBR := $(LIB).a
endif
-YSRC := $(BASEDIR)/parse.y
-YC := $(BASEDIR)/y.tab.c
-EXCEPT1 := $(YC) $(BASEDIR)/minimain.c $(BASEDIR)/load.c $(BASEDIR)/init_ext.c
-OBJY := $(patsubst %.c,%.o,$(YC))
+EXCEPT1 :=
OBJ0 := $(patsubst %.c,%.o,$(wildcard $(BASEDIR)/../tools/mrbc/*.c))
-OBJ1 := $(patsubst %.c,%.o,$(filter-out $(EXCEPT1),$(wildcard $(BASEDIR)/*.c)))
+#OBJ1 := $(patsubst %.c,%.o,$(filter-out $(EXCEPT1),$(wildcard $(BASEDIR)/*.c)))
#OBJ2 := $(patsubst %.c,%.o,$(wildcard $(BASEDIR)/ext/regex/*.c))
#OBJ3 := $(patsubst %.c,%.o,$(wildcard $(BASEDIR)/ext/enc/*.c))
-OBJS := $(OBJ0) $(OBJ1) $(OBJ2) $(OBJ3)
+OBJS := $(OBJ0)
# libraries, includes
LIBS = -lm
@@ -37,7 +35,11 @@ else
CFLAGS = -O3
endif
ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS)
-MAKE_FLAGS = --no-print-directory CC=$(CC) LL=$(LL)
+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
@@ -47,28 +49,22 @@ all : $(EXE)
@echo "make: built targets of `pwd`"
# executable constructed using linker from object files
-$(EXE) : $(OBJS) $(OBJY)
- $(LL) -o $@ $(OBJS) $(OBJY) $(LIBS)
+$(EXE) : $(OBJS) $(LIBR)
+ $(LL) -o $@ $(OBJS) $(LIBR) $(LIBS)
--include $(OBJS:.o=.d) $(OBJY:.o=.d)
+-include $(OBJS:.o=.d)
# objects compiled from source
$(OBJS) : %.o : %.c
$(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $< -o $@
-# parser complie
-$(OBJY) : $(YC)
- $(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $(YC) -o $(OBJY)
-
-# yacc complie
-$(YC) : $(YSRC)
- $(YACC) -o $(YC) $(YSRC)
+# C library compile
+$(LIBR) :
+ @$(MAKE) -C $(BASEDIR) $(MAKE_FLAGS)
# clean up
.PHONY : clean
clean :
- -rm -f $(EXE) $(OBJS) $(OBJY) $(YC)
- -rm -f $(OBJS:.o=.d) $(OBJY:.o=.d)
- -rm -f $(patsubst %.c,%.o,$(EXCEPT1)) $(patsubst %.c,%.d,$(EXCEPT1))
@echo "make: removing targets, objects and depend files of `pwd`"
-
+ -rm -f $(EXE) $(OBJS)
+ -rm -f $(OBJS:.o=.d)
Oops, something went wrong.

0 comments on commit db99923

Please sign in to comment.