.ONESHELL:
.SHELLFLAGS := -ec
+# Recipes which redirect stdout to the target of the rule (i.e., constructs
+# like cmd > $@) create empty or incomplete output files if the command fails,
+# for example when cmd was not found. Since the target exists and is uptodate
+# in this case, this may lead to all sorts of problems. The following target
+# makes sure that such files are removed.
+.DELETE_ON_ERROR:
+
PREFIX ?= /usr/local
M4 := m4
LN := ln -f
GZIP := gzip -fn9
ZCAT := zcat
+CC += -ffile-prefix-map=$(CURDIR)=.
+
+dummy != $(M4) /dev/null || printf 'failed'
+ifeq ($(dummy), failed)
+$(error m4 is required to build this package)
+endif
+dummy != printf '%%%%\n' | $(LEX) -o /dev/null || printf 'failed'
+ifeq ($(dummy), failed)
+$(error (f)lex is required to build this package)
+endif
+
DATE_FMT := +%B %Y
# To get a reproducible build, we use $(SOURCE_DATE_EPOCH) instead of the
# current time if this variable is set.
liblopsub_objs := config_file.o lopsub.o version.o
lopsubex_objs := lopsubex.o lopsubex.lsg.o $(liblopsub_objs)
+LLS_CFLAGS := -g -fPIC
+STRICT_CFLAGS := -Wall
+STRICT_CFLAGS += -Werror-implicit-function-declaration
+
$(lsg_objs) $(liblopsub_objs) $(lopsubex_objs): %.o: %.c
lopsubgen.o config_file.o:
- $(CC) -g -c -fPIC -o $@ ${@:.o=.c}
+ $(CC) $(CPPFLAGS) $(LLS_CFLAGS) $(CFLAGS) -c -o $@ ${@:.o=.c}
lsg1.o: lsg.c lsg.h
- $(CC) -g -DSTAGE1 -Wall -g -c $< -o $@
+ $(CC) $(CPPFLAGS) $(LLS_CFLAGS) $(STRICT_CFLAGS) $(CFLAGS) -DSTAGE1 -c -o $@ $<
%.o: %.c
- $(CC) -Wall -I. -g -c -fPIC -o $@ $<
+ $(CC) -I. $(CPPFLAGS) $(LLS_CFLAGS) $(STRICT_CFLAGS) $(CFLAGS) -c -o $@ $<
# linking
lopsubgen-stage1: $(lsg1_objs)
$(CC) -Wall -g $(lsg1_objs) -o $@
lopsubgen: $(lsg_objs)
- $(CC) -Wall -g -o $@ $(lsg_objs)
+ $(CC) -Wall -g $(LDFLAGS) -o $@ $(lsg_objs)
$(REALNAME): $(liblopsub_objs)
- $(CC) --shared -Wl,-soname,liblopsub.so.$(MAJOR_VERSION) -o $@ $^
+ $(CC) --shared -Wl,-soname,liblopsub.so.$(MAJOR_VERSION) \
+ $(LDFLAGS) -o $@ $^
+liblopsub.a: $(liblopsub_objs)
+ $(AR) -rcs $@ $^
+
lopsubex: $(lopsubex_objs) $(REALNAME)
$(CC) -Wall -g -o $@ $(lopsubex_objs)
distclean: clean
$(RM) *.lsg.c *.lsg.h lopsubgen.c config_file.c lopsubgen-stage1 \
lopsub.h lopsub.7 lopsub-suite.5 version.c
-
+-include Makefile.local