]> git.cameronkatri.com Git - cgit.git/blob - cgit.mk
filter: return on null filter from open and close
[cgit.git] / cgit.mk
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 "../".
4 include Makefile
5
6 CGIT_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.
20 CGIT_CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"'
21 CGIT_CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"'
22 CGIT_CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"'
23
24 ifdef NO_C99_FORMAT
25 CFLAGS += -DNO_C99_FORMAT
26 endif
27
28 ifdef NO_LUA
29 CFLAGS += -DNO_LUA
30 else
31
32 ifeq (VANILLA,$(LUA_IMPLEMENTATION))
33 CFLAGS += -llua
34 else
35 LUAJIT_LIBS := $(shell pkg-config --libs luajit)
36 LUAJIT_CFLAGS := $(shell pkg-config --cflags luajit)
37 CGIT_LIBS += $(LUAJIT_LIBS)
38 CFLAGS += $(LUAJIT_CFLAGS)
39 endif
40
41 endif
42
43 CGIT_LIBS += -ldl
44
45
46
47 CGIT_OBJ_NAMES += cgit.o
48 CGIT_OBJ_NAMES += cache.o
49 CGIT_OBJ_NAMES += cmd.o
50 CGIT_OBJ_NAMES += configfile.o
51 CGIT_OBJ_NAMES += filter.o
52 CGIT_OBJ_NAMES += html.o
53 CGIT_OBJ_NAMES += parsing.o
54 CGIT_OBJ_NAMES += scan-tree.o
55 CGIT_OBJ_NAMES += shared.o
56 CGIT_OBJ_NAMES += ui-atom.o
57 CGIT_OBJ_NAMES += ui-blob.o
58 CGIT_OBJ_NAMES += ui-clone.o
59 CGIT_OBJ_NAMES += ui-commit.o
60 CGIT_OBJ_NAMES += ui-diff.o
61 CGIT_OBJ_NAMES += ui-log.o
62 CGIT_OBJ_NAMES += ui-patch.o
63 CGIT_OBJ_NAMES += ui-plain.o
64 CGIT_OBJ_NAMES += ui-refs.o
65 CGIT_OBJ_NAMES += ui-repolist.o
66 CGIT_OBJ_NAMES += ui-shared.o
67 CGIT_OBJ_NAMES += ui-snapshot.o
68 CGIT_OBJ_NAMES += ui-ssdiff.o
69 CGIT_OBJ_NAMES += ui-stats.o
70 CGIT_OBJ_NAMES += ui-summary.o
71 CGIT_OBJ_NAMES += ui-tag.o
72 CGIT_OBJ_NAMES += ui-tree.o
73
74 CGIT_OBJS := $(addprefix $(CGIT_PREFIX),$(CGIT_OBJ_NAMES))
75
76 # Only cgit.c reference CGIT_VERSION so we only rebuild its objects when the
77 # version changes.
78 CGIT_VERSION_OBJS := $(addprefix $(CGIT_PREFIX),cgit.o)
79 $(CGIT_VERSION_OBJS): $(CGIT_PREFIX)VERSION
80 $(CGIT_VERSION_OBJS): EXTRA_CPPFLAGS = \
81 -DCGIT_VERSION='"$(CGIT_VERSION)"'
82
83 # Git handles dependencies using ":=" so dependencies in CGIT_OBJ are not
84 # handled by that and we must handle them ourselves.
85 cgit_dep_files := $(foreach f,$(CGIT_OBJS),$(dir $f).depend/$(notdir $f).d)
86 cgit_dep_files_present := $(wildcard $(cgit_dep_files))
87 ifneq ($(cgit_dep_files_present),)
88 include $(cgit_dep_files_present)
89 endif
90
91 ifeq ($(wildcard $(CGIT_PREFIX).depend),)
92 missing_dep_dirs += $(CGIT_PREFIX).depend
93 endif
94
95 $(CGIT_PREFIX).depend:
96 @mkdir -p $@
97
98 $(CGIT_PREFIX)CGIT-CFLAGS: FORCE
99 @FLAGS='$(subst ','\'',$(CGIT_CFLAGS))'; \
100 if test x"$$FLAGS" != x"`cat ../CGIT-CFLAGS 2>/dev/null`" ; then \
101 echo 1>&2 " * new CGit build flags"; \
102 echo "$$FLAGS" >$(CGIT_PREFIX)CGIT-CFLAGS; \
103 fi
104
105 $(CGIT_OBJS): %.o: %.c GIT-CFLAGS $(CGIT_PREFIX)CGIT-CFLAGS $(missing_dep_dirs)
106 $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $(CGIT_CFLAGS) $<
107
108 $(CGIT_PREFIX)cgit: $(CGIT_OBJS) GIT-LDFLAGS $(GITLIBS)
109 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) $(CGIT_LIBS)