Skip to content

Commit d4e0a38

Browse files
sej7278sudar
authored andcommitted
Simplify package vs git checkout detection
Fix #147 Fix #151 Fix #153 The following are the detailed changes - Remove ARDMK_PATH, ARDMK_FILE and arduino-mk subdirectory - Looks for ard-reset-arduino in $PATH or ARDMK_DIR/bin - Fix git-archive command in RPM SPEC file - Remove some whitespace - Remove arduino-mk dir from debian package's arduino-mk.install - Update docs to reflect the above changes - Bump Up version to 1.2.0
1 parent fa6b921 commit d4e0a38

File tree

6 files changed

+46
-71
lines changed

6 files changed

+46
-71
lines changed

Arduino.mk

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#
2020
# Original Arduino adaptation by mellis, eighthave, oli.keller
2121
#
22-
# Current version: 1.1.0
22+
# Current version: 1.2.0
2323
#
2424
# Refer to HISTORY.md file for complete history of changes
2525
#
@@ -29,9 +29,8 @@
2929
#
3030
# We need to worry about three different sorts of file:
3131
#
32-
# 1. Things which are included in this distribution e.g. ard-reset-arduino
33-
# => ARDMK_DIR - Where the *.mk files are stored
34-
# => ARDMK_PATH - Where the ard-reset-arduino script is stored
32+
# 1. The directory where the *.mk files are stored
33+
# => ARDMK_DIR
3534
#
3635
# 2. Things which are always in the Arduino distribution e.g.
3736
# boards.txt, libraries, &c.
@@ -63,10 +62,6 @@
6362
# If you don't specify these, we can try to guess, but that might not work
6463
# or work the way you want it to.
6564
#
66-
# If you don't install the ard-reset-arduino binary to /usr/local/bin, but
67-
# instead copy them to e.g. /home/mjo/arduino.mk/bin then set
68-
# ARDMK_PATH = /home/mjo/arduino.mk/bin
69-
#
7065
# If you'd rather not see the configuration output, define ARDUINO_QUIET.
7166
#
7267
########################################################################
@@ -113,7 +108,7 @@
113108
# in your Makefile:
114109
#
115110
# ARDMK_DIR := $(realpath ../../tools/Arduino-Makefile)
116-
# include $(ARDMK_DIR)/arduino-mk/Arduino.mk
111+
# include $(ARDMK_DIR)/Arduino.mk
117112
#
118113
# In any case, once this file has been created the typical workflow is just
119114
#
@@ -231,25 +226,16 @@ endif
231226
# Makefile distribution path
232227

233228
ifndef ARDMK_DIR
234-
# presume it's a level above the path to our own file
235-
ARDMK_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST))))/..)
229+
# presume it's the same path to our own file
230+
ARDMK_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST)))))
236231
else
237-
# show_config_variable macro is defined in Common.mk file and is not available yet.
232+
# show_config_variable macro is defined in Common.mk file and is not available yet.
238233
# Let's define a variable to know that user specified ARDMK_DIR
239234
ARDMK_DIR_MSG = USER
240235
endif
241236

242-
ifneq ($(wildcard $(ARDMK_DIR)/arduino-mk/Common.mk),)
243-
# git checkout
244-
ARDMK_FILE = $(ARDMK_DIR)/arduino-mk/arduino.mk
245-
include $(ARDMK_DIR)/arduino-mk/Common.mk
246-
else
247-
ifneq ($(wildcard $(ARDMK_DIR)/Common.mk),)
248-
# package install
249-
ARDMK_FILE = $(ARDMK_DIR)/arduino.mk
250-
include $(ARDMK_DIR)/Common.mk
251-
endif
252-
endif
237+
# include Common.mk now we know where it is
238+
include $(ARDMK_DIR)/Common.mk
253239

254240
# show_config_variable macro is available now. So let's print config details for ARDMK_DIR
255241
ifndef ARDMK_DIR_MSG
@@ -258,13 +244,6 @@ else
258244
$(call show_config_variable,ARDMK_DIR,[USER])
259245
endif
260246

261-
ifndef ARDMK_PATH
262-
ARDMK_PATH = $(ARDMK_DIR)/bin
263-
$(call show_config_variable,ARDMK_PATH,[COMPUTED],(relative to ARDMK_DIR))
264-
else
265-
$(call show_config_variable,ARDMK_PATH,[USER])
266-
endif
267-
268247
########################################################################
269248
# Arduino Directory
270249

