| 1 |
# Makefile for cvs-fast-export |
| 2 |
# |
| 3 |
# Build requirements: Read the "buildprep" script. |
| 4 |
# You may be able to run that to install all dependencies. |
| 5 |
# |
| 6 |
# The C compiler must support anonymous unions (GNU, clang, C11). |
| 7 |
# |
| 8 |
# If you get a link error complaining that clock_gettime() can't be |
| 9 |
# found, uncomment the line that includes -lrt in the link flags. |
| 10 |
# You'll need this if your glibc version is < 2.17; that is for RHEL 6 |
| 11 |
# or older and Debian Wheezy or older. Alas, we can't unconditionally |
| 12 |
# include -lrt because Darwin. |
| 13 |
# |
| 14 |
# You will see some meaningless failures with git 1.7.1 and older. |
| 15 |
# |
| 16 |
# Note: the reason for the .adoc extensions on README/NEWS/TODO is so they'll |
| 17 |
# display nicely in GitLab's repository-browsing interface. |
| 18 |
|
| 19 |
VERSION=$(shell sed -n <NEWS.adoc '/::/s/^\([0-9][^:]*\).*/\1/p' | head -1) |
| 20 |
|
| 21 |
.PATH: $(.PARSEDIR) |
| 22 |
prefix?=/usr/local |
| 23 |
target=$(DESTDIR)$(prefix) |
| 24 |
parsedir:=$(.PARSEDIR) |
| 25 |
srcdir=$(dir $(abspath $(firstword $(MAKEFILE_LIST))))$(parsedir) |
| 26 |
VPATH=$(srcdir) |
| 27 |
mandir?=$(DESTDIR)$(prefix)/share/man |
| 28 |
|
| 29 |
INSTALL = install |
| 30 |
TAR ?= tar |
| 31 |
BISON ?= bison |
| 32 |
FLEX ?= flex |
| 33 |
A2X ?= a2x |
| 34 |
|
| 35 |
ENV_CFLAGS := $(CFLAGS) |
| 36 |
GCC_WARNINGS1=-Wall -Wpointer-arith -Wstrict-prototypes |
| 37 |
GCC_WARNINGS2=-Wmissing-prototypes -Wmissing-declarations |
| 38 |
GCC_WARNINGS3=-Wno-unused-function -Wno-unused-label -Wno-format-zero-length |
| 39 |
GCC_WARNINGS=$(GCC_WARNINGS1) $(GCC_WARNINGS2) $(GCC_WARNINGS3) |
| 40 |
CFLAGS += $(GCC_WARNINGS) |
| 41 |
CPPFLAGS += -I. -I$(srcdir) |
| 42 |
#LIBS=-lrt |
| 43 |
CPPFLAGS += -DVERSION=\"$(VERSION)\" |
| 44 |
|
| 45 |
# Enable this for multithreading. |
| 46 |
CFLAGS += -pthread |
| 47 |
CPPFLAGS += -DTHREADS |
| 48 |
|
| 49 |
# Optimizing for speed. Un-comment for testing Linux build |
| 50 |
#CFLAGS += -march=native |
| 51 |
|
| 52 |
# To enable debugging of the Yacc grammar, uncomment the following line |
| 53 |
#CPPFLAGS += -DYYDEBUG=1 |
| 54 |
# To enable verbose debugging of the analysis stage, uncomment the following line |
| 55 |
#CPPFLAGS += -DCVSDEBUG=1 |
| 56 |
# To enable debugging of blob export, uncomment the following line |
| 57 |
#CPPFLAGS += -DFDEBUG=1 |
| 58 |
# To enable assertions of red black trees, uncomment the following line |
| 59 |
#CPPFLAGS += -DRBDEBUG=1 |
| 60 |
# To enable debugging of order instability issues |
| 61 |
#CPPFLAGS += -DORDERDEBUG=1 |
| 62 |
# To enable debugging of gitspace backlinks, uncomment the following line |
| 63 |
#CPPFLAGS += -DGITSPACEDEBUG=1 |
| 64 |
|
| 65 |
# Condition in various optimization hacks. You almost certainly |
| 66 |
# don't want to turn any of these off; the condition symbols are |
| 67 |
# present more as documentation of the program structure than |
| 68 |
# anything else |
| 69 |
CPPFLAGS += -DREDBLACK # Use red-black trees for faster symbol lookup |
| 70 |
CPPFLAGS += -DUSE_MMAP # Use mmap for reading CVS masters |
| 71 |
CPPFLAGS += -DLINESTATS # Keep track of which lines have @ string delimiters |
| 72 |
CPPFLAGS += -DTREEPACK # Reduce memory usage, particularly on large repos |
| 73 |
|
| 74 |
# First line works for GNU C. |
| 75 |
# Replace with the next if your compiler doesn't support C99 restrict qualifier |
| 76 |
CPPFLAGS+=-Drestrict=__restrict__ |
| 77 |
#CPPFLAGS+=-Drestrict="" |
| 78 |
|
| 79 |
# To enable profiling, uncomment the following line |
| 80 |
# Note: the profiler gets confused if you don't also turn off -O flags. |
| 81 |
# CFLAGS += -pg |
| 82 |
# Warning: Using -O3 has been seen to cause core dumps on repositories with |
| 83 |
# very long revision names - some bounds check gets optimized away. Don't do that. |
| 84 |
# CFLAGS += -O2 |
| 85 |
# If your toolchain supports link time optimization this is a cheap speedup |
| 86 |
# CFLAGS += -flto |
| 87 |
CFLAGS += -g |
| 88 |
# Test coverage flags |
| 89 |
# CFLAGS += -ftest-coverage -fprofile-arcs |
| 90 |
CFLAGS += $(EXTRA_CFLAGS) $(ENV_CFLAGS) |
| 91 |
|
| 92 |
#YFLAGS= --report=all |
| 93 |
LFLAGS= |
| 94 |
|
| 95 |
OBJS=gram.o lex.o rbtree.o main.o import.o dump.o cvsnumber.o \ |
| 96 |
cvsutil.o revdir.o revlist.o atom.o revcvs.o generate.o export.o \ |
| 97 |
nodehash.o tags.o authormap.o graph.o utils.o collate.o hash.o |
| 98 |
|
| 99 |
all: cvs-fast-export man html |
| 100 |
|
| 101 |
cvs-fast-export: $(OBJS) |
| 102 |
$(CC) $(CFLAGS) $(TARGET_ARCH) $(OBJS) $(LDFLAGS) $(LIBS) -o $@ |
| 103 |
|
| 104 |
$(OBJS): cvs.h cvstypes.h |
| 105 |
revcvs.o cvsutils.o rbtree.o: rbtree.h |
| 106 |
atom.o nodehash.o revcvs.o revdir.o: hash.h |
| 107 |
revdir.o: treepack.c dirpack.c revdir.c |
| 108 |
dump.o export.o graph.o main.o collate.o revdir.o: revdir.h |
| 109 |
|
| 110 |
gram.h gram.c: gram.y |
| 111 |
$(BISON) $(YFLAGS) --defines=gram.h --output-file=gram.c $(srcdir)/gram.y |
| 112 |
lex.h lex.c: lex.l |
| 113 |
$(FLEX) $(LFLAGS) --header-file=lex.h --outfile=lex.c $(srcdir)/lex.l |
| 114 |
|
| 115 |
gram.o: gram.c lex.h gram.h |
| 116 |
import.o: import.c lex.h gram.h |
| 117 |
lex.o: lex.c gram.h |
| 118 |
|
| 119 |
.SUFFIXES: .html .adoc .txt .1 |
| 120 |
|
| 121 |
# Requires asciidoc |
| 122 |
# To debug asciidoc problems, you may need to run "xmllint --nonet --noout --valid" |
| 123 |
# on the intermediate XML. |
| 124 |
.adoc.1: |
| 125 |
$(A2X) --doctype manpage --format manpage $< |
| 126 |
.adoc.html: |
| 127 |
$(A2X) --doctype manpage --format xhtml -D . $< |
| 128 |
rm -f docbook-xsl.css |
| 129 |
|
| 130 |
reporting-bugs.html: reporting-bugs.adoc |
| 131 |
TZ=UTC asciidoc reporting-bugs.adoc |
| 132 |
|
| 133 |
man: cvs-fast-export.1 cvssync.1 cvsconvert.1 |
| 134 |
|
| 135 |
html: cvs-fast-export.html cvssync.html cvsconvert.html reporting-bugs.html |
| 136 |
|
| 137 |
clean: |
| 138 |
rm -f $(OBJS) gram.h gram.c lex.h lex.c cvs-fast-export |
| 139 |
rm -f *.1 *.html docbook-xsl.css gram.output gmon.out |
| 140 |
rm -f MANIFEST index.html *.tar.gz |
| 141 |
rm -f *.gcno *.gcda |
| 142 |
|
| 143 |
|
| 144 |
# Warning: The regression tests will fail spuriously if your CVS lacks the |
| 145 |
# MirOS patches. These are carried by Debian Linux and derivatives; you can |
| 146 |
# check by Looking for "MirDebian" in the output of cvs --version. |
| 147 |
check: cvs-fast-export |
| 148 |
-make EXTRA=-q cppcheck pylint |
| 149 |
-shellcheck -f gcc buildprep tests/visualize tests/gitwash tests/incremental.sh |
| 150 |
$(MAKE) -C tests -s -f $(srcdir)tests/Makefile |
| 151 |
|
| 152 |
install: install-bin install-man |
| 153 |
install-bin: cvs-fast-export cvssync cvsconvert |
| 154 |
$(INSTALL) -d "$(target)/bin" |
| 155 |
$(INSTALL) $^ "$(target)/bin" |
| 156 |
install-man: man |
| 157 |
$(INSTALL) -d "$(mandir)/man1" |
| 158 |
$(INSTALL) -m 644 cvs-fast-export.1 "$(mandir)/man1" |
| 159 |
$(INSTALL) -m 644 cvssync.1 "$(mandir)/man1" |
| 160 |
$(INSTALL) -m 644 cvsconvert.1 "$(mandir)/man1" |
| 161 |
uninstall: uninstall-man uninstall-bin |
| 162 |
uninstall-man: |
| 163 |
cd $(mandir)/man1/ && rm -f cvs-fast-export.1 cvssync.1 cvsconvert.1 |
| 164 |
uninstall-bin: |
| 165 |
cd $(target)/bin && rm -f cvs-fast-export cvssync cvsconvert |
| 166 |
|
| 167 |
PROFILE_REPO = ~/software/groff-conversion/groff-mirror/groff |
| 168 |
gmon.out: cvs-fast-export |
| 169 |
find $(PROFILE_REPO) -name '*,v' | cvs-fast-export -k -p >/dev/null |
| 170 |
PROFILE: gmon.out |
| 171 |
gprof cvs-fast-export >PROFILE |
| 172 |
|
| 173 |
version: |
| 174 |
@echo $(VERSION) |
| 175 |
|
| 176 |
# Weird suppressions are required because of strange tricks in Bison and Flex. |
| 177 |
CSUPPRESSIONS = -U__UNUSED__ -UYYPARSE_PARAM -UYYTYPE_INT16 -UYYTYPE_INT8 \ |
| 178 |
-UYYTYPE_UINT16 -UYYTYPE_UINT8 -UYY_USER_INIT -UYY_READ_BUF_SIZE \ |
| 179 |
-UYY_NO_INPUT -UECHO -UYY_START_STACK_INCR -UYY_FATAL_ERROR \ |
| 180 |
-U_SC_NPROCESSORS_ONLN -Ushort -Usize_t -Uyytext_ptr \ |
| 181 |
-Uyyoverflow -U__cplusplus -U__APPLE__ -DCLOCK_REALTIME=0 |
| 182 |
cppcheck: |
| 183 |
cppcheck -I. --template $(CC) --enable=all $(CSUPPRESSIONS) --suppress=unusedStructMember --suppress=unusedFunction --suppress=unreadVariable --suppress=uselessAssignmentPtrArg --suppress=missingIncludeSystem $(EXTRA) --inline-suppr *.[ch] |
| 184 |
|
| 185 |
PYLINTOPTS = --rcfile=/dev/null --reports=n \ |
| 186 |
--msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \ |
| 187 |
--dummy-variables-rgx='^_' |
| 188 |
PYSUPPRESSIONS = --disable="C0103,C0111,C0301,C0325,C0326,C0410,C0411,C0413,E1305,R0201,R0205,R0801,R0903,R0912,R0913,R0914,W0142,R1705,R1718,R1721,R1724,W0221,W0621" |
| 189 |
pylint: |
| 190 |
@pylint $(PYLINTOPTS) $(PYSUPPRESSIONS) cvssync cvsconvert cvsstrip tests/*.py |
| 191 |
|
| 192 |
# Because we don't want copies of the test repositories in the distribution. |
| 193 |
distclean: clean |
| 194 |
cd tests; $(MAKE) --quiet clean |
| 195 |
|
| 196 |
SOURCES = Makefile *.[ch] *.[yl] cvssync cvsconvert cvsstrip buildprep |
| 197 |
DOCS = control *.adoc cfe-logo.png |
| 198 |
ALL = $(SOURCES) $(DOCS) tests |
| 199 |
cvs-fast-export-$(VERSION).tar.gz: $(ALL) |
| 200 |
$(TAR) --transform='s:^:cvs-fast-export-$(VERSION)/:' --show-transformed-names -cvzf cvs-fast-export-$(VERSION).tar.gz $(ALL) |
| 201 |
|
| 202 |
dist: distclean cvs-fast-export-$(VERSION).tar.gz |
| 203 |
|
| 204 |
release: cvs-fast-export-$(VERSION).tar.gz html |
| 205 |
shipper version=$(VERSION) | sh -e -x |
| 206 |
|
| 207 |
refresh: html |
| 208 |
shipper -N -w version=$(VERSION) | sh -e -x |