#!/bin/bash
set -e

# Generate the xdg-shell client glue from the protocol definition shipped by the
# wayland-protocols package. This produces:
#   xdg-shell-client-protocol.h  (the header included by square.c)
#   xdg-shell-protocol.c         (the interface/marshalling code we link in)
PROTO=$(pkg-config --variable=pkgdatadir wayland-protocols)/stable/xdg-shell/xdg-shell.xml
wayland-scanner client-header "$PROTO" xdg-shell-client-protocol.h
wayland-scanner private-code  "$PROTO" xdg-shell-protocol.c

# Build square, linking the generated xdg-shell code alongside our source.
gcc -g -o square square.c xdg-shell-protocol.c -l wayland-client
