Automatically emit make rules for header files

This commit is contained in:
Eelco Dolstra 2013-11-22 15:10:33 +00:00
parent b8e9efc476
commit bc96c4518e
2 changed files with 7 additions and 4 deletions

1
.gitignore vendored
View File

@ -129,6 +129,7 @@ Makefile.config
*.la *.la
*.o *.o
*.so *.so
*.dep
*~ *~
# GNU Global # GNU Global

View File

@ -7,10 +7,10 @@ LIBS =
QUIET = @ QUIET = @
%.o: %.cc %.o: %.cc
$(QUIET) g++ -o $@ -c $^ -g -fPIC $(CXXFLAGS) $($@_CXXFLAGS) $(QUIET) g++ -o $@ -c $< -g -fPIC $(CXXFLAGS) $($@_CXXFLAGS) -MMD -MF $(basename $@).dep -MP
%.o: %.c %.o: %.c
$(QUIET) gcc -o $@ -c $^ -g -fPIC $(CFLAGS) $($@_CFLAGS) $(QUIET) gcc -o $@ -c $< -g -fPIC $(CFLAGS) $($@_CFLAGS) -MMD -MF $(basename $@).dep -MP
# Generate Make rules for libraries. # Generate Make rules for libraries.
@ -28,7 +28,9 @@ define LIBS_template =
# Propagate CXXFLAGS to the individual object files. # Propagate CXXFLAGS to the individual object files.
$$(foreach obj, $$(_objs), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS))) $$(foreach obj, $$(_objs), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS)))
clean_list += $$(_lib) $$(_objs) include $$(wildcard $$(_d)/*.dep)
clean_list += $$(_lib) $$(_objs) $$(_d)*.dep
libs_list += $$(_lib) libs_list += $$(_lib)
endef endef
@ -48,7 +50,7 @@ define PROGRAMS_template =
# Propagate CXXFLAGS to the individual object files. # Propagate CXXFLAGS to the individual object files.
$$(foreach obj, $$(_objs), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS))) $$(foreach obj, $$(_objs), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS)))
clean_list += $$(_prog) $$(_objs) clean_list += $$(_prog) $$(_objs) $$(_d)*.dep
programs_list += $$(_prog) programs_list += $$(_prog)
endef endef