Skip to content

Commit

Permalink
build: drop extra qbconfig.h rule for auto_check_header self-test
Browse files Browse the repository at this point in the history
Although this is not as rigorously correct as the previous arrangement
(introduced with 80834ea), i.e., from the perspective of
$(abs_top_builddir)/tests/Makefile (generated from from
$(top_srcdir)/tests/Makefile.am), for which $(top_builddir)
is literally "..":

- qbconfig.h is generated from $(top_srcdir)/include/qb/qbconfig.h.in
  into $(top_builddir)/include/qb directory, and consumed from here

- rest of these header files are consumed directly from
  $(top_srcdir)/include/qb directory

this new simplified variant:

- avoids code duplication (DRY)

- works thanks to VPATH in $(abs_top_builddir)/tests/Makefile
  pointing to $(top_srcdir)/tests, which means that unsatisfied
  dependencies on "$(top_builddir)/include/qb/%.h" (resolved to
  "../include/qb/%.h") will be subsequently sought as
  "$(top_srcdir)/tests/../include/qb/%.h", which has the same effect
  as previous explicit "$(top_srcdir)/include/qb/%.h" specification
  (note that such automatic VPATH provision is supported by automake
   "since beginning" so no backward incompatibility is expected)
  • Loading branch information
jnpkrn committed Mar 10, 2016
1 parent b69c743 commit 328f99e
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,11 @@ auto_c_files = $(patsubst %.h,auto_check_header_%.c,$(public_headers))
CLEANFILES += $(auto_c_files)
MAINTAINERCLEANFILES += $(auto_c_files)

#
# The qbconfig.h file is generated from qbconfig.h.in into the build directory tree.
# We have to have a separate rule for generating the auto_check_header_ source here.
#
$(builddir)/auto_check_header_qbconfig.c: $(top_builddir)/include/qb/qbconfig.h
@name=$$(echo "$<" | sed "s|.*qb/qb||" | sed "s|\.h||") ;\
NAME=$$(echo $$name | tr [:lower:] [:upper:]) ;\
echo "#include <qb/qb$$name.h>" > $@_ ;\
echo "#ifndef QB_$${NAME}_H_DEFINED" >> $@_ ;\
echo "#error no header protector in file qb$$name.h" >> $@_ ;\
echo "#endif" >> $@_ ;\
echo "int main(void) {return 0;}" >> $@_
$(AM_V_GEN)mv $@_ $@

$(builddir)/auto_check_header_%.c: $(top_srcdir)/include/qb/%.h
# this works for both non/generated headers thanks to VPATH being
# automatically set to $(top_srcdir)/tests and $(top_builddir)
# being resolved to ".." by automake
# ($(top_srcdir)/tests/../include/qb/%.h = $(top_srcdir)/include/qb/%.h)
$(builddir)/auto_check_header_%.c: $(top_builddir)/include/qb/%.h
@name=$$(echo "$<" | sed "s|.*qb/qb||" | sed "s|\.h||") ;\
NAME=$$(echo $$name | tr [:lower:] [:upper:]) ;\
echo "#include <qb/qb$$name.h>" > $@_ ;\
Expand Down

0 comments on commit 328f99e

Please sign in to comment.