Browse Source

Makefile: list modules explicitly.

Clumsier than using wildcards, but that breaks down with nested modules
anyway.  In the longer term, we want ccantool to do the building, but for
the moment make is a necessary evil.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell 13 years ago
parent
commit
3785a28e52
3 changed files with 102 additions and 27 deletions
  1. 5 14
      Makefile
  2. 88 7
      Makefile-ccan
  3. 9 6
      Makefile-web

+ 5 - 14
Makefile

@@ -10,20 +10,9 @@
 #        Especially tools/ccanlint/ccanlint and tools/namespacize.
 #        Especially tools/ccanlint/ccanlint and tools/namespacize.
 # distclean: destroy everything back to pristine state
 # distclean: destroy everything back to pristine state
 
 
-# Trying to build the whole repo is usually a lose; there will be some
-# dependencies you don't have.
-EXCLUDE=wwviaudio ogg_to_pcm jmap jset nfs
-
 # Where make scores puts the results
 # Where make scores puts the results
 SCOREDIR=scores/$(shell whoami)/$(shell uname -s)-$(shell uname -m)-$(CC)-$(shell git describe --always --dirty)
 SCOREDIR=scores/$(shell whoami)/$(shell uname -s)-$(shell uname -m)-$(CC)-$(shell git describe --always --dirty)
 
 
-ALL=$(filter-out $(EXCLUDE), $(REALLY_ALL))
-
-ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(REALLY_ALL))
-
-# Not all modules have tests.
-ALL_TESTS=$(patsubst ccan/%/test/, %, $(foreach dir, $(ALL), $(wildcard ccan/$(dir)/test/)))
-
 # Here's my rough logarithmic timeout graph for my laptop:
 # Here's my rough logarithmic timeout graph for my laptop:
 #
 #
 # 302                                                  -     
 # 302                                                  -     
@@ -65,18 +54,20 @@ FASTTIMEOUT=750
 
 
 default: libccan.a
 default: libccan.a
 
 
+ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(MODS_NORMAL) $(MODS_EXTERNAL))
+
 include Makefile-ccan
 include Makefile-ccan
 
 
-fastcheck: $(ALL_TESTS:%=summary-fastcheck-%)
+fastcheck: $(MODS_NORMAL:%=summary-fastcheck-%)
 
 
-check: $(ALL_TESTS:%=summary-check-%)
+check: $(MODS_NORMAL:%=summary-check-%)
 
 
 distclean: clean
 distclean: clean
 	rm -f $(ALL_DEPENDS)
 	rm -f $(ALL_DEPENDS)
 
 
 scores: $(SCOREDIR)/SUMMARY
 scores: $(SCOREDIR)/SUMMARY
 
 
