Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ae241e2
get rid of stupid macos debug files
Un1q32 Oct 23, 2025
dd5304b
cross compiling
Un1q32 Oct 23, 2025
bffbe9f
support --host option
Un1q32 Oct 23, 2025
a3d33fc
make getcwd(NULL,0) check default to false, and provide variable to c…
Un1q32 Oct 23, 2025
491d9f4
add freebsd signum
Un1q32 Oct 23, 2025
3cd3ceb
add openbsd signum
Un1q32 Oct 23, 2025
87f8507
add --build stub option for autoconf compatability
Un1q32 Oct 26, 2025
fcbff8b
determine target OS from --host
silvanshade Oct 31, 2025
86121d3
make $cross_compiling true/false
Un1q32 Nov 1, 2025
1623f99
change back some stuff with the getcwd check
Un1q32 Nov 1, 2025
b679f44
nit
Un1q32 Nov 1, 2025
264c42e
fix
Un1q32 Nov 8, 2025
4c9356b
update env vars in --help
Un1q32 Nov 8, 2025
363a663
update line
Un1q32 Nov 8, 2025
0acadd6
Merge remote-tracking branch 'other/target-os-from-host' into trunk
Un1q32 Nov 8, 2025
33894ca
style nits
Un1q32 Nov 8, 2025
6c28a8c
Update configure
Un1q32 Nov 9, 2025
aa5dad9
Update configure
Un1q32 Nov 9, 2025
a84326d
Update configure
Un1q32 Nov 9, 2025
5fcbb89
fix case where $OS was defined when cross compiling, signum wouldn't …
Un1q32 Nov 9, 2025
14593e0
Merge remote-tracking branch 'upstream/trunk' into trunk
Un1q32 Nov 9, 2025
671b7c0
improve error messages
Un1q32 Nov 12, 2025
768b695
better wording
Un1q32 Nov 12, 2025
7da82a6
make linux signums arch dependent
Un1q32 Nov 13, 2025
46e35ab
remove changes to signum stuff
Un1q32 Nov 15, 2025
5270f7a
i dont think the test is needed
Un1q32 Nov 15, 2025
cd9ee40
Generic cross-signum.h
magicant Nov 15, 2025
3f18f1e
redirect stderr
Un1q32 Nov 15, 2025
92bef35
fix cross compiling detection
Un1q32 Nov 15, 2025
3eeaa86
Merge remote-tracking branch 'upstream/trunk' into trunk
Un1q32 Nov 15, 2025
3a9d1e5
update
Un1q32 Nov 15, 2025
febca70
update list
Un1q32 Nov 17, 2025
6f76387
a better approach to os detection
Un1q32 Nov 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.d
*.o
*.dSYM
Makefile
TAGS
tags
Expand Down
4 changes: 2 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ INSTALL_DIR = @INSTALL_DIR@
ARCHIVER = @ARCHIVER@
DIRS = @DIRS@
SOURCES = alias.c arith.c builtin.c exec.c expand.c hashtable.c history.c input.c job.c mail.c makesignum.c option.c parser.c path.c plist.c redir.c sig.c strbuf.c util.c variable.c xfnmatch.c xgetopt.c yash.c
HEADERS = alias.h arith.h builtin.h common.h exec.h expand.h hashtable.h history.h input.h job.h mail.h option.h parser.h path.h plist.h redir.h refcount.h sig.h siglist.h strbuf.h util.h variable.h xfnmatch.h xgetopt.h yash.h
HEADERS = alias.h arith.h builtin.h common.h cross-signum.h exec.h expand.h hashtable.h history.h input.h job.h mail.h option.h parser.h path.h plist.h redir.h refcount.h sig.h siglist.h strbuf.h util.h variable.h xfnmatch.h xgetopt.h yash.h
MAIN_OBJS = alias.o arith.o builtin.o exec.o expand.o hashtable.o input.o job.o mail.o option.o parser.o path.o plist.o redir.o sig.o strbuf.o util.o variable.o xfnmatch.o xgetopt.o yash.o
HISTORY_OBJS = history.o
BUILTINS_ARCHIVE = builtins/builtins.a
Expand Down Expand Up @@ -80,7 +80,7 @@ makesignum:
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $@.c $(LDLIBS)
sig.o: signum.h
signum.h: makesignum
./makesignum > $@
./makesignum > $@ 2> /dev/null || cp cross-signum.h $@
variable.o yash.o: configm.h
configm.h: Makefile
-@printf 'creating %s...' '$@'
Expand Down
195 changes: 129 additions & 66 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ do
nocreate="true" ;;
-d|--debug)
debug="true" ;;
--host=*)
host="${i#--host=}" ;;
--build=*) # included for autoconf compatibility, does nothing
;;
--prefix=*)
prefix="${i#--prefix=}" ;;
--exec-prefix=*)
Expand Down Expand Up @@ -151,7 +155,7 @@ do
term_lib="${i#--with-term-lib=}" ;;
?*=*)
# parse variable assignment
if echo "$i" | grep -E "^[[:alpha:]][[:alnum:]]*=" >/dev/null
if printf '%s\n' "$i" | grep -Eq "^[[:alpha:]][[:alnum:]_]*="
then
export "$i"
else
Expand All @@ -173,6 +177,7 @@ Usage: sh $0 [options...]
Available options:
--no-create do not create output files
--debug configure for debug build (GCC or Clang required)
--host=HOST sets the prefix for build tools to HOST

