From b5dcb7128d7d235b66b4d9be879d26364dd1e3e9 Mon Sep 17 00:00:00 2001 From: Beoran Date: Tue, 1 May 2012 20:13:09 +0200 Subject: First cmake build system. Works on Linux. --- mrblib/CMakeLists.txt | 35 ++++++++++++++++++++++++ mrblib/Makefile | 73 --------------------------------------------------- mrblib/Makefile.orig | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 73 deletions(-) create mode 100644 mrblib/CMakeLists.txt delete mode 100644 mrblib/Makefile create mode 100644 mrblib/Makefile.orig (limited to 'mrblib') diff --git a/mrblib/CMakeLists.txt b/mrblib/CMakeLists.txt new file mode 100644 index 000000000..30881c611 --- /dev/null +++ b/mrblib/CMakeLists.txt @@ -0,0 +1,35 @@ +# build mrblib +# need custom commands +# Compile C source from merged mruby source + +file(GLOB MRBLIB_SRC_RB "*.rb") + +# generate the a single rubu file from all the existing ones. +add_custom_command(OUTPUT mrblib.rbtmp +COMMAND cat ${MRBLIB_SRC_RB} > mrblib.rbtmp +DEPENDS ${MRBLIB_SRC_RB} +) + +# generate the intermediate representation in C +add_custom_command(OUTPUT mrblib_irep.c +COMMAND echo -B mrblib_irep -o mrblib_irep.c mrblib.rbtmp +COMMAND mrbc -Bmrblib_irep -omrblib_irep.c mrblib.rbtmp +DEPENDS mrblib.rbtmp +) + +# finally generate the library's c file +add_custom_command(OUTPUT mrblib.c +COMMAND cat init_mrblib.c mrblib_irep.c > mrblib.c +DEPENDS init_mrblib.c mrblib_irep.c +) + +# only use this C file to generate mrblib. +set(MRBLIB_SRC_C mrblib.c) +# add_library(mrblib_static STATIC ${MRBLIB_SRC_C}) +add_library(mrblib_object OBJECT ${MRBLIB_SRC_C}) +# target_link_libraries(mrblib ritevm ${MRUBY_LIBS}) +# target_link_libraries(mrblib_static ritevm_static ${MRUBY_LIBS}) +# install(TARGETS mrblib mrblib_static +# LIBRARY DESTINATION lib +# ARCHIVE DESTINATION lib) + diff --git a/mrblib/Makefile b/mrblib/Makefile deleted file mode 100644 index d22c4509f..000000000 --- a/mrblib/Makefile +++ /dev/null @@ -1,73 +0,0 @@ -# makefile discription. -# basic build file for mruby library (Ruby part) - -# project-specific macros -# extension of the executable-file is modifiable(.exe .out ...) -BASEDIR = . -TARGET := mrblib -MLIB := $(TARGET).o -CLIB := $(TARGET).c -DLIB := $(TARGET).ctmp -RLIB := $(TARGET).rbtmp -DEPLIB := $(TARGET).d -MRB1 := $(BASEDIR)/*.rb -MRBS := $(MRB1) -LIBR0 := ../lib/libmruby_core.a -LIBR := ../lib/libmruby.a - -# C compiler (gcc) -CC = gcc -LL = gcc -AR = ar -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)" -else - MAKE_FLAGS = CC='$(CC)' LL='$(LL)' ALL_CFLAGS='$(ALL_CFLAGS)' -endif - -# mruby compiler -ifeq ($(OS),Windows_NT) -MRBC = ../bin/mrbc.exe -else -MRBC = ../bin/mrbc -endif - -############################## -# generic build targets, rules - -.PHONY : all -all : $(LIBR) - -# update libmruby.a -$(LIBR) : $(MLIB) $(LIBR0) - cp $(LIBR0) $(LIBR) - $(AR) r $(LIBR) $(MLIB) - -# Compile mrblib source -$(MLIB) : $(CLIB) - $(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $(CLIB) -o $(MLIB) - -# Compile C source from merged mruby source -$(CLIB) : $(RLIB) $(MRBC) - $(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 $? > $@ - -# clean up -.PHONY : clean -clean : - @echo "make: removing targets, objects and depend files of `pwd`" - -rm -f $(MRBC) $(MLIB) $(CLIB) $(RLIB) $(DLIB) $(DEPLIB) $(LIBR) diff --git a/mrblib/Makefile.orig b/mrblib/Makefile.orig new file mode 100644 index 000000000..d22c4509f --- /dev/null +++ b/mrblib/Makefile.orig @@ -0,0 +1,73 @@ +# makefile discription. +# basic build file for mruby library (Ruby part) + +# project-specific macros +# extension of the executable-file is modifiable(.exe .out ...) +BASEDIR = . +TARGET := mrblib +MLIB := $(TARGET).o +CLIB := $(TARGET).c +DLIB := $(TARGET).ctmp +RLIB := $(TARGET).rbtmp +DEPLIB := $(TARGET).d +MRB1 := $(BASEDIR)/*.rb +MRBS := $(MRB1) +LIBR0 := ../lib/libmruby_core.a +LIBR := ../lib/libmruby.a + +# C compiler (gcc) +CC = gcc +LL = gcc +AR = ar +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)" +else + MAKE_FLAGS = CC='$(CC)' LL='$(LL)' ALL_CFLAGS='$(ALL_CFLAGS)' +endif + +# mruby compiler +ifeq ($(OS),Windows_NT) +MRBC = ../bin/mrbc.exe +else +MRBC = ../bin/mrbc +endif + +############################## +# generic build targets, rules + +.PHONY : all +all : $(LIBR) + +# update libmruby.a +$(LIBR) : $(MLIB) $(LIBR0) + cp $(LIBR0) $(LIBR) + $(AR) r $(LIBR) $(MLIB) + +# Compile mrblib source +$(MLIB) : $(CLIB) + $(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $(CLIB) -o $(MLIB) + +# Compile C source from merged mruby source +$(CLIB) : $(RLIB) $(MRBC) + $(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 $? > $@ + +# clean up +.PHONY : clean +clean : + @echo "make: removing targets, objects and depend files of `pwd`" + -rm -f $(MRBC) $(MLIB) $(CLIB) $(RLIB) $(DLIB) $(DEPLIB) $(LIBR) -- cgit v1.2.3