@@ -591,12 +570,16 @@ endif
591570
# Reset
592571

593572
ifndef RESET_CMD
573+
ARD_RESET_ARDUINO := $(shell which ard-reset-arduino)
574+
ifndef ARD_RESET_ARDUINO
575+
# same level as *.mk in bin directory when checked out from git
576+
# or in $PATH when packaged
577+
ARD_RESET_ARDUINO = $(ARDMK_DIR)/bin/ard-reset-arduino
578+
endif
594579
ifneq ($(CATERINA),)
595-
RESET_CMD = $(ARDMK_PATH)/ard-reset-arduino --caterina \
596-
$(ARD_RESET_OPTS) $(call get_monitor_port)
580+
RESET_CMD = $(ARD_RESET_ARDUINO) --caterina $(ARD_RESET_OPTS) $(call get_monitor_port)
597581
else
598-
RESET_CMD = $(ARDMK_PATH)/ard-reset-arduino \
599-
$(ARD_RESET_OPTS) $(call get_monitor_port)
582+
RESET_CMD = $(ARD_RESET_ARDUINO) $(ARD_RESET_OPTS) $(call get_monitor_port)
600583
endif
601584
endif
602585

@@ -995,7 +978,7 @@ endif
995978
# Default avrdude options
996979
# -V Do not verify
997980
# -q - suppress progress output
998-
# -D - Disable auto erase for flash memory
981+
# -D - Disable auto erase for flash memory
999982
# (-D is needed for Mega boards. See https://github.com/sudar/Arduino-Makefile/issues/114#issuecomment-25011005)
1000983
ifndef AVRDUDE_OPTS
1001984
AVRDUDE_OPTS = -q -V -D
@@ -1221,7 +1204,7 @@ help:
12211204
make set_fuses - set fuses without burning bootloader\n\
12221205
make help - show this help\n\
12231206
"
1224-
@$(ECHO) "Please refer to $(ARDMK_FILE) for more details.\n"
1207+
@$(ECHO) "Please refer to $(ARDMK_DIR)/Arduino.mk for more details.\n"
12251208

12261209
.PHONY: all upload raw_upload raw_eeprom error_on_caterina reset reset_stty ispload \
12271210
clean depends size show_boards monitor disasm symbol_sizes generated_assembly \

HISTORY.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ A Makefile for Arduino Sketches
33

44
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.
6+
### 1.2.0 (2014-01-12)
7+
- Fix: Remove use of arduino-mk subdirectory in git. Fix issue #151, #152 and #147 (https://github.com/sej7278)
68

