# This file is auto-generated by alef — DO NOT EDIT.
# alef:hash:b3135b542cb7b8e6a0c2596b1d16d6a738b344dc02314b2a41cf0825f2eea349
# To regenerate: alef generate
# To verify freshness: alef verify --exit-code
# Issues & docs: https://github.com/sample_crate-dev/alef
CC = gcc
FFI_DIR = ffi

$(FFI_DIR)/include/html_to_markdown.h: download_ffi.sh
	bash download_ffi.sh

HEADER_PATH := $(if $(wildcard $(FFI_DIR)/include/html_to_markdown.h),$(FFI_DIR)/include/html_to_markdown.h,$(if $(wildcard ../../crates/html-to-markdown-ffi/include/html_to_markdown.h),../../crates/html-to-markdown-ffi/include/html_to_markdown.h))
LIB_PATH := $(or $(wildcard $(FFI_DIR)/lib/libhtml_to_markdown_ffi.so),$(wildcard $(FFI_DIR)/lib/libhtml_to_markdown_ffi.dylib),$(wildcard $(FFI_DIR)/lib/libhtml_to_markdown_ffi.a),$(wildcard ../../target/release/libhtml_to_markdown_ffi.so),$(wildcard ../../target/release/libhtml_to_markdown_ffi.dylib),$(wildcard ../../target/release/libhtml_to_markdown_ffi.a))

FFI_INCLUDE = $(if $(wildcard $(FFI_DIR)/include/html_to_markdown.h),$(FFI_DIR)/include,$(if $(wildcard ../../crates/html-to-markdown-ffi/include/html_to_markdown.h),../../crates/html-to-markdown-ffi/include))
FFI_LIB_DIR = $(if $(wildcard $(FFI_DIR)/lib),$(FFI_DIR)/lib,$(if $(wildcard ../../target/release),../../target/release))

ifneq ($(FFI_INCLUDE),)
    CFLAGS = -Wall -Wextra -I. -I$(FFI_INCLUDE)
    LDFLAGS = -L$(FFI_LIB_DIR) -lhtml_to_markdown_ffi
else
    CFLAGS = -Wall -Wextra -I. $(shell pkg-config --cflags html_to_markdown_ffi 2>/dev/null)
    LDFLAGS = $(shell pkg-config --libs html_to_markdown_ffi 2>/dev/null)
endif

SRCS = main.c test_conversion.c test_smoke.c
TARGET = run_tests

.PHONY: all clean test

all: $(TARGET)

$(TARGET): $(SRCS) $(if $(and $(HEADER_PATH),$(LIB_PATH)),,$(FFI_DIR)/include/html_to_markdown.h)
	$(CC) $(CFLAGS) -o $@ $(SRCS) $(LDFLAGS)

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

clean:
	rm -f $(TARGET)
