Skip to content

Commit ca09cea

Browse files
author
Daniel Kroening
committed
move build commands for cbmc/version.h from common to cbmc/Makefile
1 parent 6fd77f4 commit ca09cea

File tree

3 files changed

+31
-24
lines changed

3 files changed

+31
-24
lines changed

src/Makefile

+10-5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ $(patsubst %, %.dir, $(filter-out big-int util, $(DIRS))): util.dir
3838

3939
.PHONY: languages
4040
.PHONY: clean
41+
.PHONY: version
42+
43+
version:
44+
$(MAKE) $(MAKEARGS) -C cbmc version.h
4145

4246
cpp.dir: ansi-c.dir linking.dir
4347

@@ -49,20 +53,21 @@ solvers.dir: util.dir langapi.dir
4953

5054
goto-instrument.dir: languages goto-programs.dir pointer-analysis.dir \
5155
goto-symex.dir linking.dir analyses.dir solvers.dir \
52-
json.dir
56+
json.dir version
5357

5458
cbmc.dir: languages solvers.dir goto-symex.dir analyses.dir \
5559
pointer-analysis.dir goto-programs.dir linking.dir \
56-
goto-instrument.dir
60+
goto-instrument.dir version
5761

5862
goto-analyzer.dir: languages analyses.dir goto-programs.dir linking.dir \
59-
json.dir goto-instrument.dir
63+
json.dir goto-instrument.dir version
6064

6165
goto-diff.dir: languages goto-programs.dir pointer-analysis.dir \
6266
linking.dir analyses.dir goto-instrument.dir \
63-
solvers.dir json.dir goto-symex.dir
67+
solvers.dir json.dir goto-symex.dir version
6468

65-
goto-cc.dir: languages pointer-analysis.dir goto-programs.dir linking.dir
69+
goto-cc.dir: languages pointer-analysis.dir goto-programs.dir linking.dir \
70+
version
6671

6772
# building for a particular directory
6873

src/cbmc/Makefile

+20-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,26 @@ LIBS =
5959
include ../config.inc
6060
include ../common
6161

62-
CLEANFILES = cbmc$(EXEEXT)
62+
# get version from git
63+
GIT_INFO = $(shell git describe --tags --always --dirty || echo "n/a")
64+
RELEASE_INFO = \#define CBMC_VERSION "$(CBMC_VERSION) ($(GIT_INFO))"
65+
GIT_INFO_FILE = version.h
66+
67+
$(GIT_INFO_FILE):
68+
echo '$(RELEASE_INFO)' > $@
69+
70+
generated_files: $(GIT_INFO_FILE)
71+
72+
cbmc_parse_options$(OBJEXT): $(GIT_INFO_FILE)
73+
74+
# mark the actually generated file as a phony target to enforce a rebuild - but
75+
# only if the version information has changed!
76+
KNOWN_RELEASE_INFO = $(shell cat $(GIT_INFO_FILE) 2>/dev/null)
77+
ifneq ($(RELEASE_INFO), $(KNOWN_RELEASE_INFO))
78+
.PHONY: $(GIT_INFO_FILE)
79+
endif
80+
81+
CLEANFILES = cbmc$(EXEEXT) $(GIT_INFO_FILE)
6382

6483
all: cbmc$(EXEEXT)
6584

src/common

+1-18
Original file line numberDiff line numberDiff line change
@@ -227,29 +227,12 @@ OBJ += $(patsubst %.cc, %$(OBJEXT), $(filter %.cc, $(SRC)))
227227
%.obj:%.c
228228
$(CC) $(CP_CFLAGS) /nologo /c /EHsc $< /Fo$@
229229

230-
# get version from git
231-
GIT_INFO = $(shell git describe --tags --always --dirty || echo "n/a")
232-
RELEASE_INFO = \#define CBMC_VERSION "$(CBMC_VERSION) ($(GIT_INFO))"
233-
GIT_INFO_FILE = version.h
234-
235-
$(GIT_INFO_FILE):
236-
echo '$(RELEASE_INFO)' > $@
237-
238-
$(filter %_parse_options$(OBJEXT), $(OBJ)): $(GIT_INFO_FILE)
239-
240-
# mark the actually generated file as a phony target to enforce a rebuild - but
241-
# only of the version information has changed!
242-
KNOWN_RELEASE_INFO = $(shell cat $(GIT_INFO_FILE) 2>/dev/null)
243-
ifneq ($(RELEASE_INFO), $(KNOWN_RELEASE_INFO))
244-
.PHONY: $(GIT_INFO_FILE)
245-
endif
246-
247230
clean:
248231
$(RM) $(patsubst %.cpp, %$(OBJEXT), $(filter %.cpp, $(SRC))) \
249232
$(patsubst %.cpp, %$(DEPEXT), $(filter %.cpp, $(SRC))) \
250233
$(patsubst %.cc, %$(OBJEXT), $(filter %.cc, $(SRC))) \
251234
$(patsubst %.cc, %$(DEPEXT), $(filter %.cc, $(SRC))) \
252-
$(CLEANFILES) $(GIT_INFO_FILE)
235+
$(CLEANFILES)
253236

254237
.PHONY: first_target clean all
255238
.PHONY: sources generated_files

0 commit comments

Comments
 (0)