Installation options:
--prefix=PREFIX install architecture-independent files in PREFIX
Expand Down Expand Up @@ -214,7 +219,8 @@ Influential environment variables:
MSGMERGEFLAGS, MSGINIT, MSGCONV, MSGFILTER,
ASCIIDOC, ASCIIDOCFLAGS, ASCIIDOCATTRS, A2X, A2XFLAGS,
INSTALL, INSTALL_PROGRAM, INSTALL_DATA, INSTALL_DIR,
CTAGS, CTAGSARGS, ETAGS, ETAGSARGS, CSCOPE, CSCOPEARGS
CTAGS, CTAGSARGS, ETAGS, ETAGSARGS, CSCOPE, CSCOPEARGS,
YASH_GETCWD_AUTO_MALLOC
END
exit
fi
Expand Down Expand Up @@ -291,7 +297,12 @@ trylink () {
-o "${tempout}" "${tempo}" "$@" ${LDLIBS-${ldlibs}}
}
tryexec () {
checkby "${tempout}"
if ${cross_compiling}; then
checkresult="yes"
return 0
else
checkby "${tempout}"
fi
}
checked () {
if [ $# -ge 1 ]
Expand All @@ -311,13 +322,13 @@ fail () {
exit 1
}


cc="${CC-c99}"
[ -n "$host" ] && _host="$host-"
cc="${CC-${_host}c99}"
ar="${AR-${_host}ar}"
cflags="${CFLAGS--O1 -g}"
cppflags="${CPPFLAGS-${null}}"
ldflags="${LDFLAGS-${null}}"
ldlibs="${LDLIBS-${null}}"
ar="${AR-ar}"
arflags="${ARFLAGS--rc}"
xgettext="${XGETTEXT-xgettext}"
xgettextflags="${XGETTEXTFLAGS--kgt -kNgt -kngt:1,2 \
Expand All @@ -344,10 +355,87 @@ cscope="${CSCOPE-cscope}"

confighdefs=''

# define options for debugging
if ${debug}
then
cflags="${CFLAGS--pedantic -MMD -Wall -Wextra -Og -fno-inline -ggdb}"
else
defconfigh "NDEBUG"
fi


# check if the compiler works
checking 'whether the compiler works'
cat >"${tempsrc}" <<END
int main(void) { return 0; }
END
if
trymake
then
checked "yes"
elif
[ x"${cc}" = x"${_host}c99" ] && [ x"${CC+set}" != x"set" ] && (
cc="${_host}gcc"
trymake
)
then
cc="${_host}gcc"
checked "yes (using $cc)"
elif
[ x"${cc}" = x"${_host}c99" ] && [ x"${CC+set}" != x"set" ] && (
cc="${_host}clang"
trymake
)
then
cc="${_host}clang"
checked "yes (using $cc)"
else
checked "no"
printf 'Compiler "%s" not found or not working.\n' "${CC-${cc}}" >&2
printf 'The compiler is expected to accept these options: %s\n' \
"${CFLAGS-${cflags}} ${CADDS-${null}}" >&2
fail
fi

# check if we are cross compiling
checking 'whether we are cross compiling'
cross_compiling=false
if
tryexec
then
checked "no"
else
checked "yes"
cross_compiling=true
fi

# check OS type
checking 'operating system'
ostype=$(uname -s | tr "[:upper:]" "[:lower:]")
if $cross_compiling; then
# this is a list of every os that affects the build, if you add a check like
# 'if [ "$ostype" = "foo" ]' to the configure script than 'foo' would need
# to be added to this list so it can be detected, otherwise we just set
# $ostype to 'unknown' and hope for the best.
for os in darwin freebsd sunos solaris
do
case "$host" in
*"$os"*)
ostype="$os"
break
esac
done
# sometimes there are common os names used for targets that differ from what
# 'uname -s' outputs, those are caught here and corrected.
case $ostype in
solaris)
ostype='sunos'
;;
esac
[ -z "$ostype" ] && ostype='unknown'
else
ostype=$(uname -s | tr "[:upper:]" "[:lower:]")
fi

