Commit 95d40f8f authored by Bernhard Nortmann's avatar Bernhard Nortmann
Browse files

Makefile: Ensure that user-supplied CFLAGS get respected


Signed-off-by: default avatarBernhard Nortmann <bernhard.nortmann@web.de>
parent 9d4658f9
...@@ -4,7 +4,7 @@ sudo: false ...@@ -4,7 +4,7 @@ sudo: false
language: c language: c
# treat all warnings as errors # treat all warnings as errors
env: EXTRA_CFLAGS=-Werror env: CFLAGS=-Werror
os: os:
- linux - linux
......
...@@ -17,21 +17,21 @@ ...@@ -17,21 +17,21 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
CC ?= gcc CC ?= gcc
CFLAGS = -g -O0 -Wall -Wextra $(EXTRA_CFLAGS) DEFAULT_CFLAGS := -g -O0 -Wall -Wextra -std=c99
CFLAGS += -std=c99 $(DEFINES)
CFLAGS += -Iinclude/
DEFINES = -D_POSIX_C_SOURCE=200112L DEFAULT_CFLAGS += -D_POSIX_C_SOURCE=200112L
# Define _BSD_SOURCE, necessary to expose all endian conversions properly. # Define _BSD_SOURCE, necessary to expose all endian conversions properly.
# See http://linux.die.net/man/3/endian # See http://linux.die.net/man/3/endian
DEFINES += -D_BSD_SOURCE DEFAULT_CFLAGS += -D_BSD_SOURCE
# glibc 2.20+ also requires _DEFAULT_SOURCE # glibc 2.20+ also requires _DEFAULT_SOURCE
DEFINES += -D_DEFAULT_SOURCE DEFAULT_CFLAGS += -D_DEFAULT_SOURCE
ifeq (NetBSD,$(OS)) ifeq (NetBSD,$(OS))
# add explicit _NETBSD_SOURCE, see https://github.com/linux-sunxi/sunxi-tools/pull/22 # add explicit _NETBSD_SOURCE, see https://github.com/linux-sunxi/sunxi-tools/pull/22
DEFINES += -D_NETBSD_SOURCE DEFAULT_CFLAGS += -D_NETBSD_SOURCE
endif endif
DEFAULT_CFLAGS += -Iinclude/
# Tools useful on host and target # Tools useful on host and target
TOOLS = sunxi-fexc sunxi-bootinfo sunxi-fel sunxi-nand-part TOOLS = sunxi-fexc sunxi-bootinfo sunxi-fel sunxi-nand-part
...@@ -49,6 +49,7 @@ MISC_TOOLS = phoenix_info sunxi-nand-image-builder ...@@ -49,6 +49,7 @@ MISC_TOOLS = phoenix_info sunxi-nand-image-builder
BINFILES = fel-pio.bin jtag-loop.sunxi fel-sdboot.sunxi uart0-helloworld-sdboot.sunxi BINFILES = fel-pio.bin jtag-loop.sunxi fel-sdboot.sunxi uart0-helloworld-sdboot.sunxi
CROSS_COMPILE ?= arm-none-eabi- CROSS_COMPILE ?= arm-none-eabi-
CROSS_CC ?= $(CROSS_COMPILE)gcc
MKSUNXIBOOT ?= mksunxiboot MKSUNXIBOOT ?= mksunxiboot
DESTDIR ?= DESTDIR ?=
...@@ -110,24 +111,26 @@ LIBUSB_CFLAGS ?= `pkg-config --cflags $(LIBUSB)` ...@@ -110,24 +111,26 @@ LIBUSB_CFLAGS ?= `pkg-config --cflags $(LIBUSB)`
LIBUSB_LIBS ?= `pkg-config --libs $(LIBUSB)` LIBUSB_LIBS ?= `pkg-config --libs $(LIBUSB)`
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
# Windows lacks mman.h / mmap() # Windows lacks mman.h / mmap()
DEFINES += -DNO_MMAP DEFAULT_CFLAGS += -DNO_MMAP
# portable_endian.h relies on winsock2 # portable_endian.h relies on winsock2
LIBS += -lws2_32 LIBS += -lws2_32
endif endif
HOST_CFLAGS = $(DEFAULT_CFLAGS) $(CFLAGS)
sunxi-fel: fel.c fel-to-spl-thunk.h progress.c progress.h sunxi-fel: fel.c fel-to-spl-thunk.h progress.c progress.h
$(CC) $(CFLAGS) $(LIBUSB_CFLAGS) $(LDFLAGS) -o $@ $(filter %.c,$^) $(LIBS) $(LIBUSB_LIBS) $(CC) $(HOST_CFLAGS) $(LIBUSB_CFLAGS) $(LDFLAGS) -o $@ $(filter %.c,$^) $(LIBS) $(LIBUSB_LIBS)
sunxi-nand-part: nand-part-main.c nand-part.c nand-part-a10.h nand-part-a20.h sunxi-nand-part: nand-part-main.c nand-part.c nand-part-a10.h nand-part-a20.h
$(CC) $(CFLAGS) -c -o nand-part-main.o nand-part-main.c $(CC) $(HOST_CFLAGS) -c -o nand-part-main.o nand-part-main.c
$(CC) $(CFLAGS) -c -o nand-part-a10.o nand-part.c -D A10 $(CC) $(HOST_CFLAGS) -c -o nand-part-a10.o nand-part.c -D A10
$(CC) $(CFLAGS) -c -o nand-part-a20.o nand-part.c -D A20 $(CC) $(HOST_CFLAGS) -c -o nand-part-a20.o nand-part.c -D A20
$(CC) $(LDFLAGS) -o $@ nand-part-main.o nand-part-a10.o nand-part-a20.o $(LIBS) $(CC) $(LDFLAGS) -o $@ nand-part-main.o nand-part-a10.o nand-part-a20.o $(LIBS)
sunxi-%: %.c sunxi-%: %.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(filter %.c,$^) $(LIBS) $(CC) $(HOST_CFLAGS) $(LDFLAGS) -o $@ $(filter %.c,$^) $(LIBS)
phoenix_info: phoenix_info.c phoenix_info: phoenix_info.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CC) $(HOST_CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
%.bin: %.elf %.bin: %.elf
$(CROSS_COMPILE)objcopy -O binary $< $@ $(CROSS_COMPILE)objcopy -O binary $< $@
...@@ -143,39 +146,39 @@ ARM_ELF_FLAGS += -mno-thumb-interwork -fno-stack-protector -fno-toplevel-reorder ...@@ -143,39 +146,39 @@ ARM_ELF_FLAGS += -mno-thumb-interwork -fno-stack-protector -fno-toplevel-reorder
ARM_ELF_FLAGS += -Wstrict-prototypes -Wno-format-nonliteral -Wno-format-security ARM_ELF_FLAGS += -Wstrict-prototypes -Wno-format-nonliteral -Wno-format-security
fel-pio.elf: fel-pio.c fel-pio.lds fel-pio.elf: fel-pio.c fel-pio.lds
$(CROSS_COMPILE)gcc -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -T fel-pio.lds $(CROSS_CC) -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -T fel-pio.lds
fel-pio.nm: fel-pio.elf fel-pio.nm: fel-pio.elf
$(CROSS_COMPILE)nm $< | grep -v " _" >$@ $(CROSS_COMPILE)nm $< | grep -v " _" >$@
jtag-loop.elf: jtag-loop.c jtag-loop.lds jtag-loop.elf: jtag-loop.c jtag-loop.lds
$(CROSS_COMPILE)gcc -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -T jtag-loop.lds -Wl,-N $(CROSS_CC) -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -T jtag-loop.lds -Wl,-N
fel-sdboot.elf: fel-sdboot.S fel-sdboot.lds fel-sdboot.elf: fel-sdboot.S fel-sdboot.lds
$(CROSS_COMPILE)gcc -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -T fel-sdboot.lds -Wl,-N $(CROSS_CC) -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -T fel-sdboot.lds -Wl,-N
uart0-helloworld-sdboot.elf: uart0-helloworld-sdboot.c uart0-helloworld-sdboot.lds uart0-helloworld-sdboot.elf: uart0-helloworld-sdboot.c uart0-helloworld-sdboot.lds
$(CROSS_COMPILE)gcc -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -T uart0-helloworld-sdboot.lds -Wl,-N $(CROSS_CC) -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -T uart0-helloworld-sdboot.lds -Wl,-N
boot_head_sun3i.elf: boot_head.S boot_head.lds boot_head_sun3i.elf: boot_head.S boot_head.lds
$(CROSS_COMPILE)gcc -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -T boot_head.lds -Wl,-N -DMACHID=0x1094 $(CROSS_CC) -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -T boot_head.lds -Wl,-N -DMACHID=0x1094
boot_head_sun4i.elf: boot_head.S boot_head.lds boot_head_sun4i.elf: boot_head.S boot_head.lds
$(CROSS_COMPILE)gcc -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -T boot_head.lds -Wl,-N -DMACHID=0x1008 $(CROSS_CC) -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -T boot_head.lds -Wl,-N -DMACHID=0x1008
boot_head_sun5i.elf: boot_head.S boot_head.lds boot_head_sun5i.elf: boot_head.S boot_head.lds
$(CROSS_COMPILE)gcc -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -T boot_head.lds -Wl,-N -DMACHID=0x102A $(CROSS_CC) -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -T boot_head.lds -Wl,-N -DMACHID=0x102A
sunxi-bootinfo: bootinfo.c sunxi-bootinfo: bootinfo.c
# target tools # target tools
TARGET_CFLAGS = -g -O0 -Wall -Wextra -std=c99 $(DEFINES) -Iinclude/ -static TARGET_CFLAGS = $(DEFAULT_CFLAGS) -static $(CFLAGS)
sunxi-pio: pio.c sunxi-pio: pio.c
$(CROSS_COMPILE)gcc $(TARGET_CFLAGS) -o $@ $< $(CROSS_CC) $(TARGET_CFLAGS) -o $@ $<
sunxi-meminfo: meminfo.c sunxi-meminfo: meminfo.c
$(CROSS_COMPILE)gcc $(TARGET_CFLAGS) -o $@ $< $(CROSS_CC) $(TARGET_CFLAGS) -o $@ $<
sunxi-script_extractor: script_extractor.c sunxi-script_extractor: script_extractor.c
$(CROSS_COMPILE)gcc $(TARGET_CFLAGS) -o $@ $< $(CROSS_CC) $(TARGET_CFLAGS) -o $@ $<
version.h: version.h:
@./autoversion.sh > $@ @./autoversion.sh > $@
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment