libtool=@libtool@
ldnsdir=@ldnsdir@
staticexe=@staticexe@
+EXEEXT=@EXEEXT@
configfile=@ub_conf_file@
UNBOUND_RUN_DIR=@UNBOUND_RUN_DIR@
CHECKLOCK_SRC=@CHECKLOCK_SRC@
SWIG=@SWIG@
YACC=@YACC@
LEX=@LEX@
+STRIP=@STRIP@
CC=@CC@
CPPFLAGS=-I. @CPPFLAGS@
ifneq "$(srcdir)" "."
$(srcdir)/iterator/*.c $(srcdir)/validator/*.c $(PYTHONMOD_SRC))) \
util/configparser.c util/configlexer.c $(CHECKLOCK_SRC)
COMMON_OBJ=$(addprefix $(BUILD),$(COMMON_SRC:.c=.lo))
+COMPAT_SRC=$(addprefix compat/,$(LIBOBJS:.o=.c))
COMPAT_OBJ=$(addprefix $(BUILD)compat/,$(LIBOBJS:.o=.lo))
UNITTEST_SRC=$(patsubst $(srcdir)/%,%, \
$(wildcard $(srcdir)/testcode/unit*.c)) \
CONTROL_OBJ+=$(BUILD)winrc/rsrc_unbound_control.o
CHECKCONF_OBJ+=$(BUILD)winrc/rsrc_unbound_checkconf.o
- WINAPPS=unbound-service-install unbound-service-remove anchor-update
+ WINAPPS=$(addsuffix $(EXEEXT), unbound-service-install \
+ unbound-service-remove anchor-update)
SVCINST_SRC=winrc/unbound-service-install.c winrc/w_inst.c
SVCINST_OBJ=$(addprefix $(BUILD),$(SVCINST_SRC:.c=.lo)) $(COMPAT_OBJ) \
$(BUILD)winrc/rsrc_svcinst.o
@-if test ! -d $(dir $@); then $(INSTALL) -d $(patsubst %/,%,$(dir $@)); fi
$Q$(COMPILE) -c $< -o $@
-all: $(COMMON_OBJ) unbound unbound-checkconf lib unbound-host unbound-control unbound-control-setup $(WINAPPS)
+all: $(COMMON_OBJ) unbound$(EXEEXT) unbound-checkconf$(EXEEXT) lib unbound-host$(EXEEXT) unbound-control$(EXEEXT) unbound-control-setup $(WINAPPS)
-TEST_BIN=asynclook delayer harvest lock-verify memstats perf pktview signit \
- streamtcp testbound unittest
+TEST_BIN=$(addsuffix $(EXEEXT),asynclook delayer harvest lock-verify \
+ memstats perf pktview signit streamtcp testbound unittest)
tests: all $(TEST_BIN)
test: tests
$(ldnslib):
@if test ! -z "$(ldnsdir)"; \
then (cd $(ldnsdir) && $(MAKE)); fi
+$(ldnsdir)/%:
+ @if test ! -z "$(ldnsdir)"; \
+ then (cd $(ldnsdir) && $(MAKE)); fi
else
ldnslib=
endif
-unbound: $(DAEMON_OBJ) $(ldnslib)
+unbound$(EXEEXT): $(DAEMON_OBJ) $(ldnslib)
$(INFO) Link $@
$Q$(LINK) -o $@ $(sort $(DAEMON_OBJ)) -lssl $(LIBS)
-unbound-checkconf: $(CHECKCONF_OBJ) $(ldnslib)
+unbound-checkconf$(EXEEXT): $(CHECKCONF_OBJ) $(ldnslib)
$(INFO) Link $@
$Q$(LINK) -o $@ $(sort $(CHECKCONF_OBJ)) $(LIBS)
-unbound-control: $(CONTROL_OBJ) $(ldnslib)
+unbound-control$(EXEEXT): $(CONTROL_OBJ) $(ldnslib)
$(INFO) Link $@
$Q$(LINK) -o $@ $(sort $(CONTROL_OBJ)) -lssl $(LIBS)
-unbound-host: $(HOST_OBJ) libunbound.la $(ldnslib)
+unbound-host$(EXEEXT): $(HOST_OBJ) libunbound.la $(ldnslib)
$(INFO) Link $@
$Q$(LINK) -o $@ $(sort $(HOST_OBJ)) -L. -L.libs -lunbound $(LIBS)
-unbound-service-install: $(SVCINST_OBJ)
+unbound-service-install$(EXEEXT): $(SVCINST_OBJ)
$(INFO) Link $@
$Q$(LINK) -o $@ $(sort $(SVCINST_OBJ)) $(LIBS)
-unbound-service-remove: $(SVCUNINST_OBJ)
+unbound-service-remove$(EXEEXT): $(SVCUNINST_OBJ)
$(INFO) Link $@
$Q$(LINK) -o $@ $(sort $(SVCUNINST_OBJ)) $(LIBS)
-anchor-update: $(ANCHORUPD_OBJ) libunbound.la $(ldnslib)
+anchor-update$(EXEEXT): $(ANCHORUPD_OBJ) libunbound.la $(ldnslib)
$(INFO) Link $@
$Q$(LINK) -o $@ $(sort $(ANCHORUPD_OBJ)) -L. -L.libs -lunbound $(LIBS)
-unittest: $(UNITTEST_OBJ) $(ldnslib)
+unittest$(EXEEXT): $(UNITTEST_OBJ) $(ldnslib)
$(INFO) Link $@
$Q$(LINK) -o $@ $(sort $(UNITTEST_OBJ)) $(LIBS)
-testbound: $(TESTBOUND_OBJ) $(ldnslib)
+testbound$(EXEEXT): $(TESTBOUND_OBJ) $(ldnslib)
$(INFO) Link $@
$Q$(LINK) -o $@ $(sort $(TESTBOUND_OBJ)) -lssl $(LIBS)
-lock-verify: $(LOCKVERIFY_OBJ) $(ldnslib)
+lock-verify$(EXEEXT): $(LOCKVERIFY_OBJ) $(ldnslib)
$(INFO) Link $@
$Q$(LINK) -o $@ $(sort $(LOCKVERIFY_OBJ)) $(LIBS)
-pktview: $(PKTVIEW_OBJ) $(ldnslib)
+pktview$(EXEEXT): $(PKTVIEW_OBJ) $(ldnslib)
$(INFO) Link $@
$Q$(LINK) -o $@ $(sort $(PKTVIEW_OBJ)) $(LIBS)
-signit: $(SIGNIT_OBJ) $(ldnslib)
+signit$(EXEEXT): $(SIGNIT_OBJ) $(ldnslib)
$(INFO) Link $@
$Q$(LINK) -o $@ $(sort $(SIGNIT_OBJ)) $(LIBS)
-memstats: $(MEMSTATS_OBJ) $(ldnslib)
+memstats$(EXEEXT): $(MEMSTATS_OBJ) $(ldnslib)
$(INFO) Link $@
$Q$(LINK) -o $@ $(sort $(MEMSTATS_OBJ)) $(LIBS)
-asynclook: $(ASYNCLOOK_OBJ) $(ldnslib) libunbound.la
+asynclook$(EXEEXT): $(ASYNCLOOK_OBJ) $(ldnslib) libunbound.la
$(INFO) Link $@
$Q$(LINK) -o $@ $(sort $(ASYNCLOOK_OBJ)) $(LIBS) -L. -L.libs -lunbound
-streamtcp: $(STREAMTCP_OBJ) $(ldnslib)
+streamtcp$(EXEEXT): $(STREAMTCP_OBJ) $(ldnslib)
$(INFO) Link $@
$Q$(LINK) -o $@ $(sort $(STREAMTCP_OBJ)) $(LIBS)
-perf: $(PERF_OBJ) $(ldnslib)
+perf$(EXEEXT): $(PERF_OBJ) $(ldnslib)
$(INFO) Link $@
$Q$(LINK) -o $@ $(sort $(PERF_OBJ)) $(LIBS)
-delayer: $(DELAYER_OBJ) $(ldnslib)
+delayer$(EXEEXT): $(DELAYER_OBJ) $(ldnslib)
$(INFO) Link $@
$Q$(LINK) -o $@ $(sort $(DELAYER_OBJ)) $(LIBS)
-harvest: $(HARVEST_OBJ) $(ldnslib) libunbound.la
+harvest$(EXEEXT): $(HARVEST_OBJ) $(ldnslib) libunbound.la
$(INFO) Link $@
$Q$(LINK) -o $@ $(sort $(HARVEST_OBJ)) $(LIBS) -L. -L.libs -lunbound
clean:
rm -f *.o *.d *.lo *~ tags
- rm -f unbound unbound-checkconf unbound-host unbound-control unbound-control-setup libunbound.la
+ rm -f unbound$(EXEEXT) unbound-checkconf$(EXEEXT) unbound-host$(EXEEXT) unbound-control$(EXEEXT) unbound-control-setup libunbound.la
rm -rf autom4te.cache .libs build doc/html doc/xml
realclean: clean
fi
strip:
- strip unbound
- strip unbound-checkconf
- strip unbound-control
- strip unbound-host
+ $(STRIP) unbound$(EXEEXT)
+ $(STRIP) unbound-checkconf$(EXEEXT)
+ $(STRIP) unbound-control$(EXEEXT)
+ $(STRIP) unbound-host$(EXEEXT)
install:
$(INSTALL) -m 755 -d $(DESTDIR)$(sbindir)
$(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
$(INSTALL) -m 755 -d $(DESTDIR)$(libdir)
$(INSTALL) -m 755 -d $(DESTDIR)$(includedir)
- $(LIBTOOL) --mode=install cp unbound $(DESTDIR)$(sbindir)/unbound
- $(LIBTOOL) --mode=install cp unbound-checkconf $(DESTDIR)$(sbindir)/unbound-checkconf
- $(LIBTOOL) --mode=install cp unbound-control $(DESTDIR)$(sbindir)/unbound-control
- $(LIBTOOL) --mode=install cp unbound-host $(DESTDIR)$(sbindir)/unbound-host
+ $(LIBTOOL) --mode=install cp unbound$(EXEEXT) $(DESTDIR)$(sbindir)/unbound$(EXEEXT)
+ $(LIBTOOL) --mode=install cp unbound-checkconf$(EXEEXT) $(DESTDIR)$(sbindir)/unbound-checkconf$(EXEEXT)
+ $(LIBTOOL) --mode=install cp unbound-control$(EXEEXT) $(DESTDIR)$(sbindir)/unbound-control$(EXEEXT)
+ $(LIBTOOL) --mode=install cp unbound-host$(EXEEXT) $(DESTDIR)$(sbindir)/unbound-host$(EXEEXT)
ifeq "$(WITH_PYTHONMODULE)" "yes"
$(INSTALL) -m 755 -d $(DESTDIR)$(PYTHON_SITE_PKG)
$(INSTALL) -c -m 644 pythonmod/unboundmodule.py $(DESTDIR)$(PYTHON_SITE_PKG)/unboundmodule.py
$(LIBTOOL) --mode=finish $(DESTDIR)$(libdir)
uninstall:
- rm -f -- $(DESTDIR)$(sbindir)/unbound $(DESTDIR)$(sbindir)/unbound-checkconf $(DESTDIR)$(sbindir)/unbound-host $(DESTDIR)$(sbindir)/unbound-control $(DESTDIR)$(sbindir)/unbound-control-setup
+ rm -f -- $(DESTDIR)$(sbindir)/unbound$(EXEEXT) $(DESTDIR)$(sbindir)/unbound-checkconf$(EXEEXT) $(DESTDIR)$(sbindir)/unbound-host$(EXEEXT) $(DESTDIR)$(sbindir)/unbound-control$(EXEEXT) $(DESTDIR)$(sbindir)/unbound-control-setup
rm -f -- $(DESTDIR)$(mandir)/man8/unbound.8 $(DESTDIR)$(mandir)/man8/unbound-checkconf.8 $(DESTDIR)$(mandir)/man5/unbound.conf.5 $(DESTDIR)$(mandir)/man8/unbound-control.8
rm -f -- $(DESTDIR)$(mandir)/man1/unbound-host.1 $(DESTDIR)$(mandir)/man3/libunbound.3
rm -f -- $(DESTDIR)$(includedir)/unbound.h
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),realclean)
ifeq ($(debug_enabled),yes)
--include $(addprefix $(BUILD),$(ALL_SRC:.c=.d))
+-include $(addprefix $(BUILD),$(ALL_SRC:.c=.d) $(COMPAT_SRC:.c=.d))
endif
endif
endif
DSYMUTIL
lt_ECHO
RANLIB
-STRIP
OBJDUMP
LN_S
NM
build_cpu
build
libtool
+STRIP
doxygen
YFLAGS
YACC
fi
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_STRIP+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$STRIP"; then
+ ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+ $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+ { $as_echo "$as_me:$LINENO: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+ ac_ct_STRIP=$STRIP
+ # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_STRIP"; then
+ ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_ac_ct_STRIP="strip"
+ $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+ { $as_echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_STRIP" = x; then
+ STRIP=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ STRIP=$ac_ct_STRIP
+ fi
+else
+ STRIP="$ac_cv_prog_STRIP"
+fi
+
ac_aux_dir=
for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
if test -f "$ac_dir/install-sh"; then
else
lt_cv_nm_interface="BSD nm"
echo "int some_variable = 0;" > conftest.$ac_ext
- (eval echo "\"\$as_me:7171: $ac_compile\"" >&5)
+ (eval echo "\"\$as_me:7263: $ac_compile\"" >&5)
(eval "$ac_compile" 2>conftest.err)
cat conftest.err >&5
- (eval echo "\"\$as_me:7174: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+ (eval echo "\"\$as_me:7266: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
(eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
cat conftest.err >&5
- (eval echo "\"\$as_me:7177: output\"" >&5)
+ (eval echo "\"\$as_me:7269: output\"" >&5)
cat conftest.out >&5
if $GREP 'External.*some_variable' conftest.out > /dev/null; then
lt_cv_nm_interface="MS dumpbin"
;;
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 8382 "configure"' > conftest.$ac_ext
+ echo '#line 8474 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:9749: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:9841: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:9753: \$? = $ac_status" >&5
+ echo "$as_me:9845: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:10088: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:10180: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:10092: \$? = $ac_status" >&5
+ echo "$as_me:10184: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:10193: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:10285: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:10197: \$? = $ac_status" >&5
+ echo "$as_me:10289: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:10248: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:10340: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:10252: \$? = $ac_status" >&5
+ echo "$as_me:10344: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 13051 "configure"
+#line 13143 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 13147 "configure"
+#line 13239 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
AC_PROG_LEX
AC_PROG_YACC
AC_CHECK_PROG(doxygen, doxygen, doxygen)
+AC_CHECK_TOOL(STRIP, strip)
ACX_LIBTOOL_C_ONLY
# Checks for header files.
+15 July 2009: Wouter
+ - dependencies for compat items, for crosscompile.
+ - mingw32 crosscompile changes, dependencies and zipfile creation.
+ and with System.dll from the windows NSIS you can make setup.exe.
+
14 July 2009: Wouter
- updated ldns tarball for solaris x64 compile assistance.
- no need to define RAND_MAX from config.h.
rm -r autom4te* || echo "ignored"
fi
+ # detect crosscompile, from Fedora11 at this point.
+ if test "`uname`" = "Linux"; then
+ cross="yes"
+ configure="mingw32-configure"
+ strip="i686-pc-mingw32-strip"
+ makensis="makensis" # from mingw32-nsis package
+ # on a re-configure the cache may no longer be valid...
+ if test -f mingw32-config.cache; then rm mingw32-config.cache; fi
+ else
+ cross="no" # mingw and msys
+ configure="./configure"
+ strip="strip"
+ makensis="c:/Program Files/NSIS/makensis.exe" # http://nsis.sf.net
+ fi
+
# procedure for making unbound installer on mingw.
info "Creating windows dist unbound $version"
info "Calling configure"
- echo './configure --enable-debug --enable-static-exe '"$*"
- ./configure --enable-debug --enable-static-exe $* \
+ echo "$configure"' --enable-debug --enable-static-exe '"$*"
+ $configure --enable-debug --enable-static-exe $* \
|| error_cleanup "Could not configure"
info "Calling make"
make || error_cleanup "Could not make"
rm -f $file
info "Creating $file"
mkdir tmp.$$
- strip unbound.exe
- strip anchor-update.exe
- strip unbound-control.exe
- strip unbound-host.exe
- strip unbound-checkconf.exe
- strip unbound-service-install.exe
- strip unbound-service-remove.exe
+ $strip unbound.exe
+ $strip anchor-update.exe
+ $strip unbound-control.exe
+ $strip unbound-host.exe
+ $strip unbound-checkconf.exe
+ $strip unbound-service-install.exe
+ $strip unbound-service-remove.exe
cd tmp.$$
cp ../doc/example.conf example.conf
cp ../unbound.exe ../unbound-host.exe ../unbound-control.exe ../unbound-checkconf.exe ../unbound-service-install.exe ../unbound-service-remove.exe ../LICENSE ../winrc/unbound-website.url ../winrc/service.conf ../winrc/README.txt .
info "Creating installer"
quadversion=`cat ../config.h | grep RSRC_PACKAGE_VERSION | sed -e 's/#define RSRC_PACKAGE_VERSION //' -e 's/,/\\./g'`
cat ../winrc/setup.nsi | sed -e 's/define VERSION.*$/define VERSION "'$version'"/' -e 's/define QUADVERSION.*$/define QUADVERSION "'$quadversion'"/' > ../winrc/setup_ed.nsi
- # get tool from http://nsis.sf.net
- c:/Program\ Files/NSIS/makensis.exe ../winrc/setup_ed.nsi
+ "$makensis" ../winrc/setup_ed.nsi
info "Created installer"
cd ..
rm -rf tmp.$$
* IPv6: (h.){32}.ip6.arpa. */
if(addr_is_ip6(&addr, addrlen)) {
- void* ad = &((struct sockaddr_in6*)&addr)->sin6_addr;
+ uint8_t ad[16];
const char* hex = "0123456789abcdef";
char *p = buf;
int i;
+ memmove(ad, &((struct sockaddr_in6*)&addr)->sin6_addr,
+ sizeof(ad));
for(i=15; i>=0; i--) {
- uint8_t b = ((uint8_t*)ad)[i];
+ uint8_t b = ad[i];
*p++ = hex[ (b&0x0f) ];
*p++ = '.';
*p++ = hex[ (b&0xf0) >> 4 ];
}
snprintf(buf+16*4, sizeof(buf)-16*4, "ip6.arpa. ");
} else {
- struct in_addr* ad = &((struct sockaddr_in*)&addr)->sin_addr;
+ uint8_t ad[4];
+ memmove(ad, &((struct sockaddr_in*)&addr)->sin_addr,
+ sizeof(ad));
snprintf(buf, sizeof(buf), "%u.%u.%u.%u.in-addr.arpa. ",
- (unsigned)((uint8_t*)ad)[3], (unsigned)((uint8_t*)ad)[2],
- (unsigned)((uint8_t*)ad)[1], (unsigned)((uint8_t*)ad)[0]);
+ (unsigned)ad[3], (unsigned)ad[2],
+ (unsigned)ad[1], (unsigned)ad[0]);
}
/* printed the reverse address, now the between goop and name on end */
\r
You can crosscompile unbound. This results in .exe files.\r
Install the packages: mingw32-binutils mingw32-cpp mingw32-filesystem \r
-mingw32-gcc mingw32-openssl mingw32-openssl-static mingw32-runtime\r
-mingw32-termcap mingw32-w32api mingw32-zlib mingw32-zlib-static\r
+mingw32-gcc mingw32-openssl mingw32-openssl-static mingw32-runtime zip\r
+mingw32-termcap mingw32-w32api mingw32-zlib mingw32-zlib-static mingw32-nsis\r
(package names for fedora 11).\r
\r
Then run:\r
$ mingw32-configure\r
$ make\r
\r
-It may be a good idea to pass --enable-static-exe --enable-debug to\r
-the mingw32-configure line. This enables statically linked executables\r
-so you do not need to pilfer dlls together, and debug has assertions.\r
+Copy System.dll from the windows dist of NSIS to /usr/share/nsis/Plugins/\r
+Then do ./makedist.sh -w and the setup.exe is created using nsis.\r
\r
\r
+++ CREDITS\r
!include LogicLib.nsh
!include MUI2.nsh
-!include setup_servicelib.nsh
!define VERSION "0.0.0"
!define QUADVERSION "0.0.0.0"
#ReserveFile "System.dll"
#ReserveFile "NsExec.dll"
-!define MUI_ICON "${NSISDIR}\contrib\graphics\icons\orange-install-nsis.ico"
-!define MUI_UNICON "${NSISDIR}\contrib\graphics\icons\orange-uninstall-nsis.ico"
+!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install-nsis.ico"
+!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall-nsis.ico"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_RIGHT
# install service entry
nsExec::ExecToLog '"$INSTDIR\unbound-service-install.exe"'
# start unbound service
- !insertmacro SERVICE "start" "unbound" ""
+ nsExec::ExecToLog '"$INSTDIR\unbound-service-install.exe" start'
sectionEnd
# set section descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_END
# setup macros for uninstall functions.
+!ifdef UN
!undef UN
+!endif
!define UN "un."
# uninstaller section
section "un.Unbound"
# stop unbound service
- !insertmacro SERVICE "stop" "unbound" ""
+ nsExec::ExecToLog '"$INSTDIR\unbound-service-remove.exe" stop'
# uninstall service entry
nsExec::ExecToLog '"$INSTDIR\unbound-service-remove.exe"'
# deregister uninstall
+++ /dev/null
-; Taken from http://nsis.sourceforge.net/NSIS_Service_Lib on 10-mar-2009
-;
-
-; NSIS SERVICE LIBRARY - servicelib.nsh
-; Version 1.5 - Jun 25th, 2008
-; Questions/Comments - dselkirk@hotmail.com
-;
-; Description:
-; Provides an interface to window services
-;
-; Inputs:
-; action - systemlib action ie. create, delete, start, stop, pause,
-; continue, installed, running, status
-; name - name of service to manipulate
-; param - action parameters; usage: var1=value1;var2=value2;...etc.
-; (don't forget to add a ';' after the last value!)
-;
-; Actions:
-; create - creates a new windows service
-; Parameters:
-; path - path to service executable
-; autostart - automatically start with system ie. 1|0
-; interact - interact with the desktop ie. 1|0
-; depend - service dependencies
-; user - user that runs the service
-; password - password of the above user
-; display - display name in service's console
-; description - Description of service
-;
-; delete - deletes a windows service
-; start - start a stopped windows service
-; stop - stops a running windows service
-; pause - pauses a running windows service
-; continue - continues a paused windows service
-; installed - is the provided service installed
-; Parameters:
-; action - if true then invokes the specified action
-; running - is the provided service running
-; Parameters:
-; action - if true then invokes the specified action
-; status - check the status of the provided service
-;
-; If run from uninstall define "UN" as "un." before running.
-;
-; Usage:
-; Method 1:
-; Push "action"
-; Push "name"
-; Push "param"
-; Call Service
-; Pop $0 ;response
-;
-; Method 2:
-; !insertmacro SERVICE "action" "name" "param"
-;
-; History:
-; 1.0 - 09/15/2003 - Initial release
-; 1.1 - 09/16/2003 - Changed &l to i, thx brainsucker
-; 1.2 - 02/29/2004 - Fixed documentation.
-; 1.3 - 01/05/2006 - Fixed interactive flag and pop order (Kichik)
-; 1.4 - 12/07/2006 - Added display and depend, fixed datatypes (Vitoco)
-; 1.5 - 06/25/2008 - Added description of service.(DeSafe.com/liuqixing#gmail.com)
-
-!ifndef SERVICELIB
- !define SERVICELIB
-
- !define SC_MANAGER_ALL_ACCESS 0x3F
- !define SERVICE_ALL_ACCESS 0xF01FF
-
- !define SERVICE_CONTROL_STOP 1
- !define SERVICE_CONTROL_PAUSE 2
- !define SERVICE_CONTROL_CONTINUE 3
-
- !define SERVICE_STOPPED 0x1
- !define SERVICE_START_PENDING 0x2
- !define SERVICE_STOP_PENDING 0x3
- !define SERVICE_RUNNING 0x4
- !define SERVICE_CONTINUE_PENDING 0x5
- !define SERVICE_PAUSE_PENDING 0x6
- !define SERVICE_PAUSED 0x7
-
- !ifndef UN
- !define UN ""
- !endif
-
- !macro SERVICE ACTION NAME PARAM
- Push '${ACTION}'
- Push '${NAME}'
- Push '${PARAM}'
- Call ${UN}Service
- !macroend
-
- !macro FUNC_GETPARAM
- Push $0
- Push $1
- Push $2
- Push $3
- Push $4
- Push $5
- Push $6
- Push $7
- Exch 8
- Pop $1 ;name
- Exch 8
- Pop $2 ;source
- StrCpy $0 ""
- StrLen $7 $2
- StrCpy $3 0
- lbl_loop:
- IntCmp $3 $7 0 0 lbl_done
- StrLen $4 "$1="
- StrCpy $5 $2 $4 $3
- StrCmp $5 "$1=" 0 lbl_next
- IntOp $5 $3 + $4
- StrCpy $3 $5
- lbl_loop2:
- IntCmp $3 $7 0 0 lbl_done
- StrCpy $6 $2 1 $3
- StrCmp $6 ";" 0 lbl_next2
- IntOp $6 $3 - $5
- StrCpy $0 $2 $6 $5
- Goto lbl_done
- lbl_next2:
- IntOp $3 $3 + 1
- Goto lbl_loop2
- lbl_next:
- IntOp $3 $3 + 1
- Goto lbl_loop
- lbl_done:
- Pop $5
- Pop $4
- Pop $3
- Pop $2
- Pop $1
- Exch 2
- Pop $6
- Pop $7
- Exch $0
- !macroend
-
- !macro CALL_GETPARAM VAR NAME DEFAULT LABEL
- Push $1
- Push ${NAME}
- Call ${UN}GETPARAM
- Pop $6
- StrCpy ${VAR} "${DEFAULT}"
- StrCmp $6 "" "${LABEL}" 0
- StrCpy ${VAR} $6
- !macroend
-
- !macro FUNC_SERVICE UN
- Push $0
- Push $1
- Push $2
- Push $3
- Push $4
- Push $5
- Push $6
- Push $7
- Exch 8
- Pop $1 ;param
- Exch 8
- Pop $2 ;name
- Exch 8
- Pop $3 ;action
- ;$0 return
- ;$4 OpenSCManager
- ;$5 OpenService
-
- StrCpy $0 "false"
- System::Call 'advapi32::OpenSCManagerA(n, n, i ${SC_MANAGER_ALL_ACCESS}) i.r4'
- IntCmp $4 0 lbl_done
- StrCmp $3 "create" lbl_create
- System::Call 'advapi32::OpenServiceA(i r4, t r2, i ${SERVICE_ALL_ACCESS}) i.r5'
- IntCmp $5 0 lbl_done
-
- lbl_select:
- StrCmp $3 "delete" lbl_delete
- StrCmp $3 "start" lbl_start
- StrCmp $3 "stop" lbl_stop
- StrCmp $3 "pause" lbl_pause
- StrCmp $3 "continue" lbl_continue
- StrCmp $3 "installed" lbl_installed
- StrCmp $3 "running" lbl_running
- StrCmp $3 "status" lbl_status
- Goto lbl_done
-
- ; create service
- lbl_create:
- Push $R1 ;depend
- Push $R2 ;user
- Push $R3 ;password
- Push $R4 ;interact
- Push $R5 ;autostart
- Push $R6 ;path
- Push $R7 ;display
- Push $R8 ;description
-
- !insertmacro CALL_GETPARAM $R1 "depend" "n" "lbl_depend"
- StrCpy $R1 't "$R1"'
- lbl_depend:
- StrCmp $R1 "n" 0 lbl_machine ;old name of depend param
- !insertmacro CALL_GETPARAM $R1 "machine" "n" "lbl_machine"
- StrCpy $R1 't "$R1"'
- lbl_machine:
-
- !insertmacro CALL_GETPARAM $R2 "user" "n" "lbl_user"
- StrCpy $R2 't "$R2"'
- lbl_user:
-
- !insertmacro CALL_GETPARAM $R3 "password" "n" "lbl_password"
- StrCpy $R3 't "$R3"'
- lbl_password:
-
- !insertmacro CALL_GETPARAM $R4 "interact" "0x10" "lbl_interact"
- StrCpy $6 0x10
- IntCmp $R4 0 +2
- IntOp $6 $6 | 0x100
- StrCpy $R4 $6
- lbl_interact:
-
- !insertmacro CALL_GETPARAM $R5 "autostart" "0x3" "lbl_autostart"
- StrCpy $6 0x3
- IntCmp $R5 0 +2
- StrCpy $6 0x2
- StrCpy $R5 $6
- lbl_autostart:
-
- !insertmacro CALL_GETPARAM $R6 "path" "n" "lbl_path"
- lbl_path:
-
- !insertmacro CALL_GETPARAM $R7 "display" "$2" "lbl_display"
- lbl_display:
-
- !insertmacro CALL_GETPARAM $R8 "description" "$2" "lbl_description"
- lbl_description:
-
- System::Call 'advapi32::CreateServiceA(i r4, t r2, t R7, i ${SERVICE_ALL_ACCESS}, \
- i R4, i R5, i 0, t R6, n, n, $R1, $R2, $R3) i.r6'
-
- ; write description of service
- WriteRegStr HKLM "SYSTEM\ControlSet001\Services\$2" "Description" $R8
-
- Pop $R8
- Pop $R7
- Pop $R6
- Pop $R5
- Pop $R4
- Pop $R3
- Pop $R2
- Pop $R1
- StrCmp $6 0 lbl_done lbl_good
-
- ; delete service
- lbl_delete:
- System::Call 'advapi32::DeleteService(i r5) i.r6'
- StrCmp $6 0 lbl_done lbl_good
-
- ; start service
- lbl_start:
- System::Call 'advapi32::StartServiceA(i r5, i 0, i 0) i.r6'
- StrCmp $6 0 lbl_done lbl_good
-
- ; stop service
- lbl_stop:
- Push $R1
- System::Call '*(i,i,i,i,i,i,i) i.R1'
- System::Call 'advapi32::ControlService(i r5, i ${SERVICE_CONTROL_STOP}, i $R1) i'
- System::Free $R1
- Pop $R1
- StrCmp $6 0 lbl_done lbl_good
-
- ; pause service
- lbl_pause:
- Push $R1
- System::Call '*(i,i,i,i,i,i,i) i.R1'
- System::Call 'advapi32::ControlService(i r5, i ${SERVICE_CONTROL_PAUSE}, i $R1) i'
- System::Free $R1
- Pop $R1
- StrCmp $6 0 lbl_done lbl_good
-
- ; continue service
- lbl_continue:
- Push $R1
- System::Call '*(i,i,i,i,i,i,i) i.R1'
- System::Call 'advapi32::ControlService(i r5, i ${SERVICE_CONTROL_CONTINUE}, i $R1) i'
- System::Free $R1
- Pop $R1
- StrCmp $6 0 lbl_done lbl_good
-
- ; is installed
- lbl_installed:
- !insertmacro CALL_GETPARAM $7 "action" "" "lbl_good"
- StrCpy $3 $7
- Goto lbl_select
-
- ; is service running
- lbl_running:
- Push $R1
- System::Call '*(i,i,i,i,i,i,i) i.R1'
- System::Call 'advapi32::QueryServiceStatus(i r5, i $R1) i'
- System::Call '*$R1(i, i.r6)'
- System::Free $R1
- Pop $R1
- IntFmt $6 "0x%X" $6
- StrCmp $6 ${SERVICE_RUNNING} 0 lbl_done
- !insertmacro CALL_GETPARAM $7 "action" "" "lbl_good"
- StrCpy $3 $7
- Goto lbl_select
-
- lbl_status:
- Push $R1
- System::Call '*(i,i,i,i,i,i,i) i.R1'
- System::Call 'advapi32::QueryServiceStatus(i r5, i $R1) i'
- System::Call '*$R1(i, i .r6)'
- System::Free $R1
- Pop $R1
- IntFmt $6 "0x%X" $6
- StrCpy $0 "running"
- IntCmp $6 ${SERVICE_RUNNING} lbl_done
- StrCpy $0 "stopped"
- IntCmp $6 ${SERVICE_STOPPED} lbl_done
- StrCpy $0 "start_pending"
- IntCmp $6 ${SERVICE_START_PENDING} lbl_done
- StrCpy $0 "stop_pending"
- IntCmp $6 ${SERVICE_STOP_PENDING} lbl_done
- StrCpy $0 "running"
- IntCmp $6 ${SERVICE_RUNNING} lbl_done
- StrCpy $0 "continue_pending"
- IntCmp $6 ${SERVICE_CONTINUE_PENDING} lbl_done
- StrCpy $0 "pause_pending"
- IntCmp $6 ${SERVICE_PAUSE_PENDING} lbl_done
- StrCpy $0 "paused"
- IntCmp $6 ${SERVICE_PAUSED} lbl_done
- StrCpy $0 "unknown"
- Goto lbl_done
-
- lbl_good:
- StrCpy $0 "true"
- lbl_done:
- IntCmp $5 0 +2
- System::Call 'advapi32::CloseServiceHandle(i r5) n'
- IntCmp $4 0 +2
- System::Call 'advapi32::CloseServiceHandle(i r4) n'
- Pop $4
- Pop $3
- Pop $2
- Pop $1
- Exch 3
- Pop $5
- Pop $7
- Pop $6
- Exch $0
- !macroend
-
- Function Service
- !insertmacro FUNC_SERVICE ""
- FunctionEnd
-
- Function un.Service
- !insertmacro FUNC_SERVICE "un."
- FunctionEnd
-
- Function GetParam
- !insertmacro FUNC_GETPARAM
- FunctionEnd
-
- Function un.GetParam
- !insertmacro FUNC_GETPARAM
- FunctionEnd
-
-!endif
#include "winrc/w_inst.h"
/** Install service main */
-int main(int ATTR_UNUSED(argc), char** ATTR_UNUSED(argv))
+int main(int argc, char** argv)
{
- /*FILE* out = fopen("unbound-service-install.log", "w");*/
- wsvc_install(NULL, "unbound-service-install.exe");
+ FILE* out = stdout;
+ /* out = fopen("unbound-service-install.log", "w");*/
+ if(argc == 2 && strcmp(argv[1], "start")==0) {
+ wsvc_rc_start(out);
+ return 0;
+ }
+ if(argc != 1) {
+ if(out) fprintf(out, "Usage: %s [start]\n", argv[0]);
+ else printf("Usage: %s [start]\n", argv[0]);
+ return 1;
+ }
+ wsvc_install(out, "unbound-service-install.exe");
return 0;
}
/*
- * winrc/unbound-service-install.c - windows services installation util
+ * winrc/unbound-service-remove.c - windows services installation util
*
* Copyright (c) 2009, NLnet Labs. All rights reserved.
*
#include "config.h"
#include "winrc/w_inst.h"
-/** Install service main */
-int main(int ATTR_UNUSED(argc), char** ATTR_UNUSED(argv))
+/** Remove service main */
+int main(int argc, char** argv)
{
- /*FILE* out = fopen("unbound-service-remove.log", "w");*/
+ FILE* out = stdout;
+ /* out = fopen("unbound-service-remove.log", "w");*/
+ if(argc == 2 && strcmp(argv[1], "stop")==0) {
+ wsvc_rc_stop(out);
+ return 0;
+ }
+ if(argc != 1) {
+ if(out) fprintf(out, "Usage: %s [stop]\n", argv[0]);
+ else printf("Usage: %s [stop]\n", argv[0]);
+ return 1;
+ }
wsvc_remove(NULL);
return 0;
}
#include "winrc/w_inst.h"
#include "winrc/win_svc.h"
+void wsvc_err2str(char* str, size_t len, const char* fixed, DWORD err)
+{
+ LPTSTR buf;
+ if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_ALLOCATE_BUFFER,
+ NULL, err, 0, (LPTSTR)&buf, 0, NULL) == 0) {
+ /* could not format error message */
+ snprintf(str, len, "%s GetLastError=%d", fixed, (int)err);
+ return;
+ }
+ snprintf(str, len, "%s (err=%d): %s", fixed, (int)err, buf);
+ LocalFree(buf);
+}
+
/** exit with windows error */
static void
fatal_win(FILE* out, const char* str)
{
- if(out) fprintf(out, "%s (%d)\n", str, (int)GetLastError());
+ char e[256];
+ wsvc_err2str(e, sizeof(e), str, (int)GetLastError());
+ if(out) fprintf(out, "%s\n", e);
+ else fprintf(stderr, "%s\n", e);
exit(1);
}
if(out) fprintf(out, "unbound service installed\n");
}
+
/* Remove installed service from servicecontrolmanager */
void
wsvc_remove(FILE* out)
fatal_win(out, "could not OpenService");
}
if(!DeleteService(sv)) {
+ CloseServiceHandle(sv);
+ CloseServiceHandle(scm);
fatal_win(out, "could not DeleteService");
}
CloseServiceHandle(sv);
event_reg_remove(out);
if(out) fprintf(out, "unbound service removed\n");
}
+
+
+/* Start daemon */
+void
+wsvc_rc_start(FILE* out)
+{
+ SC_HANDLE scm;
+ SC_HANDLE sv;
+ if(out) fprintf(out, "start unbound service\n");
+ scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
+ if(!scm) fatal_win(out, "could not OpenSCManager");
+ sv = OpenService(scm, SERVICE_NAME, SERVICE_START);
+ if(!sv) {
+ CloseServiceHandle(scm);
+ fatal_win(out, "could not OpenService");
+ }
+ if(!StartService(sv, 0, NULL)) {
+ CloseServiceHandle(sv);
+ CloseServiceHandle(scm);
+ fatal_win(out, "could not StartService");
+ }
+ CloseServiceHandle(sv);
+ CloseServiceHandle(scm);
+ if(out) fprintf(out, "unbound service started\n");
+}
+
+
+/* Stop daemon */
+void
+wsvc_rc_stop(FILE* out)
+{
+ SC_HANDLE scm;
+ SC_HANDLE sv;
+ SERVICE_STATUS st;
+ if(out) fprintf(out, "stop unbound service\n");
+ scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
+ if(!scm) fatal_win(out, "could not OpenSCManager");
+ sv = OpenService(scm, SERVICE_NAME, SERVICE_STOP);
+ if(!sv) {
+ CloseServiceHandle(scm);
+ fatal_win(out, "could not OpenService");
+ }
+ if(!ControlService(sv, SERVICE_CONTROL_STOP, &st)) {
+ CloseServiceHandle(sv);
+ CloseServiceHandle(scm);
+ fatal_win(out, "could not ControlService");
+ }
+ CloseServiceHandle(sv);
+ CloseServiceHandle(scm);
+ if(out) fprintf(out, "unbound service stopped\n");
+}
*/
void wsvc_remove(FILE* out);
+/**
+ * Start the service from servicecontrolmanager, tells OS to start daemon.
+ * @param out: debug output printed here (errors). or NULL.
+ */
+void wsvc_rc_start(FILE* out);
+
+/**
+ * Stop the service from servicecontrolmanager, tells OS to stop daemon.
+ * @param out: debug output printed here (errors). or NULL.
+ */
+void wsvc_rc_stop(FILE* out);
+
+/**
+ * Convert windows GetLastError() value to a neat string.
+ * @param str: destination buffer
+ * @param len: length of dest buffer
+ * @param fixed: fixed text to prepend to string.
+ * @param err: the GetLastError() value.
+ */
+void wsvc_err2str(char* str, size_t len, const char* fixed, DWORD err);
+
#endif /* WINRC_W_INST_H */
reportev(const char* str)
{
char b[256];
+ char e[256];
HANDLE* s;
LPCTSTR msg = b;
/* print quickly to keep GetLastError value */
- snprintf(b, sizeof(b), "%s: %s (%d)", SERVICE_NAME,
- str, (int)GetLastError());
+ wsvc_err2str(e, sizeof(e), str, GetLastError());
+ snprintf(b, sizeof(b), "%s: %s", SERVICE_NAME, e);
s = RegisterEventSource(NULL, SERVICE_NAME);
if(!s) return;
ReportEvent(s, /* event log */