]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Use BUILD and TARGET not HOST and TARGET
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 16 May 2022 14:31:23 +0000 (09:31 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 26 May 2022 15:00:19 +0000 (11:00 -0400)
Make.inc.in
Makefile
configure
configure.ac
scripts/boiler.mk
scripts/build/dlopen.mk
scripts/build/version.mk
scripts/jlibtool.c
scripts/libtool.mk

index 6e85b7c17d179f6180eead34967cedfd8cb0a7ea..08fae4f584df1e854b4dcd419502a47c83a242e3 100644 (file)
@@ -46,12 +46,31 @@ MAKE                = @MAKE@
 # 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 \
@@ -60,8 +79,6 @@ INCLUDE               = -I. -Isrc \
 CFLAGS         = $(INCLUDE) -fno-strict-aliasing @CFLAGS@
 CPPFLAGS       = @CPPFLAGS@
 LIBPREFIX      = @LIBPREFIX@
-LIBRARY_EXT    = @LIBRARY_EXT@
-EXEEXT         = @EXEEXT@
 
 LIBTOOL                = JLIBTOOL
 ACLOCAL                = @ACLOCAL@
index cc2e213e5b8a0ef7e6de5d2002b932e13a464956..8705038d8438f628591f9436a337351498999c74 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -119,10 +119,10 @@ ifeq "$(findstring libfreeradius-make,$(MAKECMDGOALS))" ""
 #
 #  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
 
@@ -131,19 +131,11 @@ define n
 
 
 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
 #
index fc533bd296ec944650b040b26ab958be5f6285a2..e421507b846a856be5b2c9a39cb277997a34ac64 100755 (executable)
--- a/configure
+++ b/configure
@@ -694,13 +694,13 @@ MAKE
 GMAKE
 clang_path
 TARGET_RANLIB
-HOST_RANLIB
+BUILD_RANLIB
 RANLIB
 EGREP
 GREP
 CPP
 TARGET_CC
-HOST_CC
+BUILD_CC
 OBJEXT
 EXEEXT
 ac_ct_CC
@@ -708,8 +708,12 @@ CPPFLAGS
 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
@@ -3557,10 +3561,12 @@ test -n "$target_alias" &&
     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)"
@@ -3569,17 +3575,40 @@ case "$host" in
 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
@@ -4582,8 +4611,8 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
 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
@@ -5213,8 +5242,8 @@ else
 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
index af066996d48630931adc3819e03a1d2babf30f5c..2716a07791a25c9e06df1e1b3f483d8ad00c600c 100644 (file)
@@ -216,14 +216,19 @@ dnl #############################################################
 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)"
@@ -231,22 +236,51 @@ case "$host" in
     ;;
 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
@@ -256,11 +290,11 @@ fi
 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 #
@@ -271,7 +305,7 @@ if test "x$TARGET_CC" = "x"; then
   TARGET_CC="${CC}"
 fi
 
-AC_SUBST(HOST_CC)
+AC_SUBST(BUILD_CC)
 AC_SUBST(TARGET_CC)
 
 dnl #
@@ -284,15 +318,15 @@ AC_PROG_GCC_TRADITIONAL
 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 #
index fc73b0ae87fb6e9038579ec78723559cb3817e36..c9a31debd4ba6c4c3729b2cf77b1bab28e002251 100644 (file)
@@ -38,10 +38,10 @@ else
     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
 
index 808a2cef73d6a8a37544e0f47d0a2f5c69a61ace..41c51b15e25891204b234b4f3430961a3ab1756f 100644 (file)
@@ -1,4 +1,4 @@
-TARGET                         := libfreeradius-make-dlopen.a
+TARGET                         := libfreeradius-make-dlopen.$(BUILD_LIB_EXT)
 SOURCES                                := dlopen.c log.c
 
 #
@@ -9,7 +9,7 @@ $(TARGET): CPPFLAGS             := $(filter-out -W%,$(CPPFLAGS))
 $(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}
@@ -20,7 +20,7 @@ TGT_LINKER := ${HOST_LINK.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))
index 916369aff994e669b9fa27aadb0b270f07bc7ee4..e3e20cb7c96f13844dc9b62f447f1affa37c81c6 100644 (file)
@@ -1,4 +1,4 @@
-TARGET                         := libfreeradius-make-version.a
+TARGET                         := libfreeradius-make-version.$(BUILD_LIB_EXT)
 SOURCES                                := version.c log.c
 
 #
@@ -9,7 +9,7 @@ $(TARGET): CPPFLAGS             := $(filter-out -W%,$(CPPFLAGS))
 $(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}
@@ -20,7 +20,7 @@ TGT_LINKER := ${HOST_LINK.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))
index 84a2095b7365085cb2c614ea4dc4106efecbfc3d..d412fa23995c7d0243eabfda96fe4a31527319ba 100644 (file)
@@ -45,8 +45,8 @@ typedef struct {
        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
@@ -61,14 +61,14 @@ typedef struct {
 #  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
@@ -88,12 +88,12 @@ typedef struct {
 #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
 };
 
@@ -336,7 +336,6 @@ static const target_t target_emscripten = {
        .librarian                      = "emar",
        .librarian_opts                 = "cr",
        .pic_flag                       = "-fPIC",
-       .rpath                          = "-rpath",
        .shared_opts                    = "-shared",
        .module_opts                    = "-shared",
        .linker_flag_prefix             = "-Wl,",
index 5d2032670e50bb11c377a738e1a746bbf8aef89f..60b3e9c77fe32fc1ca404e3527909dbe586fa9e4 100644 (file)
@@ -38,12 +38,12 @@ ifeq "${LIBTOOL}" "JLIBTOOL"
     # 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
@@ -75,7 +75,7 @@ ifeq "${LIBTOOL}" "JLIBTOOL"
     ${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}
 
@@ -106,10 +106,10 @@ LIBTOOL_VERBOSE=$(if ${VERBOSE},--debug,--silent)
 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}
@@ -150,6 +150,74 @@ define ADD_TARGET_RULE.la
     $(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.
 #