1# 2# SPDX-License-Identifier: BSD-3-Clause 3# 4# Copyright © 2019 Keith Packard 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 9# 10# 1. Redistributions of source code must retain the above copyright 11# notice, this list of conditions and the following disclaimer. 12# 13# 2. Redistributions in binary form must reproduce the above 14# copyright notice, this list of conditions and the following 15# disclaimer in the documentation and/or other materials provided 16# with the distribution. 17# 18# 3. Neither the name of the copyright holder nor the names of its 19# contributors may be used to endorse or promote products derived 20# from this software without specific prior written permission. 21# 22# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 27# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33# OF THE POSSIBILITY OF SUCH DAMAGE. 34# 35 36CFLAGS=--oslib=semihost -Os 37 38CFLAGS_RISCV=$(CFLAGS) -march=rv32imac -mabi=ilp32 -Triscv.ld 39CC_RISCV=riscv64-unknown-elf-gcc -specs=picolibc.specs $(CFLAGS_RISCV) 40CXXFLAGS_RISCV=$(CFLAGS) -march=rv32imac -mabi=ilp32 -Triscv-cpp.ld 41CXX_RISCV=riscv64-unknown-elf-g++ -specs=picolibcpp.specs $(CXXFLAGS_RISCV) 42 43CFLAGS_ARM=$(CFLAGS) -mcpu=cortex-m3 -Tarm.ld 44CC_ARM=arm-none-eabi-gcc -specs=picolibc.specs $(CFLAGS_ARM) 45CXXFLAGS_ARM=$(CFLAGS) -mcpu=cortex-m3 -Tarm-cpp.ld 46CXX_ARM=arm-none-eabi-g++ -specs=picolibcpp.specs $(CXXFLAGS_ARM) 47 48CFLAGS_AARCH64=$(CFLAGS) -Taarch64.ld 49CC_AARCH64=aarch64-linux-gnu-gcc -specs=picolibc.specs $(CFLAGS_AARCH64) 50CXXFLAGS_AARCH64=$(CFLAGS) -Taarch64-cpp.ld 51CXX_AARCH64=aarch64-linux-gnu-g++ -specs=picolibcpp.specs $(CXXFLAGS_AARCH64) 52 53all: \ 54 hello-world-arm.elf hello-world-aarch64.elf \ 55 hello-world-riscv.elf hello-world-native.elf \ 56 printf.elf printf-int.elf printf-float.elf 57 58all-cpp: \ 59 hello-worldpp-arm.elf hello-worldpp-aarch64.elf \ 60 hello-worldpp-riscv.elf hello-worldpp-native.elf 61 62hello-world-arm.elf: hello-world.c 63 $(CC_ARM) -o $@ $^ -Wl,-Map=hello-world-arm.map 64 65hello-world-aarch64.elf: hello-world.c 66 $(CC_AARCH64) -o $@ $^ -Wl,-Map=hello-world-aarch64.map 67 68hello-world-riscv.elf: hello-world.c 69 $(CC_RISCV) -o $@ $^ -Wl,-Map=hello-world-riscv.map 70 71hello-world-native.elf: hello-world.c 72 cc -o $@ $^ 73 74printf.elf: printf.c 75 $(CC_ARM) -o $@ $^ -Wl,-Map=printf.map 76 77printf-int.elf: printf.c 78 $(CC_ARM) -DPICOLIBC_INTEGER_PRINTF_SCANF -o $@ $^ -Wl,-Map=printf-int.map 79 80printf-float.elf: printf.c 81 $(CC_ARM) -DPICOLIBC_FLOAT_PRINTF_SCANF -o $@ $^ -Wl,-Map=printf-float.map 82 83hello-worldpp-native.elf: hello-worldpp.cpp 84 c++ -o $@ $^ 85 86hello-worldpp-arm.elf: hello-worldpp.cpp 87 $(CXX_ARM) -Wl,-Map=hello-worldpp-arm.map -o $@ $^ 88 89hello-worldpp-aarch64.elf: hello-worldpp.cpp 90 $(CXX_AARCH64) -Wl,-Map=hello-worldpp-aarch64.map -o $@ $^ 91 92hello-worldpp-riscv.elf: hello-worldpp.cpp 93 $(CXX_RISCV) -Wl,-Map=hello-worldpp-riscv.map -o $@ $^ 94 95clean: 96 rm -f *.elf *.map 97 98