Makefile: removed configure and made library builds better
This commit is contained in:
parent
2ec04c0564
commit
5b47936477
10
Makefile
10
Makefile
@ -15,9 +15,6 @@ PREFIX=/usr/local
|
|||||||
CC=cc
|
CC=cc
|
||||||
RUSTC=rustc
|
RUSTC=rustc
|
||||||
|
|
||||||
# to build, first run ./configure
|
|
||||||
include cc.mk rustc.mk
|
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: dj false fop intcmp scrut str strcmp true
|
all: dj false fop intcmp scrut str strcmp true
|
||||||
|
|
||||||
@ -46,7 +43,7 @@ test: build
|
|||||||
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
|
||||||
|
|
||||||
sysexits: build
|
build/o/libsysexits.rlib: build
|
||||||
# bandage solution until bindgen(1) gets stdin support
|
# bandage solution until bindgen(1) gets stdin support
|
||||||
printf '#define EXIT_FAILURE 1\n' | cat - include/sysexits.h \
|
printf '#define EXIT_FAILURE 1\n' | cat - include/sysexits.h \
|
||||||
> build/include/sysexits.h
|
> build/include/sysexits.h
|
||||||
@ -56,7 +53,7 @@ sysexits: build
|
|||||||
| sed 's/ /\n/g' | grep sysexits.h)" \
|
| sed 's/ /\n/g' | grep sysexits.h)" \
|
||||||
| $(RUSTC) $(RUSTCFLAGS) --crate-type lib -o build/o/libsysexits.rlib -
|
| $(RUSTC) $(RUSTCFLAGS) --crate-type lib -o build/o/libsysexits.rlib -
|
||||||
|
|
||||||
libgetopt: src/getopt-rs/lib.rs
|
build/o/libgetopt.rlib: src/getopt-rs/lib.rs
|
||||||
$(RUSTC) $(RUSTCFLAGS) --crate-type=lib --crate-name=getopt \
|
$(RUSTC) $(RUSTCFLAGS) --crate-type=lib --crate-name=getopt \
|
||||||
-o build/o/libgetopt.rlib src/getopt-rs/lib.rs
|
-o build/o/libgetopt.rlib src/getopt-rs/lib.rs
|
||||||
|
|
||||||
@ -72,8 +69,9 @@ build/bin/false: src/false.c build
|
|||||||
|
|
||||||
.PHONY: fop
|
.PHONY: fop
|
||||||
fop: build/bin/fop
|
fop: build/bin/fop
|
||||||
build/bin/fop: src/fop.rs build libgetopt sysexits
|
build/bin/fop: src/fop.rs build build/o/libgetopt.rlib build/o/libsysexits.rlib
|
||||||
$(RUSTC) $(RUSTFLAGS) --extern getopt=build/o/libgetopt.rlib \
|
$(RUSTC) $(RUSTFLAGS) --extern getopt=build/o/libgetopt.rlib \
|
||||||
|
--extern sysexits=build/o/libsysexits.rlib \
|
||||||
-o $@ src/fop.rs
|
-o $@ src/fop.rs
|
||||||
|
|
||||||
.PHONY: intcmp
|
.PHONY: intcmp
|
||||||
|
44
configure
vendored
44
configure
vendored
@ -1,44 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# Copyright (c) 2023–2024 Emma Tebibyte <emma@tebibyte.media>
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
CFLAGS='-Lbuild/lib -idirafter include -O3'
|
|
||||||
RUSTFLAGS='-Copt-level=z -Ccodegen-units=1 -Cpanic=abort -Clto=y \
|
|
||||||
-Cstrip=symbols -Ctarget-cpu=native \
|
|
||||||
--extern sysexits=build/o/libsysexits.rlib'
|
|
||||||
|
|
||||||
if [ "$1" = "clean" ]; then
|
|
||||||
rm *.mk || true
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
while test -n "$1"; do
|
|
||||||
case "$1" in
|
|
||||||
clang)
|
|
||||||
CFLAGS="$CFLAGS -Wall"
|
|
||||||
;;
|
|
||||||
gcc)
|
|
||||||
CFLAGS="$CFLAGS -s -Wl,-z,noseparate-code,-z,nosectionheader -flto"
|
|
||||||
;;
|
|
||||||
rustc) ;;
|
|
||||||
'rustc +nightly')
|
|
||||||
RUSTFLAGS="+nightly -Zlocation-detail=none $RUSTFLAGS"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
printf 'Usage: %s [clean | compiler]\n' "$0"
|
|
||||||
exit 64 # sysexits.h(3) EX_USAGE
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
|
|
||||||
printf 'CFLAGS=%s\n' "$CFLAGS" >cc.mk
|
|
||||||
printf 'RUSTFLAGS=%s\n' "$RUSTFLAGS" >rustc.mk
|
|
Loading…
Reference in New Issue
Block a user