]> Lady’s Gitweb - CGirls/blobdiff - make/cgirls.mak
Build testing infrastructure
[CGirls] / make / cgirls.mak
index 53766b5398434d0c62d55e892414c4cd9d4f4ce2..ccbc9ebbd3840e3563402267f514e123056275c3 100644 (file)
@@ -12,7 +12,7 @@ SHELL = /bin/sh
 # The variable `CGIRLSDIR´ is used to point back to the directory containing the C·Girls code.
 CGIRLSDIR := ..
 cgirls : $(CGIRLSDIR)/cgirls
-PHONY : cgirls
+.PHONY : cgirls
 include Makefile
 
 # The `gen-version.sh´ script updates the `VERSION´ file when·ever the version changes.
@@ -20,7 +20,7 @@ include Makefile
 $(CGIRLSDIR)/VERSION : VERSIONFORCE
        @cd '$(CGIRLSDIR)' && $(SHELL_PATH_SQ) sh/gen-version.sh VERSION
 VERSIONFORCE : ;
-PHONY : VERSIONFORCE
+.PHONY : VERSIONFORCE
 -include $(CGIRLSBUILDDIR)/VERSION
 
 # `CGIRLS_CFLAGS´ is a separate variable so that it can be tracked separately, to avoid rebuilding all of Git when these variables change.
@@ -33,11 +33,13 @@ CGIRLS_SOURCE_FILES := $(shell cd '$(CGIRLSDIR)' && $(SOURCES_CMD))
 CGIRLS_H_SOURCES = $(filter %.h,$(CGIRLS_SOURCE_FILES))
 
 # `CGIRLS_OBJS´ lists the object files which this make·file is expected to create.
-# These are listed one per line to make merges easier.
-# `CGIRLSBUILDDIR´ is added as a prefix at the end.
-CGIRLS_OBJS :=
-CGIRLS_OBJS += cgirls.o
-CGIRLS_OBJS := $(addprefix $(CGIRLSDIR)/,$(CGIRLS_OBJS))
+# `CGIRLS_TESTOBJS´ lists the additional object files used for the testing programs.
+CGIRLS_OBJS := $(patsubst %.c,%.o,$(shell find '$(CGIRLSDIR)' '(' -path '$(CGIRLSDIR)' -o -prune ')' -a -type f -a  -name '*.c' -a '!' -name 'cgirls-test-*.c'))
+CGIRLS_TESTOBJS := $(patsubst %.c,%.o,$(shell find '$(CGIRLSDIR)' '(' -path '$(CGIRLSDIR)' -o -prune ')' -a -type f -a -name 'cgirls-test-*.c'))
+CGIRLS_TESTS := $(patsubst %.o,%,$(CGIRLS_TESTOBJS))
+
+# `CGIRLS_ALLOBJS´ contains both `CGIRLS_OBJS´ and `CGIRLS_TESTOBJS´.
+CGIRLS_ALLOBJS = $(CGIRLS_OBJS) $(CGIRLS_TESTOBJS)
 
 # Only `cgirls.c´ references CGIRLS_VERSION so we only rebuild its objects when the version changes.
 CGIRLS_VERSION_OBJS := $(CGIRLSDIR)/cgirls.o
@@ -47,8 +49,8 @@ $(CGIRLS_VERSION_OBJS) : EXTRA_CPPFLAGS = \
 
 # Git handles dependencies using `:=´, so they have already been computed by this point.
 # We have to manage the dependency files for `CGIRLS_OBJS´ ourselves.
-cgirls_dep_files := $(foreach f,$(CGIRLS_OBJS),$(dir $f).depend/$(notdir $f).d)
-cgirls_dep_dirs := $(addsuffix .depend,$(sort $(dir $(CGIRLS_OBJS))))
+cgirls_dep_files := $(foreach f,$(CGIRLS_ALLOBJS),$(dir $f).depend/$(notdir $f).d)
+cgirls_dep_dirs := $(addsuffix .depend,$(sort $(dir $(CGIRLS_ALLOBJS))))
 ifeq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
 $(cgirls_dep_dirs) :
        @mkdir -p $@
@@ -60,9 +62,13 @@ ifneq ($(cgirls_dep_files_present),)
 include $(cgirls_dep_files_present)
 endif
 else
-$(CGIRLS_OBJS) : $(CGIRLS_H_SOURCES) $(LIB_H) $(GENERATED_H)
+$(CGIRLS_ALLOBJS) : $(CGIRLS_H_SOURCES) $(LIB_H) $(GENERATED_H)
 endif
 
+# At this point, all the variables have been defined.
+# Include custom modifications, if defined.
+-include $(CGIRLSDIR)/make/config.mak
+
 # This saves the value of `CGIRLS_CFLAGS´ to force a rebuild of `CGIRLS_OBJS´ if the flags should change.
 $(CGIRLSDIR)/CGIRLS-CFLAGS : FORCE
        @FLAGS='$(subst ','"'"',$(CGIRLS_CFLAGS))'; \
@@ -72,7 +78,11 @@ $(CGIRLSDIR)/CGIRLS-CFLAGS : FORCE
                fi
 
 # Objects are built and linked the same as with Git, except depending on the additional `CGIRLS-CFLAGS´ file and using `ALL_CGIRLS_CFLAGS´ in place of `ALL_CFLAGS´.
-$(CGIRLS_OBJS) : $(CGIRLSDIR)/%.o : $(CGIRLSDIR)/%.c GIT-CFLAGS $(CGIRLSDIR)/CGIRLS-CFLAGS $(missing_dep_dirs)
+$(CGIRLS_ALLOBJS) : $(CGIRLSDIR)/%.o : $(CGIRLSDIR)/%.c GIT-CFLAGS $(CGIRLSDIR)/CGIRLS-CFLAGS $(missing_dep_dirs)
        $(QUIET_CC)$(CC) -o $@ -c $(dep_args) $(ALL_CGIRLS_CFLAGS) $(EXTRA_CPPFLAGS) $<
 $(CGIRLSDIR)/cgirls : $(CGIRLS_OBJS) GIT-LDFLAGS $(GITLIBS)
-       $(QUIET_LINK)$(CC) $(ALL_CGIRLS_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(sort $(LIBS))
+       $(QUIET_LINK)$(CC) $(ALL_CGIRLS_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
+$(CGIRLS_TESTS) : $(CGIRLSDIR)/% : $(CGIRLSDIR)/%.o $(filter-out $(CGIRLSDIR)/cgirls.o,$(CGIRLS_OBJS)) GIT-LDFLAGS $(GITLIBS)
+       $(QUIET_LINK)$(CC) $(ALL_CGIRLS_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
+cgirls-tests : $(CGIRLS_TESTS) ;
+.PHONY : cgirls-tests
This page took 0.176616 seconds and 4 git commands to generate.