DIRS=dist build $(PLUGIN_DIR)
CXX=clang++ -std=c++23 -O3
NAME=seam_carving
PLUGIN_DIR=$(HOME)/.config/GIMP/3.0/plug-ins/$(NAME)

all: $(DIRS) $(PLUGIN_DIR)/$(NAME)

$(PLUGIN_DIR)/$(NAME): dist/plugin
	cp $< $@

dist/plugin: build/plugin.o
	$(CXX) $< -o $@ $(shell pkg-config --libs gimp-3.0 gimpui-3.0 gegl-0.4)
	chmod +x $@

build/plugin.o: plugin.cpp
	$(CXX) -c $< -o $@ $(shell pkg-config --cflags gimp-3.0 gimpui-3.0 gegl-0.4) 

clean:
	rm -rf $(DIRS)
	rm compile_commands.json

$(DIRS):
	mkdir -p $@
