Merge pull request #234 from WeAreLeka/std-flags

CFLAGS_STD and CXXFLAGS_STD
This commit is contained in:
Sudar 2014-08-14 14:59:44 +05:30
commit e17b2a4781
4 changed files with 101 additions and 14 deletions

View file

@ -925,16 +925,23 @@ ifneq ($(CATERINA),)
endif
ifndef CFLAGS_STD
CFLAGS_STD = -std=gnu99
CFLAGS_STD =
$(call show_config_variable,CFLAGS_STD,[DEFAULT])
else
$(call show_config_variable,CFLAGS_STD,[USER])
endif
CFLAGS += $(EXTRA_FLAGS) $(EXTRA_CFLAGS)
CXXFLAGS += -fno-exceptions $(EXTRA_FLAGS) $(EXTRA_CXXFLAGS)
ifndef CXXFLAGS_STD
CXXFLAGS_STD =
$(call show_config_variable,CXXFLAGS_STD,[DEFAULT])
else
$(call show_config_variable,CXXFLAGS_STD,[USER])
endif
CFLAGS += $(CFLAGS_STD)
CXXFLAGS += -fno-exceptions $(CXXFLAGS_STD)
ASFLAGS += -x assembler-with-cpp
LDFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -Wl,--gc-sections -O$(OPTIMIZATION_LEVEL) $(EXTRA_FLAGS) $(EXTRA_CXXFLAGS) $(EXTRA_LDFLAGS)
LDFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -Wl,--gc-sections -O$(OPTIMIZATION_LEVEL)
SIZEFLAGS ?= --mcu=$(MCU) -C
# for backwards compatibility, grab ARDUINO_PORT if the user has it set

View file

