Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7ae3b46908 |
120
Makefile
120
Makefile
@@ -8,31 +8,18 @@
|
|||||||
# permitted in any medium without royalty provided the copyright notice and this
|
# permitted in any medium without royalty provided the copyright notice and this
|
||||||
# notice are preserved. This file is offered as-is, without any warranty.
|
# notice are preserved. This file is offered as-is, without any warranty.
|
||||||
|
|
||||||
.POSIX:
|
#.POSIX:
|
||||||
|
|
||||||
# if using BSD make(1), remove these pragmas because they break it
|
include config.mk
|
||||||
.PRAGMA: posix_202x # future POSIX standard support à la pdpmake(1)
|
|
||||||
.PRAGMA: command_comment # breaks without this?
|
|
||||||
|
|
||||||
DESTDIR ?= dist
|
|
||||||
PREFIX ?= /usr/local
|
|
||||||
|
|
||||||
MANDIR != [ $(PREFIX) = / ] && printf '/usr/share/man\n' \
|
|
||||||
|| printf '/share/man\n'
|
|
||||||
SYSEXITS != printf '\043include <sysexits.h>\n' | cpp -M - | sed 's/ /\n/g' \
|
|
||||||
| sed -n 's/sysexits\.h//p' || printf 'include\n'
|
|
||||||
|
|
||||||
CC ?= cc
|
|
||||||
RUSTC ?= rustc
|
|
||||||
RUSTLIBS = --extern getopt=build/o/libgetopt.rlib \
|
|
||||||
--extern sysexits=build/o/libsysexits.rlib \
|
|
||||||
--extern strerror=build/o/libstrerror.rlib
|
|
||||||
CFLAGS += -I$(SYSEXITS)
|
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: dj false fop hru intcmp mm npc rpn scrut str strcmp swab true
|
all: prepare
|
||||||
|
@$(MAKE) -C lib
|
||||||
|
@$(MAKE) -C bin
|
||||||
|
|
||||||
build:
|
|
||||||
|
.PHONY: prepare
|
||||||
|
prepare:
|
||||||
# keep build/include until bindgen(1) has stdin support
|
# keep build/include until bindgen(1) has stdin support
|
||||||
# https://github.com/rust-lang/rust-bindgen/issues/2703
|
# https://github.com/rust-lang/rust-bindgen/issues/2703
|
||||||
mkdir -p build/bin build/include build/lib build/o build/test
|
mkdir -p build/bin build/include build/lib build/o build/test
|
||||||
@@ -44,99 +31,14 @@ clean:
|
|||||||
dist: all
|
dist: all
|
||||||
mkdir -p $(DESTDIR)/$(PREFIX)/bin $(DESTDIR)/$(PREFIX)/share/man/man1
|
mkdir -p $(DESTDIR)/$(PREFIX)/bin $(DESTDIR)/$(PREFIX)/share/man/man1
|
||||||
cp build/bin/* $(DESTDIR)/$(PREFIX)/bin
|
cp build/bin/* $(DESTDIR)/$(PREFIX)/bin
|
||||||
cp docs/*.1 $(DESTDIR)/$(PREFIX)/$(MANDIR)/man1
|
cp bin/*/*.1 $(DESTDIR)/$(PREFIX)/share/man/man1
|
||||||
|
|
||||||
|
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
install: dist
|
install: dist
|
||||||
cp -r $(DESTDIR)/* /
|
cp -r $(DESTDIR)/* /
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: build
|
test: prepare
|
||||||
tests/posix-compat.sh
|
tests/posix-compat.sh
|
||||||
$(RUSTC) --test src/getopt-rs/lib.rs -o build/test/getopt
|
$(RUSTC) --test src/getopt-rs/lib.rs -o build/test/getopt
|
||||||
|
|
||||||
.PHONY: rustlibs
|
|
||||||
rustlibs: build/o/libsysexits.rlib build/o/libgetopt.rlib \
|
|
||||||
build/o/libstrerror.rlib
|
|
||||||
|
|
||||||
build/o/libgetopt.rlib: build src/getopt-rs/lib.rs
|
|
||||||
$(RUSTC) $(RUSTFLAGS) --crate-type=lib --crate-name=getopt \
|
|
||||||
-o $@ src/getopt-rs/lib.rs
|
|
||||||
|
|
||||||
build/o/libstrerror.rlib: build src/strerror.rs
|
|
||||||
$(RUSTC) $(RUSTFLAGS) --crate-type=lib -o $@ \
|
|
||||||
src/strerror.rs
|
|
||||||
|
|
||||||
build/o/libsysexits.rlib: build $(SYSEXITS)sysexits.h
|
|
||||||
# bandage solution until bindgen(1) gets stdin support
|
|
||||||
printf '#define EXIT_FAILURE 1\n' | cat - $(SYSEXITS)sysexits.h \
|
|
||||||
> build/include/sysexits.h
|
|
||||||
bindgen --default-macro-constant-type signed --use-core --formatter=none \
|
|
||||||
build/include/sysexits.h | $(RUSTC) $(RUSTFLAGS) --crate-type lib -o $@ -
|
|
||||||
|
|
||||||
.PHONY: dj
|
|
||||||
dj: build/bin/dj
|
|
||||||
build/bin/dj: src/dj.c build
|
|
||||||
$(CC) $(CFLAGS) -o $@ src/dj.c
|
|
||||||
|
|
||||||
.PHONY: false
|
|
||||||
false: build/bin/false
|
|
||||||
build/bin/false: src/false.c build
|
|
||||||
$(CC) $(CFLAGS) -o $@ src/false.c
|
|
||||||
|
|
||||||
.PHONY: fop
|
|
||||||
fop: build/bin/fop
|
|
||||||
build/bin/fop: src/fop.rs build rustlibs
|
|
||||||
$(RUSTC) $(RUSTFLAGS) $(RUSTLIBS) -o $@ src/fop.rs
|
|
||||||
|
|
||||||
.PHONY: hru
|
|
||||||
hru: build/bin/hru
|
|
||||||
build/bin/hru: src/hru.rs build rustlibs
|
|
||||||
$(RUSTC) $(RUSTFLAGS) $(RUSTLIBS) -o $@ src/hru.rs
|
|
||||||
|
|
||||||
.PHONY: intcmp
|
|
||||||
intcmp: build/bin/intcmp
|
|
||||||
build/bin/intcmp: src/intcmp.c build
|
|
||||||
$(CC) $(CFLAGS) -o $@ src/intcmp.c
|
|
||||||
|
|
||||||
.PHONY: mm
|
|
||||||
mm: build/bin/mm
|
|
||||||
build/bin/mm: src/mm.c build
|
|
||||||
$(CC) $(CFLAGS) -o $@ src/mm.c
|
|
||||||
|
|
||||||
.PHONY: npc
|
|
||||||
npc: build/bin/npc
|
|
||||||
build/bin/npc: src/npc.c build
|
|
||||||
$(CC) $(CFLAGAS) -o $@ src/npc.c
|
|
||||||
|
|
||||||
.PHONY: rpn
|
|
||||||
rpn: build/bin/rpn
|
|
||||||
build/bin/rpn: src/rpn.rs build rustlibs
|
|
||||||
$(RUSTC) $(RUSTFLAGS) $(RUSTLIBS) -o $@ src/rpn.rs
|
|
||||||
|
|
||||||
.PHONY: scrut
|
|
||||||
scrut: build/bin/scrut
|
|
||||||
build/bin/scrut: src/scrut.c build
|
|
||||||
$(CC) $(CFLAGS) -o $@ src/scrut.c
|
|
||||||
|
|
||||||
.PHONY: str
|
|
||||||
str: build/bin/str
|
|
||||||
build/bin/str: src/str.c build
|
|
||||||
$(CC) $(CFLAGS) -o $@ src/str.c
|
|
||||||
|
|
||||||
.PHONY: strcmp
|
|
||||||
strcmp: build/bin/strcmp
|
|
||||||
build/bin/strcmp: src/strcmp.c build
|
|
||||||
$(CC) $(CFLAGS) -o $@ src/strcmp.c
|
|
||||||
|
|
||||||
.PHONY: swab
|
|
||||||
swab: build/bin/swab
|
|
||||||
build/bin/swab: src/swab.rs build build/o/libsysexits.rlib
|
|
||||||
$(RUSTC) $(RUSTFLAGS) --extern getopt=build/o/libgetopt.rlib \
|
|
||||||
--extern sysexits=build/o/libsysexits.rlib \
|
|
||||||
-o $@ src/swab.rs
|
|
||||||
|
|
||||||
.PHONY: true
|
|
||||||
true: build/bin/true
|
|
||||||
build/bin/true: src/true.c build
|
|
||||||
$(CC) $(CFLAGS) -o $@ src/true.c
|
|
||||||
|
|||||||
91
bin/Makefile
Normal file
91
bin/Makefile
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
# Copyright (c) 2023–2024 Emma Tebibyte <emma@tebibyte.media>
|
||||||
|
# Copyright (c) 2023–2024 DTB <trinity@trinity.moe>
|
||||||
|
# Copyright (c) 2023 Sasha Koshka <sashakoshka@tebibyte.media>
|
||||||
|
# Copyright (c) 2024 Aaditya Aryal <aryalaadi123@gmail.com>
|
||||||
|
# SPDX-License-Identifier: FSFAP
|
||||||
|
#
|
||||||
|
# Copying and distribution of this file, with or without modification, are
|
||||||
|
# permitted in any medium without royalty provided the copyright notice and this
|
||||||
|
# notice are preserved. This file is offered as-is, without any warranty.
|
||||||
|
|
||||||
|
include ../config.mk
|
||||||
|
|
||||||
|
.PHONY: bin
|
||||||
|
bin: dj false fop hru intcmp mm npc rpn scrut str strcmp swab true
|
||||||
|
|
||||||
|
.PHONY: lib
|
||||||
|
|
||||||
|
# TODO: this does not have to be here
|
||||||
|
.PHONY: prepare
|
||||||
|
prepare:
|
||||||
|
# keep ..$(BUILD)/include until bindgen(1) has stdin support
|
||||||
|
# https://github.com/rust-lang/rust-bindgen/issues/2703
|
||||||
|
mkdir -p ../$(BUILD)/bin ../$(BUILD)/include ../$(BUILD)/lib
|
||||||
|
mkdir -p ../$(BUILD)/test ../$(BUILD)/o
|
||||||
|
|
||||||
|
.PHONY: dj
|
||||||
|
dj: ../$(BUILD)/bin/dj
|
||||||
|
../$(BUILD)/bin/dj: dj/dj.c prepare
|
||||||
|
$(CC) $(CFLAGS) -o $@ dj/dj.c
|
||||||
|
|
||||||
|
.PHONY: false
|
||||||
|
false: ../$(BUILD)/bin/false
|
||||||
|
../$(BUILD)/bin/false: false/false.c prepare
|
||||||
|
$(CC) $(CFLAGS) -o $@ false/false.c
|
||||||
|
|
||||||
|
.PHONY: fop
|
||||||
|
fop: ../$(BUILD)/bin/fop
|
||||||
|
../$(BUILD)/bin/fop: fop/fop.rs prepare lib
|
||||||
|
$(RUSTC) $(RUSTFLAGS) $(RUSTLIBS) -o $@ fop/fop.rs
|
||||||
|
|
||||||
|
.PHONY: hru
|
||||||
|
hru: ../$(BUILD)/bin/hru
|
||||||
|
../$(BUILD)/bin/hru: hru/hru.rs prepare lib
|
||||||
|
$(RUSTC) $(RUSTFLAGS) $(RUSTLIBS) -o $@ hru/hru.rs
|
||||||
|
|
||||||
|
.PHONY: intcmp
|
||||||
|
intcmp: ../$(BUILD)/bin/intcmp
|
||||||
|
../$(BUILD)/bin/intcmp: intcmp/intcmp.c prepare
|
||||||
|
$(CC) $(CFLAGS) -o $@ intcmp/intcmp.c
|
||||||
|
|
||||||
|
.PHONY: mm
|
||||||
|
mm: ../$(BUILD)/bin/mm
|
||||||
|
../$(BUILD)/bin/mm: mm/mm.c prepare
|
||||||
|
$(CC) $(CFLAGS) -o $@ mm/mm.c
|
||||||
|
|
||||||
|
.PHONY: npc
|
||||||
|
npc: ../$(BUILD)/bin/npc
|
||||||
|
../$(BUILD)/bin/npc: npc/npc.c prepare
|
||||||
|
$(CC) $(CFLAGAS) -o $@ npc/npc.c
|
||||||
|
|
||||||
|
.PHONY: rpn
|
||||||
|
rpn: ../$(BUILD)/bin/rpn
|
||||||
|
../$(BUILD)/bin/rpn: rpn/rpn.rs prepare lib
|
||||||
|
$(RUSTC) $(RUSTFLAGS) $(RUSTLIBS) -o $@ rpn/rpn.rs
|
||||||
|
|
||||||
|
.PHONY: scrut
|
||||||
|
scrut: ../$(BUILD)/bin/scrut
|
||||||
|
../$(BUILD)/bin/scrut: scrut/scrut.c prepare
|
||||||
|
$(CC) $(CFLAGS) -o $@ scrut/scrut.c
|
||||||
|
|
||||||
|
.PHONY: str
|
||||||
|
str: ../$(BUILD)/bin/str
|
||||||
|
../$(BUILD)/bin/str: str/str.c prepare
|
||||||
|
$(CC) $(CFLAGS) -o $@ str/str.c
|
||||||
|
|
||||||
|
.PHONY: strcmp
|
||||||
|
strcmp: ../$(BUILD)/bin/strcmp
|
||||||
|
../$(BUILD)/bin/strcmp: strcmp/strcmp.c prepare
|
||||||
|
$(CC) $(CFLAGS) -o $@ strcmp/strcmp.c
|
||||||
|
|
||||||
|
.PHONY: swab
|
||||||
|
swab: ../$(BUILD)/bin/swab
|
||||||
|
../$(BUILD)/bin/swab: swab/swab.rs prepare lib
|
||||||
|
$(RUSTC) $(RUSTFLAGS) --extern getopt=../$(BUILD)/o/libgetopt.rlib \
|
||||||
|
--extern sysexits=../$(BUILD)/o/libsysexits.rlib \
|
||||||
|
-o $@ swab/swab.rs
|
||||||
|
|
||||||
|
.PHONY: true
|
||||||
|
true: ../$(BUILD)/bin/true
|
||||||
|
../$(BUILD)/bin/true: true/true.c prepare
|
||||||
|
$(CC) $(CFLAGS) -o $@ true/true.c
|
||||||
@@ -32,12 +32,18 @@ use sysexits::{ EX_DATAERR, EX_IOERR, EX_UNAVAILABLE, EX_USAGE };
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let argv = args().collect::<Vec<String>>();
|
let argv = args().collect::<Vec<String>>();
|
||||||
let mut d = 0x1E.to_string();
|
let mut d = '␞';
|
||||||
let mut arg_parser = Parser::new(&argv, "d:");
|
let mut arg_parser = Parser::new(&argv, "d:");
|
||||||
|
|
||||||
while let Some(opt) = arg_parser.next() {
|
while let Some(opt) = arg_parser.next() {
|
||||||
match opt {
|
match opt {
|
||||||
Ok(Opt('d', Some(arg))) => d = arg,
|
Ok(Opt('d', Some(arg))) => {
|
||||||
|
let arg_char = arg.chars().collect::<Vec<char>>();
|
||||||
|
if arg_char.len() > 1 {
|
||||||
|
eprintln!("{}: {}: Not a character.", argv[0], arg);
|
||||||
|
exit(EX_USAGE);
|
||||||
|
} else { d = arg_char[0]; }
|
||||||
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -57,7 +63,7 @@ fn main() {
|
|||||||
|
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
let _ = stdin().read_to_string(&mut buf);
|
let _ = stdin().read_to_string(&mut buf);
|
||||||
let mut fields = buf.split(&d).collect::<Vec<&str>>();
|
let mut fields = buf.split(d).collect::<Vec<&str>>();
|
||||||
|
|
||||||
let opts = argv
|
let opts = argv
|
||||||
.iter()
|
.iter()
|
||||||
@@ -106,15 +106,6 @@ oserr(char *s, char *r){
|
|||||||
} \
|
} \
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
/* Prints a usage text, in which s is the program being run (i.e. argv[0]), and
|
|
||||||
* returns an exit status appropriate for a usage error. */
|
|
||||||
int usage(char *s){
|
|
||||||
|
|
||||||
fprintf(stderr, "Usage: %s (-aenu) (-i [input])... (-o [output])...\n", s);
|
|
||||||
|
|
||||||
return EX_USAGE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]){
|
int main(int argc, char *argv[]){
|
||||||
int c;
|
int c;
|
||||||
struct Files files[2]; /* {read, write} */
|
struct Files files[2]; /* {read, write} */
|
||||||
@@ -187,15 +178,12 @@ int main(int argc, char *argv[]){
|
|||||||
k = 1;
|
k = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
retval = usage(argv[0]);
|
fprintf(stderr, "Usage: %s (-aenu) (-i [input])..."
|
||||||
|
" (-o [output])...\n", argv[0]);
|
||||||
|
retval = EX_USAGE;
|
||||||
terminate;
|
terminate;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(optind != argc){
|
|
||||||
retval = usage(argv[0]);
|
|
||||||
terminate;
|
|
||||||
}
|
|
||||||
|
|
||||||
files[0].s += files[0].s == 0;
|
files[0].s += files[0].s == 0;
|
||||||
files[1].s += files[1].s == 0;
|
files[1].s += files[1].s == 0;
|
||||||
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2023–2024 DTB <trinity@trinity.moe>
|
* Copyright (c) 2023 DTB <trinity@trinity.moe>
|
||||||
* Copyright (c) 2024 Emma Tebibyte <emma@tebibyte.media>
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under
|
* This program is free software: you can redistribute it and/or modify it under
|
||||||
@@ -18,15 +17,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h> /* fprintf(3), stderr, NULL */
|
#include <stdio.h> /* fprintf(3), stderr, NULL */
|
||||||
#include <stdlib.h> /* EXIT_FAILURE, EXIT_SUCCESS */
|
#include <stdlib.h> /* EXIT_FAILURE */
|
||||||
#include <string.h> /* memset(3), strchr(3) */
|
#include <string.h> /* memset(3), strchr(3) */
|
||||||
#ifndef EX_USAGE
|
|
||||||
# include <sysexits.h>
|
|
||||||
#endif
|
|
||||||
#include <unistd.h> /* access(3), getopt(3), F_OK, R_OK, W_OK, X_OK */
|
#include <unistd.h> /* access(3), getopt(3), F_OK, R_OK, W_OK, X_OK */
|
||||||
#include <sys/stat.h> /* lstat(3), stat struct, S_ISBLK, S_ISCHR, S_ISDIR,
|
#include <sys/stat.h> /* lstat(3), stat struct, S_ISBLK, S_ISCHR, S_ISDIR,
|
||||||
* S_ISFIFO, S_ISGID, S_ISREG, S_ISLNK, S_ISSOCK,
|
* S_ISFIFO, S_ISGID, S_ISREG, S_ISLNK, S_ISSOCK,
|
||||||
* S_ISUID, S_ISVTX */
|
* S_ISUID, S_ISVTX */
|
||||||
|
#include <sysexits.h>
|
||||||
|
|
||||||
static char args[] = "bcdefghkprsuwxLS";
|
static char args[] = "bcdefghkprsuwxLS";
|
||||||
static char ops[(sizeof args) / (sizeof *args)];
|
static char ops[(sizeof args) / (sizeof *args)];
|
||||||
@@ -60,7 +57,7 @@ int main(int argc, char *argv[]){
|
|||||||
|
|
||||||
argv += optind;
|
argv += optind;
|
||||||
do{ if(access(*argv, F_OK) != 0 || lstat(*argv, &buf) == -1)
|
do{ if(access(*argv, F_OK) != 0 || lstat(*argv, &buf) == -1)
|
||||||
return EXIT_FAILURE; /* doesn't exist or isn't stattable */
|
return 1; /* doesn't exist or isn't stattable */
|
||||||
|
|
||||||
for(i = 0; ops[i] != '\0'; ++i)
|
for(i = 0; ops[i] != '\0'; ++i)
|
||||||
if(ops[i] == 'e')
|
if(ops[i] == 'e')
|
||||||
@@ -100,8 +97,8 @@ usage: fprintf(stderr, "Usage: %s (-%s) [file...]\n",
|
|||||||
&& !S_ISLNK(buf.st_mode))
|
&& !S_ISLNK(buf.st_mode))
|
||||||
|| (ops[i] == 'S'
|
|| (ops[i] == 'S'
|
||||||
&& !S_ISSOCK(buf.st_mode)))
|
&& !S_ISSOCK(buf.st_mode)))
|
||||||
return EXIT_FAILURE;
|
return 1;
|
||||||
}while(*++argv != NULL);
|
}while(*++argv != NULL);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return 0;
|
||||||
}
|
}
|
||||||
29
config.mk
Normal file
29
config.mk
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# Copyright (c) 2023–2024 Emma Tebibyte <emma@tebibyte.media>
|
||||||
|
# Copyright (c) 2023–2024 DTB <trinity@trinity.moe>
|
||||||
|
# Copyright (c) 2023 Sasha Koshka <sashakoshka@tebibyte.media>
|
||||||
|
# Copyright (c) 2024 Aaditya Aryal <aryalaadi123@gmail.com>
|
||||||
|
# SPDX-License-Identifier: FSFAP
|
||||||
|
#
|
||||||
|
# Copying and distribution of this file, with or without modification, are
|
||||||
|
# permitted in any medium without royalty provided the copyright notice and this
|
||||||
|
# notice are preserved. This file is offered as-is, without any warranty.
|
||||||
|
|
||||||
|
# if using BSD make(1), remove these pragmas because they break it
|
||||||
|
.PRAGMA: posix_202x # future POSIX standard support à la pdpmake(1)
|
||||||
|
.PRAGMA: command_comment # breaks without this?
|
||||||
|
|
||||||
|
DESTDIR ?= dist
|
||||||
|
PREFIX ?= /usr/local
|
||||||
|
BUILD ?= build
|
||||||
|
|
||||||
|
SYSEXITS != printf '\043include <sysexits.h>\n' | cpp -M - | sed 's/ /\n/g' \
|
||||||
|
| sed -n 's/sysexits\.h//p' || printf 'include\n'
|
||||||
|
|
||||||
|
CC ?= cc
|
||||||
|
RUSTC ?= rustc
|
||||||
|
RUSTLIBS = --extern getopt=../$(BUILD)/o/libgetopt.rlib \
|
||||||
|
--extern sysexits=../$(BUILD)/o/libsysexits.rlib \
|
||||||
|
--extern strerror=../$(BUILD)/o/libstrerror.rlib
|
||||||
|
|
||||||
|
CFLAGs += --std=c99 -Wall -pedantic -Werror
|
||||||
|
CFLAGS += -I$(SYSEXITS)
|
||||||
30
lib/Makefile
Normal file
30
lib/Makefile
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# Copyright (c) 2023–2024 Emma Tebibyte <emma@tebibyte.media>
|
||||||
|
# Copyright (c) 2023–2024 DTB <trinity@trinity.moe>
|
||||||
|
# Copyright (c) 2023 Sasha Koshka <sashakoshka@tebibyte.media>
|
||||||
|
# Copyright (c) 2024 Aaditya Aryal <aryalaadi123@gmail.com>
|
||||||
|
# SPDX-License-Identifier: FSFAP
|
||||||
|
#
|
||||||
|
# Copying and distribution of this file, with or without modification, are
|
||||||
|
# permitted in any medium without royalty provided the copyright notice and this
|
||||||
|
# notice are preserved. This file is offered as-is, without any warranty.
|
||||||
|
|
||||||
|
include ../config.mk
|
||||||
|
|
||||||
|
.PHONY: lib
|
||||||
|
lib: ../$(BUILD)/o/libsysexits.rlib ../$(BUILD)/o/libgetopt.rlib \
|
||||||
|
../$(BUILD)/o/libstrerror.rlib
|
||||||
|
|
||||||
|
../$(BUILD)/o/libgetopt.rlib: getopt-rs/lib.rs
|
||||||
|
$(RUSTC) $(RUSTFLAGS) --crate-type=lib --crate-name=getopt \
|
||||||
|
-o $@ getopt-rs/lib.rs
|
||||||
|
|
||||||
|
../$(BUILD)/o/libstrerror.rlib: strerror.rs
|
||||||
|
$(RUSTC) $(RUSTFLAGS) --crate-type=lib -o $@ \
|
||||||
|
strerror.rs
|
||||||
|
|
||||||
|
../$(BUILD)/o/libsysexits.rlib: $(SYSEXITS)sysexits.h
|
||||||
|
# bandage solution until bindgen(1) gets stdin support
|
||||||
|
printf '#define EXIT_FAILURE 1\n' | cat - $(SYSEXITS)sysexits.h \
|
||||||
|
> ../$(BUILD)/include/sysexits.h
|
||||||
|
bindgen --default-macro-constant-type signed --use-core --formatter=none \
|
||||||
|
../$(BUILD)/include/sysexits.h | $(RUSTC) $(RUSTFLAGS) --crate-type lib -o $@ -
|
||||||
Reference in New Issue
Block a user