Peel squash and cut in half lengthwise. Remove center seeds and strings, and then slice thinly.
Heat butter in a skillet, over a medium flame. Add onions, salt and pepper and sauté for 10 minutes.
Comine flour, brown sugar and spices. Combine apples and flour mixture toss to coat well.
Place half of the squash into a buttered 9x13x2-inch baking dish.
Arrange half the apples in a layer on top of the squash place the remaining squash on top of the apples. Cover with the remaining apples. Top with the sautéed onions.
Pour stock over all.
Bake at 350 degrees for 45-50 minutes, until squash is tender combine breadcrumbs, cheese, and bacon-mix well. Spread mixture over the gratin. Bake for 15 minutes, until lightly browned remove from heat and allow to cool slightly before serving.