1aae2a388900ad012d9b09cf2dcacd28ddb7dd5b
[pub/USBasp.git] / LUFA / Build / lufa_build.mk
1 #
2 # LUFA Library
3 # Copyright (C) Dean Camera, 2015.
4 #
5 # dean [at] fourwalledcubicle [dot] com
6 # www.lufa-lib.org
7 #
8
9 DMBS_BUILD_MODULES +=
10 DMBS_BUILD_TARGETS +=
11 DMBS_BUILD_MANDATORY_VARS += LUFA_PATH ARCH F_USB
12 DMBS_BUILD_OPTIONAL_VARS += BOARD
13 DMBS_BUILD_PROVIDED_VARS +=
14 DMBS_BUILD_PROVIDED_MACROS +=
15
16 # -----------------------------------------------------------------------------
17 # LUFA Core Build Buildsystem Makefile Module.
18 # -----------------------------------------------------------------------------
19 # DESCRIPTION:
20 # Subclass of the standard DMBS GCC build module, with LUFA specific
21 # extensions. This module provides the core build rules for the compilation
22 # of LUFA projects using GCC.
23 # -----------------------------------------------------------------------------
24 # TARGETS:
25 #
26 # (None)
27 #
28 # MANDATORY PARAMETERS:
29 #
30 # LUFA_PATH - Path to the LUFA library core
31 # ARCH - Device architecture name
32 # F_USB - Speed of the USB core clock, in Hz
33 #
34 # OPTIONAL PARAMETERS:
35 #
36 # BOARD - LUFA board drivers to use
37 #
38 # PROVIDED VARIABLES:
39 #
40 # (None)
41 #
42 # PROVIDED MACROS:
43 #
44 # (None)
45 #
46 # -----------------------------------------------------------------------------
47
48 SHELL = /bin/sh
49
50 ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
51 ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
52 ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
53
54 # Sanity check user supplied values
55 $(call ERROR_IF_EMPTY, LUFA_PATH)
56 $(call ERROR_IF_EMPTY, ARCH)
57 $(call ERROR_IF_EMPTY, F_USB)
58
59 # Default values of optionally user-supplied variables
60 BOARD ?= NONE
61
62 # Determine the utility prefix to use for the selected architecture
63 ifeq ($(ARCH), XMEGA)
64 $(warning The XMEGA device support is currently EXPERIMENTAL (incomplete and/or non-functional), and is included for preview purposes only.)
65 else ifeq ($(ARCH), UC3)
66 $(warning The UC3 device support is currently EXPERIMENTAL (incomplete and/or non-functional), and is included for preview purposes only.)
67 endif
68
69 # LUFA specific standard build options
70 C_FLAGS += -I. -I$(patsubst %/,%,$(LUFA_PATH))/..
71 C_FLAGS += -DARCH=ARCH_$(ARCH) -DBOARD=BOARD_$(BOARD) -DF_USB=$(F_USB)UL
72
73 # This flag is required for bootloaders as GCC will emit invalid jump table
74 # assembly code for devices with large amounts of flash; the jump table target
75 # is extracted from FLASH without using the correct ELPM instruction, resulting
76 # in a pseudo-random jump target.
77 C_FLAGS += -fno-jump-tables
78
79 DMBS_PATH := $(LUFA_PATH)/Build/DMBS/DMBS
80 include $(DMBS_PATH)/gcc.mk