# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'mkmf'
extension_name = 'atomic_reference'
dir_config(extension_name)

case CONFIG["arch"]
when /mswin32|mingw|solaris/
    $CFLAGS += " -march=native"
when 'i686-linux'
    $CFLAGS += " -march-i686"
end

try_run(<<CODE,$CFLAGS) && ($defs << '-DHAVE_GCC_CAS')
int main() {
  int i = 1;
  __sync_bool_compare_and_swap(&i, 1, 4);
  return (i != 4);
}
CODE

create_makefile(extension_name)

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'mkmf'
extension_name = 'atomic_reference'
dir_config(extension_name)

case CONFIG["arch"]
when /mswin32|mingw|solaris/
    $CFLAGS += " -march=native"
when 'i686-linux'
    $CFLAGS += " -march=i686"
end

try_run(<<CODE,$CFLAGS) && ($defs << '-DHAVE_GCC_CAS')
int main() {
  int i = 1;
  __sync_bool_compare_and_swap(&i, 1, 4);
  return (i != 4);
}
CODE

create_makefile(extension_name)

Fix -march-i686 not supported in Ubuntu 12.04 LTS
Fix -march-i686 not supported in Ubuntu 12.04 LTS

```
root@eric:/usr/local/rvm/gems/ruby-1.9.3-p392/gems/atomic-1.1.11/ext# cat mkmf.log 
"gcc -o conftest -I/usr/local/rvm/rubies/ruby-1.9.3-p392/include/ruby-1.9.1/i686-linux -I/usr/local/rvm/rubies/ruby-1.9.3-p392/include/ruby-1.9.1/ruby/backward -I/usr/local/rvm/rubies/ruby-1.9.3-p392/include/ruby-1.9.1 -I.  -D_FILE_OFFSET_BITS=64  -I/usr/local/rvm/usr/include  -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration  -fPIC -march-i686 conftest.c  -L. -L/usr/local/rvm/rubies/ruby-1.9.3-p392/lib -Wl,-R/usr/local/rvm/rubies/ruby-1.9.3-p392/lib -L/usr/local/rvm/usr/lib -Wl,-R/usr/local/rvm/usr/lib -L.  -rdynamic -Wl,-export-dynamic -L/usr/local/rvm/usr/lib  -Wl,-R/usr/local/rvm/usr/lib      -Wl,-R -Wl,/usr/local/rvm/rubies/ruby-1.9.3-p392/lib -L/usr/local/rvm/rubies/ruby-1.9.3-p392/lib -lruby  -lpthread -lrt -ldl -lcrypt -lm   -lc"
cc1: error: unrecognized command line option ‘-march-i686’
```