1#
2# Copyright (C) 2019 Remi Pommarel <repk@triplefau.lt>
3#
4# SPDX-License-Identifier:     BSD-3-Clause
5# https://spdx.org/licenses
6#
7MAKE_HELPERS_DIRECTORY := ../../make_helpers/
8include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
9include ${MAKE_HELPERS_DIRECTORY}build_env.mk
10
11PROJECT := doimage${BIN_EXT}
12OBJECTS := doimage.o
13V := 0
14
15HOSTCCFLAGS := -Wall -Werror -pedantic -std=c99 -D_GNU_SOURCE
16
17ifeq (${DEBUG},1)
18  HOSTCCFLAGS += -g -O0 -DDEBUG
19else
20  HOSTCCFLAGS += -O2
21endif
22
23ifeq (${V},0)
24  Q := @
25else
26  Q :=
27endif
28
29HOSTCC := gcc
30
31.PHONY: all clean distclean
32
33all: ${PROJECT}
34
35${PROJECT}: ${OBJECTS} Makefile
36	@echo "  HOSTLD  $@"
37	${Q}${HOSTCC} ${OBJECTS} -o $@
38	@${ECHO_BLANK_LINE}
39	@echo "Built $@ successfully"
40	@${ECHO_BLANK_LINE}
41
42%.o: %.c Makefile
43	@echo "  HOSTCC  $<"
44	${Q}${HOSTCC} -c ${HOSTCCFLAGS} $< -o $@
45
46clean:
47	$(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS})
48
49distclean: clean
50