79
### 1.2.0 (2014-01-12)
810
- Add: Add RPM SPECfile and new `package` directory to store package instructions and files (https://github.com/sej7278)
@@ -23,7 +25,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it
2325
- Fix: Handle relative paths of bootloader file while burning bootloaders. Fix #126 and #142 (https://github.com/sej7278)
2426
- New: Add `CONTRIBUTING.md` explaining how to contribute to the project.
2527
- New: Force -Os optimization for SoftwareSerial. Add `OPTIMIZATION_FLAGS` and `DEBUG_FLAGS`. (https://github.com/mahoy)
26-
- Fix: Use `ARDUINO_HEADER` variable instead of hardcoded file names. Fix #131
28+
- Fix: Use `ARDUINO_HEADER` variable instead of hardcoded file names. Fix #131
2729

2830
### 1.0.1 (2013-09-25)
2931
- Unconditionally add -D in avrdude options. See #114
@@ -112,7 +114,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it
112114

113115
### 0.10 17.ix.12 M J Oldfield
114116
- Added installation notes for Fedora (ex Rickard Lindberg).
115-
- Changed size target so that it looks at the ELF object,
117+
- Changed size target so that it looks at the ELF object,
116118
not the hexfile (ex Jared Szechy and Scott Howard).
117119
- Fixed ARDUNIO typo in README.md (ex Kalin Kozhuharov).
118120
- Tweaked OBJDIR handling (ex Matthias Urlichs and Scott Howard).
@@ -132,7 +134,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it
132134
- Autodetect ARDMK_DIR based on location of this file
133135
- Added support for utility directory within SYS and USER libraries
134136

135-
### 0.9.3 13.vi.2012
137+
### 0.9.3 13.vi.2012
136138

137139
- Auto detect ARDUINO_DIR, Arduino version (https://github.com/rpavlik/)
138140
- Categorize libs into user and system (https://github.com/rpavlik/)
@@ -141,12 +143,12 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it
141143
- Changed bytes option for the head shell command, so that it works in Mac as well
142144
- Auto detect Serial Baud rate from sketch if possible
143145

144-
### 0.9.2 06.vi.2012
146+
### 0.9.2 06.vi.2012
145147

146148
- Allow user to choose source files (LOCAL_*_SRCS flags) (https://github.com/Gaftech)
147149
- Modified "make size" behavior: using --mcu option and targeting .elf file instead of .hex file.(https://github.com/Gaftech)
148150

149-
### 0.9.1 06.vi.2012
151+
### 0.9.1 06.vi.2012
150152

151153
- Corrected the ubuntu package names
152154
- Prevent the *file-not-found* error if the depends.mk file is not needed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ On the Mac you might want to set:
1414

1515
ARDUINO_DIR = /Applications/Arduino.app/Contents/Resources/Java
1616
ARDMK_DIR = /usr/local
17+
AVR_TOOLS_DIR = /usr
1718

18-
On Linux, you might prefer:
19+
On Linux, you shouldn't need to set anything other than your board type and port:
1920

20-
ARDUINO_DIR = /usr/share/arduino
21-
ARDMK_DIR = /usr/share/arduino
22-
ARDMK_PATH = /usr/bin
23-
AVR_TOOLS_DIR = /usr
21+
BOARD_TAG = mega2560
22+
MONITOR_PORT = /dev/ttyACM0
2423

24+
- `BOARD_TAG` - Type of board, for a list see boards.txt or `make show_boards`
25+
- `MONITOR_PORT` - The port where your Arduino is plugged in, usually `/dev/ttyACM0` or `/dev/ttyUSB0`
2526
- `ARDUINO_DIR` - Path to Arduino installation
2627
- `ARDMK_DIR` - Path where the `*.mk` are present. If you installed the package, then it is usually `/usr/share/arduino`
27-
- `ARDMK_PATH` - Path where the `ard-reset-arduino` script is present. If you installed the package, then it is usually `/usr/bin`
2828
- `AVR_TOOLS_DIR` - Path where the avr tools chain binaries are present. If you are going to use the binaries that came with Arduino installation, then you don't have to set it.
2929

3030
The Makefile also delegates resetting the board to a short Perl program.
@@ -80,7 +80,7 @@ It is possible to use [`colorgcc`](https://github.com/colorgcc/colorgcc) with th
8080

8181
## Versioning
8282

83-
The current version of the makefile is `1.1.0`. You can find the full history in the [HISTORY.md](HISTORY.md) file
83+
The current version of the makefile is `1.2.0`. You can find the full history in the [HISTORY.md](HISTORY.md) file
8484

8585
This project adheres to Semantic [Versioning 2.0](http://semver.org/).
8686

@@ -92,7 +92,7 @@ published by the Free Software Foundation; either version 2.1 of the License, or
9292

9393
## Contribution
9494

95-
All contributions (even documentation) are welcome :) Open a pull request and I would be happy to merge them.
95+
All contributions (even documentation) are welcome :) Open a pull request and I would be happy to merge them.
9696
Also checkout the [contribution guide](CONTRIBUTING.md) for more details.
9797

9898
If you are looking for ideas to work on, then check out the following TODO items or the [issue tracker](https://github.com/sudar/Arduino-Makefile/issues/).
@@ -108,7 +108,7 @@ If you find an issue or have an idea for a feature then log them in the [issue t
108108

109109
## Credits
110110

111-
This makefile was originally created by [Martin Oldfield](http://mjo.tc/atelier/2009/02/arduino-cli.html) and he maintained it till v0.10.2.
111+
This makefile was originally created by [Martin Oldfield](http://mjo.tc/atelier/2009/02/arduino-cli.html) and he maintained it till v0.10.2.
112112
From May 2013, it is maintained by [Sudar](http://hardwarefun.com/tutorials/compiling-arduino-sketches-using-makefile)
113113

114114
## Similar works

chipKIT.mk

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,11 @@
2727
# The show_config_variable is unavailable before we include the common makefile,
2828
# so we defer logging the ARDMK_DIR info until it happens in Arduino.mk
2929
ifndef ARDMK_DIR
30-
# presume it's a level above the path to our own file
31-
ARDMK_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST))))/..)
30+
# presume it's the same path to our own file
31+
ARDMK_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST)))))
3232
endif
3333

34-
ifndef ARDMK_PATH
35-
ARDMK_PATH = $(ARDMK_DIR)/bin
36-
endif
37-
38-
ifneq ($(wildcard $(ARDMK_DIR)/arduino-mk/Common.mk),)
39-
# git checkout
40-
include $(ARDMK_DIR)/arduino-mk/Common.mk
41-
else
42-
ifneq ($(wildcard $(ARDMK_DIR)/Common.mk),)
43-
# package install
44-
include $(ARDMK_DIR)/Common.mk
45-
endif
46-
endif
34+
include $(ARDMK_DIR)/Common.mk
4735

4836
ifndef MPIDE_DIR
4937
AUTO_MPIDE_DIR := $(firstword \
@@ -110,4 +98,4 @@ LDFLAGS += -T$(ARDUINO_CORE_PATH)/chipKIT-application-COMMON.ld
11098
CPPFLAGS += -mno-smart-io -fno-short-double
11199
CFLAGS_STD =
112100

113-
include $(ARDMK_DIR)/arduino-mk/Arduino.mk
101+
include $(ARDMK_DIR)/Arduino.mk

packaging/fedora/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ First install the dependencies as root:
66

77
From the top-level Arduino-Makefile directory you've checked out of github, run the following (as unprivileged user) to create a compressed tarball using the naming conventions required by rpmbuild:
88

9-
git archive --prefix=arduino-mk-1.1.0/ --format=tar -o ../arduino-mk-1.1.0.tar.gz -v HEAD | gzip
9+
git archive HEAD --prefix=arduino-mk-1.2.0/ -o ../arduino-mk-1.2.0.tar.gz
1010

1111
If you don't already have a rpmbuild setup (e.g. you've not installed the SRPM) you will need to create the directories:
1212

1313
mkdir -p ~/rpmbuild/{SOURCES,SPECS}
1414

1515
Then copy the tarball and specfile into those directories:
1616

17-
cp ../arduino-mk-1.1.0.tar.gz ~/rpmbuild/SOURCES/
17+
cp ../arduino-mk-1.2.0.tar.gz ~/rpmbuild/SOURCES/
1818
cp packaging/fedora/arduino-mk.spec ~/rpmbuild/SPECS/
1919

2020
Then compile. This will create a binary and source RPM:

packaging/fedora/arduino-mk.spec

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Name: arduino-mk
2-
Version: 1.1.0
2+
Version: 1.2.0
33
Release: 1%{dist}
44
Summary: Program your Arduino from the command line
55
Packager: Simon John <[email protected]>
@@ -33,8 +33,8 @@ install -m 755 -d %{buildroot}/%{_docdir}/%{name}
3333
install -m 755 -d %{buildroot}/%{_docdir}/%{name}/examples
3434
for dir in `find examples -type d` ; do install -m 755 -d %{buildroot}/%{_docdir}/%{name}/$dir ; done
3535
for file in `find examples -type f ! -name .gitignore` ; do install -m 644 $file %{buildroot}/%{_docdir}/%{name}/$file ; done
36-
install -m 644 %{name}/*.mk %{buildroot}/%{_datadir}/arduino
37-
install -m 644 %{name}/licence.txt %{buildroot}/%{_docdir}/%{name}
36+
install -m 644 *.mk %{buildroot}/%{_datadir}/arduino
37+
install -m 644 licence.txt %{buildroot}/%{_docdir}/%{name}
3838
install -m 755 bin/ard-reset-arduino %{buildroot}/%{_bindir}/ard-reset-arduino
3939
help2man %{buildroot}/%{_bindir}/ard-reset-arduino -n "Reset Arduino board" -s 1 -m "Arduino CLI Reset" --version-string=%{version} -N -o %{buildroot}/%{_mandir}/man1/ard-reset-arduino.1
4040

@@ -51,5 +51,7 @@ rm -rf %{buildroot}
5151
%{_docdir}/%{name}/examples
5252

5353
%changelog
54+
* Mon Jan 13 2014 Simon John <[email protected]>
55+
- Removed arduino-mk subdirectory
5456
* Mon Dec 30 2013 Simon John <[email protected]>
5557
- Initial release.

0 commit comments

Comments
 (0)