aboutsummaryrefslogtreecommitdiff
path: root/mule-attiny/bitbang_updi_reset/Makefile
blob: 919411c5f4c5d205eef2646ec67e64668a27f228 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# updi-reset makefile
# date : 15/02/2023

# Support building from outside of directory (via e.g. `make -C <path>`
# taken from <https://stackoverflow.com/a/23324703>
MAKE_PATH = $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

CROSS_COMPILE ?=
CC = $(CROSS_COMPILE)gcc

CFLAGS ?= -Wall -Werror

# Executable
EXEC = $(MAKE_PATH)/updi_reset

# For testing purposes
ifeq ($(findstring reset,${MAKECMDGOALS}), reset)
ifndef RST_GPIOCHIP_IDX
$(error RST_GPIOCHIP_IDX is not set)
endif
ifndef RST_GPIO_IDX
$(error RST_GPIO_IDX is not set)
endif
endif

.PHONY: reset build clean

build: $(EXEC)
$(EXEC): *.c *.h Makefile
	$(CC) serial_emu.c updi_emu.c updi_reset.c -lgpiod $(CFLAGS) -o $(EXEC)

# For testing purposes
reset: $(EXEC)
# Give this script the highest scheduling priority (-20) To avoid extra intra-packet sampling delays.
	nice --20 $(EXEC) $(RST_GPIOCHIP_IDX) $(RST_GPIO_IDX)

clean:
	rm -f $(EXEC)