-BUILDDIR = $(PWD)/build
-SRCDIR = $(PWD)/src
+MAKEFLAGS += --no-print-directory
+
+TOPDIR = $(shell pwd)
+BUILDDIR = $(TOPDIR)/build
+SRCDIR = $(TOPDIR)/src
+PREFIX = /usr/local
+
+include $(TOPDIR)/libcmdline.vars.mk
+
+export TOPDIR
+export BUILDDIR
+export SRCDIR
+export PREFIX
SUBDIRS = lib
+SUBDIRS += calculator_server
SUBDIRS += trivial_rdline
SUBDIRS += extension_example
SUBDIRS += calculator_standalone
-SUBDIRS += calculator_server
SUBDIRS += client
-SUBDIRS += event_server
SUBDIRS += genconf
+ifeq ($(HAVE_EVENT_LIB),y)
+SUBDIRS += event_server
+endif
-# configuration for lib, not adviced to modify it except for
-# really small devices, because it changes the API.
-# CFLAGS += -DNO_RDLINE_HISTORY
-# CFLAGS += -DNO_RDLINE_KILL_BUF
-CFLAGS += -DCMDLINE_HAVE_FLOAT
-CFLAGS += -DCMDLINE_HAVE_SOCKET
-
-CFLAGS += -Wall -Werror
-CFLAGS += -O0 -g
-
-CFLAGS += -I$(SRCDIR)/lib
-
-# needed if you want to parse float
-LDFLAGS += -lm
-
-
-export CFLAGS LDFLAGS
-
-_all: all
-
-all clean:
- for i in $(SUBDIRS) ; do \
- make -C ${BUILDDIR}/$$i \
- VPATH=${SRCDIR}/$$i $@ || exit $$? ; \
- done
+include $(TOPDIR)/libcmdline.subdir.mk