Commit | Line | Data |
---|---|---|
172d42d9 AG |
1 | # Copyright 2012 Adam Green (http://mbed.org/users/AdamGreen/) |
2 | # | |
3 | # Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | # you may not use this file except in compliance with the License. | |
5 | # You may obtain a copy of the License at | |
6 | # | |
7 | # http://www.apache.org/licenses/LICENSE-2.0 | |
8 | # | |
9 | # Unless required by applicable law or agreed to in writing, software | |
10 | # distributed under the License is distributed on an "AS IS" BASIS, | |
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | # See the License for the specific language governing permissions and | |
13 | # limitations under the License. | |
14 | ############################################################################### | |
15 | # USAGE: | |
16 | # Variables that must be defined in including makefile. | |
17 | # PROJECT: Name to be given to the output binary for this project. | |
18 | # BUILD_DIR: The directory containing this build.mk file. | |
19 | # | |
20 | # Variables that may be optionally set in makefile. | |
21 | # SRC: The root directory for the sources of your project. Defaults to '.'. | |
22 | # LIBS_PREFIX: List of library/object files to prepend to mbed.ar capi.ar libs. | |
23 | # LIBS_SUFFIX: List of library/object files to append to mbed.ar capi.ar libs. | |
24 | # BUILD_TYPE: Type of build to produce. Allowed values are: | |
25 | # Debug - Build for debugging. Disables optimizations and | |
26 | # links in debug MRI runtime. Best debugging | |
27 | # experience. | |
28 | # Release - Build for release with no debug support. | |
29 | # Checked - Release build with debug support. Due to | |
30 | # optimizations, debug experience won't be as good | |
31 | # as Debug but might be needed when bugs don't | |
32 | # reproduce in Debug builds. | |
33 | # default: Release | |
34 | # DEVICES: List of devices for which to build. This list be space delimited | |
35 | # and can include the following devices: | |
36 | # LPC1768, LPC11U24 | |
37 | # default: LPC1768 | |
38 | # GPFLAGS: Additional compiler flags used when building C++ sources. | |
39 | # GCFLAGS: Additional compiler flags used when building C sources. | |
40 | # AS_GCFLAGS: Additional compiler flags used by GCC when building | |
41 | # preprocessed assembly language sources. | |
42 | # AS_FLAGS: Additional assembler flags used when building assembly language | |
43 | # sources. | |
44 | # NO_FLOAT_SCANF: When set to 1, scanf() will not support %f specifier to | |
45 | # input floating point values. Reduces code size. | |
46 | # NO_FLOAT_PRINTF: When set to 1, scanf() will not support %f specifier to | |
47 | # output floating point values. Reduces code size. | |
48 | # VERBOSE: When set to 1, all build commands will be displayed to console. | |
49 | # It defaults to 0 which suppresses the output of the build tool | |
50 | # command lines themselves. | |
51 | # MRI_BREAK_ON_INIT: Should the program halt before calling into main(), | |
52 | # allowing the developer time to set breakpoints in main() | |
53 | # or in code run from within global constructors. | |
54 | # default: 1 - break on init. | |
55 | # MRI_SEMIHOST_STDIO: Set to non-zero value to allow debug monitor to use | |
56 | # semi-host calls to redirect stdin/stdout/stderr to the | |
57 | # gdb console. | |
58 | # default: 1 for Debug/Checked builds and 0 for Release. | |
59 | # MRI_UART: Select the UART to be used by the debugger. See mri.h for | |
60 | # allowed values. | |
61 | # default: MRI_UART_MBED_USB - Use USB based UART on the mbed. | |
62 | # Example makefile: | |
63 | # PROJECT=HelloWorld | |
64 | # BUILD_DIR=../.. | |
65 | # | |
66 | # include $(BUILD_DIR)/build.mk | |
67 | # | |
68 | ############################################################################### | |
69 | ||
70 | # Check for undefined variables. | |
71 | ifndef PROJECT | |
72 | $(error makefile must set PROJECT variable.) | |
73 | endif | |
74 | ||
75 | ifndef BUILD_DIR | |
76 | $(error makefile must set BUILD_DIR.) | |
77 | endif | |
78 | ||
79 | ||
80 | # Default DEVICES to LPC1768 if nothing else has been specified. | |
81 | DEVICES?=lpc1768 | |
82 | ||
83 | ||
84 | # Use DEVICES variable to determine which builds to perform. | |
85 | CLEAN_DEVICES=$(addsuffix .clean,$(DEVICES)) | |
86 | .PHONY: all clean $(DEVICES) $(CLEAN_DEVICES) deploy deploy-lpc1768 deploy-lpc11u24 | |
87 | ||
88 | all: $(DEVICES) | |
89 | ||
90 | clean: $(CLEAN_DEVICES) | |
91 | ||
92 | export | |
93 | $(DEVICES): | |
94 | @echo Building for device $@ | |
95 | @$(MAKE) -f $(BUILD_DIR)/$@.mk all | |
96 | ||
97 | $(CLEAN_DEVICES): %.clean: | |
98 | @echo Cleaning up for device $* | |
99 | @$(MAKE) -f $(BUILD_DIR)/$*.mk clean | |
100 | ||
101 | ifdef LPC_DEPLOY | |
102 | deploy deploy-lpc1768: | |
103 | @echo Deploying to target. | |
104 | $(subst PROJECT,LPC1768/$(PROJECT),$(LPC_DEPLOY)) | |
105 | ||
106 | deploy-lpc11u24: | |
107 | @echo Deploying to target. | |
108 | $(subst PROJECT,LPC11U24/$(PROJECT),$(LPC_DEPLOY)) | |
109 | endif |