include defs.mk

all:: $(ALL_TARGETS)

# e.g. make -f freeswitch.mk $(pwd)/unpacked/freeswitch-1.6.10/configure
.PHONY : $(PPC_ARCH)
$(PPC_ARCH):

.PHONY : $(ARM_ARCH)
$(ARM_ARCH):

.PHONY : $(A8_ARCH)
$(A8_ARCH):
	
.PHONY : $(NATIVE)
$(NATIVE):
	
.PHONY : $(X86_64_ARCH)
$(X86_64_ARCH): $(X86_64_ARCH)/freeswitch

.PHONY : $(X86_64_ARCH)/freeswitch
$(X86_64_ARCH)/freeswitch: $(freeswitch_loc)/configure
	cd $(TOP)
	mkdir -p $@
	cd $@ && \
	export PKG_CONFIG_PATH=$(X86_64_INSTALL)/usr/lib/pkgconfig && \
	export ac_cv_func_malloc_0_nonnull=yes && \
	export ac_cv_func_realloc_0_nonnull=yes && \
	export ac_cv_file__dev_urandom=yes && \
	export ac_cv_exeext=no && \
	export ac_cv_gcc_supports_w_no_unused_result=no && \
	export ac_cv_lib_z_inflateReset=yes && \
	export ac_cv_lib_jpeg_jpeg_std_error=yes && \
	export ac_cv_lib_ssl_SSL_CTX_set_tlsext_use_srtp=yes && \
	export ac_cv_file__dev_ptmx=yes && \
	export ac_cv_file__dev_zero=yes && \
	export apr_cv_mutex_recursive=yes && \
	export ac_cv_func_setpgrp_void=yes && \
	export apr_cv_tcp_nodelay_with_cork=yes && \
	export ac_cv_sizeof_struct_iovec=8 && \
	export ax_cv_func_aligned_alloc=no && \
	export ac_cv_file_dbd_apr_dbd_mysql_c=no && \
	export ac_cv_header_stdatomic_h=no && \
        CPPFLAGS="-I$($X86_64_INSTALL)/usr/include" \
	CFLAGS="-Wno-error=strict-aliasing \
                    -Wno-error=unused-value"\
        LDFLAGS="-L$($X86_64_INSTALL)/usr/lib" \
	$(freeswitch_loc)/configure \
	    --build=`uname -m` \
	    --host=$(X86_64_ARCH) \
	    --exec-prefix=/usr \
	    --prefix=/var/lib/freeswitch \
	    --libexecdir=/usr/lib \
	    --libdir=/usr/lib \
	    --sysconfdir=/etc \
	    --datarootdir=/usr/share \
	    --includedir=/usr/include/freeswitch \
	    --with-modinstdir=/usr/lib/freeswitch/mod \
	    --localstatedir=/var \
	    --with-rundir=/var/run \
            --disable-silent-rules \
	    --disable-core-libedit-support \
	    --disable-debug \
	    --disable-core-odbc-support \
            --disable-core-pgsql-pkgconfig \
	    --disable-system-xmlrpc-c \
            --disable-libyuv \
            --disable-libvpx \
	    --without-erlang \
	    --without-python \
	    --with-ldap=yes \
            --with-ldap-lib=$(X86_64_INSTALL)/usr/lib \
	    --with-sysroot=$(X86_64_INSTALL) \
            --with-random=/dev/urandom \
            --with-ptmx=/dev/ptmx \
            CFLAGS="-fPIC -Wno-error=strict-aliasing"
	$(MAKE) -C $@ $(X86_64_BUILD)/freeswitch/modules.conf
	$(MAKE) -j $(SIMUL) -C $@ DESTDIR=$(X86_64_INSTALL) \
	  CPPFLAGS="-I$(freeswitch_loc)/src/include -D_GNU_SOURCE -DHAVE_UINT64_T" \
	  install
	rm -rf $(X86_64_INSTALL)/etc/freeswitch/*
