31 lines
890 B
Python
31 lines
890 B
Python
Import('env')
|
|
|
|
env['AS'] = 'i686-elf-as'
|
|
env['CC'] = 'i686-elf-gcc'
|
|
env['CXX'] = 'i686-elf-g++'
|
|
env['LD'] = 'i686-elf-g++'
|
|
|
|
def get_crt_object(name: str) -> str:
|
|
import subprocess
|
|
|
|
cmd = [env['CXX']]
|
|
cmd.extend(env['CXXFLAGS'])
|
|
cmd.append(f'-print-file-name={name}')
|
|
result = subprocess.run(cmd, stdout=subprocess.PIPE)
|
|
return result.stdout.decode('utf-8').strip()
|
|
crtbegin_o = get_crt_object('crtbegin.o')
|
|
crtend_o = get_crt_object('crtend.o')
|
|
crti_o = env.Object('src/crt/crti.s')
|
|
crtn_o = env.Object('src/crt/crtn.s')
|
|
|
|
i686_sources = Split('''
|
|
src/kernel/boot.s
|
|
src/kernel/startup.cpp
|
|
''')
|
|
|
|
env['LINKCOM'] = env['LINKCOM'].replace('$_LIBFLAGS', f'{crti_o[0].abspath} {crtbegin_o} $_LIBFLAGS {crtend_o} {crtn_o[0].abspath}')
|
|
|
|
env.Append(KERNEL_SOURCES = [env.File(f) for f in i686_sources])
|
|
env.Append(KERNEL_DEPENDENCIES = [crti_o, crtn_o])
|
|
|
|
Return('env') |