-$(SCOREDIR)/SUMMARY: $(patsubst ccan/%/_info, $(SCOREDIR)/score-%, $(wildcard ccan/*/_info))
+$(SCOREDIR)/SUMMARY: $(MODS:%=$(SCOREDIR)/score-%)
 	git describe --always > $@
 	git describe --always > $@
 	uname -a >> $@
 	uname -a >> $@
 	$(CC) -v >> $@
 	$(CC) -v >> $@

+ 88 - 7
Makefile-ccan

@@ -6,6 +6,93 @@
 CCAN_CFLAGS=-g3 -ggdb -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wwrite-strings -Wundef -DCCAN_STR_DEBUG=1
 CCAN_CFLAGS=-g3 -ggdb -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wwrite-strings -Wundef -DCCAN_STR_DEBUG=1
 CFLAGS = $(CCAN_CFLAGS) -I. $(DEPGEN)
 CFLAGS = $(CCAN_CFLAGS) -I. $(DEPGEN)
 
 
+# Normal modules: no external dependencies, just a header:
+MODS_NORMAL_NO_SRC := alignof \
+	array_size \
+	asearch \
+	build_assert \
+	bytestring \
+	cast \
+	check_type \
+	compiler \
+	container_of \
+	darray \
+	endian \
+	objset \
+	short_types \
+	tcon \
+	tlist \
+	typesafe_cb
+
+# No external dependencies, with C code:
+MODS_NORMAL_WITH_SRC := alloc \
+	antithread \
+	asort \
+	asprintf \
+	autodata \
+	avl \
+	bdelta \
+	block_pool \
+	btree \
+	ccan_tokenizer \
+	charset \
+	ciniparser \
+	crc \
+	crcsync \
+	daemonize \
+	daemon_with_notify \
+	dgraph \
+	err \
+	failtest \
+	foreach \
+	grab_file \
+	hash \
+	htable \
+	idtree \
+	ilog \
+	isaac \
+	iscsi \
+	json \
+	lbalance \
+	likely \
+	list \
+	md4 \
+	net \
+	noerr \
+	opt \
+	ptr_valid \
+	rbtree \
+	read_write_all \
+	rfc822 \
+	sparse_bsearch \
+	str \
+	stringmap \
+	strmap \
+	strset \
+	str_talloc \
+	take \
+	tal \
+	talloc \
+	talloc_link \
+	tally \
+	tap \
+	time \
+	ttxml
+
+MODS_NORMAL:=$(MODS_NORMAL_WITH_SRC) $(MODS_NORMAL_NO_SRC)
+
+# Modules which require external dependencies, thus may not pass check.
+MODS_EXTERNAL_NO_SRC:=
+
+MODS_EXTERNAL_WITH_SRC:=jmap \
+	jset \
+	nfs \
+	ogg_to_pcm \
+	wwviaudio
+
+MODS_EXTERNAL:=$(MODS_EXTERNAL_NO_SRC) $(MODS_EXTERNAL_WITH_SRC)
+
+MODS:=$(MODS_EXTERNAL) $(MODS_NORMAL)
 
 
 default: libccan.a
 default: libccan.a
 
 
@@ -13,14 +100,8 @@ default: libccan.a
 DEPGEN=-MD
 DEPGEN=-MD
 -include ccan/*/*.d
 -include ccan/*/*.d
 
 
-# Anything with an _info file is a module.
-REALLY_ALL=$(patsubst ccan/%/_info, %, $(wildcard ccan/*/_info))
-
-# Exclude any modules we can't build.
-ALL=$(filter-out $(EXCLUDE), $(REALLY_ALL))
-
 # Anything with C files needs building; dir leaves / on, sort uniquifies
 # Anything with C files needs building; dir leaves / on, sort uniquifies
