Skip to content

Commit

Permalink
Merge pull request #255 from dosemu2/meson
Browse files Browse the repository at this point in the history
Meson
  • Loading branch information
stsp authored Dec 30, 2024
2 parents 6c30dba + 0db3eea commit 2df22af
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 35 deletions.
16 changes: 5 additions & 11 deletions fdpp/kernel/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,15 @@ SRCS = [

nargs = ['-DXCPU=186', '-DWITHFAT32', '-DFDPP']

lib = static_library('dummy',
executable(TARGET + '.elf',
[SRCS, sfiles, plt_inc],
include_directories: incdir2,
nasm_args: nargs,
build_by_default: false)
nasm_ld = find_program(['i686-linux-gnu-ld', 'i386-elf-ld', 'x86_64-linux-gnu-ld', 'ld.bfd'])
custom_target(TARGET + '.elf',
output: [TARGET + '.elf', TARGET + '.map'],
input: lib.extract_all_objects(recursive: true),
command: [nasm_ld, '-melf_i386', '-static',
'-Map=@OUTPUT1@', '-o', '@OUTPUT0@',
'--emit-relocs', '-T' + kernel_ld, '@INPUT@'],
link_args: ['-Wl,-melf_i386', '-Wl,-static',
'-Wl,-Map=' + TARGET + '.map', '-nostdlib',
'-Wl,--emit-relocs', '-Wl,-T' + kernel_ld],
install: true,
install_dir: get_option('datadir') / 'fdpp',
install_mode: 'rw-r--r--',
build_by_default: true)
install_mode: 'rw-r--r--')

VERSION = meson.project_version()
43 changes: 19 additions & 24 deletions fdpp/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ project('libfdpp', ['c', 'cpp'], default_options: ['cpp_std=c++20'],

MF = meson.current_source_dir() / 'parsers/mkfar.sh'
PD = meson.current_source_dir() / 'parsers/parse_decls.sh'
RAI = meson.current_source_dir() / 'run_arg_in.sh'
RAO = meson.current_source_dir() / 'run_arg_out.sh'
tg = dependency('thunk_gen')
TG = tg.get_variable(pkgconfig: 'binary')
MA = tg.get_variable(pkgconfig: 'mkadscript')
TGS = tg.get_variable(pkgconfig: 'tgscript')
TGM4 = tg.get_variable(pkgconfig: 'm4script')
TFLAGS = ['-a', '2', '-p', '2']
TGMK = tg.get_variable(pkgconfig: 'makeinc')
TFLAGS = '-a 2 -p 2'
SRC = 'src'
rel_inc = 'include/fdpp'
incdir = include_directories(rel_inc)
Expand Down Expand Up @@ -61,10 +60,13 @@ ccgen = generator(find_program(MF),
capture: true)
ccfiles = ccgen.process(CFILES)

make = find_program('make')

gad = custom_target('glob_asmdefs.h',
output: 'glob_asmdefs.h',
input: 'src/glob_asm.h',
command: [MA, '@INPUT@'],
command: [RAO, 'glob_asmdefs.h', make, '-f', TGMK,
'glob_asmdefs.h', 'GLOB_ASM=@INPUT@'],
capture: true)

GEN_TMP = { '1':'thunk_calls.tmp', '2':'thunk_asms.tmp' }
Expand Down Expand Up @@ -97,32 +99,25 @@ pap = custom_target('plt_asmp.h',
env: env,
capture: true)

tgenv = environment()
tgenv.set('TFLAGS', TFLAGS)

tc = custom_target('thunk_calls.h',
output: 'thunk_calls.h',
input: GEN['thunk_calls.tmp'],
command: [TG, TFLAGS],
feed: true,
capture: true)

ta1 = custom_target('thunk_asms1.h',
output: 'thunk_asms1.h',
input: GEN['thunk_asms.tmp'],
command: [TG, TFLAGS, '1'],
feed: true,
capture: true)

ta2 = custom_target('thunk_asms2.h',
output: 'thunk_asms2.h',
input: GEN['thunk_asms.tmp'],
command: [TG, TFLAGS, '2'],
command: [RAI, 'thunk_calls.tmp', 'thunk_calls.h',
make, '-f', TGMK, 'thunk_calls.h'],
env: tgenv,
feed: true,
capture: true)

ta = custom_target('thunk_asms.h',
output: 'thunk_asms.h',
input: [ta1, ta2],
command: ['sh', '-c', 'cat @INPUT0@ | ' + TGS + ' ' + TGM4 +
' | cat - @INPUT1@'],
input: GEN['thunk_asms.tmp'],
command: [RAI, 'thunk_asms.tmp', 'thunk_asms.h',
make, '-f', TGMK, 'thunk_asms.h'],
env: tgenv,
feed: true,
capture: true)

FDPP_CFILES = ['smalloc.c', 'farhlp_sta.c']
Expand Down
10 changes: 10 additions & 0 deletions fdpp/run_arg_in.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

cat >$1
shift
OUT=$1
shift
PRG=$1
shift
$PRG $* 1>&2
cat $OUT
8 changes: 8 additions & 0 deletions fdpp/run_arg_out.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

OUT=$1
shift
PRG=$1
shift
$PRG $* 1>&2
cat $OUT

0 comments on commit 2df22af

Please sign in to comment.