configure: ObjC support

Assume that the default C compiler and the default ObjC compiler match
(default for OSX).

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This commit is contained in:
Luca Barbato 2015-11-23 17:08:49 -05:00
parent 0e2395293b
commit 9f57f134c1
2 changed files with 53 additions and 1 deletions

View File

@ -1,6 +1,7 @@
include config.mak include config.mak
vpath %.c $(SRC_PATH) vpath %.c $(SRC_PATH)
vpath %.m $(SRC_PATH)
vpath %.h $(SRC_PATH) vpath %.h $(SRC_PATH)
vpath %.S $(SRC_PATH) vpath %.S $(SRC_PATH)
vpath %.asm $(SRC_PATH) vpath %.asm $(SRC_PATH)
@ -26,6 +27,8 @@ IFLAGS := -I. -I$(SRC_PATH)
CPPFLAGS := $(IFLAGS) $(CPPFLAGS) CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
CFLAGS += $(ECFLAGS) CFLAGS += $(ECFLAGS)
CCFLAGS = $(CPPFLAGS) $(CFLAGS) CCFLAGS = $(CPPFLAGS) $(CFLAGS)
OBJCFLAGS += $(EOBJCFLAGS)
OBJCCFLAGS = $(CPPFLAGS) $(CFLAGS) $(OBJCFLAGS)
ASFLAGS := $(CPPFLAGS) $(ASFLAGS) ASFLAGS := $(CPPFLAGS) $(ASFLAGS)
YASMFLAGS += $(IFLAGS:%=%/) -Pconfig.asm YASMFLAGS += $(IFLAGS:%=%/) -Pconfig.asm
HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS) HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS)
@ -38,6 +41,7 @@ endef
COMPILE_C = $(call COMPILE,CC) COMPILE_C = $(call COMPILE,CC)
COMPILE_S = $(call COMPILE,AS) COMPILE_S = $(call COMPILE,AS)
COMPILE_M = $(call COMPILE,OBJCC)
COMPILE_HOSTC = $(call COMPILE,HOSTCC) COMPILE_HOSTC = $(call COMPILE,HOSTCC)
%.o: %.c %.o: %.c
@ -46,6 +50,9 @@ COMPILE_HOSTC = $(call COMPILE,HOSTCC)
%.o: %.S %.o: %.S
$(COMPILE_S) $(COMPILE_S)
%.o: %.m
$(COMPILE_M)
%_host.o: %.c %_host.o: %.c
$(COMPILE_HOSTC) $(COMPILE_HOSTC)

47
configure vendored
View File

