-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.mk
72 lines (65 loc) · 3.31 KB
/
Makefile.mk
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
# This file is licensed under the the MIT License.
#
# Copyright (c) 2014 Matthijs Kooijman <matthijs@stdin.nl>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
#
# This Makefile snippet is intended to be included by other Makefiles.
# You can then either:
# - include the $(ARDUINO_UNIX_SOURCES) in the build, or
# - include the $(ARDUINO_UNIX_OBJECTS) in the link, or
# - include the $(ARDUINO_UNIX_LIB_A) in the link
#
# You should also make your Makefile targets depend on the relevant
# files.
#
# In either case, you should put $(ARDUINO_UNIX_INCLUDE_PATH) in the
# include path for all sources compiled (including the
# ARDUINO_UNIX_SOURCES) and link with -lstdc++.
ARDUINO_UNIX_DEFAULT_GOAL := $(.DEFAULT_GOAL)
ARDUINO_UNIX_ROOT_PATH := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
ARDUINO_UNIX_INCLUDE_PATH := $(ARDUINO_UNIX_ROOT_PATH)/include
ARDUINO_UNIX_SRC_PATH := $(ARDUINO_UNIX_ROOT_PATH)/src
ARDUINO_UNIX_CXX_SOURCES := $(wildcard $(ARDUINO_UNIX_SRC_PATH)/*.cpp)
ARDUINO_UNIX_C_SOURCES := $(wildcard $(ARDUINO_UNIX_SRC_PATH)/*.c)
ARDUINO_UNIX_SOURCES := $(ARDUINO_UNIX_C_SOURCES) $(ARDUINO_UNIX_CXX_SOURCES)
ARDUINO_UNIX_C_OBJECTS := $(ARDUINO_UNIX_C_SOURCES:.c=.o)
ARDUINO_UNIX_CXX_OBJECTS := $(ARDUINO_UNIX_CXX_SOURCES:.cpp=.o)
ARDUINO_UNIX_OBJECTS := $(ARDUINO_UNIX_C_OBJECTS) $(ARDUINO_UNIX_CXX_OBJECTS)
ARDUINO_UNIX_LIB_A := $(ARDUINO_UNIX_ROOT_PATH)/ArduinoUnix.a
ARDUINO_UNIX_CFLAGS += -I$(ARDUINO_UNIX_INCLUDE_PATH) -Wall
ARDUINO_UNIX_CXXFLAGS += -I$(ARDUINO_UNIX_INCLUDE_PATH) -Wall
ARDUINO_UNIX_GCC ?= gcc
ARDUINO_UNIX_AR ?= ar
$(ARDUINO_UNIX_C_OBJECTS): %.o: %.c
$(ARDUINO_UNIX_GCC) -c $(ARDUINO_UNIX_CPPFLAGS) $(ARDUINO_UNIX_CFLAGS) -o $@ $<
$(ARDUINO_UNIX_CXX_OBJECTS): %.o: %.cpp
$(ARDUINO_UNIX_GCC) -c $(ARDUINO_UNIX_CPPFLAGS) $(ARDUINO_UNIX_CXXFLAGS) -o $@ $<
$(ARDUINO_UNIX_LIB_A): $(ARDUINO_UNIX_OBJECTS)
rm -f $(ARDUINO_UNIX_LIB_A)
$(ARDUINO_UNIX_AR) -qvc $(ARDUINO_UNIX_LIB_A) $(ARDUINO_UNIX_OBJECTS)
clean: clean-arduino-unix
clean-arduino-unix:
rm -f $(ARDUINO_UNIX_OBJECTS) $(ARDUINO_UNIX_LIB_A)
# Reset the default goal to whatever it was at the start of this file.
# This is useful if there was no default goal yet, and makes sure that
# the goals in this file are never selected as default goal
.DEFAULT_GOAL := $(ARDUINO_UNIX_DEFAULT_GOAL)