-- -- HAMSTER_GCC.LUA Copyright (c) 2003-05, asko.kauppi@sci.fi -- -- Compiler adapter for GNU C(++) compiler, version 2.95 or later. -- -- Usage: -- Used either directly ('-l hamster_gcc') or via autodetecting -- '-l hamster' library. -- -- Author: -- asko.kauppi@sci.fi -- -- License: -- GPL (see 'license.txt') -- -- To-do: ... -- -- Subscript finding (this part should be same in all front-ends) -- local MY_PATH for pat in string.gfind( LUA_PATH, "[^;]+" ) do local try= string.gsub( pat, "%?%.lua", "" ) local fh= io.open(try.."hamster.lua","r") if fh then fh:close(); MY_PATH=try; break end end assert( MY_PATH, "Path to Hamster not found!" ) -- "Tools/Hamster/" local m= rawget(_G,"arg") and arg[1] or assert( dofile( MY_PATH.."hamster_core.lua" ) ) -- passes an error message (if necessary) assert( m._info ) ----- -- Tell our personality (gcc) -- function m.CompilerConfig( env ) -- local cc= os.getenv("CC") or (DARWIN and "cc") or "gcc" local cxx= os.getenv("CXX") or (DARWIN and "c++") or "g++" local cfg= { program_suffix= WIN32 and ".exe" or nil, sharedlib_suffix= (WIN32 and ".dll") or (DARWIN and ".dylib") or ".so", -- Linux, BSD, QNX staticlib_suffix= ".a", staticlib_prefix= "lib", staticobj_suffix= ".o", sharedobj_suffix= ".os", -- c_cmd= cc.." $CPPFLAGS $CCFLAGS -c $SOURCE -o $TARGET", cpp_cmd= cxx.." $CPPFLAGS $CXXFLAGS -c $SOURCE -o $TARGET", asm_cmd= nil, -- NOT IMPLEMENTED YET! shared_flag= (LINUX or DARWIN or BSD or QNX) and "-fPIC" or "", -- staticlib_cmd= "ar r $TARGET $SOURCE", staticlib_cmd2= "ranlib $TARGET", -- sharedlib_cmd= cxx.." $SHLINKFLAGS -o $TARGET $SOURCE $LIBPATH $LIBS", link_cmd= cxx.." $LINKFLAGS -o $TARGET $SOURCE $LIBPATH $LIBS", -- inc_flag= "-I", def_flag= "-D", lib_flag= "-l", libpath_flag= "-L", } return cfg end -- local make= os.getenv("MAKE") if (not make) and WIN32 then if HOST_WIN32_NATIVE then make= "mingw32-make" -- don't use 'make', that'd be confused with "make.cmd" elseif HOST_WIN32_MSYS then make= "make.exe" -- MSYS else --"make" -- cross compiling (Linux/OS X host) end end m._make= ASSUME(make or "make") rawset(_G,"hamster",m) rawset(_G,"CC","gcc") return m