checked "${ostype}"
case "${ostype}" in
darwin)
Expand All @@ -358,26 +446,35 @@ case "${ostype}" in
;;
esac


# check POSIX conformance
checking 'POSIX conformance'
posixver=$(getconf _POSIX_VERSION 2>/dev/null)
if [ -n "${posixver}" ] && [ x"${posixver}" != x"undefined" ]
then
checked "${posixver}"
if ${cross_compiling}; then
checked "guessing 200112"
posixver="200112"
else
checked "no"
posixver=""
posixver=$(getconf _POSIX_VERSION 2>/dev/null)
if [ -n "${posixver}" ] && [ x"${posixver}" != x"undefined" ]
then
checked "${posixver}"
else
checked "no"
posixver=""
fi
fi

checking 'SUS conformance'
xopenver=$(getconf _XOPEN_VERSION 2>/dev/null)
if [ -n "${xopenver}" ] && [ x"${xopenver}" != x"undefined" ]
then
checked "${xopenver}"
if ${cross_compiling}; then
checked "guessing 600"
xopenver="600"
else
checked "no"
xopenver=""
xopenver=$(getconf _XOPEN_VERSION 2>/dev/null)
if [ -n "${xopenver}" ] && [ x"${xopenver}" != x"undefined" ]
then
checked "${xopenver}"
else
checked "no"
xopenver=""
fi
fi

case "${ostype}" in
Expand All @@ -394,49 +491,6 @@ case "${ostype}" in
;;
esac


# define options for debugging
if ${debug}
then
cflags="${CFLAGS--pedantic -MMD -Wall -Wextra -Og -fno-inline -ggdb}"
else
defconfigh "NDEBUG"
fi


# check if the compiler works
checking 'whether the compiler works'
cat >"${tempsrc}" <<END
int main(void) { return 0; }
END
if
trymake && tryexec
then
checked "yes"
elif
[ x"${cc}" = x"c99" ] && [ x"${CC+set}" != x"set" ] && (
cc='gcc'
trymake && tryexec
)
then
checked "yes (using gcc)"
cc='gcc'
elif
[ x"${cc}" = x"c99" ] && [ x"${CC+set}" != x"set" ] && (
cc='clang'
trymake && tryexec
)
then
checked "yes (using clang)"
cc='clang'
else
checked "no"
printf 'Compiler "%s" not found or not working.\n' "${CC-${cc}}" >&2
printf 'The compiler is expected to accept these options: %s\n' \
"${CFLAGS-${cflags}} ${CADDS-${null}}" >&2
fail
fi

# check if the compiler accepts the -O2 option if we are not debugging
if ! ${debug} && [ x"${CFLAGS+set}" != x"set" ]
then
Expand Down Expand Up @@ -1417,7 +1471,8 @@ fi

# check if getcwd accepts (NULL,0) as argument
checking "if getcwd(NULL,0) returns malloc'ed string"
cat >"${tempsrc}" <<END
if [ -z "$YASH_GETCWD_AUTO_MALLOC" ]; then
cat >"${tempsrc}" <<END
${confighdefs}
#include <errno.h>
#include <stdlib.h>
Expand Down Expand Up @@ -1450,8 +1505,16 @@ int main(void) {
free(wd11); free(wd2); return 0;
}
END
trymake && tryexec
checked
if ${cross_compiling}; then
checked "assuming no"
checkresult="no"
else
trymake && tryexec
checked
fi
else
checked "$YASH_GETCWD_AUTO_MALLOC"
fi
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "GETCWD_AUTO_MALLOC"
Expand Down
Loading
Loading