Skip to content

Commit 152d943

Browse files
jnarebgitster
authored andcommitted
gitweb: Create install target for gitweb in Makefile
Installing gitweb is now as easy as # make gitwebdir=/var/www/cgi-bin gitweb-install ;# as root The gitweb/INSTALL file was updated accordingly, to make use of this new target. Fix shell quoting, i.e. setting bindir_SQ etc., in gitweb/Makefile. Those variables were not used previously. Signed-off-by: Jakub Narebski <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8515392 commit 152d943

File tree

3 files changed

+35
-11
lines changed

3 files changed

+35
-11
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,6 +2004,9 @@ endif
20042004
done; } && \
20052005
./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
20062006

2007+
install-gitweb:
2008+
$(MAKE) -C gitweb install
2009+
20072010
install-doc:
20082011
$(MAKE) -C Documentation install
20092012

gitweb/INSTALL

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ First you have to generate gitweb.cgi from gitweb.perl using
66
gitweb.css, git-logo.png and git-favicon.png) to their destination.
77
For example if git was (or is) installed with /usr prefix, you can do
88

9-
$ make prefix=/usr gitweb ;# as yourself
10-
# cp gitweb/*.cgi gitweb/*.css \
11-
gitweb/*.js gitweb/*.png \
12-
/var/www/cgi-bin/ ;# as root
9+
$ make prefix=/usr gitweb ;# as yourself
10+
# make gitwebdir=/var/www/cgi-bin install-gitweb ;# as root
1311

1412
Alternatively you can use autoconf generated ./configure script to
1513
set up path to git binaries (via config.mak.autogen), so you can write
@@ -18,9 +16,8 @@ instead
1816
$ make configure ;# as yourself
1917
$ ./configure --prefix=/usr ;# as yourself
2018
$ make gitweb ;# as yourself
21-
# cp gitweb/*.cgi gitweb/*.css \
22-
gitweb/*.js gitweb/*.png \
23-
/var/www/cgi-bin/ ;# as root
19+
# make gitwebdir=/var/www/cgi-bin \
20+
install-gitweb ;# as root
2421

2522
The above example assumes that your web server is configured to run
2623
[executable] files in /var/www/cgi-bin/ as server scripts (as CGI

gitweb/Makefile

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ all::
1212

1313
prefix ?= $(HOME)
1414
bindir ?= $(prefix)/bin
15+
gitwebdir ?= /var/www/cgi-bin
16+
1517
RM ?= rm -f
18+
INSTALL ?= install
1619

1720
# default configuration for gitweb
1821
GITWEB_CONFIG = gitweb_config.perl
@@ -49,9 +52,11 @@ SHELL_PATH ?= $(SHELL)
4952
PERL_PATH ?= /usr/bin/perl
5053

5154
# Shell quote;
52-
bindir_SQ = $(subst ','\'',$(bindir)) #'
53-
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) #'
54-
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) #'
55+
bindir_SQ = $(subst ','\'',$(bindir))#'
56+
gitwebdir_SQ = $(subst ','\'',$(gitwebdir))#'
57+
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))#'
58+
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))#'
59+
DESTDIR_SQ = $(subst ','\'',$(DESTDIR))#'
5560

5661
# Quiet generation (unless V=1)
5762
QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
@@ -80,20 +85,30 @@ endif
8085

8186
all:: gitweb.cgi
8287

88+
GITWEB_PROGRAMS = gitweb.cgi
89+
8390
ifdef JSMIN
91+
GITWEB_FILES += gitweb.min.js
8492
GITWEB_JS = gitweb.min.js
8593
all:: gitweb.min.js
8694
gitweb.min.js: gitweb.js GITWEB-BUILD-OPTIONS
8795
$(QUIET_GEN)$(JSMIN) <$< >$@
96+
else
97+
GITWEB_FILES += gitweb.js
8898
endif
8999

90100
ifdef CSSMIN
101+
GITWEB_FILES += gitweb.min.css
91102
GITWEB_CSS = gitweb.min.css
92103
all:: gitweb.min.css
93104
gitweb.min.css: gitweb.css GITWEB-BUILD-OPTIONS
94105
$(QUIET_GEN)$(CSSMIN) <$ >$@
106+
else
107+
GITWEB_FILES += gitweb.css
95108
endif
96109

110+
GITWEB_FILES += git-logo.png git-favicon.png
111+
97112
GITWEB_REPLACE = \
98113
-e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
99114
-e 's|++GIT_BINDIR++|$(bindir)|g' \
@@ -127,8 +142,17 @@ gitweb.cgi: gitweb.perl GITWEB-BUILD-OPTIONS
127142
chmod +x $@+ && \
128143
mv $@+ $@
129144

145+
### Installation rules
146+
147+
install: all
148+
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)'
149+
$(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)'
150+
$(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebdir_SQ)'
151+
152+
### Cleaning rules
153+
130154
clean:
131155
$(RM) gitweb.cgi gitweb.min.js gitweb.min.css GITWEB-BUILD-OPTIONS
132156

133-
.PHONY: all clean .FORCE-GIT-VERSION-FILE FORCE
157+
.PHONY: all clean install .FORCE-GIT-VERSION-FILE FORCE
134158

0 commit comments

Comments
 (0)