# flags set on the command line and the environmental variables
MAKEFLAGS = @FR_MAKEFLAGS@
-HOST_CC = @HOST_CC@
-HOST_RANLIB = @HOST_RANLIB@
+BUILD_SYSTEM = @BUILD_SYSTEM@
+BUILD_CC = @BUILD_CC@
+BUILD_RANLIB = @BUILD_RANLIB@
+BUILD_EXE_EXT = @BUILD_EXE_EXT@
+BUILD_LIB_EXT = @BUILD_LIB_EXT@
TARGET_SYSTEM = @TARGET_SYSTEM@
TARGET_CC = @TARGET_CC@
TARGET_RANLIB = @TARGET_RANLIB@
+TARGET_EXE_EXT = @TARGET_EXE_EXT@
+TARGET_LIB_EXT = @TARGET_LIB_EXT@
+
+# Lazy alias seeing as it's used everywhere
+L = .$(TARGET_LIB_EXT)
+
+ifneq "${TARGET_EXE_EXT}" ""
+E = .$(TARGET_EXE_EXT)
+else
+E =
+endif
+
+ifneq (,$(findstring wasm,${TARGET_SYSTEM}))
+TARGET_IS_WASM = yes
+endif
+
INCLUDE = -I. -Isrc \
-include src/freeradius-devel/autoconf.h \
-include src/freeradius-devel/build.h \
CFLAGS = $(INCLUDE) -fno-strict-aliasing @CFLAGS@
CPPFLAGS = @CPPFLAGS@
LIBPREFIX = @LIBPREFIX@
-LIBRARY_EXT = @LIBRARY_EXT@
-EXEEXT = @EXEEXT@
LIBTOOL = JLIBTOOL
ACLOCAL = @ACLOCAL@
#
# Avoid calling shell if we don't need to build support libraries
#
-ifeq "$(wildcard build/lib/.libs/libfreeradius-make-dlopen.${LIBRARY_EXT})" ""
+ifeq "$(wildcard build/lib/.libs/libfreeradius-make-dlopen.${BUILD_LIB_EXT})" ""
BUILD_MAKE_LIBS=yes
endif
-ifeq "$(wildcard build/lib/.libs/libfreeradius-make-version.${LIBRARY_EXT})" ""
+ifeq "$(wildcard build/lib/.libs/libfreeradius-make-version.${BUILD_LIB_EXT})" ""
BUILD_MAKE_LIBS=yes
endif
endef
-$(info $(subst CC,$nCC,$(shell $(MAKE) VERBOSE=$(VERBOSE) libfreeradius-make-dlopen.a libfreeradius-make-version.a)))
+$(info $(subst CC,$nCC,$(shell $(MAKE) VERBOSE=$(VERBOSE) libfreeradius-make-dlopen.${BUILD_LIB_EXT} libfreeradius-make-version.${BUILD_LIB_EXT})))
endif
-ifeq "${HOST_LIBRARY_EXT}" ""
-ifneq "$(findstring Darwin,$(shell hostinfo 2>/dev/null))" ""
-HOST_LIBRARY_EXT := dylib
-else
-HOST_LIBRARY_EXT := so
-endif
-endif
-
-load build/lib/.libs/libfreeradius-make-dlopen.${HOST_LIBRARY_EXT}(dlopen_gmk_setup)
-load build/lib/.libs/libfreeradius-make-version.${HOST_LIBRARY_EXT}(version_gmk_setup)
+load build/lib/.libs/libfreeradius-make-dlopen.${BUILD_LIB_EXT}(dlopen_gmk_setup)
+load build/lib/.libs/libfreeradius-make-version.${BUILD_LIB_EXT}(version_gmk_setup)
else
#
GMAKE
clang_path
TARGET_RANLIB
-HOST_RANLIB
+BUILD_RANLIB
RANLIB
EGREP
GREP
CPP
TARGET_CC
-HOST_CC
+BUILD_CC
OBJEXT
EXEEXT
ac_ct_CC
LDFLAGS
CFLAGS
CC
-LIBRARY_EXT
+BUILD_EXE_EXT
+BUILD_LIB_EXT
+TARGET_EXE_EXT
+TARGET_LIB_EXT
TARGET_SYSTEM
+BUILD_SYSTEM
target_os
target_vendor
target_cpu
NONENONEs,x,x, &&
program_prefix=${target_alias}-
+BUILD_SYSTEM="$build"
+
TARGET_SYSTEM="$target"
-case "$host" in
+case "$target" in
*-darwin*)
CFLAGS="$CFLAGS -DDARWIN -mmacosx-version-min=$(sw_vers -productVersion)"
LDFLAGS="$LDFLAGS -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -mmacosx-version-min=$(sw_vers -productVersion)"
esac
case "$target" in
+ *wasm*)
+ library_ext="wasm"
+ exe_ext="js"
+ ;;
+
*-darwin*)
library_ext="dylib"
+ exe_ext=""
;;
*)
library_ext="so"
+ exe_ext=""
;;
esac
+TARGET_LIB_EXT="$library_ext"
+
+TARGET_EXE_EXT="$exe_ext"
+
+
+case "$build" in
+ *-darwin*)
+ library_ext="dylib"
+ exe_ext=""
+ ;;
-LIBRARY_EXT="$library_ext"
+ *)
+ library_ext="so"
+ exe_ext=""
+ ;;
+esac
+BUILD_LIB_EXT="$library_ext"
+BUILD_EXE_EXT="$exe_ext"
if test "x$TARGET_CC" != "x"; then
ac_compiler_gnu=$ac_cv_c_compiler_gnu
-if test "x$HOST_CC" = "x"; then
- HOST_CC="${CC}"
+if test "x$BUILD_CC" = "x"; then
+ BUILD_CC="${CC}"
fi
if test "x$TARGET_CC" = "x"; then
fi
-if test "x$HOST_RANLIB" = "x"; then
- HOST_RANLIB="${RANLIB}"
+if test "x$BUILD_RANLIB" = "x"; then
+ BUILD_RANLIB="${RANLIB}"
fi
if test "x$TARGET_RANLIB" = "x"; then
dnl #
dnl # Get system information
dnl #
-AC_CANONICAL_SYSTEM
+dnl # AC_CANONICAL_SYSTEM is obsolete, AC_CANONICAL_TARGET figures
+dnl # out build and host as well.
+dnl #
+AC_CANONICAL_TARGET
+
+AC_SUBST(BUILD_SYSTEM, "$build")
AC_SUBST(TARGET_SYSTEM, "$target")
dnl #
dnl # clang etc. on OSX no longer searches the default paths for things,
dnl # so we have to add them back in.
dnl #
-case "$host" in
+case "$target" in
*-darwin*)
CFLAGS="$CFLAGS -DDARWIN -mmacosx-version-min=$(sw_vers -productVersion)"
LDFLAGS="$LDFLAGS -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -mmacosx-version-min=$(sw_vers -productVersion)"
;;
esac
+dnl #
+dnl # Figure out executable extensions and library extensions
+dnl # for our build target.
+dnl #
case "$target" in
+ *wasm*)
+ library_ext="wasm"
+ exe_ext="js"
+ ;;
+
*-darwin*)
library_ext="dylib"
+ exe_ext=""
;;
*)
library_ext="so"
+ exe_ext=""
;;
esac
+AC_SUBST(TARGET_LIB_EXT, "$library_ext")
+AC_SUBST(TARGET_EXE_EXT, "$exe_ext")
-AC_SUBST(LIBRARY_EXT, "$library_ext")
+dnl #
+dnl # Figure out executable extensions and library extensions
+dnl # for the build system, i.e. binaries we create to help
+dnl # with the build process.
+dnl #
+case "$build" in
+ *-darwin*)
+ library_ext="dylib"
+ exe_ext=""
+ ;;
+ *)
+ library_ext="so"
+ exe_ext=""
+ ;;
+esac
+AC_SUBST(BUILD_LIB_EXT, "$library_ext")
+AC_SUBST(BUILD_EXE_EXT, "$exe_ext")
dnl #
dnl # If TARGET_CC is set, then that's the CC we use for the rest of the tests.
-dnl # We don't check HOST_CC for anything as it's only used to build our make libs
+dnl # We don't check BUILD_CC for anything as it's only used to build our make libs
dnl # and jlibtool.
dnl #
if test "x$TARGET_CC" != "x"; then
AC_PROG_CC
dnl #
-dnl # If HOST_CC (the build system compiler) isn't set it defaults to the compiler
+dnl # If BUILD_CC (the build system compiler) isn't set it defaults to the compiler
dnl # we found.
dnl #
-if test "x$HOST_CC" = "x"; then
- HOST_CC="${CC}"
+if test "x$BUILD_CC" = "x"; then
+ BUILD_CC="${CC}"
fi
dnl #
TARGET_CC="${CC}"
fi
-AC_SUBST(HOST_CC)
+AC_SUBST(BUILD_CC)
AC_SUBST(TARGET_CC)
dnl #
AC_PROG_CC_SUNPRO
AC_PROG_RANLIB
-if test "x$HOST_RANLIB" = "x"; then
- HOST_RANLIB="${RANLIB}"
+if test "x$BUILD_RANLIB" = "x"; then
+ BUILD_RANLIB="${RANLIB}"
fi
if test "x$TARGET_RANLIB" = "x"; then
TARGET_RANLIB="${RANLIB}"
fi
-AC_SUBST(HOST_RANLIB)
+AC_SUBST(BUILD_RANLIB)
AC_SUBST(TARGET_RANLIB)
dnl #
Q=
endif
-ifeq "${HOST_CC}" ""
- HOST_CC := $(shell which cc)
- ifeq "${HOST_CC}" ""
- HOST_CC := ${CC}
+ifeq "${BUILD_CC}" ""
+ BUILD_CC := $(shell which cc)
+ ifeq "${BUILD_CC}" ""
+ BUILD_CC := ${CC}
endif
endif
-TARGET := libfreeradius-make-dlopen.a
+TARGET := libfreeradius-make-dlopen.$(BUILD_LIB_EXT)
SOURCES := dlopen.c log.c
#
$(TARGET): LDFLAGS := $(filter-out -fsanitize%,$(LDFLAGS))
#
-# This gets built with the HOST_CC i.e. the one we use to bootstrap
+# This gets built with the BUILD_CC i.e. the one we use to bootstrap
# this build system.
#
SRC_CC := ${HOST_COMPILE.c}
# that building the target succeeds.
#
#ifneq "$(MAKECMDGOALS)" "$(TARGET)"
-#load ${BUILD_DIR}/lib/.libs/libfreeradius-make-dlopen.${LIBRARY_EXT}(dlopen_gmk_setup)
+#load ${BUILD_DIR}/lib/.libs/libfreeradius-make-dlopen.$(BUILD_LIB_EXT)(dlopen_gmk_setup)
#$(info $(dlopen /home/foo/libcrypto,ASN1_verify,/home/user,/foo,/usr/local/Cellar/openssl@1.1/1.1.1d/lib))
#$(info $(dlsym libcrypto,ASN1_verify))
-TARGET := libfreeradius-make-version.a
+TARGET := libfreeradius-make-version.$(BUILD_LIB_EXT)
SOURCES := version.c log.c
#
$(TARGET): LDFLAGS := $(filter-out -fsanitize%,$(LDFLAGS))
#
-# This gets built with the HOST_CC i.e. the one we use to bootstrap
+# This gets built with the BUILD_CC i.e. the one we use to bootstrap
# this build system.
#
SRC_CC := ${HOST_COMPILE.c}
# that building the target succeeds.
#
#ifneq "$(MAKECMDGOALS)" "$(TARGET)"
-#load ${BUILD_DIR}/lib/.libs/libfreeradius-make-version.${LIBRARY_EXT}(version_gmk_setup)
+#load ${BUILD_DIR}/lib/.libs/libfreeradius-make-version.$(BUILD_LIB_EXT)(version_gmk_setup)
#$(info $(dlopen /home/foo/libcrypto,ASN1_verify,/home/user,/foo,/usr/local/Cellar/openssl@1.1/1.1.1d/lib))
#$(info $(dlsym libcrypto,ASN1_verify))
char const *ranlib; //!< Archiver/indexer.
} toolset_t;
-#ifndef HOST_CC
-# define HOST_CC "clang"
+#ifndef BUILD_CC
+# define BUILD_CC "clang"
#endif
#ifndef HOST_CXX
# define HOST_LINK_CXX "g++"
#endif
-#ifndef HOST_RANLIB
+#ifndef BUILD_RANLIB
# if !defined(__EMX__) && !defined(_OSD_POSIX)
-# define HOST_RANLIB "ranlib"
+# define BUILD_RANLIB "ranlib"
# endif
#endif
#ifndef TARGET_CC
-# define TARGET_CC HOST_CC
+# define TARGET_CC BUILD_CC
#endif
#ifndef TARGET_CXX
#endif
static const toolset_t toolset_host = {
- .cc = HOST_CC,
+ .cc = BUILD_CC,
.cxx = HOST_CXX,
.link_c = HOST_LINK_C,
.link_cxx = HOST_LINK_CXX,
-#ifdef HOST_RANLIB
- .ranlib = HOST_RANLIB
+#ifdef BUILD_RANLIB
+ .ranlib = BUILD_RANLIB
#endif
};
.librarian = "emar",
.librarian_opts = "cr",
.pic_flag = "-fPIC",
- .rpath = "-rpath",
.shared_opts = "-shared",
.module_opts = "-shared",
.linker_flag_prefix = "-Wl,",
# Pass compiler and ranlib paths through to jlibtool if they're
# defined in the environment. This lets us define a separate
# compiler to build the toolchain and
- ifdef HOST_CC
- JLIBTOOL_DEFS += -DHOST_CC=\"${HOST_CC}\" -DHOST_LINK_C=\"${HOST_CC}\"
+ ifdef BUILD_CC
+ JLIBTOOL_DEFS += -DBUILD_CC=\"${BUILD_CC}\" -DHOST_LINK_C=\"${BUILD_CC}\"
endif
- ifdef HOST_RANLIB
- JLIBTOOL_DEFS += -DHOST_RANLIB=\"${HOST_RANLIB}\"
+ ifdef BUILD_RANLIB
+ JLIBTOOL_DEFS += -DBUILD_RANLIB=\"${BUILD_RANLIB}\"
endif
ifndef TARGET_CC
${JLIBTOOL}: ${top_makedir}/jlibtool.c
$(Q)mkdir -p $(dir $@)
$(Q)echo CC jlibtool.c
- $(Q)${HOST_CC} $< -o $@ ${JLIBTOOL_DEFS}
+ $(Q)${BUILD_CC} $< -o $@ ${JLIBTOOL_DEFS}
jlibtool: ${JLIBTOOL}
OBJ_EXT = lo
COMPILE.c = ${LIBTOOL} ${LIBTOOL_VERBOSE} --target=${TARGET_SYSTEM} --mode=compile ${TARGET_CC}
-HOST_COMPILE.c = ${LIBTOOL} ${LIBTOOL_VERBOSE} --mode=compile ${HOST_CC}
+HOST_COMPILE.c = ${LIBTOOL} ${LIBTOOL_VERBOSE} --mode=compile ${BUILD_CC}
LINK.c = ${LIBTOOL} ${LIBTOOL_VERBOSE} --target=${TARGET_SYSTEM} --mode=link ${TARGET_CC}
-HOST_LINK.c = ${LIBTOOL} ${LIBTOOL_VERBOSE} --mode=link ${HOST_CC}
+HOST_LINK.c = ${LIBTOOL} ${LIBTOOL_VERBOSE} --mode=link ${BUILD_CC}
COMPILE.cxx = ${LIBTOOL} ${LIBTOOL_VERBOSE} --target=${TARGET_SYSTEM} --mode=compile ${CXX}
LINK.cxx = ${LIBTOOL} ${LIBTOOL_VERBOSE} --target=${TARGET_SYSTEM} --mode=link ${CXX}
$(DIR)/: ${1}
endef
+# ADD_TARGET_RULE.so - Build a ".so" target.
+#
+# USE WITH EVAL
+#
+define ADD_TARGET_RULE.so
+ # So "make ${1}" works
+ .PHONY: ${1}
+ ${1}: $${${1}_BUILD}/${1}
+
+ # Create libtool library ${1}
+ $${${1}_BUILD}/${1}: $${${1}_OBJS} $${${1}_PRLIBS}
+ $(Q)$(strip mkdir -p $(dir $${${1}_BUILD}/${1}))
+ @$(ECHO) LINK $${${1}_BUILD}/${1}
+ $(Q)$${${1}_LINKER} -o $${${1}_BUILD}/${1} -rpath ${libdir} $${LDFLAGS} \
+ $${${1}_LDFLAGS} $${${1}_OBJS} $${LDLIBS} $${${1}_LDLIBS} \
+ $${${1}_PRLIBS}
+ $(Q)$${${1}_POSTMAKE}
+
+ ifneq "${ANALYZE.c}" ""
+ scan.${1}: $${${1}_PLISTS}
+ endif
+
+ .PHONY: $(DIR)
+ $(DIR)/: ${1}
+endef
+
+# ADD_TARGET_RULE.dll - Build a ".dll" target.
+#
+# USE WITH EVAL
+#
+define ADD_TARGET_RULE.dll
+$(ADD_TARGET_RULE.so)
+endef
+
+# ADD_TARGET_RULE.dylib - Build a ".dylib" target.
+#
+# USE WITH EVAL
+#
+define ADD_TARGET_RULE.dylib
+$(ADD_TARGET_RULE.so)
+endef
+
+# ADD_TARGET_RULE.wasm - Build a ".wasm" target.
+#
+# USE WITH EVAL
+#
+define ADD_TARGET_RULE.wasm
+ # So "make ${1}" works
+ .PHONY: ${1}
+ ${1}: $${${1}_BUILD}/${1}
+
+ # Create libtool library ${1}
+ $${${1}_BUILD}/${1}: $${${1}_OBJS} $${${1}_PRLIBS}
+ $(Q)$(strip mkdir -p $(dir $${${1}_BUILD}/${1}))
+ @$(ECHO) LINK $${${1}_BUILD}/${1}
+ $(Q)$${${1}_LINKER} -o $${${1}_BUILD}/${1} $${LDFLAGS} \
+ $${${1}_LDFLAGS} $${${1}_OBJS} $${LDLIBS} $${${1}_LDLIBS} \
+ $${${1}_PRLIBS}
+ $(Q)$${${1}_POSTMAKE}
+
+ ifneq "${ANALYZE.c}" ""
+ scan.${1}: $${${1}_PLISTS}
+ endif
+
+ .PHONY: $(DIR)
+ $(DIR)/: ${1}
+endef
+
# ADD_LOCAL_RULE.exe - Parametric "function" that adds a rule to build
# a local version of the target.
#