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:
parent
dde4d1d62f
commit
b0e9ae6e0d
3 changed files with 89 additions and 46 deletions
129
configure
vendored
129
configure
vendored
|
@ -4,19 +4,22 @@ OS=`uname -s`
|
|||
DEBUG=0
|
||||
PREFIX=/usr/local
|
||||
|
||||
create_generic_config_h() {
|
||||
cat <<EOF > src/config.h
|
||||
#ifndef _CONFIG_H
|
||||
#define _CONFIG_H
|
||||
config_h_append_generic_endian() {
|
||||
cat <<EOF >> "$1"
|
||||
|
||||
/*
|
||||
* Generic compatibility
|
||||
*/
|
||||
#include <endian.h>
|
||||
#endif /* _CONFIG_H */
|
||||
EOF
|
||||
}
|
||||
|
||||
create_darwin_config_h() {
|
||||
cat <<EOF > src/config.h
|
||||
#ifndef _CONFIG_H
|
||||
#define _CONFIG_H
|
||||
config_h_append_darwin_endian() {
|
||||
cat <<EOF >> "$1"
|
||||
|
||||
/*
|
||||
* Darwin compatibility
|
||||
*/
|
||||
#include <libkern/OSByteOrder.h>
|
||||
|
||||
#define htobe16(n) OSSwapHostToBigInt16(n)
|
||||
|
@ -33,32 +36,55 @@ create_darwin_config_h() {
|
|||
#define htole64(n) OSSwapHostToLittleInt64(n)
|
||||
#define be64toh(n) OSSwapBigToHostInt64(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 */
|
||||
EOF
|
||||
}
|
||||
|
||||
create_common_build_mk() {
|
||||
if [ "$DEBUG" = 1 ]; then
|
||||
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
|
||||
build_mk_append_generic() {
|
||||
cat <<'EOF' >> "$1"
|
||||
LLFLAGS = -shared -Wl,-soname=$(SONAME)
|
||||
|
||||
STATIC = lib$(LIBNAME).a
|
||||
|
@ -74,8 +100,8 @@ PREFIX = $PREFIX
|
|||
EOF
|
||||
}
|
||||
|
||||
create_darwin_build_mk() {
|
||||
create_common_build_mk $@
|
||||
build_mk_append_darwin() {
|
||||
build_mk_create_common $@
|
||||
|
||||
cat <<'EOF' >> mk/build.mk
|
||||
LLFLAGS = -dynamiclib -current_version $(VERSION)
|
||||
|
@ -93,6 +119,30 @@ PREFIX = $PREFIX
|
|||
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
|
||||
case $arg in
|
||||
"--enable-debug")
|
||||
|
@ -105,14 +155,5 @@ if [ ! -d "mk" ]; then
|
|||
mkdir -m 0755 mk
|
||||
fi
|
||||
|
||||
case $OS in
|
||||
Darwin)
|
||||
create_darwin_config_h
|
||||
create_darwin_build_mk
|
||||
;;
|
||||
|
||||
*)
|
||||
create_generic_config_h
|
||||
create_generic_build_mk
|
||||
;;
|
||||
esac
|
||||
config_h_create "src/config.h"
|
||||
build_mk_create "src/build.mk"
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <util.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -13,6 +12,8 @@
|
|||
#include <patty/ax25.h>
|
||||
#include <patty/daemon.h>
|
||||
|
||||
#include "../src/config.h"
|
||||
|
||||
static void usage(int argc, char **argv, const char *message, ...) {
|
||||
if (message != NULL) {
|
||||
va_list args;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <util.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/socket.h>
|
||||
|
@ -12,6 +11,8 @@
|
|||
|
||||
#include <patty/ax25.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
struct slot {
|
||||
size_t len;
|
||||
int ack;
|
||||
|
|
Loading…
Add table
Reference in a new issue