/elec/propeller-clock

To get this branch, use:
bzr branch http://bzr.ed.am/elec/propeller-clock

« back to all changes in this revision

Viewing changes to src/Makefile

  • Committer: edam
  • Date: 2012-01-14 16:55:37 UTC
  • Revision ID: edam@waxworlds.org-20120114165537-71ftm2myrqoztubn
added DS1307 real-time clock library and updated Makefile

Show diffs side-by-side

added added

removed removed

27
27
#_______________________________________________________________________________
28
28
#
29
29
#
30
 
# This is a general purpose makefile for use with Arduino (see
31
 
# http://arduino.cc/) hardware and software.  It works with the
32
 
# arduino-1.0 release and requires that to be downloaded separately.
33
 
# It can be downloaded from http://ed.am/dev/make/arduino-makefile
34
 
# where you can also find more information and documentation on it's
35
 
# use.  The following text can only really be considered a reference
36
 
# to it's use.
 
30
# This is a general purpose makefile for use with Arduino hardware and
 
31
# software.  It works with the arduino-1.0 release and requires that
 
32
# software to be downloaded separately (see http://arduino.cc/).  To
 
33
# download the latest version of this makefile, visit the following
 
34
# website, where you can also find more information and documentation
 
35
# on it's use.  The following text can only really be considered a
 
36
# reference to it's use.
 
37
#
 
38
#   http://ed.am/dev/make/arduino-makefile
37
39
#
38
40
# To install, it is suggested that you keep arduino.mk somewhere and
39
41
# either symlink to it or include it in your make files.  I keep mine
43
45
#
44
46
# This makefile can be used as a drop-in replacement for the Arduino
45
47
# IDE's build system.  Simply create a symlink to it under the name
46
 
# "Makefile" and run make as described below (remembering to specify a
47
 
# BOARD).  You would create the symlink like like so:
 
48
# "Makefile" and run make (remembering to specify an ARDUINODIR and
 
49
# BOARD, as described below).  You would create the symlink like like
 
50
# so:
48
51
#
49
 
#       $ ln -s ~/src/arduino.mk Makefile
 
52
#   $ ln -s ~/src/arduino.mk Makefile
50
53
#
51
54
# The presence of a .ino or .pde file causes the arduino.mk to
52
55
# atuomatically determine va;ues for SOURCES, TARGET and LIBRARIES.
62
65
# default main() that calls init() and loop().  Here is an example
63
66
# Makefile:
64
67
#
65
 
#       SOURCES := main.cc foo.cc
66
 
#       LIBRARIES := EEPROM
67
 
#       include ~/src/arduino.mk
 
68
#   SOURCES := main.cc foo.cc
 
69
#   LIBRARIES := EEPROM
 
70
#   include ~/src/arduino.mk
68
71
#
69
72
# A complete list of all the settings you can use in your Makefile
70
73
# follows shortly.  It should be noted, however, that some variables
71
 
# are better specified in the environment or on the command line than
72
 
# in a Makefile.  Specifically, the BOARD and SERIALDEV (if it is not
73
 
# automatically detected).
74
 
#
75
 
# When running make, you might want to specify the board type:
76
 
#
77
 
#       $ BOARD=pro5v make
78
 
#
79
 
# Or in the environment:
80
 
#
81
 
#       $ export BOARD=pro5v
82
 
#       $ make
 
74
# are better specified in the environment (or on the command line)
 
75
# than in your Makefile.  Specifically, the ARDUINODIR, BOARD and, if
 
76
# it is not automatically detected, SERIALDEV.
 
77
#
 
78
# When running make, you might want to specify the board and path to
 
79
# your installation of the arduino software, like this:
 
80
#
 
81
#   $ export ARDUINODIR=~/opt/arduino-1.0
 
82
#   $ export BOARD=pro5v
 
83
#   $ make
83
84
#
84
85
# For a list of available board types, run `make boards`.
85
86
86
 
# Here is a list of all configuration parameters:
 
87
# Here is a complete list of configuration parameters:
 
88
#
 
89
# ARDUINODIR   The path where you have installed/unpacked the arduino
 
90
#              software (from http://arduino.cc/)
87
91
#
88
92
# BOARD        Specify a target board type.
89
93
#
91
95
#              found.  If unspecified, an attempt is made to determine
92
96
#              the name of a connected arduino's serial device.
93
97
#
94
 
# The following configuration parameters can be determined automatically:
95
 
#
96
 
# TARGET       The name of the target file.  This need not be set if it
97
 
#              is not determined automatically.
 
98
# TARGET       The name of the target file.  This is set automatically
 
99
#              if a .ino or .pde is found, but it is not neccesary to
 
100
#              set it otherwise.
98
101
#
99
102
# SOURCES      A list of all source files of whatever language.  The
100
103
#              language type is determined by the file extension.
 
104
#              This is set automatically if a .ino or .pde is found.
101
105
#
102
 
# LIBRARIES    A list of arduino libraries to build and include.
 
106
# LIBRARIES    A list of arduino libraries to build and include.  This
 
107
#              is set automatically if a .ino or .pde is found.
103
108
#
104
109
# This general-purpose makefile also defines the following goals for
105
110
# use on the command line when you run make:
117
122
#              target, from those that that would be built for the
118
123
#              project.
119
124
#
 
125
# boards       This is not a real goal.  It just displays a list of
 
126
#              available board names, so that you can set the BOARD
 
127
#              environment variable appropriately.
 
128
#
 
129
# monitor      This is not a real goal.  It starts screen on the serial
 
130
#              device.  It is ment to be an equivelant to the arduino
 
