Permalink
Browse files

Make CFLAG choices in Makefiles more flexible

  • Loading branch information...
1 parent f88a839 commit 83e5999d7efcad648e9ecbd64c51b305b6261999 @bovi bovi committed Jun 18, 2012
Showing with 82 additions and 33 deletions.
  1. +12 −5 Makefile
  2. +12 −5 mrblib/Makefile
  3. +12 −5 src/Makefile
  4. +12 −5 test/Makefile
  5. +10 −3 tools/mirb/Makefile
  6. +12 −5 tools/mrbc/Makefile
  7. +12 −5 tools/mruby/Makefile
View
@@ -7,12 +7,19 @@ export LL = gcc
export AR = ar
export YACC = bison
-DEBUG_MODE = 1
-ifeq ($(DEBUG_MODE),1)
-CFLAGS = -g -O3
-else
-CFLAGS = -O3
+ifeq ($(strip $(COMPILE_MODE)),)
+ # default compile option
+ COMPILE_MODE = debug
+endif
+
+ifeq ($(COMPILE_MODE),debug)
+ CFLAGS = -g -O3
+else ifeq ($(COMPILE_MODE),release)
+ CFLAGS = -O3
+else ifeq ($(COMPILE_MODE),small)
+ CFLAGS = -Os
endif
+
ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS)
ifeq ($(OS),Windows_NT)
MAKE_FLAGS = --no-print-directory CC=$(CC) LL=$(LL) ALL_CFLAGS='$(ALL_CFLAGS)'
View
@@ -18,12 +18,19 @@ LIBR := ../lib/libmruby.a
# libraries, includes
INCLUDES = -I../src -I../include
-DEBUG_MODE = 1
-ifeq ($(DEBUG_MODE),1)
-CFLAGS = -g
-else
-CFLAGS = -O3
+ifeq ($(strip $(COMPILE_MODE)),)
+ # default compile option
+ COMPILE_MODE = debug
+endif
+
+ifeq ($(COMPILE_MODE),debug)
+ CFLAGS = -g -O3
+else ifeq ($(COMPILE_MODE),release)
+ CFLAGS = -O3
+else ifeq ($(COMPILE_MODE),small)
+ CFLAGS = -Os
endif
+
ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS)
ifeq ($(OS),Windows_NT)
MAKE_FLAGS = CC=$(CC) LL=$(LL) ALL_CFLAGS="$(ALL_CFLAGS)"
View
@@ -19,12 +19,19 @@ OBJS := $(OBJ1) $(OBJ2) $(OBJ3)
# libraries, includes
INCLUDES = -I$(BASEDIR) -I$(BASEDIR)/../include
-DEBUG_MODE = 1
-ifeq ($(DEBUG_MODE),1)
-CFLAGS = -g -O3
-else
-CFLAGS = -O3
+ifeq ($(strip $(COMPILE_MODE)),)
+ # default compile option
+ COMPILE_MODE = debug
endif
+
+ifeq ($(COMPILE_MODE),debug)
+ CFLAGS = -g -O3
+else ifeq ($(COMPILE_MODE),release)
+ CFLAGS = -O3
+else ifeq ($(COMPILE_MODE),small)
+ CFLAGS = -Os
+endif
+
ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS)
View
@@ -20,12 +20,19 @@ OBJS := driver.o $(MLIB)
LIBS = -lm
INCLUDES = -I$(BASEDIR)/../src -I$(BASEDIR)/../include
-DEBUG_MODE = 1
-ifeq ($(DEBUG_MODE),1)
-CFLAGS = -g
-else
-CFLAGS = -O3
+ifeq ($(strip $(COMPILE_MODE)),)
+ # default compile option
+ COMPILE_MODE = debug
+endif
+
+ifeq ($(COMPILE_MODE),debug)
+ CFLAGS = -g -O3
+else ifeq ($(COMPILE_MODE),release)
+ CFLAGS = -O3
+else ifeq ($(COMPILE_MODE),small)
+ CFLAGS = -Os
endif
+
ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS)
ifeq ($(OS),Windows_NT)
MAKE_FLAGS = CC=$(CC) LL=$(LL) ALL_CFLAGS="$(ALL_CFLAGS)"
View
@@ -21,12 +21,19 @@ EXTS := $(EXT1)
LIBS = -lm
INCLUDES = -I$(BASEDIR) -I$(BASEDIR)/../include
-DEBUG_MODE = 1
-ifeq ($(DEBUG_MODE),1)
+ifeq ($(strip $(COMPILE_MODE)),)
+ # default compile option
+ COMPILE_MODE = debug
+endif
+
+ifeq ($(COMPILE_MODE),debug)
CFLAGS = -g -O3
-else
+else ifeq ($(COMPILE_MODE),release)
CFLAGS = -O3
+else ifeq ($(COMPILE_MODE),small)
+ CFLAGS = -Os
endif
+
ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS)
ifeq ($(OS),Windows_NT)
MAKE_FLAGS = CC=$(CC) LL=$(LL) ALL_CFLAGS="$(ALL_CFLAGS)"
View
@@ -23,12 +23,19 @@ LIBS = -lm
INCLUDES = -I$(BASEDIR) -I$(BASEDIR)/../include
# compiler, linker (gcc)
-DEBUG_MODE = 1
-ifeq ($(DEBUG_MODE),1)
-CFLAGS = -g -O3
-else
-CFLAGS = -O3
+ifeq ($(strip $(COMPILE_MODE)),)
+ # default compile option
+ COMPILE_MODE = debug
+endif
+
+ifeq ($(COMPILE_MODE),debug)
+ CFLAGS = -g -O3
+else ifeq ($(COMPILE_MODE),release)
+ CFLAGS = -O3
+else ifeq ($(COMPILE_MODE),small)
+ CFLAGS = -Os
endif
+
ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS)
ifeq ($(OS),Windows_NT)
MAKE_FLAGS = CC=$(CC) LL=$(LL) ALL_CFLAGS="$(ALL_CFLAGS)"
View
@@ -26,12 +26,19 @@ LIBS = -lm
INCLUDES = -I$(BASEDIR) -I$(BASEDIR)/../include
# compiler, linker (gcc)
-DEBUG_MODE = 1
-ifeq ($(DEBUG_MODE),1)
-CFLAGS = -g -O3
-else
-CFLAGS = -O3
+ifeq ($(strip $(COMPILE_MODE)),)
+ # default compile option
+ COMPILE_MODE = debug
+endif
+
+ifeq ($(COMPILE_MODE),debug)
+ CFLAGS = -g -O3
+else ifeq ($(COMPILE_MODE),release)
+ CFLAGS = -O3
+else ifeq ($(COMPILE_MODE),small)
+ CFLAGS = -Os
endif
+
ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS)
ifeq ($(OS),Windows_NT)
MAKE_FLAGS = CC=$(CC) LL=$(LL) ALL_CFLAGS="$(ALL_CFLAGS)"

0 comments on commit 83e5999

Please sign in to comment.