Last active
May 30, 2022 01:18
-
-
Save basinilya/e00ea0055f74092b4790 to your computer and use it in GitHub Desktop.
gcc precompiled header with proper Automake Dependency Tracking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdafx.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdafx.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
COMPILE = gcc | |
DEPDIR = .deps | |
am__mv = mv | |
OBJECTS = foo.o bar.o | |
all: $(OBJECTS) | |
# The recipe for stdafx.uptodate ensures that the .gch file is up to date | |
$(OBJECTS): stdafx.uptodate | |
# The .gch file MAY remain outdated after changing some include file, because we | |
# don't make it depend on the headers, because we don't know the dependency | |
# mechanism used by automake. | |
# If it's outdated, the rule to create stdafx.uptodate will re-make both | |
# stdafx.h.gch and stdafx.o | |
stdafx.o: stdafx.h.gch | |
# Missing .norecomp file indicates that stdafx.o was recompiled during this run, | |
# but stdafx.gch was not. Then delete stdafx.h.gch and re-run this rule using | |
# submake. | |
# It's optimized to build a clean tarball. Each time you change headers, | |
# stdafx.o will be compiled twice, but the tradeoff is small, because it will | |
# use existing precompiled header both times. | |
stdafx.uptodate: stdafx.o | |
rm stdafx.h.gch.norecomp 2>/dev/null && touch stdafx.uptodate && exit; \ | |
rm -f stdafx.h.gch && $(MAKE) $(AM_MAKEFLAGS) stdafx.uptodate | |
# .norecomp file indicates that the .gch file was generated during this run. | |
# It's normally deleted by the .uptodate rule. | |
# | |
# If you explicitly make stdafx.o or make stdafx.h.gch , then it will be deleted | |
# by the make program as .INTERMEDIATE file, but be wary of buggy make versions | |
# that fail to delete intermediate files - don't make those two files explicitly. | |
# | |
# The '-MD' flag is needed because of: | |
# Bug 28483 - Dependency tracking should be on by default when copiling .gchs | |
# | |
%.gch %.gch.norecomp: % | |
$(COMPILE) -MD -c -o $*.gch $* | |
rm -f $*.d | |
touch $*.gch.norecomp | |
.INTERMEDIATE: stdafx.h.gch.norecomp | |
clean: | |
rm -f *.gch *.uptodate *.norecomp *.o | |
.PHONY: all clean | |
# do what ./configure script does to create the missing .Po files | |
%.Po: | |
@mkdir -p $(DEPDIR) | |
@touch $@ | |
# recipe generated by automake | |
.c.o: | |
$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< | |
$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po | |
# recipe generated by automake with: libstdafx_a_CFLAGS = -fpch-deps | |
stdafx.o: stdafx.c | |
$(COMPILE) -fpch-deps -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< | |
$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po | |
-include ./$(DEPDIR)/stdafx.Po | |
-include ./$(DEPDIR)/foo.Po | |
-include ./$(DEPDIR)/bar.Po |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdafx.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "testheader.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// bbb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment