aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2016-10-26 14:07:43 +0200
committerKarel Kočí <cynerd@email.cz>2016-10-26 14:07:43 +0200
commitde427bb856c7d0a19bbed031cd8f7b36de9ed605 (patch)
treec8e2bb2d8128efe84e12adcf652253e63eebbedb
parentd9494c07ad3a89a2435b0a6306dc634cf5a346e5 (diff)
downloadgeml-de427bb856c7d0a19bbed031cd8f7b36de9ed605.tar.gz
geml-de427bb856c7d0a19bbed031cd8f7b36de9ed605.tar.bz2
geml-de427bb856c7d0a19bbed031cd8f7b36de9ed605.zip
Update configure script
-rw-r--r--Makefile81
-rwxr-xr-xconfigure60
2 files changed, 59 insertions, 82 deletions
diff --git a/Makefile b/Makefile
index 78414f4..3a5f87e 100644
--- a/Makefile
+++ b/Makefile
@@ -5,23 +5,14 @@ MAKEFLAGS += --no-builtin-rules
# than default.
O ?= .
# This variable can be overwritten to show executed commands
-Q = @
+Q ?= @
# Load configuration
-include $(O)/.config.mk
-
-# TODO add CROSS_COMPILE support
-BISON ?= bison
-CC ?= gcc
-# TODO also other tools
-
-
.PHONY: all
all: $(O)/geml
-# TODO modules
-
ifeq ($(DEBUG),yes)
CFLAGS += -ggdb -DDEBUG
endif
@@ -32,17 +23,10 @@ CFLAGS += -Iinclude -include $(O)/build/config.h
SRC = geml.c \
utils.c \
io.c \
- command.c \
parser.c
### End of source files list ####################
CSRC = $(patsubst %,src/%,$(filter %.c,$(SRC)))
-YSRC = $(patsubst %,src/%,$(filter %.y,$(SRC)))
-CYSRC = $(patsubst %,%.c,$(YSRC))
-HYSRC = $(patsubst %,%.h,$(YSRC))
-CSRC += $(CYSRC)
-GPERFSRC = $(patsubst %,src/%,$(filter %.gperf,$(SRC)))
-HGPERFSRC = $(patsubst %,%.h,$(GPERFSRC))
OBJ = $(patsubst src/%.c,$(O)/build/%.o,$(CSRC))
DEP = $(patsubst src/%.c,$(O)/build/%.d,$(CSRC))
@@ -57,11 +41,11 @@ help:
@echo " clean - Cleans builded files"
@echo " distclean - Same as clean but also removes distributed generated files"
@echo " docs - Build html documentation"
- @echo " serve-docs - Start html server with documentation on localhost:4000"
+ @echo " serve-docs - Start html server with documentation on localhost:8000"
@echo " clean-docs - Removes generated documentation"
@echo "Some enviroment variables to be defined:"
- @echo " CROSS_COMPILE - Specifies installation prefix. Default is /usr/local"
@echo " Q - Define emty to show executed commands"
+ @echo " O - Output path."
.PHONY: install
install:
@@ -80,34 +64,13 @@ clean::
$(Q)$(RM) $(O)/geml
.PHONY: distclean
distclean:: clean
- @echo " CLEAN distributed"
- $(Q)$(RM) $(CYSRC)
- $(Q)$(RM) $(HYSRC)
- $(Q)$(RM) $(HGPERFSRC)
@echo " CLEAN configuration"
$(Q)$(RM) $(O)/.config
-docs/%.dot.png: docs/%.dot
- @echo " DOT $@"
- $(Q)dot -Tpng -O $<
-
-.PHONY: docs
-docs: docs/parser-states.dot.png
- @echo " DOC $@"
- $(Q)mkdocs build
-
-.PHONY: serve-docs
-serve-docs: docs/parser-states.dot.png
- $(Q)mkdocs serve
-
-.PHONY: clean-docs
-clean-docs:
- @echo " CLEAN docs"
- $(Q)$(RM) docs/parser-states.dot.png
- $(Q)$(RM) -r site
-
+## Building targets ##
ifeq (,$(filter clean distclean help docs serve-docs clean-docs \
,$(MAKECMDGOALS))) # Ignore build targets if goal is not building
+
ifeq ($(DEBUG),yes)
-include $(DEP) # If developing, use dependencies from source files
.PHONY: dependency dep
@@ -120,7 +83,7 @@ endif # DEBUG
$(O)/geml: $(OBJ)
@echo " LD $@"
- $(Q)$(CC) $(CFLAGS) $^ -o $@
+ $(Q)$(CC) $(LDFLAGS) $^ -o $@
$(OBJ): $(O)/build/%.o: src/%.c $(O)/build/config.h
@mkdir -p "$(@D)"
@@ -131,22 +94,32 @@ $(O)/build/config.h: $(O)/.config
@mkdir -p "$(@D)"
@echo " CONF $@"
$(Q)./configure --op-h > $@
-
-$(HGPERFSRC): %.y.h: %.y.c
- @
-$(CYSRC): %.y.c: %.y
- @echo " BISON $@"
- $(Q)$(BISON) -d -o $@ $<
-
-$(HGPERFSRC): %.h: %
- @echo " GPERF $@"
- $(Q)$(GPERF) --output-file=$@ $<
endif
-# Configuation files
+## Configuation files ##
$(O)/.config:
$(error Please run configure script first)
$(O)/.config.mk: $(O)/.config
@echo " CONF $@"
$(Q)./configure --op-makefile > $@
+
+## Documentation targets ##
+.PHONY: docs
+docs: docs/parser-states.dot.png
+ @echo " DOC $@"
+ $(Q)$(MKDOCS) build
+
+.PHONY: serve-docs
+serve-docs: docs/parser-states.dot.png
+ $(Q)$(MKDOCS) serve
+
+.PHONY: clean-docs
+clean-docs:
+ @echo " CLEAN docs"
+ $(Q)$(RM) docs/parser-states.dot.png
+ $(Q)$(RM) -r site
+
+docs/%.dot.png: docs/%.dot
+ @echo " DOT $@"
+ $(Q)$(DOT) -Tpng -O $<
diff --git a/configure b/configure
index 0b1c07b..01778d0 100755
--- a/configure
+++ b/configure
@@ -8,12 +8,15 @@
CNFS="GEML_VERSION:0.1:string:F:T
GEML_CONTACT:cynerd@email.cz:string:F:T
PREFIX:/usr/local:string:T:F
-MOD_LUA:yes::T:F
-MOD_PYTHON:yes::T:F
+EPREFIX:/usr/local:string:T:F
DEBUG:no::T:F
+CC:cc::T:F
CFLAGS:::T:F
-LFLAGS:::T:F"
+LFLAGS:::T:F
+DOT:dot::T:F
+MKDOCS:mkdocs::T:F"
############################################################################
+# TODO add options to fine tune installation directories
print_help() {
echo "Usage: ./configure [OPTION]..."
@@ -21,19 +24,22 @@ print_help() {
echo "and prepare it for building."
echo
echo " --help, -h Give this help list"
- echo " --prefix=PATH Set PATH as installation prefix."
- echo " In default /usr/local"
echo " --debug, -d Enable development features."
echo " --release, -r Disable development features for project."
echo " --dep-check Force depencency check for this machine."
- echo
- echo " --mod-lua-enable, --mod-lua-disable"
- echo " Set if Lua module should be compiled. In default is enabled."
- echo " --mod-python-enable, --mod-python-disable"
- echo " Set if Python module should be compiled. In default is enabled."
+ echo " --prefix=PREFIX Set PREFIX as installation prefix for"
+ echo " architecture independent files."
+ echo " In default /usr/local"
+ echo " --exec-prefix=EPREFIX Set EPREFIX as installation prefix for"
+ echo " architecture dependent files."
+ echo " In default PREFIX"
echo
echo "Environment variables:"
- echo " CROSS_COMPILE Prefix for compilation tools."
+ echo " CC C compiler command."
+ echo " CFLAGS C compiler flags."
+ echo " LDFLAGS C Linker flags."
+ echo " DOT Directed graphs drawing program."
+ echo " MKDOCS Project documentation generator."
echo
echo "GEML version $GEML_VERSION"
echo "Report bugs to <$GEML_CONTACT>."
@@ -42,13 +48,19 @@ print_help() {
CONFIG_FILE=.config
CONFIGURED_FILE=.configured # TODO
+# Backup variables from environment
+ENVVARS="CC CFLAGS LDFLAGS DOT MKDOCS"
+for E in $ENVVARS; do
+ eval "[ -n \"\${$E+y}\" ]" && eval "BACKUP_$E=\$$E"
+done
+
# TODO support for values with escaped colons
-# Load default configuration
-eval `echo "$CNFS" | grep -o -E '^[^:]*:[^:]*' | sed 's/:/=/'`
+# Load default configuration if variable not set from environment
+eval `echo "$CNFS" | sed -ne 's/^\([^:]*\):\([^:]*\).*$/\1=\2/p'`
# Load existing configuration
if [ -f "$CONFIG_FILE" ]; then
- source ./"$CONFIG_FILE"
+ . ./"$CONFIG_FILE"
fi
# Requested operation.
@@ -73,18 +85,6 @@ while [ "$#" -gt 0 ]; do
-r|--release)
DEBUG=no
;;
- --mod-lua-enable)
- MOD_LUA=yes
- ;;
- --mod-lua-disable)
- MOD_LUA=no
- ;;
- --mod-python-enable)
- MOD_PYTHON=yes
- ;;
- --mod-python-disable)
- MOD_PYTHON=no
- ;;
--op-makefile)
OP=m
;;
@@ -99,6 +99,11 @@ while [ "$#" -gt 0 ]; do
shift
done
+# Recover from enviroment variables
+for E in $ENVVARS; do
+ eval "[ -n \"\${BACKUP_$E+y}\" ]" && eval "$E=\$BACKUP_$E"
+done
+
# Basically save configuration to file
configure() {
echo "# GEML configuration file" > "$CONFIG_FILE"
@@ -119,7 +124,6 @@ doext() {
GEMLDIR=`dirname "$0"`
echo "# This is external Makefile for GEML." > Makefile
- echo "export CROSS_COMPILE=$CROSS_COMPILE" >> Makefile
echo >> Makefile
echo "GEML_PATH = $GEMLDIR" >> Makefile
echo >> Makefile
@@ -128,7 +132,7 @@ doext() {
echo >> Makefile
echo "MAKEFLAGS += --no-print-directory" >> Makefile
echo >> Makefile
- echo "Q = @" >> Makefile
+ echo "Q ?= @" >> Makefile
echo ".PHONY: all \$(MAKECMDGOALS)" >> Makefile
echo "all \$(MAKECMDGOALS):" >> Makefile
echo " \$(Q)\$(MAKE) \$(MAKEARGS) \$@" >> Makefile