From: Arran Cudbard-Bell Date: Mon, 16 May 2022 14:31:23 +0000 (-0500) Subject: Use BUILD and TARGET not HOST and TARGET X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ffeea8a655735d8487a4d9a06cbe5ca943bf9e5a;p=thirdparty%2Ffreeradius-server.git Use BUILD and TARGET not HOST and TARGET --- diff --git a/Make.inc.in b/Make.inc.in index 6e85b7c17d1..08fae4f584d 100644 --- a/Make.inc.in +++ b/Make.inc.in @@ -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@ diff --git a/Makefile b/Makefile index cc2e213e5b8..8705038d843 100644 --- 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 # diff --git a/configure b/configure index fc533bd296e..e421507b846 100755 --- 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 diff --git a/configure.ac b/configure.ac index af066996d48..2716a07791a 100644 --- a/configure.ac +++ b/configure.ac @@ -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 # diff --git a/scripts/boiler.mk b/scripts/boiler.mk index fc73b0ae87f..c9a31debd4b 100644 --- a/scripts/boiler.mk +++ b/scripts/boiler.mk @@ -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 diff --git a/scripts/build/dlopen.mk b/scripts/build/dlopen.mk index 808a2cef73d..41c51b15e25 100644 --- a/scripts/build/dlopen.mk +++ b/scripts/build/dlopen.mk @@ -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)) diff --git a/scripts/build/version.mk b/scripts/build/version.mk index 916369aff99..e3e20cb7c96 100644 --- a/scripts/build/version.mk +++ b/scripts/build/version.mk @@ -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)) diff --git a/scripts/jlibtool.c b/scripts/jlibtool.c index 84a2095b736..d412fa23995 100644 --- a/scripts/jlibtool.c +++ b/scripts/jlibtool.c @@ -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,", diff --git a/scripts/libtool.mk b/scripts/libtool.mk index 5d2032670e5..60b3e9c77fe 100644 --- a/scripts/libtool.mk +++ b/scripts/libtool.mk @@ -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. #