-
Notifications
You must be signed in to change notification settings - Fork 39
/
Makefile
129 lines (113 loc) · 4.52 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# NOTE: to compile with avr-gcc less than verson 4.2.3, you must
# remove the atmega328p from the list of target devices below:
devices := atmega48 atmega168 atmega328p atmega324p atmega644p atmega1284p atmega1284p_x2
mcu_atmega48 := atmega48
mcu_atmega168 := atmega168
mcu_atmega328p := atmega328p
mcu_atmega324p := atmega324p
mcu_atmega644p := atmega644p
mcu_atmega1284p := atmega1284p
mcu_atmega1284p_x2 := atmega1284p
LIBRARY_OBJECTS=\
OrangutanAnalog \
OrangutanBuzzer \
OrangutanDigital \
OrangutanLCD \
OrangutanLEDs \
OrangutanMotors \
OrangutanPulseIn \
OrangutanPushbuttons \
OrangutanResources \
OrangutanSerial \
OrangutanServos \
OrangutanSPIMaster \
OrangutanTime \
OrangutanSVP \
OrangutanX2 \
Pololu3pi \
PololuQTRSensors \
PololuWheelEncoders
SHELL = sh
# We need to do our recursive make with cd, since WinAVR does not support make -C.
# See WinAVR bug 1932584, "recursive make call fails"
.PHONY: library_files
library_files:
@echo making library files
$(foreach device,$(devices),cd devices/$(device) && $(MAKE) && cd ../.. &&) echo -n
# Change the path to allow make within sh to work: see WinAVR bug 1915456 "make ignores parameters when executed from sh"
PATH := $(shell echo $$PATH | sed 's/\(WinAVR-[0-9]*\)\/bin/\\1\/utils\/bin/g'):$(PATH)
LIBRARY_FILES := $(foreach device,$(devices),libpololu_$(device).a)
.PHONY: clean
clean:
$(foreach device,$(devices),cd devices/$(device) && $(MAKE) clean && cd ../.. &&) echo -n
rm -f $(LIBRARY_FILES)
# "make install" basically just copies the .a and files to the lib directory,
# and the header files to the include directory. The tricky thing is
# determining which directories those are in this makefile.
#
# By default, this makefile will install .a files in $(LIB)
# and header files in $(LIB)/../include/pololu, where LIB is determined
# by running `avr-gcc -print-search-dirs`, looking on the libraries
# line, taking the last directory listed.
#
# This seems to be a good choice on most systems because it points to
# a path that does not include the avr-gcc version number.
#
# You can check what directories this makefile will use by running
# make show_prefix
#
# You can override this behavior by inserting a line below that manually
# sets INCLUDE_POLOLU and LIB to a directory of your choice.
# For example, you could uncomment these lines:
# LIB := /usr/lib/avr/lib
# INCLUDE_POLOLU := /usr/lib/avr/include
#
# Note: Unless you specify LIB and INCLUDE_POLOLU as described above,
# or you add the AVR Studio 5 toolchain to your path, running
# 'make install' will NOT install the library into the AVR Studio 5
# toolchain. For Windows users, we recommend using the library's
# executable installer.
# Figure out what operating system we are running in.
UNAME := $(shell uname)
ifeq ($(findstring NT, $(UNAME)), NT)
WINDOWS=true
endif
ifeq ($(findstring MINGW, $(UNAME)), MINGW)
WINDOWS=true
endif
ifeq ($(origin LIB), undefined)
ifdef WINDOWS
# Directories are separated with ;
LIB := $(shell avr-gcc -print-search-dirs | grep -e "^libraries" | sed 's/.*;//')
else
# Directories are separated with :
LIB := $(shell avr-gcc -print-search-dirs | grep -e "^libraries" | sed 's/.*://')
endif
endif
INCLUDE_POLOLU ?= $(LIB)/../include/pololu
# Normalize the directory names so they don't have ".." in them.
# Doesn't work in Windows.
ifndef WINDOWS
LIB := $(abspath $(LIB))
INCLUDE_POLOLU := $(abspath $(INCLUDE_POLOLU))
endif
INSTALL_FILES := install -m=r--
.PHONY: show_prefix
show_prefix:
@echo The Pololu AVR Library object files \(.a\) will be installed in $(LIB)
@echo The header files \(.h\) will be installed in $(INCLUDE_POLOLU)
.PHONY: install
install: $(LIBRARY_FILES)
install -d $(LIB)
install -d $(INCLUDE_POLOLU)
install $(foreach device,$(devices),libpololu_$(device).a) $(LIB)
$(INSTALL_FILES) pololu/*.h $(INCLUDE_POLOLU)
for OrangutanObject in $(LIBRARY_OBJECTS); do install -d $(INCLUDE_POLOLU)/$$OrangutanObject ; $(INSTALL_FILES) src/$$OrangutanObject/*.h $(INCLUDE_POLOLU)/$$OrangutanObject ; done
install -d $(INCLUDE_POLOLU)/OrangutanResources/include
$(INSTALL_FILES) src/OrangutanResources/include/*.h $(INCLUDE_POLOLU)/OrangutanResources/include
$(INSTALL_FILES) pololu/orangutan $(INCLUDE_POLOLU)
@echo "Installation is complete."
# Include additional Makefile rules that are only available if you have
# downloaded the actual source of the library (from github).
# Silently fail otherwise.
-include src.mk