131
#              serial monitor.
120
132
#_______________________________________________________________________________
121
133
#
122
134
 
123
135
# The full path to the arduino software, from arduino.cc
 
136
ifndef ARDUINODIR
124
137
ARDUINODIR := $(wildcard ~/opt/arduino-1.0)
 
138
endif
125
139
 
126
140
# check arduino software
127
141
ifeq ($(wildcard $(ARDUINODIR)/hardware/arduino/boards.txt), )
128
 
$(error ARDUINODIR is not set correctly at the top of arduino.mk)
 
142
$(error ARDUINODIR is not set correctly; arduino software not found)
129
143
endif
130
144
 
131
145
# auto mode?
146
160
endif
147
161
 
148
162
# no target? use default
149
 
ifndef TARGET
 
163
ifeq ($(TARGET), )
150
164
TARGET := a.out
151
165
endif
152
166
 
153
167
# no serial device? attempt to detect an arduino
154
 
ifndef SERIALDEV
 
168
ifeq ($(SERIALDEV), )
155
169
SERIALDEV := $(firstword $(wildcard /dev/ttyACM? /dev/ttyUSB?))
156
170
endif
 
171
ifeq ($(SERIALDEV), )
 
172
$(error SERIALDEV is unset and could not be automatically determined)
 
173
endif
157
174
 
158
175
# no board? oh dear...
159
176
ifndef BOARD
167
184
# files
168
185
OBJECTS := $(addsuffix .o, $(basename $(SOURCES)))
169
186
ARDUINOSRCDIR := $(ARDUINODIR)/hardware/arduino/cores/arduino
 
187
ARDUINOLIBSDIR := $(ARDUINODIR)/libraries
170
188
ARDUINOLIB := _arduino.a
171
189
ARDUINOLIBTMP := _arduino.a.tmp
172
190
ARDUINOLIBOBJS := $(patsubst %, $(ARDUINOLIBTMP)/%.o, $(basename $(notdir \
173
191
        $(wildcard $(addprefix $(ARDUINOSRCDIR)/, *.c *.cpp)))))
174
192
ARDUINOLIBOBJS += $(foreach lib, $(LIBRARIES), \
175
193
        $(patsubst %, $(ARDUINOLIBTMP)/%.o, $(basename $(notdir \
176
 
        $(wildcard $(addprefix $(ARDUINODIR)/libraries/$(lib)/, *.c *.cpp))))))
 
194
        $(wildcard $(addprefix $(ARDUINOLIBSDIR)/$(lib)/, *.c *.cpp)) \
 
195
        $(wildcard $(addprefix $(ARDUINOLIBSDIR)/$(lib)/utility/, *.c *.cpp)) ))))
177
196
 
178
197
# obtain board parameters from the arduino boards.txt file
179
198
BOARDS_FILE := $(ARDUINODIR)/hardware/arduino/boards.txt
201
220
CPPFLAGS += -mmcu=$(BOARD_BUILD_MCU) -DF_CPU=$(BOARD_BUILD_FCPU)
202
221
CPPFLAGS += -I. -Iutil -Iutility -I$(ARDUINOSRCDIR)
203
222
CPPFLAGS += -I$(ARDUINODIR)/hardware/arduino/variants/$(BOARD_BUILD_VARIANT)/
204
 
CPPFLAGS += $(addprefix -I$(ARDUINODIR)/libraries/,$(LIBRARIES))
 
223
CPPFLAGS += $(addprefix -I$(ARDUINODIR)/libraries/, $(LIBRARIES))
 
224
CPPFLAGS += $(patsubst %, -I$(ARDUINODIR)/libraries/%/utility, $(LIBRARIES))
205
225
AVRDUDEFLAGS = -C $(ARDUINODIR)/hardware/tools/avrdude.conf -DV
206
226
AVRDUDEFLAGS += -p $(BOARD_BUILD_MCU) -P $(SERIALDEV)
207
227
AVRDUDEFLAGS += -c $(BOARD_UPLOAD_PROTOCOL) -b $(BOARD_UPLOAD_SPEED)
213
233
#_______________________________________________________________________________
214
234
#                                                                          RULES
215
235
 
216
 
.PHONY: all target upload clean boards
 
236
.PHONY: all target upload clean boards monitor
217
237
 
218
238
all: target upload
219
239
 
233
253
        @sed -ne '/^#/d;s/^\(.*\).name=\(.*\)/\1            \2/;T' \
234
254
                -e 's/\(.\{12\}\) *\(.*\)/\1 \2/;p' $(BOARDS_FILE)
235
255
 
 
256
monitor:
 
257
        screen $(SERIALDEV)
 
258
 
236
259
# building the target
237
260
 
238
261
$(TARGET).hex: $(TARGET).elf
272
295
$(ARDUINOLIBTMP)/%.o: $(ARDUINODIR)/libraries/*/%.cpp
273
296
        @test -d $(ARDUINOLIBTMP) || mkdir $(ARDUINOLIBTMP)
274
297
        $(COMPILE.cpp) -o $@ $<
 
298
 
 
299
$(ARDUINOLIBTMP)/%.o: $(ARDUINODIR)/libraries/*/utility/%.c
 
300
        @test -d $(ARDUINOLIBTMP) || mkdir $(ARDUINOLIBTMP)
 
301
        $(COMPILE.c) -o $@ $<
 
302
 
 
303
$(ARDUINOLIBTMP)/%.o: $(ARDUINODIR)/libraries/*/utility/%.cpp
 
304
        @test -d $(ARDUINOLIBTMP) || mkdir $(ARDUINOLIBTMP)
 
305
        $(COMPILE.cpp) -o $@ $<