Buildings and group amalgamations