Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 121 lines (102 sloc) 3.202 kb
e0d6430 Hiroshi Mimaki add mruby sources
mimaki authored
1 # makefile discription.
2 # basic build file for Rite-VM(mruby)
3 # 11.Apr.2011 coded by Kenji Yoshimoto.
4 # 17.Jan.2012 coded by Hiroshi Mimaki.
5
6 # project-specific macros
7 # extension of the executable-file is modifiable(.exe .out ...)
8 TARGET := bin/mrubysample
9 RITEVM := lib/ritevm
10 MRUBY := tools/mruby/mruby
11 ifeq ($(OS),Windows_NT)
12 EXE := $(TARGET).exe
13 LIB := $(RITEVM).lib
14 MRB := $(MRUBY).exe
15 else
16 EXE := $(TARGET)
17 LIB := $(RITEVM).a
18 MRB := $(MRUBY)
19 endif
20 MSRC := src/minimain.c
21 YSRC := src/parse.y
22 YC := src/y.tab.c
23 EXCEPT1 := $(YC) $(MSRC)
24 OBJM := $(patsubst %.c,%.o,$(MSRC))
25 OBJY := $(patsubst %.c,%.o,$(YC))
26 OBJ1 := $(patsubst %.c,%.o,$(filter-out $(EXCEPT1),$(wildcard src/*.c)))
27 #OBJ2 := $(patsubst %.c,%.o,$(wildcard ext/regex/*.c))
28 #OBJ3 := $(patsubst %.c,%.o,$(wildcard ext/enc/*.c))
29 OBJS := $(OBJ1) $(OBJ2) $(OBJ3)
30 # mruby libraries
31 EXTC := mrblib/mrblib.c
32 EXTRB := $(wildcard mrblib/*.rb)
33 EXT0 := $(patsubst %.c,%.o,src/$(EXTC))
34 # ext libraries
35 EXTS := $(EXT0)
36
37 # libraries, includes
38 LIBS = $(LIB) -lm
39 INCLUDES = -I./src -I./include
40
41 # library for iOS
42 IOSLIB := $(RITEVM)-ios.a
43 IOSSIMLIB := $(RITEVM)-iossim.a
44 IOSDEVLIB := $(RITEVM)-iosdev.a
45 IOSSIMCC := xcrun -sdk iphoneos llvm-gcc-4.2 -arch i386 -isysroot "/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/"
46 IOSDEVCC := xcrun -sdk iphoneos llvm-gcc-4.2 -arch armv7 -isysroot "/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/"
47
48 # compiler, linker (gcc)
49 CC = gcc
50 LL = gcc
51 YACC = bison
52 DEBUG_MODE = 1
53 ifeq ($(DEBUG_MODE),1)
54 CFLAGS = -g
55 else
56 CFLAGS = -O3
57 endif
58 ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS)
59 MAKE_FLAGS = --no-print-directory CC="$(CC)" LL="$(LL)"
60
61 ##############################
62 # generic build targets, rules
63
64 .PHONY : all
65 all : $(LIB) $(MRB) $(EXE)
66 @echo "make: built targets of `pwd`"
67
68 ##############################
69 # make library for iOS
70 .PHONY : ios
71 ios : $(IOSLIB)
72
73 $(IOSLIB) : $(IOSSIMLIB) $(IOSDEVLIB)
74 lipo -arch i386 $(IOSSIMLIB) -arch armv7 $(IOSDEVLIB) -create -output $(IOSLIB)
75
76 $(IOSSIMLIB) :
77 $(MAKE) clean -C src $(MAKE_FLAGS)
78 $(MAKE) -C src $(MAKE_FLAGS) CC="$(IOSSIMCC)" LL="$(IOSSIMCC)"
79 cp $(LIB) $(IOSSIMLIB)
80
81 $(IOSDEVLIB) :
82 $(MAKE) clean -C src $(MAKE_FLAGS)
83 $(MAKE) -C src $(MAKE_FLAGS) CC="$(IOSDEVCC)" LL="$(IOSDEVCC)"
84 cp $(LIB) $(IOSDEVLIB)
85
86 # executable constructed using linker from object files
87 $(EXE) : $(OBJM) $(LIB)
88 $(LL) -o $@ $(OBJM) $(LIBS)
89
90 -include $(OBJS:.o=.d)
91
92 # src compile
93 $(LIB) : $(EXTS) $(OBJS) $(OBJY)
94 $(MAKE) -C src $(MAKE_FLAGS)
95
96 # mruby interpreter compile
97 $(MRB) : $(EXTS) $(OBJS) $(OBJY)
98 $(MAKE) -C tools/mruby $(MAKE_FLAGS)
99
100 # objects compiled from source
101 $(OBJS) :
102 $(MAKE) -C src $(MAKE_FLAGS) && $(MAKE) -C tools/mruby $(MAKE_FLAGS)
103
104 # extend libraries complile
105 $(EXTS) : $(EXTRB)
106 $(MAKE) -C mrblib $(MAKE_FLAGS)
107
108 # test module compile
109 $(OBJM) : $(MSRC)
110 $(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $(MSRC) -o $(OBJM)
111
112 # clean up
113 .PHONY : clean
114 clean :
115 $(MAKE) clean -C src $(MAKE_FLAGS)
116 $(MAKE) clean -C tools/mruby $(MAKE_FLAGS)
117 -rm -f $(EXE) $(OBJM)
118 -rm -f $(OBJM:.o=.d)
119 -rm -f $(IOSLIB) $(IOSSIMLIB) $(IOSDEVLIB)
120 @echo "make: removing targets, objects and depend files of `pwd`"
Something went wrong with that request. Please try again.