# Copyright (C) 2012 Alejandro Mery # Copyright (C) 2012,2013 Henrik Nordstrom # Copyright (C) 2013 Patrick Wood # Copyright (C) 2013 Pat Wood # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . CC ?= gcc CFLAGS = -g -O0 -Wall -Wextra CFLAGS += -std=c99 $(DEFINES) CFLAGS += -Iinclude/ DEFINES = -D_POSIX_C_SOURCE=200112L # Define _BSD_SOURCE, necessary to expose all endian conversions properly. # See http://linux.die.net/man/3/endian DEFINES += -D_BSD_SOURCE # glibc 2.20+ also requires _DEFAULT_SOURCE DEFINES += -D_DEFAULT_SOURCE ifeq (NetBSD,$(OS)) # add explicit _NETBSD_SOURCE, see https://github.com/linux-sunxi/sunxi-tools/pull/22 DEFINES += -D_NETBSD_SOURCE endif # Tools useful on host and target TOOLS = sunxi-fexc # Symlinks to sunxi-fexc FEXC_LINKS = bin2fex fex2bin .PHONY: all clean all: tools tools: $(FEXC_LINKS) clean: @rm -vf $(TOOLS) $(FEXC_LINKS) @rm -vf *.o *.elf *.sunxi *.bin *.nm *.orig $(TOOLS): Makefile common.h fex2bin bin2fex: sunxi-fexc ln -nsf $< $@ sunxi-fexc: fexc.h script.h script.c \ script_uboot.h script_uboot.c \ script_bin.h script_bin.c \ script_fex.h script_fex.c sunxi-%: %.c $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(filter %.c,$^) $(LIBS) .gitignore: Makefile @for x in $(TOOLS) $(FEXC_LINKS) '*.o' '*.swp'; do \ echo "$$x"; \ done > $@