@ -244,6 +244,7 @@ Toolchain options:
--ar=AR use archive tool AR [$ar_default] --ar=AR use archive tool AR [$ar_default]
--as=AS use assembler AS [$as_default] --as=AS use assembler AS [$as_default]
--cc=CC use C compiler CC [$cc_default] --cc=CC use C compiler CC [$cc_default]
--objcc=OCC use ObjC compiler OCC [$cc_default]
--dep-cc=DEPCC use dependency generator DEPCC [$cc_default] --dep-cc=DEPCC use dependency generator DEPCC [$cc_default]
--ld=LD use linker LD --ld=LD use linker LD
--pkg-config=PKGCONFIG use pkg-config tool PKGCONFIG [$pkg_config_default] --pkg-config=PKGCONFIG use pkg-config tool PKGCONFIG [$pkg_config_default]
@ -256,6 +257,7 @@ Toolchain options:
--host-libs=HLIBS use libs HLIBS when linking for host --host-libs=HLIBS use libs HLIBS when linking for host
--host-os=OS compiler host OS [$target_os] --host-os=OS compiler host OS [$target_os]
--extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS] --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]
--extra-objcflags=FLAGS add FLAGS to OBJCFLAGS [$CFLAGS]
--extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS] --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
--extra-ldexeflags=ELDFLAGS add ELDFLAGS to LDEXEFLAGS [$LDEXEFLAGS] --extra-ldexeflags=ELDFLAGS add ELDFLAGS to LDEXEFLAGS [$LDEXEFLAGS]
--extra-libs=ELIBS add ELIBS [$ELIBS] --extra-libs=ELIBS add ELIBS [$ELIBS]
@ -695,6 +697,10 @@ add_asflags(){
append ASFLAGS $($asflags_filter "$@") append ASFLAGS $($asflags_filter "$@")
} }
add_objcflags(){
append OBJCFLAGS $($objcflags_filter "$@")
}
add_ldflags(){ add_ldflags(){
append LDFLAGS $($ldflags_filter "$@") append LDFLAGS $($ldflags_filter "$@")
} }
@ -749,6 +755,13 @@ check_cc(){
check_cmd $cc $CPPFLAGS $CFLAGS "$@" $CC_C $(cc_o $TMPO) $TMPC check_cmd $cc $CPPFLAGS $CFLAGS "$@" $CC_C $(cc_o $TMPO) $TMPC
} }
check_objcc(){
log check_objcc "$@"
cat > $TMPC
log_file $TMPC
check_cmd $objcc $CPPFLAGS $CFLAGS $OBJCFLAGS "$@" $OBJCC_C $(cc_o $TMPO) $TMPC
}
check_cpp(){ check_cpp(){
log check_cpp "$@" log check_cpp "$@"
cat > $TMPC cat > $TMPC
@ -847,6 +860,19 @@ check_cflags(){
test_cflags "$@" && add_cflags "$@" test_cflags "$@" && add_cflags "$@"
} }
test_objcflags(){
log test_cflags "$@"
set -- $($cflags_filter "$@")
check_objcc "$@" <<EOF
int x;
EOF
}
check_objcflags(){
log check_cflags "$@"
test_objcflags "$@" && add_objcflags "$@"
}
test_ldflags(){ test_ldflags(){
log test_ldflags "$@" log test_ldflags "$@"
check_ld "$@" <<EOF check_ld "$@" <<EOF
@ -1710,6 +1736,7 @@ CMDLINE_SET="
as as
build_suffix build_suffix
cc cc
objcc
cpu cpu
cross_prefix cross_prefix
custom_allocator custom_allocator
@ -1742,6 +1769,7 @@ CMDLINE_SET="
CMDLINE_APPEND=" CMDLINE_APPEND="
extra_cflags extra_cflags
extra_objcflags
host_cppflags host_cppflags
" "
@ -2417,6 +2445,9 @@ AS_O='-o $@'
CC_C='-c' CC_C='-c'
CC_E='-E -o $@' CC_E='-E -o $@'
CC_O='-o $@' CC_O='-o $@'
OBJCC_C='-c'
OBJCC_E='-E -o $@'
OBJCC_O='-o $@'
LD_O='-o $@' LD_O='-o $@'
LD_LIB='-l%' LD_LIB='-l%'
LD_PATH='-L' LD_PATH='-L'
@ -2733,6 +2764,7 @@ fi
ar_default="${cross_prefix}${ar_default}" ar_default="${cross_prefix}${ar_default}"
cc_default="${cross_prefix}${cc_default}" cc_default="${cross_prefix}${cc_default}"
occ_default="${cross_prefix}${occ_default}"
nm_default="${cross_prefix}${nm_default}" nm_default="${cross_prefix}${nm_default}"
pkg_config_default="${cross_prefix}${pkg_config_default}" pkg_config_default="${cross_prefix}${pkg_config_default}"
ranlib="${cross_prefix}${ranlib}" ranlib="${cross_prefix}${ranlib}"
@ -3179,16 +3211,22 @@ test -n "$cc_type" && enable $cc_type ||
warn "Unknown C compiler $cc, unable to select optimal CFLAGS" warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
: ${as_default:=$cc} : ${as_default:=$cc}
: ${objcc_default:=$cc}
: ${dep_cc_default:=$cc} : ${dep_cc_default:=$cc}
: ${ld_default:=$cc} : ${ld_default:=$cc}
: ${host_ld_default:=$host_cc} : ${host_ld_default:=$host_cc}
set_default ar as dep_cc ld host_ld set_default ar as objcc dep_cc ld host_ld
probe_cc as "$as" probe_cc as "$as"
asflags_filter=$_flags_filter asflags_filter=$_flags_filter
add_asflags $_flags $_cflags add_asflags $_flags $_cflags
set_ccvars AS set_ccvars AS
probe_cc objcc "$objcc"
objcflags_filter=$_flags_filter
add_objcflags $_flags $_cflags
set_ccvars OBJC
probe_cc ld "$ld" probe_cc ld "$ld"
ldflags_filter=$_flags_filter ldflags_filter=$_flags_filter
add_ldflags $_flags $_ldflags add_ldflags $_flags $_ldflags
@ -3224,6 +3262,7 @@ else
fi fi
add_cflags $extra_cflags add_cflags $extra_cflags
add_objcflags $extra_objcflags
add_asflags $extra_cflags add_asflags $extra_cflags
if test -n "$sysroot"; then if test -n "$sysroot"; then
@ -4975,7 +5014,9 @@ CC_IDENT=$cc_ident
ARCH=$arch ARCH=$arch
INTRINSICS=$intrinsics INTRINSICS=$intrinsics
CC=$cc CC=$cc
OBJCC=$cc
AS=$as AS=$as
OBJCC=$objcc
LD=$ld LD=$ld
DEPCC=$dep_cc DEPCC=$dep_cc
DEPCCFLAGS=$DEPCCFLAGS \$(CPPFLAGS) DEPCCFLAGS=$DEPCCFLAGS \$(CPPFLAGS)
@ -4991,9 +5032,13 @@ STRIP=$strip
LN_S=$ln_s LN_S=$ln_s
CPPFLAGS=$CPPFLAGS CPPFLAGS=$CPPFLAGS
CFLAGS=$CFLAGS CFLAGS=$CFLAGS
OBJCFLAGS=$OBJCFLAGS
ASFLAGS=$ASFLAGS ASFLAGS=$ASFLAGS
AS_C=$AS_C AS_C=$AS_C
AS_O=$AS_O AS_O=$AS_O
OBJCC_C=$OBJCC_C
OBJCC_E=$OBJCC_E
OBJCC_O=$OBJCC_O
CC_C=$CC_C CC_C=$CC_C
CC_E=$CC_E CC_E=$CC_E
CC_O=$CC_O CC_O=$CC_O