summaryrefslogtreecommitdiffhomepage
path: root/src/Makefile
diff options
context:
space:
mode:
authorJon <[email protected]>2012-05-02 20:46:09 -0400
committerJon <[email protected]>2012-05-22 10:50:28 -0400
commit9f89da6eef2c830db6fc3abb08fe755ae7ce9b6c (patch)
treed1feb367d93853b5f05ce2bbed2171a561631b31 /src/Makefile
parentb5dcb7128d7d235b66b4d9be879d26364dd1e3e9 (diff)
downloadmruby-9f89da6eef2c830db6fc3abb08fe755ae7ce9b6c.tar.gz
mruby-9f89da6eef2c830db6fc3abb08fe755ae7ce9b6c.zip
Add native and cross compiling CMake build support
Diffstat (limited to 'src/Makefile')
-rw-r--r--src/Makefile64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 000000000..14485041d
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,64 @@
+# makefile discription.
+# basic build file for mruby library
+
+# project-specific macros
+# extension of the executable-file is modifiable(.exe .out ...)
+BASEDIR = .
+TARGET := ../lib/libmruby_core.a
+YSRC := $(BASEDIR)/parse.y
+YC := $(BASEDIR)/y.tab.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)
+
+# 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
+else
+CFLAGS = -O3
+endif
+ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS)
+
+##############################
+# generic build targets, rules
+
+.PHONY : all
+all : $(TARGET)
+
+# executable constructed using linker from object files
+$(TARGET) : $(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 $@
+
+# parser complie
+$(OBJY) : $(YC)
+ $(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $(YC) -o $(OBJY)
+
+# yacc complie
+$(YC) : $(YSRC)
+ $(YACC) -o $(YC) $(YSRC)
+
+# clean up
+.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))