diff options
author | dzwdz | 2023-09-22 23:42:30 +0200 |
---|---|---|
committer | dzwdz | 2023-09-22 23:42:30 +0200 |
commit | 6a4d4a41a664e6a4c406a449ea847abd4a224bcf (patch) | |
tree | 0a637697c8697929beb8f4b7ff69d8b74f9e28bb /configure | |
parent | a3d6aa9f8d427b86a33dc05bed98a2e88229a285 (diff) |
build: support single file commands
Diffstat (limited to 'configure')
-rwxr-xr-x | configure | 19 |
1 files changed, 13 insertions, 6 deletions
@@ -1,12 +1,17 @@ #!/usr/bin/env python3 from glob import glob +import os file = open('Makefile', 'w', encoding='utf-8') def raw(s): print(s, file=file) def srcobj(path): - srcs = glob(path + '/**/*.[csS]', recursive=True) + srcs = None + if os.path.isfile(path): + srcs = [path] + else: + srcs = glob(path + '/**/*.[csS]', recursive=True) objs = ['out/obj/' + src.removeprefix('src/') + '.o' for src in srcs] return ' ' + ' '.join(objs) + ' ' @@ -95,13 +100,15 @@ t('out/fs/boot/grub/grub.cfg', 'src/kernel/arch/amd64/grub.cfg', ['cp $< $@']) t('out/fs.e2', '', ['mkfs.ext2 $@ 1024 >/dev/null']) -userbins = glob('*', root_dir='src/cmd/') -raw("USERBINS = " + " ".join(userbins)) - -for cmd in userbins: - t(f'out/initrd/bin/amd64/{cmd}', '$(LIB) ' + srcobj(f'src/cmd/{cmd}'), [ +userbins = [] +for src in glob('*', root_dir='src/cmd/'): + cmd = src.removesuffix('.c') + t(f'out/initrd/bin/amd64/{cmd}', '$(LIB) ' + srcobj(f'src/cmd/{src}'), [ '$(CC) $^ -o $@' ]) + userbins.append(cmd) + +raw("USERBINS = " + " ".join(userbins)) # don't build the example implementation from libext2 t('out/obj/cmd/ext2fs/ext2/example.c.o', '', ['touch $@']) |