From dfd9159f3db987e9115715cded7a4408179e3ed9 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Tue, 7 Aug 2012 02:11:25 +0100 Subject: build: change checkheaders to use regular build rules Many compilers need special flags to compile *.h files as regular source code, if they will do so at all. Rather than hoping all compilers will have such a flag and adding mappings for it, create wrapper .c files for test building single headers. This allows using the regular rule for compiling C files without the need for special flags, and it also provides proper dependency tracking for these objects. Signed-off-by: Mans Rullgard --- .gitignore | 2 +- Makefile | 4 ++-- common.mak | 8 +++++--- library.mak | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 56b304070d..19dbe88ff6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ *.def *.dll *.exe -*.ho +*.h.c *.lib *.pc *.so diff --git a/Makefile b/Makefile index 20e6a3861b..682eda75a4 100644 --- a/Makefile +++ b/Makefile @@ -45,8 +45,8 @@ COMPILE_S = $(call COMPILE,AS) %.o: %.S $(COMPILE_S) -%.ho: %.h - $(CC) $(CCFLAGS) -c $(CC_O) -x c $< +%.h.c: + $(Q)echo '#include "$*.h"' >$@ %.ver: %.v $(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@ diff --git a/common.mak b/common.mak index aed11f7891..f94a43d35a 100644 --- a/common.mak +++ b/common.mak @@ -28,7 +28,9 @@ DEP_LIBS := $(foreach NAME,$(FFLIBS),lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME) ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h)) SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-) SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%) -checkheaders: $(filter-out $(SKIPHEADERS:.h=.ho),$(ALLHEADERS:.h=.ho)) +HOBJS = $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o)) +checkheaders: $(HOBJS) +.SECONDARY: $(HOBJS:.o=.c) alltools: $(TOOLS) @@ -45,8 +47,8 @@ $(TOOLOBJS): | tools OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOSTOBJS) $(TESTOBJS)) -CLEANSUFFIXES = *.d *.o *~ *.ho *.map *.ver +CLEANSUFFIXES = *.d *.o *~ *.h.c *.map *.ver DISTCLEANSUFFIXES = *.pc LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a --include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d)) +-include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d)) diff --git a/library.mak b/library.mak index cd3fdc28f9..3045640e0b 100644 --- a/library.mak +++ b/library.mak @@ -20,7 +20,7 @@ $(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm $(DEPYASM) $(YASMFLAGS) -I $( $(@:.o=.d) $(YASM) $(YASMFLAGS) -I $(