#! /usr/bin/make -f

# libfoo.42 is a split package.
libfoo.42 libfoo.42-dbg libfoo.42-dev: libfoo.42.buildstamp

# This is the real target for all packages installed from the same build.
libfoo.42.buildstamp:
	# The current working directory is the temporary build/install directory.
	# In this directory are 'src', 'dest', and any buildstamps.
	cd src
	# Configure, build, and install the software.
	./configure --prefix=/usr
	make
	make DESTDIR=../dest install
	cd ..
	# Make a debugging binary, strip the regular one of debugging symbols, and
	# add to the regular binary a link directing GDB to the debugging binary.
	objcopy --only-keep-debug dest/usr/lib/libfoo.so.42 \
		dest/usr/lib/debug/usr/lib/libfoo.so.42
	strip -g dest/usr/lib/libfoo.so.42
	objcopy --add-gnu-debuglink=/usr/lib/debug/usr/lib/libfoo.so.42 \
		dest/usr/lib/libfoo.so.42
	# Move files from 'dest' into a binary package.
	opk-installfiles libfoo.42
	opk-installfiles libfoo.42-dbg
	opk-installfiles libfoo.42-dev
	# Pack each binary package.
	opk-pack libfoo.42
	opk-pack libfoo.42-dbg
	opk-pack libfoo.42-dev
	# Touch the build stamp to prevent these packages from being built again.
	touch libfoo.42.buildstamp