2 # Note on my Mobile Pentium II, -march=pentium2 delivers twice the performance of i386
4 #OptDbg=-O3 -march=pentium2
7 CWFLAGS
=-Wall
-Werror
-Wstrict-prototypes
-Wextra
-Wno-unused-parameter
-Wno-missing-field-initializers
9 CFLAGS
=$(OptDbg
) -I.
$(CWFLAGS
)
13 INSTALL
= /usr
/bin
/install
15 BINDIR
= $(PREFIX
)/bin
16 MANDIR
= $(PREFIX
)/share
/man
17 MAN1DIR
= $(MANDIR
)/man1
18 MAN5DIR
= $(MANDIR
)/man5
21 # Where to place intermediate objects
23 # Where to place final objects
27 LIBOBJ
= load.o parse.o split.o extract.o diff.o bestmatch.o merge2.o ccan
/hash
/hash.o
28 OBJ
=wiggle.o ReadMe.o vpatch.o
30 BOBJ
=$(patsubst %.o
,$(O
)/%.o
,$(OBJ
))
31 BLIBOBJ
=$(patsubst %.o
,$(O
)/%.o
,$(LIBOBJ
))
33 all: $(BIN
)/wiggle
$(DOC
)/wiggle.man
test
34 lib
: $(O
)/libwiggle.a
41 QUIET_CC
= $(Q
:@
=@echo
' CC '$@
;)
42 QUIET_AR
= $(Q
:@
=@echo
' AR '$@
;)
43 QUIET_LINK
= $(Q
:@
=@echo
' LINK '$@
;)
44 QUIET_MAN
= $(Q
:@
=@echo
' MAN '$@
;)
45 QUIET_CLEAN
= $(Q
:@
=@echo
' CLEAN '$@
;)
48 $(BIN
)/wiggle
: $(BOBJ
) $(O
)/libwiggle.a
49 $(QUIET_LINK
)$(CC
) $(CFLAGS
) $^
$(LDLIBS
) -o
$@
51 $(O
)/libwiggle.a
: $(BLIBOBJ
)
52 $(QUIET_AR
)ar cr
$@
$^
56 $(O
)/split.o
:: ccan
/hash
/hash.h config.h
58 $(BOBJ
) $(BLIBOBJ
) :: $(O
)/%.o
: %.c
60 $(QUIET_CC
)$(CC
) $(CFLAGS
) -c
-o
$@
$<
62 VERSION
= $(shell [ -d .git
] && git
2> /dev
/null describe HEAD
)
63 VERS_DATE
= $(shell [ -d .git
] && git
2> /dev
/null log
-n1
--format
=format
:%cd
--date
=short
)
64 DVERS
= $(if
$(VERSION
),-DVERSION
=\"$(VERSION
)\",)
65 DDATE
= $(if
$(VERS_DATE
),-DVERS_DATE
=\"$(VERS_DATE
)\",)
66 CFLAGS
+= $(DVERS
) $(DDATE
)
71 valgrind
: wiggle dotest
77 $(DOC
)/wiggle.man
: wiggle
.1
78 $(QUIET_MAN
)nroff
-man wiggle
.1 > $@
80 clean: targets artifacts dirs
82 $(QUIET_CLEAN
)rm -f
$(O
)/*.
[ao
] $(O
)/ccan
/hash
/*.o
$(DOC
)/*.man
$(BIN
)/wiggle .version
* demo.patch version
84 $(QUIET_CLEAN
)find .
-name core
-o
-name
'*.tmp*' -o
-name .tmp
-o
-name .time | xargs
rm -f
85 dirs
: targets artifacts
86 $(QUIET_CLEAN
)[ -d
$(O
)/ccan
/hash
] && rmdir
-p
$(O
)/ccan
/hash || true
87 $(QUIET_CLEAN
)[ -d
$(O
) ] && rmdir
-p
$(O
) || true
89 install : $(BIN
)/wiggle wiggle
.1
90 $(INSTALL
) -d
$(DESTDIR
)$(BINDIR
) $(DESTDIR
)$(MAN1DIR
)
91 $(INSTALL
) $(STRIP
) -m
755 $(BIN
)/wiggle
$(DESTDIR
)$(BINDIR
)
92 $(INSTALL
) -m
644 wiggle
.1 $(DESTDIR
)$(MAN1DIR
)
94 version
: ReadMe.c wiggle
.1
96 @sed
-n
-e
's/.*VERSION "\([0-9.]*\)".*/\1/p' ReadMe.c
> .version-readme
97 @sed
-n
-e
's/.*WIGGLE 1 "" v\([0-9.]*\)$$/\1/p' wiggle
.1 > .version-man
98 @cmp
-s .version-readme .version-man
&& cat .version-man
> version ||
{ echo Inconsistant versions.
; exit
1;}
100 dist : test clean version
102 rm -f DIST
/wiggle-
`cat version`
103 git archive
--prefix wiggle-
`cat version`/ v
`cat version` | gzip
-9 > DIST
/wiggle-
`cat version`.
tar.gz
109 diff
-rup demo.orig demo.patched | sed
's/demo.patched/demo/' > demo.patch