# This makefile manages a build environment targeting native platforms with gcc
# and web platforms with either emscripten or binaryen (js or wasm).
################################################################################
-# Each .c file is automatically compiled into an environment-dependent object
+# Each .c file is autopresidential debate california timematically compiled into an environment-dependent object
# file of compiler-specific format (.o for gcc, .bc for llvm/emcc/em++).
################################################################################
default: all
# Source languages handled by this build system
LANGS := c cpp go
# Source-to-source languages handled by this build system
-SLANGS := y
+SLANGS := y rl
# Language-specific compilers and flags passed in from environment
c_C := $(strip $(notdir $(CC)))
c_FLAGS := $(strip $(CFLAGS)) -I.
go_C := gccgo
go_FLAGS := $(c_FLAGS)
# Source to source languages
+# Bison
y_C := bison
y_FLAGS := -d
y_STEM := tab
y_TRG := c h
+# Ragel
+rl_C := ragel
+rl_FLAGS := -C
+rl_TRG := c
# Compiler-specific associations. Each compiler has a binary object suffix
# (OBJ), an archiver (AR), and an archiver object suffix (AROBJ). Each compiler
# may optionally have defined a linker (LD), and a binary output suffix (OUT).
# Foreach target type in the source-to-source language, add this source's
# targets to the list of the current source-to-source language targets
$(foreach trg,$($(slang)_TRG),
-$(eval SLANG_TRG += $(SLANG_SRC:%.$(slang)=%.$($(slang)_STEM:%=%.)$(trg))))
+$(eval SLANG_TRG += $(SLANG_SRC:%.$(slang)=%.$(if $($(slang)_STEM),$($(slang)_STEM).)$(trg))))
# Stat the source file's last-modified time to the var SRC_TIME
$(foreach src,$(SLANG_SRC),
$(eval SRC_TIME := $(shell stat -c %Y $(src)))
)
# Put these targets on the MAKE_TARGETS list to be removed during "clean",
# regardless of whether or not they were built just now.
-$(eval MAKE_TARGETS += $(SLANG_TRG))
+$(eval MAKE_TARGETS+= $(SLANG_TRG))
))
endef
# Compile a source language to a language that compiles to binary, but only if
$(eval ALLDEPS := $(MDEPS) $(DEPS)),\
$(error Cannot generate deps for: $1, file not found))\
$(eval SRC_OBJ := $(basename $1).$($2_OBJ))\
-$(eval MAKE_TARGETS += $(SRC_OBJ))\
+$(eval MAKE_TARGETS+= $(SRC_OBJ))\
# Object for $1
$(SRC_OBJ): $(ALLDEPS)
$(eval DRIVER_DBGTARG := $(DRIVER_TARG_DIR)$(basename $(notdir $(DRIVER_TARG)))-d$($2_OUT))
$(eval SCRUB_TARGETS += $(DRIVER_DBGTARG))
$(eval MAKE_DIRS += $(DRIVER_TARG_DIR).$($2_DBG)/)
-$(DRIVER_DBGTARG): $(DRIVER_DBGDEPS) | $(DRIVER_TARG_DIR).$($2_DBG)/
+$(DRIVER_DBGTARG): $(DRIVER_DBGDEPS) | $(DRIVER_TARG_DIR)
$($2_C) $($2_FLAGS) $(DRIVER_DBGSRC) -o $$@
# Make a rule to run this driver after building
$(DRIVER_NAME)-run: $(DRIVER_TARG)
# modules as static libs).
define MODULE_ARCRULE =
$(eval ARCDEPS := $(filter $1/%.$(c_OBJ),$(foreach lang,$(LANGS),$($(lang)_MOD_TRG))))\
-$(eval MAKE_TARGETS += $1.$(c_AROBJ))\
+$(eval MAKE_TARGETS+= $1.$(c_AROBJ))\
+
$1.$(c_AROBJ): $(ARCDEPS)
$(c_AR) cr $$@ $$^
$(if $(c_DBG),
$(eval undefine DBGARCDEPS)
$(foreach arcdep,$(ARCDEPS),$(eval DBGARCDEPS += $(dir $(arcdep)).$(c_DBG)/$(notdir $(arcdep))))
-$(eval MAKE_TARGETS += .$(c_DBG)/$1.$(c_AROBJ))\
+$(eval MAKE_TARGETS+= .$(c_DBG)/$1.$(c_AROBJ))\
.$(c_DBG)/$1.$(c_AROBJ): $(DBGARCDEPS) | .$(c_DBG)/
$(c_AR) cr $$@ $$^
@echo Build Complete
# Rule to make any dirs that we're in charge of
-$(MAKE_DIRS):
+$(sort $(MAKE_DIRS)):
@mkdir -p $@
# Cleaning rules.