# Makefile for pandora panorama gimp plugin

# This tries to build pandora for every version of GIMP installed.
# Unfortunately GIMP doesn't have any standard way of doing that,
# so Pandora has to probe for all these possible versions.

# But starting with GIMP 2.2, it can't do that probe, because
# all possible versions have the same name, gimptool-2.0, even
# if they're really 2.2 or 2.3. See bug 310565; maybe this will
# be solved eventually. Meanwhile, you can only install to whichever
# GIMP comes first in your path.

GIMP_1_2_DIR=${HOME}/.gimp-1.2/plug-ins
GIMP_2_0_DIR=${HOME}/.gimp-2.0/plug-ins
GIMP_2_2_DIR=${HOME}/.gimp-2.2/plug-ins
GIMP_2_3_DIR=${HOME}/.gimp-2.3/plug-ins
GIMP_2_4_DIR=${HOME}/.gimp-2.4/plug-ins

GIMPTOOL_1_2=$(shell which gimptool-1.2)
GIMPTOOL_2_0=$(shell which gimptool-2.0)
GIMPTOOL_2_2=$(shell which gimptool-2.2)
GIMPTOOL_2_3=$(shell which gimptool-2.3)

# We don't need C99, but gcc 3.3 forces it by default, so we don't
# see errors that might kill other people's builds.  Force C89:
export CFLAGS=-std=c89

# Most people will want make install, but this dummy target is for
# people who don't want a makefile to install anything unless asked.
build:
	@echo Type make install to build and install the plugin.
	@echo I will try to install it for every version of GIMP
	@echo you have installed.

install:
	if test -x "${GIMPTOOL_2_0}"; then make install-2.0; fi
	if test -x "${GIMPTOOL_1_2}"; then make ${GIMP_1_2_DIR}/pandora_gen; fi

# pandora-match is experimental and not very useful yet.
# Most people probably shouldn't bother.
debug-all:
	if test -x "${GIMPTOOL_1_2}"; then make debug-1.2; fi
	if test -x "${GIMPTOOL_2_3}"; then make debug-2.3; fi

install-2.0:
	gimptool-2.0 --install-strip pandora_gen.c

install-1.2: ${GIMP_1_2_DIR}/pandora_gen

debug-2.3: ${GIMP_2_3_DIR}/pandora_gen ${GIMP_2_3_DIR}/pandora_match

debug-1.2: ${GIMP_1_2_DIR}/pandora_gen ${GIMP_1_2_DIR}/pandora_match

# pandora_gen stuff

${GIMP_1_2_DIR}/pandora_gen: pandora_gen.c
	mkdir -p ${GIMP_1_2_DIR}
	gimptool-1.2 --install-strip pandora_gen.c


# pandora_match stuff

${GIMP_1_2_DIR}/pandora_match: pandora_match.c
	mkdir -p ${GIMP_1_2_DIR}
	gimptool-1.2 --install-strip pandora_match.c

${GIMP_2_0_DIR}/pandora_match: pandora_match.c
	mkdir -p ${GIMP_2_0_DIR}
	gimptool-2.0 --install-strip pandora_match.c

clean:
	rm -f pandora_match pandora_gen *.o

