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 "../".
8 -include $(CGIT_PREFIX
)cgit.conf
10 # The CGIT_* variables are inherited when this file is called from the
11 # main Makefile - they are defined there.
13 $(CGIT_PREFIX
)VERSION
: force-version
14 @cd
$(CGIT_PREFIX
) && '$(SHELL_PATH_SQ)' .
/gen-version.sh
"$(CGIT_VERSION)"
15 -include $(CGIT_PREFIX
)VERSION
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)"'
24 PKG_CONFIG ?
= pkg-config
27 CFLAGS
+= -DNO_C99_FORMAT
31 LUA_MESSAGE
:= linking without specified Lua support
32 CGIT_CFLAGS
+= -DNO_LUA
34 ifeq ($(LUA_PKGCONFIG
),)
35 LUA_PKGCONFIG
:= $(shell for
pc in luajit lua lua5.2 lua5.1
; do \
36 $(PKG_CONFIG
) --exists
$$pc 2>/dev
/null
&& echo
$$pc && break
; \
38 LUA_MODE
:= autodetected
42 ifneq ($(LUA_PKGCONFIG
),)
43 LUA_MESSAGE
:= linking with
$(LUA_MODE
) $(LUA_PKGCONFIG
)
44 LUA_LIBS
:= $(shell $(PKG_CONFIG
) --libs
$(LUA_PKGCONFIG
) 2>/dev
/null
)
45 LUA_CFLAGS
:= $(shell $(PKG_CONFIG
) --cflags $(LUA_PKGCONFIG
) 2>/dev
/null
)
46 CGIT_LIBS
+= $(LUA_LIBS
)
47 CGIT_CFLAGS
+= $(LUA_CFLAGS
)
49 LUA_MESSAGE
:= linking without autodetected Lua support
51 CGIT_CFLAGS
+= -DNO_LUA
56 # Add -ldl to linker flags on systems that commonly use GNU libc.
57 ifneq (,$(filter $(uname_S
),Linux GNU GNU
/kFreeBSD
))
61 # glibc 2.1+ offers sendfile which the most common C library on Linux
62 ifeq ($(uname_S
),Linux
)
63 HAVE_LINUX_SENDFILE
= YesPlease
66 ifdef HAVE_LINUX_SENDFILE
67 CGIT_CFLAGS
+= -DHAVE_LINUX_SENDFILE
70 CGIT_OBJ_NAMES
+= cgit.o
71 CGIT_OBJ_NAMES
+= cache.o
72 CGIT_OBJ_NAMES
+= cmd.o
73 CGIT_OBJ_NAMES
+= configfile.o
74 CGIT_OBJ_NAMES
+= filter.o
75 CGIT_OBJ_NAMES
+= html.o
76 CGIT_OBJ_NAMES
+= parsing.o
77 CGIT_OBJ_NAMES
+= scan-tree.o
78 CGIT_OBJ_NAMES
+= shared.o
79 CGIT_OBJ_NAMES
+= ui-atom.o
80 CGIT_OBJ_NAMES
+= ui-blame.o
81 CGIT_OBJ_NAMES
+= ui-blob.o
82 CGIT_OBJ_NAMES
+= ui-clone.o
83 CGIT_OBJ_NAMES
+= ui-commit.o
84 CGIT_OBJ_NAMES
+= ui-diff.o
85 CGIT_OBJ_NAMES
+= ui-log.o
86 CGIT_OBJ_NAMES
+= ui-patch.o
87 CGIT_OBJ_NAMES
+= ui-plain.o
88 CGIT_OBJ_NAMES
+= ui-refs.o
89 CGIT_OBJ_NAMES
+= ui-repolist.o
90 CGIT_OBJ_NAMES
+= ui-shared.o
91 CGIT_OBJ_NAMES
+= ui-snapshot.o
92 CGIT_OBJ_NAMES
+= ui-ssdiff.o
93 CGIT_OBJ_NAMES
+= ui-stats.o
94 CGIT_OBJ_NAMES
+= ui-summary.o
95 CGIT_OBJ_NAMES
+= ui-tag.o
96 CGIT_OBJ_NAMES
+= ui-tree.o
98 CGIT_OBJS
:= $(addprefix $(CGIT_PREFIX
),$(CGIT_OBJ_NAMES
))
100 # Only cgit.c reference CGIT_VERSION so we only rebuild its objects when the
102 CGIT_VERSION_OBJS
:= $(addprefix $(CGIT_PREFIX
),cgit.o cgit.sp
)
103 $(CGIT_VERSION_OBJS
): $(CGIT_PREFIX
)VERSION
104 $(CGIT_VERSION_OBJS
): EXTRA_CPPFLAGS
= \
105 -DCGIT_VERSION
='"$(CGIT_VERSION)"'
107 # Git handles dependencies using ":=" so dependencies in CGIT_OBJ are not
108 # handled by that and we must handle them ourselves.
109 cgit_dep_files
:= $(foreach f
,$(CGIT_OBJS
),$(dir $f).depend
/$(notdir $f).d
)
110 cgit_dep_files_present
:= $(wildcard $(cgit_dep_files
))
111 ifneq ($(cgit_dep_files_present
),)
112 include $(cgit_dep_files_present
)
115 ifeq ($(wildcard $(CGIT_PREFIX
).depend
),)
116 missing_dep_dirs
+= $(CGIT_PREFIX
).depend
119 $(CGIT_PREFIX
).depend
:
122 $(CGIT_PREFIX
)CGIT-CFLAGS
: FORCE
123 @FLAGS
='$(subst ','\'',$(CGIT_CFLAGS
))'; \
124 if test x"$$FLAGS" != x"`cat ../CGIT-CFLAGS 2>/dev/null`" ; then \
125 echo 1>&2 " * new CGit build flags"; \
126 echo "$$FLAGS" >$(CGIT_PREFIX)CGIT-CFLAGS; \
129 $(CGIT_OBJS): %.o: %.c GIT-CFLAGS $(CGIT_PREFIX)CGIT-CFLAGS $(missing_dep_dirs)
130 $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $(CGIT_CFLAGS) $<
132 $(CGIT_PREFIX)cgit: $(CGIT_OBJS) GIT-LDFLAGS $(GITLIBS)
133 @echo 1>&1 " * $(LUA_MESSAGE)"
134 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) $(CGIT_LIBS)
136 CGIT_SP_OBJS := $(patsubst %.o,%.sp,$(CGIT_OBJS))
138 $(CGIT_SP_OBJS): %.sp: %.c GIT-CFLAGS $(CGIT_PREFIX)CGIT-CFLAGS FORCE
139 $(QUIET_SP)cgcc -no-compile $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $(CGIT_CFLAGS) $(SPARSE_FLAGS) $<
141 cgit-sparse: $(CGIT_SP_OBJS)