Skip to content

Commit 5a0c80b

Browse files
authored
Merge pull request #583 from wingunder/move_core_link_last
Moved CORE_LIB to the last position of the defined linked objects.
2 parents fe84c59 + ed608ce commit 5a0c80b

File tree

9 files changed

+117
-1
lines changed

9 files changed

+117
-1
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
sudo: required
12
language: c
23
compiler:
34
- gcc

Arduino.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1610,7 +1610,7 @@ ifeq ($(findstring sam, $(strip $(ARCHITECTURE))), sam)
16101610
$(CC) $(LINKER_SCRIPTS) -Wl,-Map=$(OBJDIR)/$(TARGET).map -o $@ $(LOCAL_OBJS) $(OTHER_OBJS) $(OTHER_LIBS) $(LDFLAGS) $(CORE_LIB) -Wl,--end-group
16111611
# otherwise traditional
16121612
else
1613-
$(CC) $(LDFLAGS) -o $@ $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) $(OTHER_LIBS) -lc -lm $(LINKER_SCRIPTS)
1613+
$(CC) $(LDFLAGS) -o $@ $(LOCAL_OBJS) $(OTHER_OBJS) $(OTHER_LIBS) $(CORE_LIB) -lc -lm $(LINKER_SCRIPTS)
16141614
endif
16151615

16161616
$(CORE_LIB): $(CORE_OBJS) $(LIB_OBJS) $(PLATFORM_LIB_OBJS) $(USER_LIB_OBJS)

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The following is the rough list of changes that went into different versions.
55
I tried to give credit whenever possible. If I have missed anyone, kindly add it to the list.
66

77
### In Development
8+
- Fix: Moved CORE_LIB to the last position of the defined linked objects. (https://github.com/wingunder)
89
- Fix: Moved ATtiny examples to ATtinyBlink, updated alternate core instructions (issue #537) (https://github.com/sej7278)
910
- Fix: Add -fno-devirtualize flag to workaround g++ segfault bug (issue #486). (https://github.com/sej7278)
1011
- Fix: Quote the prefix tag in the space_pad_to function
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// A derived Blink, that uses an example 3rd party library.
2+
// Turns on an LED on for one second, then off for one second, repeatedly.
3+
// This example code is in the public domain.
4+
5+
#include <TogglePin.h>
6+
7+
#ifdef ARDUINO
8+
#if ARDUINO >= 100
9+
#include "Arduino.h"
10+
#else
11+
#include "WProgram.h"
12+
#endif
13+
#endif // ARDUINO
14+
15+
int main()
16+
{
17+
init();
18+
TogglePin led(13, false);
19+
while (true) {
20+
delay(1000);
21+
led.toggle();
22+
}
23+
}

examples/Blink3rdPartyLib/Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This program is free software and is licensed under the same conditions as
2+
# describe in https://github.com/sudar/Arduino-Makefile/blob/master/licence.txt
3+
4+
# This is an example Makefile, that demonstrates the linking of a third party
5+
# library. In this case the third party library resides in the ./Toggle
6+
# sub-directory. Note that the archive TOGGLE_ARCHIVE _only_ contains the
7+
# compiled Toggle.c.o object. The TOGGLE_ARCHIVE is thus very lean, but it
8+
# requires the Arduino libraries, which are being build in this directory,
9+
# together with Blink, the 'main' program.
10+
11+
include board.mk
12+
13+
TOGGLE_ARCHIVE = build-$(BOARD_TAG)/libtoggle.a
14+
15+
CXXFLAGS += -IToggle
16+
OTHER_OBJS = Toggle/$(TOGGLE_ARCHIVE)
17+
18+
include ../../Arduino.mk
19+
20+
Toggle/$(TOGGLE_ARCHIVE):
21+
$(MAKE) -C Toggle $(TOGGLE_ARCHIVE)
22+
23+
clean::
24+
$(MAKE) -C Toggle clean
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This program is free software and is licensed under the same conditions as
2+
# describe in https://github.com/sudar/Arduino-Makefile/blob/master/licence.txt
3+
4+
# This is an example Makefile, that is being used to build an archive
5+
# from locally compiled objects.
6+
#
7+
# All source files in this directory will automatically get compiled
8+
# and archived into the build-$(BOARD_TAG)/libtoggle.a target.
9+
10+
include ../board.mk
11+
include ../../../Arduino.mk
12+
13+
build-$(BOARD_TAG)/libtoggle.a: $(LOCAL_OBJS)
14+
$(AR) rcs $@ $(LOCAL_OBJS)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// This program is free software and is licensed under the same conditions as
2+
// describe in https://github.com/sudar/Arduino-Makefile/blob/master/licence.txt
3+
4+
#include "TogglePin.h"
5+
6+
#ifdef ARDUINO
7+
#if ARDUINO >= 100
8+
#include "Arduino.h"
9+
#else
10+
#include "WProgram.h"
11+
#endif
12+
#endif // ARDUINO
13+
14+
TogglePin::TogglePin(int pinNumber, bool state)
15+
: _pinNumber(pinNumber), _state(state)
16+
{
17+
pinMode(_pinNumber, OUTPUT);
18+
digitalWrite(_pinNumber, _state ? HIGH : LOW);
19+
}
20+
21+
bool
22+
TogglePin::toggle()
23+
{
24+
_state = !_state;
25+
digitalWrite(_pinNumber, _state ? HIGH : LOW);
26+
return _state;
27+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// This program is free software and is licensed under the same conditions as
2+
// describe in https://github.com/sudar/Arduino-Makefile/blob/master/licence.txt
3+
4+
#ifndef TOGGLEPIN_H_
5+
#define TOGGLEPIN_H_
6+
7+
class TogglePin
8+
{
9+
public:
10+
TogglePin(int pinNumber, bool state);
11+
12+
bool toggle();
13+
14+
private:
15+
const int _pinNumber;
16+
bool _state;
17+
};
18+
19+
#endif

examples/Blink3rdPartyLib/board.mk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This program is free software and is licensed under the same conditions as
2+
# describe in https://github.com/sudar/Arduino-Makefile/blob/master/licence.txt
3+
4+
# The following can be overridden at make-time, by setting an environment
5+
# variable with the same name. eg. BOARD_TAG=pro5v328 make
6+
7+
BOARD_TAG ?= uno

0 commit comments

Comments
 (0)