-DIRS=$(patsubst %/, %, $(sort $(foreach m, $(ALL), $(dir $(wildcard ccan/$m/*.c)))))
+DIRS=$(patsubst %/, %, $(sort $(foreach m, $(MODS_NORMAL_WITH_SRC), $(dir $(wildcard ccan/$m/*.c)))))
 
 
 # Generate everyone's separate Makefiles.
 # Generate everyone's separate Makefiles.
 -include $(foreach dir, $(DIRS), $(dir)-Makefile)
 -include $(foreach dir, $(DIRS), $(dir)-Makefile)

+ 9 - 6
Makefile-web

@@ -1,23 +1,26 @@
 # This can be overridden on cmdline to generate pages elsewhere.
 # This can be overridden on cmdline to generate pages elsewhere.
 WEBDIR=/home/rusty/www/html/ccan
 WEBDIR=/home/rusty/www/html/ccan
 
 
-# Ignore EXCLUDE when making webpages.
-ALL_PAGES=$(patsubst %, $(WEBDIR)/info/%.html, $(REALLY_ALL))
-DIRECT_TARBALLS=$(patsubst %, $(WEBDIR)/tarballs/%.tar.bz2, $(REALLY_ALL))
-DEPEND_TARBALLS=$(patsubst %, $(WEBDIR)/tarballs/with-deps/%.tar.bz2, $(REALLY_ALL))
+ALL_PAGES=$(patsubst %, $(WEBDIR)/info/%.html, $(MODS_NORMAL) $(MODS_EXTERNAL))
+DIRECT_TARBALLS=$(patsubst %, $(WEBDIR)/tarballs/%.tar.bz2, $(MODS_NORMAL) $(MODS_EXTERNAL))
+DEPEND_TARBALLS=$(patsubst %, $(WEBDIR)/tarballs/with-deps/%.tar.bz2, $(MODS_NORMAL) $(MODS_EXTERNAL))
 WEB_SUBDIRS=$(WEBDIR)/tarballs $(WEBDIR)/junkcode $(WEBDIR)/tarballs/with-deps $(WEBDIR)/info
 WEB_SUBDIRS=$(WEBDIR)/tarballs $(WEBDIR)/junkcode $(WEBDIR)/tarballs/with-deps $(WEBDIR)/info
 JUNKDIRS=$(wildcard junkcode/*)
 JUNKDIRS=$(wildcard junkcode/*)
 JUNKPAGES=$(JUNKDIRS:%=$(WEBDIR)/%.html)
 JUNKPAGES=$(JUNKDIRS:%=$(WEBDIR)/%.html)
 JUNKBALLS=$(JUNKDIRS:%=$(WEBDIR)/%.tar.bz2)
 JUNKBALLS=$(JUNKDIRS:%=$(WEBDIR)/%.tar.bz2)
 
 
-upload: fastcheck
+upload: fastcheck modcheck
 	git push origin HEAD:master
 	git push origin HEAD:master
 	git push github HEAD:master
 	git push github HEAD:master
 
 
+# Check MODS list in Makefile-ccan matches modules we find.
+modcheck:
+	@FOUND=$$(echo $$(find ccan -name _info | sed 's,ccan/\(.*\)/_info,\1,' | sort) ); LISTED=$$(echo $$(echo $(MODS) | tr ' ' '\012' | sort) ); if [ "$$FOUND" = "$$LISTED" ]; then exit 0; fi; while true; do a="$${FOUND%% *}"; b="$${LISTED%% *}"; if [ "$$a" != "$$b" ]; then echo "$$a found but $$b in MOD" >&2; exit 1; fi; FOUND="$${FOUND#* }"; LISTED="$${LISTED#* }"; done
+
 clean-tree:
 clean-tree:
 	! git status --porcelain | grep .
 	! git status --porcelain | grep .
 
 
-webpages: clean-tree $(WEB_SUBDIRS) $(WEBDIR)/index.html $(WEBDIR)/upload.html $(WEBDIR)/uploader.php $(WEBDIR)/example-config.h $(WEBDIR)/ccan.jpg $(DIRECT_TARBALLS) $(DEPEND_TARBALLS) $(WEBDIR)/ccan.tar.bz2 $(WEBDIR)/Makefile-ccan $(ALL_PAGES) junkpages
+webpages: modcheck clean-tree $(WEB_SUBDIRS) $(WEBDIR)/index.html $(WEBDIR)/upload.html $(WEBDIR)/uploader.php $(WEBDIR)/example-config.h $(WEBDIR)/ccan.jpg $(DIRECT_TARBALLS) $(DEPEND_TARBALLS) $(WEBDIR)/ccan.tar.bz2 $(WEBDIR)/Makefile-ccan $(ALL_PAGES) junkpages
 
 
 junkpages: $(WEBDIR)/list.html $(WEBDIR)/junkcode $(JUNKPAGES) $(JUNKBALLS)
 junkpages: $(WEBDIR)/list.html $(WEBDIR)/junkcode $(JUNKPAGES) $(JUNKBALLS)
 $(WEB_SUBDIRS): $(WEBDIR)
 $(WEB_SUBDIRS): $(WEBDIR)