giant used to build frames for specialized(my 1989 sirrus is probably giant made, as giant came out with their own road bike that was almost an exact duplicate a few years later. as were most of the allez and other specialized models from the mid-eighties on). but since merida bought a 50% share in specialized, i'd assume they are building most, if not all of the current specialized line.
trek, i have no idea, but i wouldn't doubt that giant builds many of their bikes as well.