mirror of
https://github.com/cofyc/dnscrypt-wrapper.git
synced 2024-10-03 22:58:01 +03:00
add configure.ac
This commit is contained in:
parent
d985a1ff7b
commit
ed2662b10b
18
.gitignore
vendored
18
.gitignore
vendored
@ -1,5 +1,23 @@
|
|||||||
*.[aos]
|
*.[aos]
|
||||||
*.out
|
*.out
|
||||||
|
*.tar.gz
|
||||||
|
*.pyc
|
||||||
*~
|
*~
|
||||||
/tags
|
/tags
|
||||||
/dnscrypt-wrapper
|
/dnscrypt-wrapper
|
||||||
|
/version.h
|
||||||
|
/test-*
|
||||||
|
!test-*.c
|
||||||
|
*.so
|
||||||
|
*.so.dSYM/
|
||||||
|
.depend/
|
||||||
|
/tests/tmp/
|
||||||
|
/config.log
|
||||||
|
/configure
|
||||||
|
/autom4te.cache/
|
||||||
|
/config.mak.autogen
|
||||||
|
/config.mak
|
||||||
|
/config.status
|
||||||
|
/MAIN-CFLAGS
|
||||||
|
/MAIN-LDFLAGS
|
||||||
|
*.pid
|
||||||
|
170
Makefile
170
Makefile
@ -1,22 +1,74 @@
|
|||||||
# dnscrypt-wrapper Makefile
|
# The default target of this Makefile is...
|
||||||
#
|
|
||||||
# The default target
|
|
||||||
all::
|
all::
|
||||||
|
|
||||||
|
# Section starts with '###'.
|
||||||
|
#
|
||||||
|
# Define V=1 to have a more verbose compile.
|
||||||
|
|
||||||
|
### Defaults
|
||||||
|
|
||||||
|
BASIC_CFLAGS = -O2 -std=c99 -pedantic -Wall -I./argparse
|
||||||
|
BASIC_LDFLAGS = -lm -lsodium -levent
|
||||||
|
|
||||||
|
# Guard against environment variables
|
||||||
|
LIB_H =
|
||||||
|
LIB_OBJS =
|
||||||
|
DEP_LIBS =
|
||||||
|
|
||||||
|
# Having this variable in your environment would break pipelines because you
|
||||||
|
# case "cd" to echo its destination to stdout.
|
||||||
|
unexport CDPATH
|
||||||
|
|
||||||
|
### Configurations
|
||||||
|
|
||||||
|
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
|
||||||
|
uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
|
||||||
|
uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
|
||||||
|
uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
|
||||||
|
uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
|
||||||
|
uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
|
||||||
|
|
||||||
|
# CFLAGS and LDFLAGS are for users to override
|
||||||
|
CFLAGS = -g -O2 -Wall
|
||||||
|
LDFLAGS =
|
||||||
|
STRIP ?= strip
|
||||||
|
|
||||||
|
# We use ALL_* variants
|
||||||
|
ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS)
|
||||||
|
ALL_LDFLAGS = $(LDFLAGS) $(BASIC_LDFLAGS)
|
||||||
|
|
||||||
|
prefix = /usr/local
|
||||||
|
bindir = $(prefix)/bin
|
||||||
|
sharedir = $(prefix)/share
|
||||||
|
mandir = share/man
|
||||||
|
infodir = share/info
|
||||||
|
export prefix bindir sharedir
|
||||||
|
|
||||||
CC = cc
|
CC = cc
|
||||||
RM = rm -rf
|
RM = rm -rf
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
BINDIR = $(PREFIX)/bin
|
BINDIR = $(PREFIX)/bin
|
||||||
|
|
||||||
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
|
|
||||||
|
|
||||||
FINAL_CFLAGS = $(CFLAGS) -O2 -std=c99 -pedantic -Wall
|
|
||||||
FINAL_LDFLAGS = $(LDFLAGS) -lm -lsodium -levent
|
|
||||||
|
|
||||||
ifeq ($(uname_S),Linux)
|
ifeq ($(uname_S),Linux)
|
||||||
FINAL_LDFLAGS += -lrt
|
ALL_LDFLAGS += -lrt
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifneq ($(findstring $(MAKEFLAGS),s), s)
|
||||||
|
ifndef V
|
||||||
|
QUIET_CC = @echo ' ' CC $@;
|
||||||
|
QUIET_AR = @echo ' ' AR $@;
|
||||||
|
QUIET_LINK = @echo ' ' LINK $@;
|
||||||
|
QUIET_GEN = @echo ' ' GEN $@;
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# configuration generated by ./configure script
|
||||||
|
-include config.mak.autogen
|
||||||
|
# manual configuration
|
||||||
|
-include config.mak
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
LIB_H = dnscrypt.h udp_request.h edns.h logger.h argparse/argparse.h
|
LIB_H = dnscrypt.h udp_request.h edns.h logger.h argparse/argparse.h
|
||||||
|
|
||||||
LIB_OBJS += dnscrypt.o
|
LIB_OBJS += dnscrypt.o
|
||||||
@ -24,13 +76,79 @@ LIB_OBJS += udp_request.o
|
|||||||
LIB_OBJS += tcp_request.o
|
LIB_OBJS += tcp_request.o
|
||||||
LIB_OBJS += edns.o
|
LIB_OBJS += edns.o
|
||||||
LIB_OBJS += logger.o
|
LIB_OBJS += logger.o
|
||||||
LIB_OBJS += main.o
|
|
||||||
LIB_OBJS += rfc1035.o
|
LIB_OBJS += rfc1035.o
|
||||||
LIB_OBJS += safe_rw.o
|
LIB_OBJS += safe_rw.o
|
||||||
LIB_OBJS += cert.o
|
LIB_OBJS += cert.o
|
||||||
LIB_OBJS += pidfile.o
|
LIB_OBJS += pidfile.o
|
||||||
|
|
||||||
LDADD += argparse/libargparse.a
|
DEP_LIBS += argparse/libargparse.a
|
||||||
|
|
||||||
|
### Automatically dependencies rules
|
||||||
|
|
||||||
|
OBJECTS := $(LIB_OBJS) main.o
|
||||||
|
|
||||||
|
ifndef COMPUTE_HEADER_DEPENDENCIES
|
||||||
|
COMPUTE_HEADER_DEPENDENCIES = auto
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(COMPUTE_HEADER_DEPENDENCIES),auto)
|
||||||
|
dep_check = $(shell $(CC) \
|
||||||
|
-c -MF /dev/null -MMD -MP -x c /dev/null -o /dev/null 2>&1; \
|
||||||
|
echo $$?)
|
||||||
|
ifeq ($(dep_check),0)
|
||||||
|
override COMPUTE_HEADER_DEPENDENCIES = yes
|
||||||
|
else
|
||||||
|
override COMPUTE_HEADER_DEPENDENCIES = no
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
|
||||||
|
USE_COMPUTED_HEADER_DEPENDENCIES = YesPlease
|
||||||
|
else
|
||||||
|
ifneq ($(COMPUTE_HEADER_DEPENDENCIES),no)
|
||||||
|
$(error please set COMPUTE_HEADER_DEPENDENCIES to yes, no, or auto \
|
||||||
|
(not "$(COMPUTE_HEADER_DEPENDENCIES)"))
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d)
|
||||||
|
dep_dirs := $(addsuffix .depend,$(sort $(dir $(OBJECTS))))
|
||||||
|
|
||||||
|
ifeq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
|
||||||
|
$(dep_dirs):
|
||||||
|
@mkdir -p $@
|
||||||
|
missing_dep_dirs := $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs))
|
||||||
|
dep_file = $(dir $@).depend/$(notdir $@).d
|
||||||
|
dep_args = -MF $(dep_file) -MMD -MP
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef USE_COMPUTED_HEADER_DEPENDENCIES
|
||||||
|
# Take advantage of gcc's on-the-fly dependency generation
|
||||||
|
# See <http://gcc.gnu.org/gcc-3.0/features.html>.
|
||||||
|
dep_files_present := $(wildcard $(dep_files))
|
||||||
|
ifneq ($(dep_files_present),)
|
||||||
|
include $(dep_files_present)
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
$(OBJECTS): $(LIB_H)
|
||||||
|
endif
|
||||||
|
|
||||||
|
### Build rules
|
||||||
|
|
||||||
|
configure: configure.ac
|
||||||
|
$(QUIET_GEN)autoconf -o $@ $<
|
||||||
|
|
||||||
|
ifdef AUTOCONFIGURED
|
||||||
|
config.status: configure
|
||||||
|
$(QUIET_GEN)if test -f config.status; then \
|
||||||
|
./config.status --recheck; \
|
||||||
|
else \
|
||||||
|
./configure; \
|
||||||
|
fi
|
||||||
|
reconfigure config.mak.autogen: config.status
|
||||||
|
$(QUIET_LINK)./config.status
|
||||||
|
.PHONY: reconfigure # This is a convenience target.
|
||||||
|
endif
|
||||||
|
|
||||||
argparse/libargparse.a: argparse/argparse.h
|
argparse/libargparse.a: argparse/argparse.h
|
||||||
@$(MAKE) -C argparse libargparse.a
|
@$(MAKE) -C argparse libargparse.a
|
||||||
@ -40,15 +158,33 @@ argparse/argparse.h:
|
|||||||
|
|
||||||
$(LIB_OBJS): $(LIB_H)
|
$(LIB_OBJS): $(LIB_H)
|
||||||
|
|
||||||
all:: dnscrypt-wrapper
|
TRACK_CFLAGS = $(CC):$(subst ','\'',$(ALL_CFLAGS))
|
||||||
|
|
||||||
%.o: %.c
|
MAIN-CFLAGS: FORCE
|
||||||
$(CC) $(FINAL_CFLAGS) -c $<
|
@FLAGS='$(TRACK_CFLAGS)'; \
|
||||||
|
if test x"$$FLAGS" != x"`cat MAIN-CFLAGS 2>/dev/null`"; then \
|
||||||
|
echo "$$FLAGS" > $@; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
TRACK_LDFLAGS = $(subst ','\'',$(ALL_LDFLAGS))
|
||||||
|
|
||||||
|
MAIN-LDFLAGS: FORCE
|
||||||
|
@FLAGS='$(TRACK_LDFLAGS)'; \
|
||||||
|
if test x"$$FLAGS" != x"`cat MAIN-LDFLAGS 2>/dev/null`"; then \
|
||||||
|
echo "$$FLAGS" > $@; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
$(OBJECTS): %.o: %.c $(missing_dep_dirs) MAIN-CFLAGS
|
||||||
|
$(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $<
|
||||||
|
|
||||||
|
dnscrypt-wrapper: $(OBJECTS) $(DEP_LIBS) MAIN-LDFLAGS
|
||||||
|
$(QUIET_LINK)$(CC) -o $@ $(filter %.o %.a,$^) $(ALL_LDFLAGS)
|
||||||
|
|
||||||
main.o: version.h
|
main.o: version.h
|
||||||
|
|
||||||
dnscrypt-wrapper: $(LIB_OBJS) $(LDADD)
|
all:: dnscrypt-wrapper
|
||||||
$(CC) $(FINAL_CFLAGS) -o $@ $^ $(FINAL_LDFLAGS)
|
|
||||||
|
### Misc rules
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
install -p -m 755 dnscrypt-wrapper $(BINDIR)
|
install -p -m 755 dnscrypt-wrapper $(BINDIR)
|
||||||
@ -60,4 +196,4 @@ clean:
|
|||||||
$(RM) dnscrypt-wrapper
|
$(RM) dnscrypt-wrapper
|
||||||
$(RM) $(LIB_OBJS)
|
$(RM) $(LIB_OBJS)
|
||||||
|
|
||||||
.PHONY: all install uninstall clean
|
.PHONY: all install uninstall clean FORCE
|
||||||
|
16
config.mak.in
Normal file
16
config.mak.in
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# Makefile configuration, included by Makefile.
|
||||||
|
|
||||||
|
CC = @CC@
|
||||||
|
CFLAGS = @CFLAGS@
|
||||||
|
CPPFLAGS = @CPPFLAGS@
|
||||||
|
LDFLAGS = @LDFLAGS@
|
||||||
|
AR = @AR@
|
||||||
|
TAR = @TAR@
|
||||||
|
|
||||||
|
prefix = @prefix@
|
||||||
|
exec_prefix = @exec_prefix@
|
||||||
|
bindir = @bindir@
|
||||||
|
datarootdir = @datarootdir@
|
||||||
|
sysconfdir = @sysconfdir@
|
||||||
|
srcdir = @srcdir@
|
||||||
|
mandir=@mandir@
|
89
configure.ac
Normal file
89
configure.ac
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
#
|
||||||
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
#
|
||||||
|
# Run ./configure with your options to generate config.mak.autogen file which
|
||||||
|
# is used by Makefile.
|
||||||
|
#
|
||||||
|
|
||||||
|
## Definitions of private macros.
|
||||||
|
|
||||||
|
# CONF_SUBST_INIT
|
||||||
|
# -------------------
|
||||||
|
# Prepare shell variables and autoconf machine required by later calls
|
||||||
|
# to CONF_SUBST.
|
||||||
|
AC_DEFUN([CONF_SUBST_INIT],
|
||||||
|
[config_appended_defs=; newline='
|
||||||
|
'
|
||||||
|
AC_CONFIG_COMMANDS([$config_file],
|
||||||
|
[echo "$config_appended_defs" >> "$config_file"],
|
||||||
|
[config_file=$config_file
|
||||||
|
config_appended_defs="$config_appended_defs"])]
|
||||||
|
)
|
||||||
|
|
||||||
|
# CONF_SUBST(VAL, VAR)
|
||||||
|
# ------------------------
|
||||||
|
# Cause the line "VAR=VAL" to be eventually appended to ${config_file}.
|
||||||
|
AC_DEFUN([CONF_SUBST], [AC_REQUIRE([CONF_SUBST_INIT])
|
||||||
|
config_appended_defs="$config_appended_defs${newline}dnl
|
||||||
|
$1=m4_if([$#],[1],[${$1}],[$2])"]
|
||||||
|
)
|
||||||
|
|
||||||
|
## Configure body starts here.
|
||||||
|
|
||||||
|
AC_PREREQ([2.59])
|
||||||
|
AC_INIT
|
||||||
|
|
||||||
|
config_file=config.mak.autogen
|
||||||
|
config_in=config.mak.in
|
||||||
|
|
||||||
|
# AUTOCONFIGURED
|
||||||
|
CONF_SUBST([AUTOCONFIGURED], [YesPlease])
|
||||||
|
|
||||||
|
# Checks for programs
|
||||||
|
AC_PROG_CC
|
||||||
|
AC_CHECK_TOOLS(AR, [gar ar], :)
|
||||||
|
AC_CHECK_PROGS(TAR, [gtar tar])
|
||||||
|
|
||||||
|
# libevent
|
||||||
|
AC_ARG_WITH(event,
|
||||||
|
[AS_HELP_STRING([--with-event=DIR], [where to find the event library])],
|
||||||
|
[if test -d "$withval"; then
|
||||||
|
LDFLAGS="$LDFLAGS -L$withval/lib"
|
||||||
|
CFLAGS="$CFLAGS -I$withval/include"
|
||||||
|
fi],
|
||||||
|
withval=yes # default
|
||||||
|
)
|
||||||
|
if test "$withval" != no; then
|
||||||
|
AC_CHECK_LIB(event,event_base_new,
|
||||||
|
[LIBS="-levent $LIBS"],
|
||||||
|
[AC_MSG_ERROR([event is required - see http://libevent.org/])]
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# libsodium
|
||||||
|
AC_ARG_WITH(sodium,
|
||||||
|
[AS_HELP_STRING([--with-sodium=DIR], [where to find the event library])],
|
||||||
|
[if test -d "$withval"; then
|
||||||
|
LDFLAGS="$LDFLAGS -L$withval/lib"
|
||||||
|
CFLAGS="$CFLAGS -I$withval/include"
|
||||||
|
fi],
|
||||||
|
withval=yes # default
|
||||||
|
)
|
||||||
|
if test "$withval" != no; then
|
||||||
|
AC_CHECK_LIB(sodium,sodium_init,
|
||||||
|
[LIBS="-lsodium $LIBS"],
|
||||||
|
[AC_MSG_ERROR([sodium is required - see https://github.com/jedisct1/libsodium])]
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Output files
|
||||||
|
AC_CONFIG_FILES(["${config_file}":"${config_in}"])
|
||||||
|
AC_OUTPUT
|
||||||
|
|
||||||
|
# Show summary.
|
||||||
|
AC_MSG_RESULT([
|
||||||
|
Configuration summary:
|
||||||
|
|
||||||
|
Support for event library: $ac_cv_lib_event_event_base_new
|
||||||
|
Support for sodium library: $ac_cv_lib_sodium_sodium_init
|
||||||
|
])
|
Loading…
Reference in New Issue
Block a user