all repos — cgit @ 747b035dda97ae359ed00d84744acfa8cc009fb2

a hyperfast web frontend for git written in c

cgit.mk (view raw)

 1# This Makefile is run in the "git" directory in order to re-use Git's
 2# build variables and operating system detection.  Hence all files in
 3# CGit's directory must be prefixed with "../".
 4include Makefile
 5
 6CGIT_PREFIX = ../
 7
 8-include $(CGIT_PREFIX)cgit.conf
 9
10# The CGIT_* variables are inherited when this file is called from the
11# main Makefile - they are defined there.
12
13$(CGIT_PREFIX)VERSION: force-version
14	@cd $(CGIT_PREFIX) && '$(SHELL_PATH_SQ)' ./gen-version.sh "$(CGIT_VERSION)"
15-include $(CGIT_PREFIX)VERSION
16.PHONY: force-version
17
18# CGIT_CFLAGS is a separate variable so that we can track it separately
19# and avoid rebuilding all of Git when these variables change.
20CGIT_CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"'
21CGIT_CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"'
22CGIT_CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"'
23
24ifdef NO_C99_FORMAT
25	CFLAGS += -DNO_C99_FORMAT
26endif
27
28CGIT_OBJ_NAMES += cgit.o
29CGIT_OBJ_NAMES += cache.o
30CGIT_OBJ_NAMES += cmd.o
31CGIT_OBJ_NAMES += configfile.o
32CGIT_OBJ_NAMES += html.o
33CGIT_OBJ_NAMES += parsing.o
34CGIT_OBJ_NAMES += scan-tree.o
35CGIT_OBJ_NAMES += shared.o
36CGIT_OBJ_NAMES += ui-atom.o
37CGIT_OBJ_NAMES += ui-blob.o
38CGIT_OBJ_NAMES += ui-clone.o
39CGIT_OBJ_NAMES += ui-commit.o
40CGIT_OBJ_NAMES += ui-diff.o
41CGIT_OBJ_NAMES += ui-log.o
42CGIT_OBJ_NAMES += ui-patch.o
43CGIT_OBJ_NAMES += ui-plain.o
44CGIT_OBJ_NAMES += ui-refs.o
45CGIT_OBJ_NAMES += ui-repolist.o
46CGIT_OBJ_NAMES += ui-shared.o
47CGIT_OBJ_NAMES += ui-snapshot.o
48CGIT_OBJ_NAMES += ui-ssdiff.o
49CGIT_OBJ_NAMES += ui-stats.o
50CGIT_OBJ_NAMES += ui-summary.o
51CGIT_OBJ_NAMES += ui-tag.o
52CGIT_OBJ_NAMES += ui-tree.o
53CGIT_OBJ_NAMES += vector.o
54
55CGIT_OBJS := $(addprefix $(CGIT_PREFIX),$(CGIT_OBJ_NAMES))
56
57# Only cgit.c reference CGIT_VERSION so we only rebuild its objects when the
58# version changes.
59CGIT_VERSION_OBJS := $(addprefix $(CGIT_PREFIX),cgit.o)
60$(CGIT_VERSION_OBJS): $(CGIT_PREFIX)VERSION
61$(CGIT_VERSION_OBJS): EXTRA_CPPFLAGS = \
62	-DCGIT_VERSION='"$(CGIT_VERSION)"'
63
64
65# Git handles dependencies using ":=" so dependencies in CGIT_OBJ are not
66# handled by that and we must handle them ourselves.
67cgit_dep_files := $(foreach f,$(CGIT_OBJS),$(dir $f).depend/$(notdir $f).d)
68cgit_dep_files_present := $(wildcard $(cgit_dep_files))
69ifneq ($(cgit_dep_files_present),)
70include $(cgit_dep_files_present)
71endif
72
73ifeq ($(wildcard $(CGIT_PREFIX).depend),)
74missing_dep_dirs += $(CGIT_PREFIX).depend
75endif
76
77$(CGIT_PREFIX).depend:
78	@mkdir -p $@
79
80$(CGIT_PREFIX)CGIT-CFLAGS: FORCE
81	@FLAGS='$(subst ','\'',$(CGIT_CFLAGS))'; \
82	    if test x"$$FLAGS" != x"`cat ../CGIT-CFLAGS 2>/dev/null`" ; then \
83		echo 1>&2 "    * new CGit build flags"; \
84		echo "$$FLAGS" >$(CGIT_PREFIX)CGIT-CFLAGS; \
85            fi
86
87$(CGIT_OBJS): %.o: %.c GIT-CFLAGS $(CGIT_PREFIX)CGIT-CFLAGS $(missing_dep_dirs)
88	$(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $(CGIT_CFLAGS) $<
89
90$(CGIT_PREFIX)cgit: $(CGIT_OBJS) GIT-LDFLAGS $(GITLIBS)
91	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)