From bcceb270ce8782bbe6c433afb19f41f8d4b09fec Mon Sep 17 00:00:00 2001 From: Ralph Ronnquist Date: Mon, 18 Jul 2022 16:14:49 +1000 Subject: [PATCH] reorg fixup --- Makefile | 8 ++++++++ common.mk | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 Makefile create mode 100644 common.mk diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..57ac9b7 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +LIBDIRS = vector typing logic htable +APPDIRS = socket-sniff tests + +default: $(LIBDIRS) $(APPDIRS) + for d in $^ ; do $(MAKE) -C $$d default ; done + +clean: $(LIBDIRS) $(APPDIRS) + for d in $^ ; do $(MAKE) -C $$d clean ; done diff --git a/common.mk b/common.mk new file mode 100644 index 0000000..9a46c34 --- /dev/null +++ b/common.mk @@ -0,0 +1,25 @@ +BASEDIR := $(shell dirname $$(pwd)) +LIBDIRS = vector typing logic +INCDIRS = $(addprefix -I$(BASEDIR)/,$(LIBDIRS)) +CFLAGS = -Wall -g -fmax-errors=1 -I. $(INCDIRS) +LDLIBS = -lm + +%.h: + echo "#ifndef ${@:.h=_H}" > $@ + echo "#define ${@:.h=_H}" >> $@ + echo "#endif" >> $@ + +define STDCC +.INTERMEDIATE: $1.o +CLEANRM += $1.o +$1.o: $1.c | $1.h +endef + +$(foreach OBJ,$(LIBOBJS:.o=),$(eval $(call STDCC,$(OBJ)))) + +CLEANRM += $(LIBRARY) +$(LIBRARY): $(LIBOBJS) + $(AR) r $@ $^ + +clean: + rm -f $(CLEANRM) -- 2.39.2