diff --git a/libraries/AP_Common/AP_Common.h b/libraries/AP_Common/AP_Common.h index 0cfdbc3da1..8f5932b666 100644 --- a/libraries/AP_Common/AP_Common.h +++ b/libraries/AP_Common/AP_Common.h @@ -88,15 +88,22 @@ typedef struct { # undef PROGMEM # define PROGMEM __attribute__(()) #else + #ifndef __PROG_TYPES_COMPAT__ # undef PROGMEM # define PROGMEM __attribute__(( section(".progmem.data") )) #endif + #endif # undef PSTR /* Need const type for progmem - new for avr-gcc 4.6 */ # if __AVR__ && __GNUC__ == 4 && __GNUC_MINOR__ > 5 + #ifdef __PROG_TYPES_COMPAT__ + # define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); \ + (const prog_char_t *)&__c[0]; })) + #else # define PSTR(s) (__extension__({static const prog_char __c[] PROGMEM = (s); \ (const prog_char_t *)&__c[0]; })) + #endif #else # define PSTR(s) (__extension__({static prog_char __c[] PROGMEM = (s); \ (prog_char_t *)&__c[0]; })) @@ -107,7 +114,6 @@ typedef struct { // this gets the gcc __format__ checking right #define FPSTR(s) (wchar_t *)(s) - static inline int strcasecmp_P(const char *str1, const prog_char_t *pstr) { return strcasecmp_P(str1, (const prog_char *)pstr); diff --git a/libraries/AP_Common/Arduino.mk b/libraries/AP_Common/Arduino.mk index 381125f253..0f8f71bf0f 100644 --- a/libraries/AP_Common/Arduino.mk +++ b/libraries/AP_Common/Arduino.mk @@ -228,19 +228,19 @@ endif # # Tool options # -DEFINES = -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERS) $(EXTRAFLAGS) +DEFINES = -D__PROG_TYPES_COMPAT__ -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERS) $(EXTRAFLAGS) OPTFLAGS = -Os -Wformat -Wall -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wformat=2 -Wno-reorder DEPFLAGS = -MD -MT $@ # XXX warning options TBD CXXOPTS = -mcall-prologues -ffunction-sections -fdata-sections -fno-exceptions COPTS = -mcall-prologues -ffunction-sections -fdata-sections -ASOPTS = -assembler-with-cpp +ASOPTS = LISTOPTS = -adhlns=$(@:.o=.lst) CXXFLAGS = -g -mmcu=$(MCU) $(DEFINES) -Wa,$(LISTOPTS) $(OPTFLAGS) $(DEPFLAGS) $(CXXOPTS) -CFLAGS = -g -mmcu=$(MCU) $(DEFINES) -Wa,$(LISTOPTS) $(OPTFLAGS) $(DEPFLAGS) $(COPTS) -ASFLAGS = -g -mmcu=$(MCU) $(DEFINES) $(LISTOPTS) $(DEPFLAGS) $(ASOPTS) +CFLAGS = -g -mmcu=$(MCU) $(DEFINES) $(OPTFLAGS) $(DEPFLAGS) $(COPTS) +ASFLAGS = -g -mmcu=$(MCU) $(DEFINES) $(DEPFLAGS) $(ASOPTS) LDFLAGS = -g -mmcu=$(MCU) $(OPTFLAGS) -Wl,--relax,--gc-sections -Wl,-Map -Wl,$(SKETCHMAP) ifeq ($(BOARD),mega)