CC = gcc
CFLAGS = -Wall -Wextra -Werror -pedantic -std=c11 -g -O2
LDFLAGS = -lcurl -ljson-c

TARGET = devranta
SOURCES = devranta.c
OBJECTS = $(SOURCES:.c=.o)

.PHONY: all clean test

all: $(TARGET)

$(TARGET): $(OBJECTS)
	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@

clean:
	rm -f $(OBJECTS) $(TARGET)

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

debug: CFLAGS += -DDEBUG -g3 -fsanitize=address,undefined
debug: $(TARGET)

install: $(TARGET)
	mkdir -p /usr/local/lib
	mkdir -p /usr/local/include
	cp $(TARGET) /usr/local/lib/
	# You might want to copy header file here if you create one