Improved portability in ./configure

Improved portability in ./configure to add detection for various smaller
items, such as headers necessary for openpty(3), et cetera; improve
overall script structure
This commit is contained in:
XANTRONIX Development 2020-09-03 18:46:45 -05:00 committed by XANTRONIX Industrial
parent dde4d1d62f
commit b0e9ae6e0d
3 changed files with 89 additions and 46 deletions

129
configure vendored
View file

@ -4,19 +4,22 @@ OS=`uname -s`
DEBUG=0 DEBUG=0
PREFIX=/usr/local PREFIX=/usr/local
create_generic_config_h() { config_h_append_generic_endian() {
cat <<EOF > src/config.h cat <<EOF >> "$1"
#ifndef _CONFIG_H
#define _CONFIG_H /*
* Generic compatibility
*/
#include <endian.h> #include <endian.h>
#endif /* _CONFIG_H */
EOF EOF
} }
create_darwin_config_h() { config_h_append_darwin_endian() {
cat <<EOF > src/config.h cat <<EOF >> "$1"
#ifndef _CONFIG_H
#define _CONFIG_H /*
* Darwin compatibility
*/
#include <libkern/OSByteOrder.h> #include <libkern/OSByteOrder.h>
#define htobe16(n) OSSwapHostToBigInt16(n) #define htobe16(n) OSSwapHostToBigInt16(n)
@ -33,32 +36,55 @@ create_darwin_config_h() {
#define htole64(n) OSSwapHostToLittleInt64(n) #define htole64(n) OSSwapHostToLittleInt64(n)
#define be64toh(n) OSSwapBigToHostInt64(n) #define be64toh(n) OSSwapBigToHostInt64(n)
#define le64toh(n) OSSwapLittleToHostInt64(n) #define le64toh(n) OSSwapLittleToHostInt64(n)
EOF
}
config_h_append_bsd_pty() {
cat <<EOF >> "$1"
/*
* BSD openpty(3) compatibility
*/
#include <util.h>
EOF
}
config_h_append_linux_pty() {
cat <<EOF >> "$1"
/*
* Linux openpty(3) compatibility
*/
#include <pty.h>
EOF
}
config_h_create() {
cat <<EOF > "$1"
#ifndef _CONFIG_H
#define _CONFIG_H
EOF
if [ "$OS" = "Darwin" ]; then
config_h_append_darwin_endian "$1"
else
config_h_append_generic_endian "$1"
fi
if [ "$OS" = "Linux" ]; then
config_h_append_linux_pty "$1"
else
config_h_append_bsd_pty "$1"
fi
cat <<EOF >> "$1"
#endif /* _CONFIG_H */ #endif /* _CONFIG_H */
EOF EOF
} }
create_common_build_mk() { build_mk_append_generic() {
if [ "$DEBUG" = 1 ]; then cat <<'EOF' >> "$1"
cat <<'EOF' > mk/build.mk
CGFLAGS = -g -fno-inline
EOF
else
cat <<'EOF' > mk/build.mk
CGFLAGS =
EOF
fi
cat <<'EOF' >> mk/build.mk
CWFLAGS = -Wall
COFLAGS = -O2
CFLAGS = $(CGFLAGS) $(CWFLAGS) $(COFLAGS)
EOF
}
create_generic_build_mk() {
create_common_build_mk $@
cat <<'EOF' >> mk/build.mk
LLFLAGS = -shared -Wl,-soname=$(SONAME) LLFLAGS = -shared -Wl,-soname=$(SONAME)
STATIC = lib$(LIBNAME).a STATIC = lib$(LIBNAME).a
@ -74,8 +100,8 @@ PREFIX = $PREFIX
EOF EOF
} }
create_darwin_build_mk() { build_mk_append_darwin() {
create_common_build_mk $@ build_mk_create_common $@
cat <<'EOF' >> mk/build.mk cat <<'EOF' >> mk/build.mk
LLFLAGS = -dynamiclib -current_version $(VERSION) LLFLAGS = -dynamiclib -current_version $(VERSION)
@ -93,6 +119,30 @@ PREFIX = $PREFIX
EOF EOF
} }
build_mk_create() {
if [ "$DEBUG" = 1 ]; then
cat <<'EOF' > "$1"
CGFLAGS = -g -fno-inline
EOF
else
cat <<'EOF' > "$1"
CGFLAGS =
EOF
fi
if [ "$OS" = "Darwin" ]; then
build_mk_append_darwin "$1"
else
build_mk_append_generic "$1"
fi
cat <<'EOF' >> mk/build.mk
CWFLAGS = -Wall
COFLAGS = -O2
CFLAGS = $(CGFLAGS) $(CWFLAGS) $(COFLAGS)
EOF
}
for arg in $@; do for arg in $@; do
case $arg in case $arg in
"--enable-debug") "--enable-debug")
@ -105,14 +155,5 @@ if [ ! -d "mk" ]; then
mkdir -m 0755 mk mkdir -m 0755 mk
fi fi
case $OS in config_h_create "src/config.h"
Darwin) build_mk_create "src/build.mk"
create_darwin_config_h
create_darwin_build_mk
;;
*)
create_generic_config_h
create_generic_build_mk
;;
esac

View file

@ -3,7 +3,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
#include <util.h>
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -13,6 +12,8 @@
#include <patty/ax25.h> #include <patty/ax25.h>
#include <patty/daemon.h> #include <patty/daemon.h>
#include "../src/config.h"
static void usage(int argc, char **argv, const char *message, ...) { static void usage(int argc, char **argv, const char *message, ...) {
if (message != NULL) { if (message != NULL) {
va_list args; va_list args;

View file

@ -2,7 +2,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <util.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/socket.h> #include <sys/socket.h>
@ -12,6 +11,8 @@
#include <patty/ax25.h> #include <patty/ax25.h>
#include "config.h"
struct slot { struct slot {
size_t len; size_t len;
int ack; int ack;