Browse Source

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 <mans@mansr.com>
tags/n1.0
Mans Rullgard 13 years ago
parent
commit
dfd9159f3d
4 changed files with 9 additions and 7 deletions
  1. +1
    -1
      .gitignore
  2. +2
    -2
      Makefile
  3. +5
    -3
      common.mak
  4. +1
    -1
      library.mak

+ 1
- 1
.gitignore View File

@@ -4,7 +4,7 @@
*.def *.def
*.dll *.dll
*.exe *.exe
*.ho
*.h.c
*.lib *.lib
*.pc *.pc
*.so *.so


+ 2
- 2
Makefile View File

@@ -45,8 +45,8 @@ COMPILE_S = $(call COMPILE,AS)
%.o: %.S %.o: %.S
$(COMPILE_S) $(COMPILE_S)


%.ho: %.h
$(CC) $(CCFLAGS) -c $(CC_O) -x c $<
%.h.c:
$(Q)echo '#include "$*.h"' >$@


%.ver: %.v %.ver: %.v
$(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@ $(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@


+ 5
- 3
common.mak View File

@@ -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)) ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-) SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-)
SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%) 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) alltools: $(TOOLS)


@@ -45,8 +47,8 @@ $(TOOLOBJS): | tools


OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOSTOBJS) $(TESTOBJS)) OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOSTOBJS) $(TESTOBJS))


CLEANSUFFIXES = *.d *.o *~ *.ho *.map *.ver
CLEANSUFFIXES = *.d *.o *~ *.h.c *.map *.ver
DISTCLEANSUFFIXES = *.pc DISTCLEANSUFFIXES = *.pc
LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a 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))

+ 1
- 1
library.mak View File

@@ -20,7 +20,7 @@ $(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
$(DEPYASM) $(YASMFLAGS) -I $(<D)/ -M -o $@ $< > $(@:.o=.d) $(DEPYASM) $(YASMFLAGS) -I $(<D)/ -M -o $@ $< > $(@:.o=.d)
$(YASM) $(YASMFLAGS) -I $(<D)/ -o $@ $< $(YASM) $(YASMFLAGS) -I $(<D)/ -o $@ $<


$(OBJS) $(SUBDIR)%.ho $(TESTOBJS): CPPFLAGS += -DHAVE_AV_CONFIG_H
$(OBJS) $(SUBDIR)%.h.o $(TESTOBJS): CPPFLAGS += -DHAVE_AV_CONFIG_H
$(TESTOBJS): CPPFLAGS += -DTEST $(TESTOBJS): CPPFLAGS += -DTEST


$(SUBDIR)$(LIBNAME): $(OBJS) $(SUBDIR)$(LIBNAME): $(OBJS)


Loading…
Cancel
Save