# Simple cross-platform Makefile for the ISO 26262 tests
# Usage:
#   make           # build the test binary
#   make test      # run the tests
#   make clean     # remove the binary
#   make distclean # also remove the zip bundle

CC ?= cc
CFLAGS ?= -O2 -std=c11 -Wall -Wextra -Wpedantic

UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
  # clock_gettime may require librt on some older libcs
  LDLIBS += -lrt
endif

TARGET := iso26262_tests
SRC    := iso26262_part6_tests.c

all: $(TARGET)

$(TARGET): $(SRC)
	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)

test: $(TARGET)
	./$(TARGET)

clean:
	$(RM) $(TARGET)

distclean: clean
	$(RM) iso26262_tests_bundle.zip

.PHONY: all test clean distclean
