aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-11-01 21:53:30 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-11-01 21:53:30 +0000
commit4d4023555b8c4e5812d2ac67242fe7754acc6def (patch)
tree17036a33b500972a312f1a5b2c75bee313f4b4d1
parenta68250b79bf5358b7cf67bbd9185409a17993abc (diff)
issue #4678
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6936 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-xChangeLog2
-rwxr-xr-xMakefile21
-rwxr-xr-xacl.c1
-rwxr-xr-xapps/Makefile20
-rwxr-xr-xast_expr2.c2
-rwxr-xr-xast_expr2.fl2
-rwxr-xr-xast_expr2.y2
-rwxr-xr-xast_expr2f.c2
-rwxr-xr-xasterisk.c4
-rwxr-xr-xcdr/Makefile15
-rwxr-xr-xchannels/Makefile32
-rwxr-xr-xcodecs/Makefile19
-rwxr-xr-xcodecs/gsm/Makefile7
-rwxr-xr-xconfig.c6
-rwxr-xr-xcygwin/Makefile6
-rwxr-xr-xcygwin/cygloader.c33
-rwxr-xr-xdb.c4
-rwxr-xr-xformats/Makefile12
-rwxr-xr-xfuncs/Makefile9
-rwxr-xr-xinclude/asterisk/compat.h8
-rwxr-xr-xinclude/asterisk/lock.h4
-rwxr-xr-xpbx/Makefile10
-rwxr-xr-xres/Makefile30
-rwxr-xr-xstdtime/private.h2
-rwxr-xr-xutils.c7
-rwxr-xr-xutils/streamplayer.c2
26 files changed, 207 insertions, 55 deletions
diff --git a/ChangeLog b/ChangeLog
index 6206f02b0..3e90921ef 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2005-11-01 Kevin P. Fleming <kpfleming@digium.com>
+ * many files: more Cygwin build system support (issue #4678)
+
* apps/app_parkandannounce.c (parkandannounce_exec): supply parent channel to ast_request_and_dial so channel variables can be inherited (issue #5564)
* include/asterisk/channel.h: add parent_channel field
* channel.c (__ast_request_and_dial): use parent_channel field to inherit variables into new channel
diff --git a/Makefile b/Makefile
index 4170b0828..49511b558 100755
--- a/Makefile
+++ b/Makefile
@@ -216,6 +216,7 @@ endif
INCLUDE+=-Iinclude -I../include
ASTCFLAGS+=-pipe -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE #-DMAKE_VALGRIND_HAPPY
ASTCFLAGS+=$(OPTIMIZE)
+ASTOBJ=-o asterisk
ifeq ($(findstring BSD,${OSARCH}),BSD)
PROC=$(shell uname -m)
@@ -263,6 +264,15 @@ ifeq (${OSARCH},SunOS)
INCLUDE+=-Iinclude/solaris-compat -I$(CROSS_COMPILE_TARGET)/usr/local/ssl/include
endif
+ifeq ($(findstring CYGWIN,${OSARCH}),CYGWIN)
+CYGLOADER=cygwin_a
+OSARCH=CYGWIN
+ASTOBJ=-shared -o asterisk.dll -Wl,--out-implib=libasterisk.dll.a -Wl,--export-all-symbols
+ASTLINK=
+LIBS+=-lpthread -lncurses -lm -lresolv
+ASTSBINDIR=${MODULES_DIR}
+endif
+
ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/pkg/include/zaptel.h),)
ASTCFLAGS+=-DZAPTEL_OPTIMIZATIONS
endif
@@ -471,8 +481,11 @@ stdtime/libtime.a: FORCE
exit 1; \
fi
-asterisk: editline/libedit.a db1-ast/libdb1.a stdtime/libtime.a $(OBJS)
- $(CC) $(DEBUG) -o asterisk $(ASTLINK) $(OBJS) $(LIBEDIT) db1-ast/libdb1.a stdtime/libtime.a $(LIBS)
+cygwin_a:
+ $(MAKE) -C cygwin all
+
+asterisk: ${CYGLOADER} editline/libedit.a db1-ast/libdb1.a stdtime/libtime.a $(OBJS)
+ $(CC) $(DEBUG) ${ASTOBJ} $(ASTLINK) $(OBJS) $(LIBEDIT) db1-ast/libdb1.a stdtime/libtime.a $(LIBS)
muted: muted.o
$(CC) $(AUDIO_LIBS) -o muted muted.o
@@ -595,7 +608,9 @@ bininstall: all
mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme
- $(INSTALL) -m 755 asterisk $(DESTDIR)$(ASTSBINDIR)/
+ if [ -f asterisk ]; then $(INSTALL) -m 755 asterisk $(DESTDIR)$(ASTSBINDIR)/; fi
+ if [ -f cygwin/asterisk.exe ]; then $(INSTALL) -m 755 cygwin/asterisk.exe $(DESTDIR)$(ASTSBINDIR)/; fi
+ if [ -f asterisk.dll ]; then $(INSTALL) -m 755 asterisk.dll $(DESTDIR)$(ASTSBINDIR)/; fi
ln -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
$(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
$(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
diff --git a/acl.c b/acl.c
index 7fd13ccf5..326cdb66d 100755
--- a/acl.c
+++ b/acl.c
@@ -68,6 +68,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/utils.h"
#include "asterisk/lock.h"
#include "asterisk/srv.h"
+#include "asterisk/compat.h"
#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)
AST_MUTEX_DEFINE_STATIC(routeseq_lock);
diff --git a/apps/Makefile b/apps/Makefile
index f7e309e3f..4c276c25a 100755
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -22,7 +22,7 @@ APPS=app_dial.so app_playback.so app_voicemail.so app_directory.so app_mp3.so\
app_enumlookup.so app_transfer.so app_setcidnum.so app_cdr.so \
app_hasnewvoicemail.so app_sayunixtime.so app_cut.so app_read.so \
app_setcdruserfield.so app_random.so app_ices.so app_eval.so \
- app_nbscat.so app_sendtext.so app_exec.so app_sms.so \
+ app_nbscat.so app_sendtext.so app_exec.so \
app_groupcount.so app_txtcidname.so app_controlplayback.so \
app_talkdetect.so app_alarmreceiver.so app_userevent.so app_verbose.so \
app_test.so app_forkcdr.so app_math.so app_realtime.so \
@@ -63,7 +63,13 @@ ifneq ($(shell if [[ 0x`$(CROSS_COMPILE_BIN)curl-config --vernum` -ge 0x70907 ]]
endif
endif
+ifeq (${OSARCH},CYGWIN)
+CYGSOLINK=-Wl,--out-implib=lib$@.a -Wl,--export-all-symbols
+CYGSOLIB=-L.. -L. -L../res -lasterisk.dll -lres_features.so -lres_adsi.so -lres_monitor.so
+else
CFLAGS+=-fPIC
+APPS+=app_sms.so
+endif
#
# If you have UnixODBC you can use ODBC voicemail
@@ -81,10 +87,10 @@ clean:
rm -f *.so *.o look .depend
%.so : %.o
- $(CC) $(SOLINK) -o $@ $<
-
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB}
+
app_rpt.so : app_rpt.o
- $(CC) $(SOLINK) -o $@ $< -ltonezone
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -ltonezone
install: all
for x in $(APPS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
@@ -92,16 +98,16 @@ install: all
rm -f $(DESTDIR)$(MODULES_DIR)/app_qcall.so
app_curl.so: app_curl.o
- $(CC) $(SOLINK) -o $@ $< $(CURLLIBS)
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(CURLLIBS)
app_sql_postgres.o: app_sql_postgres.c
$(CC) -pipe -I/usr/local/pgsql/include $(CFLAGS) -c -o app_sql_postgres.o app_sql_postgres.c
app_sql_postgres.so: app_sql_postgres.o
- $(CC) $(SOLINK) -o $@ $< -L/usr/local/pgsql/lib -lpq
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -L/usr/local/pgsql/lib -lpq
app_sql_odbc.so: app_sql_odbc.o
- $(CC) $(SOLINK) -o $@ $< -lodbc
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lodbc
look: look.c
$(CC) -pipe -O6 -g look.c -o look -lncurses
diff --git a/ast_expr2.c b/ast_expr2.c
index e68bd84a1..39928d5f7 100755
--- a/ast_expr2.c
+++ b/ast_expr2.c
@@ -132,7 +132,7 @@
#include <string.h>
#include <locale.h>
#include <ctype.h>
-#ifndef SOLARIS
+#if !defined(SOLARIS) && !defined(__CYGWIN__)
#include <err.h>
#else
#define quad_t int64_t
diff --git a/ast_expr2.fl b/ast_expr2.fl
index 39df6013b..7a54ed36b 100755
--- a/ast_expr2.fl
+++ b/ast_expr2.fl
@@ -5,7 +5,7 @@
#include <string.h>
#include <locale.h>
#include <ctype.h>
-#ifndef SOLARIS
+#if !defined(SOLARIS) && !defined(__CYGWIN__)
#include <err.h>
#else
#define quad_t int64_t
diff --git a/ast_expr2.y b/ast_expr2.y
index 9aab0f164..15da7ecb8 100755
--- a/ast_expr2.y
+++ b/ast_expr2.y
@@ -18,7 +18,7 @@
#include <string.h>
#include <locale.h>
#include <ctype.h>
-#ifndef SOLARIS
+#if !defined(SOLARIS) && !defined(__CYGWIN__)
#include <err.h>
#else
#define quad_t int64_t
diff --git a/ast_expr2f.c b/ast_expr2f.c
index b3e88f1e6..defaa100c 100755
--- a/ast_expr2f.c
+++ b/ast_expr2f.c
@@ -956,7 +956,7 @@ static yyconst yy_state_type yy_NUL_trans[33] =
#include <string.h>
#include <locale.h>
#include <ctype.h>
-#ifndef SOLARIS
+#if !defined(SOLARIS) && !defined(__CYGWIN__)
#include <err.h>
#else
#define quad_t int64_t
diff --git a/asterisk.c b/asterisk.c
index 4d796c4c1..785b64a91 100755
--- a/asterisk.c
+++ b/asterisk.c
@@ -2048,6 +2048,8 @@ int main(int argc, char *argv[])
ast_verbose("[ Reading Master Configuration ]");
ast_readconfig();
+#ifndef __CYGWIN__
+
if (!is_child_of_nonroot && ast_set_priority(option_highpriority)) {
exit(1);
}
@@ -2083,6 +2085,8 @@ int main(int argc, char *argv[])
ast_verbose("Running as user '%s'\n", runuser);
}
+#endif /* __CYGWIN__ */
+
term_init();
printf(term_end());
fflush(stdout);
diff --git a/cdr/Makefile b/cdr/Makefile
index e3db4ba22..3f6a7602e 100755
--- a/cdr/Makefile
+++ b/cdr/Makefile
@@ -13,7 +13,12 @@
MODS=cdr_csv.so cdr_manager.so cdr_custom.so
+ifeq (${OSARCH},CYGWIN)
+CYGSOLINK=-Wl,--out-implib=lib$@.a -Wl,--export-all-symbols
+CYGSOLIB=-L.. -L. -lasterisk.dll
+else
CFLAGS+=-fPIC
+endif
ifeq ($(findstring BSD,${OSARCH}),BSD)
CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
@@ -110,23 +115,23 @@ clean:
rm -f *.so *.o .depend
%.so : %.o
- $(CC) $(SOLINK) -o $@ $<
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB}
ifneq ($(wildcard .depend),)
include .depend
endif
cdr_odbc.so: cdr_odbc.o
- $(CC) $(SOLINK) -o $@ $< -lodbc $(MLFLAGS)
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lodbc $(MLFLAGS)
cdr_tds.so: cdr_tds.o
- $(CC) $(SOLINK) -o $@ $< -ltds $(MLFLAGS)
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -ltds $(MLFLAGS)
cdr_pgsql.so: cdr_pgsql.o
- $(CC) $(SOLINK) -o $@ $< -lpq -lz $(MLFLAGS)
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lpq -lz $(MLFLAGS)
cdr_sqlite.so: cdr_sqlite.o
- $(CC) $(SOLINK) -o $@ $< -lsqlite $(MLFLAGS)
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lsqlite $(MLFLAGS)
depend: .depend
diff --git a/channels/Makefile b/channels/Makefile
index 068cbe14b..55f50b30f 100755
--- a/channels/Makefile
+++ b/channels/Makefile
@@ -14,11 +14,11 @@
# the GNU General Public License
#
-CHANNEL_LIBS=chan_modem.so chan_sip.so \
- chan_modem_aopen.so \
- chan_modem_bestdata.so \
- chan_agent.so chan_mgcp.so chan_iax2.so \
- chan_local.so chan_skinny.so chan_features.so
+CHANNEL_LIBS=chan_sip.so chan_agent.so chan_mgcp.so chan_iax2.so chan_local.so chan_skinny.so chan_features.so
+
+ifneq (${OSARCH},CYGWIN)
+CHANNEL_LIBS+=chan_modem.so chan_modem_aopen.so chan_modem_bestdata.so
+endif
ifeq ($(findstring BSD,${OSARCH}),BSD)
CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
@@ -35,6 +35,12 @@ ifeq (${OSARCH},Linux)
CHANH323LIB=-ldl
endif
+ifeq (${OSARCH},CYGWIN)
+CYGSOLINK=-Wl,--out-implib=lib$@.a -Wl,--export-all-symbols
+CYGSOLIB=-L.. -L. -L../res -lasterisk.dll -lres_features.so
+CYG_CHAN_AGENT=-lres_monitor.so
+endif
+
ifeq ($(PROC),sparc64)
PROC=ultrasparc
CFLAGS += -mtune=$(PROC) -O3 -pipe -fomit-frame-pointer -mcpu=v8
@@ -53,7 +59,9 @@ endif
ifneq (${OSARCH},Darwin)
ifneq (${OSARCH},SunOS)
- CHANNEL_LIBS+=chan_oss.so chan_modem_i4l.so
+ ifneq (${OSARCH},CYGWIN)
+ CHANNEL_LIBS+=chan_oss.so chan_modem_i4l.so
+ endif
endif
endif
@@ -113,7 +121,10 @@ ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/vpbapi.h),)
endif
CFLAGS+=-DCRYPTO
+
+ifneq ($(OSARCH),CYGWIN)
CFLAGS+=-fPIC
+endif
CFLAGS+=#-DVOFRDUMPER
@@ -140,7 +151,7 @@ clean:
rm -f busy.h ringtone.h gentone gentone-ulaw
%.so : %.o
- $(CC) $(SOLINK) -o $@ $<
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} ${LIBS}
ifneq ($(wildcard .depend),)
include .depend
@@ -180,7 +191,7 @@ chan_oss.so: chan_oss.o
endif
chan_iax2.so: chan_iax2.o iax2-parser.o iax2-provision.o
- $(CC) $(SOLINK) -o $@ chan_iax2.o iax2-parser.o iax2-provision.o
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} chan_iax2.o iax2-parser.o iax2-provision.o ${CYGSOLIB}
chan_zap.o: chan_zap.c
$(CC) -c $(CFLAGS) -o chan_zap.o chan_zap.c
@@ -189,7 +200,10 @@ chan_zap.so: chan_zap.o
$(CC) $(SOLINK) -o $@ $< $(ZAPPRI) $(ZAPR2) -ltonezone
chan_sip.so: chan_sip.o
- $(CC) $(SOLINK) -o $@ chan_sip.o
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} chan_sip.o ${CYGSOLIB}
+
+chan_agent.so: chan_agent.o
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} chan_agent.o ${CYGSOLIB} ${CYG_CHAN_AGENT}
chan_alsa.o: $(ALSA_SRC)
diff --git a/codecs/Makefile b/codecs/Makefile
index 602215886..edf029219 100755
--- a/codecs/Makefile
+++ b/codecs/Makefile
@@ -11,6 +11,11 @@
# the GNU General Public License
#
+ifeq (${OSARCH},CYGWIN)
+CYGSOLINK=-Wl,--out-implib=lib$@.a -Wl,--export-all-symbols
+CYGSOLIB=-L.. -L. -lasterisk.dll
+endif
+
ifneq ($(wildcard g723.1/coder.c),)
MODG723=codec_g723_1.so
LIBG723=g723.1/libg723.a
@@ -92,28 +97,28 @@ $(LIBILBC):
$(MAKE) -C ilbc all
$(MODILBC): codec_ilbc.o $(LIBILBC)
- $(CC) $(SOLINK) -o $@ $< $(LIBILBC)
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(LIBILBC)
codec_g723_1.so : codec_g723_1.o $(LIBG723)
- $(CC) $(SOLINK) -o $@ $< $(LIBG723)
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(LIBG723)
codec_g723_1b.o : codec_g723_1.c
$(CC) -c -o $@ $(CFLAGS) -DANNEX_B -Dsingle $<
codec_g723_1b.so : codec_g723_1b.o $(LIBG723B)
- $(CC) $(SOLINK) -o $@ $< $(LIBG723B) -lm
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(LIBG723B) -lm
codec_gsm.so: codec_gsm.o $(LIBGSMT)
- $(CC) $(SOLINK) -o $@ $< $(LIBGSM)
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(LIBGSM)
$(MODSPEEX): codec_speex.o
- $(CC) $(SOLINK) -o $@ $< $(LIBSPEEX)
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(LIBSPEEX)
codec_lpc10.so: codec_lpc10.o $(LIBLPC10)
- $(CC) $(SOLINK) -o $@ $< $(LIBLPC10) -lm
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(LIBLPC10) -lm
%.so : %.o
- $(CC) $(SOLINK) -o $@ $<
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB}
ifneq ($(wildcard .depend),)
include .depend
diff --git a/codecs/gsm/Makefile b/codecs/gsm/Makefile
index 76f9e89ae..a2b5dcf1e 100755
--- a/codecs/gsm/Makefile
+++ b/codecs/gsm/Makefile
@@ -36,6 +36,7 @@ WAV49 = -DWAV49
######### which support MMX instructions. This should be newer pentiums,
######### ppro's, etc, as well as the AMD K6 and K7. The compile will
######### probably require gcc.
+PROC=$(shell uname -m)
ifneq (${OSARCH},Darwin)
ifneq (${OSARCH},SunOS)
@@ -90,7 +91,11 @@ PG =
# CCFLAGS = -c -O
CC ?= gcc
-CCFLAGS += -c -DNeedFunctionPrototypes=1 -funroll-loops -fPIC $(OPTIMIZE)
+CCFLAGS += -c -DNeedFunctionPrototypes=1 -funroll-loops $(OPTIMIZE)
+ifneq ($(findstring CYGWIN,${OSARCH}),CYGWIN)
+CCFLAGS += -fPIC
+endif
+
LD = $(CC)
diff --git a/config.c b/config.c
index f279b1640..beb2f4df3 100755
--- a/config.c
+++ b/config.c
@@ -33,7 +33,7 @@
#include <sys/stat.h>
#define AST_INCLUDE_GLOB 1
#ifdef AST_INCLUDE_GLOB
-#ifdef __Darwin__
+#if defined(__Darwin__) || defined(__CYGWIN__)
#define GLOB_ABORTED GLOB_ABEND
#endif
# include <glob.h>
@@ -693,7 +693,11 @@ int config_text_file_save(const char *configfile, const struct ast_config *cfg,
}
time(&t);
ast_copy_string(date, ctime(&t), sizeof(date));
+#ifdef __CYGWIN__
+ if ((f = fopen(fn, "w+"))) {
+#else
if ((f = fopen(fn, "w"))) {
+#endif
if ((option_verbose > 1) && !option_debug)
ast_verbose( VERBOSE_PREFIX_2 "Saving '%s': ", fn);
fprintf(f, ";!\n");
diff --git a/cygwin/Makefile b/cygwin/Makefile
new file mode 100755
index 000000000..124628f9c
--- /dev/null
+++ b/cygwin/Makefile
@@ -0,0 +1,6 @@
+OBJS=cygloader.o
+all: $(OBJS)
+$(OBJS) : %.o: %.c
+ $(CC) $< -o asterisk.exe
+clean:
+ rm -f asterisk.exe
diff --git a/cygwin/cygloader.c b/cygwin/cygloader.c
new file mode 100755
index 000000000..0d48c0f6c
--- /dev/null
+++ b/cygwin/cygloader.c
@@ -0,0 +1,33 @@
+#include <unistd.h>
+#include <dlfcn.h>
+#include <stdio.h>
+
+#define OK 0
+#define MODULE_NOT_FOUND 1
+#define INVALID_NUMBER_ARGUMENTS 2
+
+int main(int argc, char **argv) {
+ /* Asterisk entry point */
+ char* error = NULL;
+ int (*ast_main)(int argc, char **argv);
+
+ void *handle = dlopen ("asterisk.dll", RTLD_GLOBAL);
+ if (handle == NULL) {
+ fputs (dlerror(), stderr);
+ fputs ("\r\n", stderr);
+ return MODULE_NOT_FOUND;
+ }
+ printf("\r\nAsterisk module loaded successfully");
+ ast_main = dlsym(handle, "main");
+ if ((error = dlerror()) != NULL) {
+ fputs("Asterisk main not found", stderr);
+ fputs(error, stderr);
+ exit(1);
+ }
+ printf("\r\nAsterisk entry point found");
+ /* run asterisk main */
+ (*ast_main)(argc, argv);
+ dlclose(handle);
+ printf("\r\nAsterisk stopped");
+ return OK;
+}
diff --git a/db.c b/db.c
index ae12909fd..543aa4dda 100755
--- a/db.c
+++ b/db.c
@@ -53,6 +53,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/manager.h"
#include "db1-ast/include/db.h"
+#ifdef __CYGWIN__
+#define dbopen __dbopen
+#endif
+
static DB *astdb;
AST_MUTEX_DEFINE_STATIC(dblock);
diff --git a/formats/Makefile b/formats/Makefile
index 823515c24..31f973390 100755
--- a/formats/Makefile
+++ b/formats/Makefile
@@ -35,25 +35,29 @@ endif
GSMLIB=../codecs/gsm/lib/libgsm.a
+ifeq (${OSARCH},CYGWIN)
+CYGSOLINK=-Wl,--out-implib=lib$@.a -Wl,--export-all-symbols
+CYGSOLIB=-L.. -L. -lasterisk.dll
+else
CFLAGS+=-fPIC
-
+endif
all: depend $(FORMAT_LIBS)
clean:
rm -f *.so *.o .depend
%.so : %.o
- $(CC) $(SOLINK) -o $@ $<
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB}
ifneq ($(wildcard .depend),)
include .depend
endif
format_mp3.so : format_mp3.o
- $(CC) $(SOLINK) -o $@ $< -lm
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lm
format_ogg_vorbis.so : format_ogg_vorbis.o
- $(CC) $(SOLINK) -o $@ $< -logg -lvorbis -lvorbisenc -lm
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -logg -lvorbis -lvorbisenc -lm
install: all
for x in $(FORMAT_LIBS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
diff --git a/funcs/Makefile b/funcs/Makefile
index 7ec63b407..14bbd80a3 100755
--- a/funcs/Makefile
+++ b/funcs/Makefile
@@ -33,7 +33,12 @@ FUNC_SOURCES=$(BUILTINS:.o=.c)
FUNC_STRUCTS=$(shell grep 'struct ast_custom_function' $(FUNC_SOURCES) | awk '{print $$3};')
+ifeq (${OSARCH},CYGWIN)
+CYGSOLINK=-Wl,--out-implib=lib$@.a -Wl,--export-all-symbols
+CYGSOLIB=-L.. -L. -lasterisk.dll
+else
CFLAGS+=-fPIC
+endif
ifeq ($(findstring BSD,${OSARCH}),BSD)
CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
@@ -45,7 +50,7 @@ clean:
rm -f *.so *.o .depend pbx_functions.h
%.so : %.o
- $(CC) $(SOLINK) -o $@ $<
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB}
#$(BUILTINS) : CFLAGS += -DBUILTIN_FUNC
@@ -59,7 +64,7 @@ pbx_functions.h: $(FUNC_SOURCES)
pbx_functions.o: pbx_functions.h
pbx_functions.so: pbx_functions.o #$(BUILTINS)
- $(CC) $(SOLINK) -o $@ $<
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB}
install: all
for x in $(FUNCS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
diff --git a/include/asterisk/compat.h b/include/asterisk/compat.h
index fc4791b9c..fb6a5d59f 100755
--- a/include/asterisk/compat.h
+++ b/include/asterisk/compat.h
@@ -63,8 +63,12 @@ int unsetenv(const char *name);
#ifdef __CYGWIN__
#define _WIN32_WINNT 0x0500
-#include <windows.h>
-#include <w32api/ws2tcpip.h>
+#ifndef INET_ADDRSTRLEN
+#define INET_ADDRSTRLEN 16
+#endif
+#ifndef INET6_ADDRSTRLEN
+#define INET6_ADDRSTRLEN 46
+#endif
#endif /* __CYGWIN__ */
#define HAVE_VASPRINTF
diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h
index 5c6236015..edc112698 100755
--- a/include/asterisk/lock.h
+++ b/include/asterisk/lock.h
@@ -41,6 +41,10 @@
0x20 } }
#endif
+#ifdef __CYGWIN__
+#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
+#endif
+
#ifdef BSD
#ifdef __GNUC__
#define AST_MUTEX_INIT_W_CONSTRUCTORS
diff --git a/pbx/Makefile b/pbx/Makefile
index 7af318a93..f86ae4859 100755
--- a/pbx/Makefile
+++ b/pbx/Makefile
@@ -28,7 +28,13 @@ GTK_LIBS=`${CROSS_COMPILE_BIN}gtk-config --libs gthread`
MOC=$(QTDIR)/bin/moc
KDE_FLAGS=-I$(KDEDIR)/include -I$(KDEDIR)/include/kde -I$(QTDIR)/include
KDE_LIBS=-L$(KDEDIR)/lib -L$(QTDIR)/lib -lqt -lkdecore -lkdeui
+
+ifeq (${OSARCH},CYGWIN)
+CYGSOLINK=-Wl,--out-implib=lib$@.a -Wl,--export-all-symbols
+CYGSOLIB=-L.. -L. -L../res -lasterisk.dll
+else
CFLAGS+=-fPIC
+endif
KDE_CONSOLE_OBJS=pbx_kdeconsole_main.o pbx_kdeconsole.o
@@ -53,13 +59,13 @@ pbx_kdeconsole.so: $(KDE_CONSOLE_OBJS)
$(CC) $(SOLINK) -o $@ $(KDE_CONSOLE_OBJS) $(KDE_LIBS)
pbx_dundi.so: dundi-parser.o pbx_dundi.o
- $(CC) $(SOLINK) -o $@ pbx_dundi.o dundi-parser.o -lz
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} pbx_dundi.o dundi-parser.o -lz ${CYGSOLIB}
%.moc : %.h
$(MOC) $< -o $@
%.so : %.o
- $(CC) $(SOLINK) -o $@ $<
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB}
ifneq ($(wildcard .depend),)
include .depend
diff --git a/res/Makefile b/res/Makefile
index f688b37bf..b4170e397 100755
--- a/res/Makefile
+++ b/res/Makefile
@@ -11,8 +11,7 @@
# the GNU General Public License
#
-MODS=res_adsi.so res_features.so res_musiconhold.so res_indications.so res_monitor.so \
- res_agi.so
+MODS=res_indications.so res_monitor.so res_adsi.so res_agi.so res_features.so
ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/odbcinst.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/odbcinst.h),)
ifneq (${OSARCH},FreeBSD)
@@ -41,6 +40,15 @@ ifeq ($(findstring BSD,${OSARCH}),BSD)
CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
endif
+ifeq (${OSARCH},CYGWIN)
+CYGSOLINK=-Wl,--out-implib=lib$@.a -Wl,--export-all-symbols
+CYGSOLIB=-L.. -L. -lasterisk.dll
+CYG_RES_CONFIG_ODBC_LIB=-lres_odbc.so
+CYG_RES_FEATURES_LIB=-lres_adsi.so -lres_monitor.so
+else
+MODS+=res_musiconhold.so
+endif
+
CRYPTO_LIBS=-lssl -lcrypto
CFLAGS+=
@@ -52,7 +60,11 @@ endif
#
# Work around buggy RedHat 9.0
#
+ifeq (${OSARCH},CYGWIN)
+CFLAGS+=-DOPENSSL_NO_KRB5
+else
CFLAGS+=-DOPENSSL_NO_KRB5 -fPIC
+endif
all: depend $(MODS)
@@ -63,19 +75,25 @@ install: all
for x in $(MODS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
res_crypto.so: res_crypto.o
- $(CC) $(SOLINK) -o $@ $< $(CRYPTO_LIBS)
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(CRYPTO_LIBS)
clean:
rm -f *.so *.o .depend
res_odbc.so: res_odbc.o
- $(CC) $(SOLINK) -o $@ $< -lodbc
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lodbc
res_osp.so: res_osp.o $(OSPLIB)
- $(CC) $(SOLINK) -o $@ $^
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(OSPLIB)
%.so : %.o
- $(CC) $(SOLINK) -o $@ $<
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB}
+
+res_features.so: res_features.o
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} ${CYG_RES_FEATURES_LIB}
+
+res_config_odbc.so: res_config_odbc.o
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} ${CYG_RES_CONFIG_ODBC_LIB}
ifneq ($(wildcard .depend),)
include .depend
diff --git a/stdtime/private.h b/stdtime/private.h
index 90329d3fa..60479d787 100755
--- a/stdtime/private.h
+++ b/stdtime/private.h
@@ -9,9 +9,11 @@
*/
/* Stuff moved from Makefile.inc to reduce clutter */
+#ifndef __CYGWIN__
#ifndef TM_GMTOFF
#define TM_GMTOFF tm_gmtoff
#define TM_ZONE tm_zone
+#endif
#define STD_INSPIRED 1
#define PCTS 1
#define HAVE_LONG_DOUBLE 1
diff --git a/utils.c b/utils.c
index d3292ff90..9dffe253a 100755
--- a/utils.c
+++ b/utils.c
@@ -44,6 +44,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/logger.h"
#include "asterisk/md5.h"
#include "asterisk/options.h"
+#include "asterisk/compat.h"
#define AST_API_MODULE /* ensure that inlinable API functions will be built in this module if required */
#include "asterisk/strings.h"
@@ -57,7 +58,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
static char base64[64];
static char b2a[256];
-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__) || defined(__CYGWIN__)
/* duh? ERANGE value copied from web... */
#define ERANGE 34
@@ -741,10 +742,14 @@ int vasprintf(char **strp, const char *fmt, va_list ap)
#endif /* !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC) */
#ifndef HAVE_STRTOQ
+#ifndef LONG_MIN
#define LONG_MIN (-9223372036854775807L-1L)
/* min value of a "long int" */
+#endif
+#ifndef LONG_MAX
#define LONG_MAX 9223372036854775807L
/* max value of a "long int" */
+#endif
/*
* Convert a string to a quad integer.
diff --git a/utils/streamplayer.c b/utils/streamplayer.c
index 4cd953114..24f3142b8 100755
--- a/utils/streamplayer.c
+++ b/utils/streamplayer.c
@@ -31,7 +31,7 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__Darwin__)
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__Darwin__) || defined(__CYGWIN__)
#include <netinet/in.h>
#endif
#include <sys/time.h>