@ -11,6 +11,11 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it
- Fix: Make avr-g++ use CXXFLAGS instead of CFLAGS. (https://github.com/sej7278)
- Add: Add information about overriding system libs (Issue #229). (https://github.com/sej7278)
- Add: Add information about reporting bugs to the correct project (Issue #231). (https://github.com/sej7278)
- Fix: Allow the use of CFLAGS_STD and CXXFLAGS_STD and set defaults (Issue #234) (https://github.com/ladislas)
- Tweak: Remove \$(EXTRA_XXX) variables (Issue #234) (https://github.com/ladislas)
- Add: Add documentation about CFLAGS_STD and CXXFLAGS_STD (Issue #234) (https://github.com/ladislas)
- Tweak: Update Malefile-example.mk with STD flags (https://github.com/ladislas)
### 1.3.4 (2014-07-12)
- Tweak: Allow spaces in "Serial.begin (....)". (Issue #190) (https://github.com/pdav)

View file

@ -784,14 +784,70 @@ OPTIMIZATION_LEVEL = 3
**Description:**
Flags to pass to the C compiler.
Controls, *exclusively*, which C standard is to be used for compilation.
Defaults to `-std=gnu99`
Defaults to `undefined`
Possible values:
* With `avr-gcc 4.3`, shipped with the Arduino IDE:
* `undefined`
* `-std=c99`
* `-std=gnu89` - This is the default for C code
* `-std=gnu99`
* With `avr-gcc 4.7, 4.8 or 4.9`, installed by you
* `undefined`
* `-std=c99`
* `-std=c11`
* `-std=gnu89` - This is the default for C code
* `-std=gnu99`
* `-std=gnu11`
For more information, please refer to the [Options Controlling C Dialect](https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html)
**Example:**
```Makefile
<unset as per chipKIT.mk>
CFLAGS_STD = = -std=gnu89
```
**Requirement:** *Optional*
----
### CXXFLAGS_STD
**Description:**
Controls, *exclusively*, which C++ standard is to be used for compilation.
Defaults to `undefined`
Possible values:
* With `avr-gcc 4.3`, shipped with the Arduino IDE:
* `undefined`
* `-std=c++98`
* `-std=c++0x`
* `-std=gnu++98` - This is the default for C code
* `-std=gnu++0x`
* With `avr-gcc 4.7, 4.8 or 4.9`, installed by you
* `undefined`
* `-std=c++98`
* `-std=c++11`
* `-std=c++1y`
* `-std=c++14`
* `-std=gnu++98` - This is the default for C++ code
* `-std=gnu++11`
* `-std=gnu++1y`
* `-std=gnu++14`
For more information, please refer to the [Options Controlling C Dialect](https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html)
**Example:**
```Makefile
CXXFLAGS_STD = = -std=gnu++98
```
**Requirement:** *Optional*

View file

@ -2,26 +2,30 @@
### This is an example Makefile and it MUST be configured to suit your needs.
### For detailled explanations about all the avalaible options,
### please refer to https://github.com/sudar/Arduino-Makefile/blob/master/arduino-mk-vars.md
### Original project where this Makefile comes from: https://github.com/WeAreLeka/Bare-Arduino-Project
### PROJECT_DIR
### This is the path to where you have created/cloned your project
PROJECT_DIR = /Users/Ladislas/dev/leka/moti
PROJECT_DIR = /Users/MyUserName/path/to/my/Project
### ARDMK_DIR
### Path to the Arduino-Makefile directory.
ARDMK_DIR = $(PROJECT_DIR)/arduino-mk
ARDMK_DIR = $(PROJECT_DIR)/Arduino-Makefile
### ARDUINO_DIR
### Path to the Arduino application and ressources directory.
### On OS X:
ARDUINO_DIR = /Applications/Arduino.app/Contents/Resources/Java
### or on Linux: (remove the one you don't want)
ARDUINO_DIR = /usr/share/arduino
### USER_LIB_PATH
### Path to where the your project's libraries are stored.
USER_LIB_PATH := $(PROJECT_DIR)/lib
USER_LIB_PATH := $(PROJECT_DIR)/lib
### BOARD_TAG
### It must be set to the board you are currently using. (i.e uno, mega2560, etc.)
BOARD_TAG = mega2560
BOARD_TAG = uno
### MONITOR_BAUDRATE
### It must be set to Serial baudrate value you are using.
@ -29,21 +33,36 @@ MONITOR_BAUDRATE = 115200
### AVR_TOOLS_DIR
### Path to the AVR tools directory such as avr-gcc, avr-g++, etc.
### On OS X with `homebrew`:
AVR_TOOLS_DIR = /usr/local
### or on Linux: (remove the one you don't want)
AVR_TOOLS_DIR = /usr/bin
### AVRDDUDE
### Path to avrdude directory.
### On OS X with `homebrew`:
AVRDDUDE = /usr/local/bin/avrdude
### or on Linux: (remove the one you don't want)
AVRDDUDE = /usr/bin/avrdude
### CPPFLAGS
### CFLAGS_STD
### Set the C standard to be used during compilation. Documentation (https://github.com/WeAreLeka/Arduino-Makefile/blob/std-flags/arduino-mk-vars.md#cflags_std)
CFLAGS_STD = -std=gnu11
### CXXFLAGS_STD
### Set the C++ standard to be used during compilation. Documentation (https://github.com/WeAreLeka/Arduino-Makefile/blob/std-flags/arduino-mk-vars.md#cxxflags_std)
CXXFLAGS_STD = -std=gnu++11
### CXXFLAGS
### Flags you might want to set for debugging purpose. Comment to stop.
CPPFLAGS = -pedantic -Wall -Wextra
CXXFLAGS += -pedantic -Wall -Wextra
### MONITOR_PORT
### The port your board is connected to. Using an '*' tries all the ports and finds the right one.
MONITOR_PORT = /dev/tty.usbmodem*
### don't touch this
### CURRENT_DIR
### Do not touch - used for binaries path
CURRENT_DIR = $(shell basename $(CURDIR))
### OBJDIR