Skip to content

Commit 732056e

Browse files
committed
btrfs-progs: build: split makefile to generated and stable parts
It's not really necessary to configure and regenerate Makefiles in cases like adding a new source file. The build environment and optional features are not affected by that. Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 0c49ff5 commit 732056e

File tree

4 files changed

+47
-28
lines changed

4 files changed

+47
-28
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ cscope.out
6767
.clang_complete
6868
depcomp
6969
libtool
70-
Makefile
70+
Makefile.inc
7171
Documentation/Makefile
7272
missing
7373
mkinstalldirs

Makefile.in renamed to Makefile

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,15 @@
3737
# Export all variables to sub-makes by default
3838
export
3939

40-
include Makefile.extrawarn
40+
-include Makefile.inc
41+
ifneq ($(MAKEFILE_INC_INCLUDED),yes)
42+
$(error Makefile.inc not generated, please configure first)
43+
endif
4144

42-
CC = @CC@
43-
LN_S = @LN_S@
44-
AR = @AR@
45-
RM = @RM@
46-
RMDIR = @RMDIR@
47-
INSTALL = @INSTALL@
48-
DISABLE_DOCUMENTATION = @DISABLE_DOCUMENTATION@
49-
DISABLE_BTRFSCONVERT = @DISABLE_BTRFSCONVERT@
50-
BTRFSCONVERT_EXT2 = @BTRFSCONVERT_EXT2@
5145
TAGS_CMD := ctags
5246

47+
include Makefile.extrawarn
48+
5349
EXTRA_CFLAGS :=
5450
EXTRA_LDFLAGS :=
5551

@@ -60,7 +56,7 @@ DEBUG_CFLAGS :=
6056
TOPDIR := $(shell pwd)
6157

6258
# Common build flags
63-
CFLAGS = @CFLAGS@ \
59+
CFLAGS = $(SUBST_CFLAGS) \
6460
-include config.h \
6561
-DBTRFS_FLAT_INCLUDES \
6662
-D_XOPEN_SOURCE=700 \
@@ -72,19 +68,15 @@ CFLAGS = @CFLAGS@ \
7268
$(DEBUG_CFLAGS_INTERNAL) \
7369
$(EXTRA_CFLAGS)
7470

75-
LDFLAGS = @LDFLAGS@ \
71+
LDFLAGS = $(SUBST_LDFLAGS) \
7672
-rdynamic -L$(TOPDIR) $(EXTRA_LDFLAGS)
7773

78-
LIBS_BASE = @UUID_LIBS@ @BLKID_LIBS@ -L. -pthread
79-
LIBS_COMP = @ZLIB_LIBS@ @LZO2_LIBS@
8074
LIBS = $(LIBS_BASE)
8175
LIBBTRFS_LIBS = $(LIBS_BASE)
8276

8377
# Static compilation flags
8478
STATIC_CFLAGS = $(CFLAGS) -ffunction-sections -fdata-sections
8579
STATIC_LDFLAGS = -static -Wl,--gc-sections
86-
STATIC_LIBS_BASE = @UUID_LIBS_STATIC@ @BLKID_LIBS_STATIC@ -L. -pthread
87-
STATIC_LIBS_COMP = @ZLIB_LIBS_STATIC@ @LZO2_LIBS_STATIC@
8880
STATIC_LIBS = $(STATIC_LIBS_BASE)
8981

9082
# don't use FORTIFY with sparse because glibc with FORTIFY can
@@ -124,14 +116,6 @@ TESTS = fsck-tests.sh convert-tests.sh
124116

125117
udev_rules = 64-btrfs-dm.rules
126118

127-
prefix ?= @prefix@
128-
exec_prefix = @exec_prefix@
129-
bindir = @bindir@
130-
libdir ?= @libdir@
131-
incdir = @includedir@/btrfs
132-
udevdir = @UDEVDIR@
133-
udevruledir = ${udevdir}/rules.d
134-
135119
ifeq ("$(origin V)", "command line")
136120
BUILD_VERBOSE = $(V)
137121
endif
@@ -201,7 +185,6 @@ endif
201185

202186
# external libs required by various binaries; for btrfs-foo,
203187
# specify btrfs_foo_libs = <list of libs>; see $($(subst...)) rules below
204-
btrfs_convert_libs = @EXT2FS_LIBS@ @COM_ERR_LIBS@
205188
btrfs_convert_cflags = -DBTRFSCONVERT_EXT2=$(BTRFSCONVERT_EXT2)
206189
btrfs_fragments_libs = -lgd -lpng -ljpeg -lfreetype
207190
btrfs_debug_tree_objects = cmds-inspect-dump-tree.o
@@ -514,7 +497,7 @@ clean-doc:
514497
clean-gen:
515498
@echo "Cleaning Generated Files"
516499
$(Q)$(RM) -rf -- version.h config.status config.cache connfig.log \
517-
configure.lineno config.status.lineno Makefile \
500+
configure.lineno config.status.lineno Makefile.inc \
518501
Documentation/Makefile tags \
519502
config.log config.h config.h.in~ aclocal.m4 \
520503
configure autom4te.cache/ config/

Makefile.inc.in

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Variables set during configure phase:
2+
# * build environment, paths
3+
# * features (eg. convert, documentation)
4+
export
5+
6+
CC = @CC@
7+
LN_S = @LN_S@
8+
AR = @AR@
9+
RM = @RM@
10+
RMDIR = @RMDIR@
11+
INSTALL = @INSTALL@
12+
DISABLE_DOCUMENTATION = @DISABLE_DOCUMENTATION@
13+
DISABLE_BTRFSCONVERT = @DISABLE_BTRFSCONVERT@
14+
BTRFSCONVERT_EXT2 = @BTRFSCONVERT_EXT2@
15+
16+
SUBST_CFLAGS = @CFLAGS@
17+
SUBST_LDFLAGS = @LDFLAGS@
18+
19+
LIBS_BASE = @UUID_LIBS@ @BLKID_LIBS@ -L. -pthread
20+
LIBS_COMP = @ZLIB_LIBS@ @LZO2_LIBS@
21+
STATIC_LIBS_BASE = @UUID_LIBS_STATIC@ @BLKID_LIBS_STATIC@ -L. -pthread
22+
STATIC_LIBS_COMP = @ZLIB_LIBS_STATIC@ @LZO2_LIBS_STATIC@
23+
24+
prefix ?= @prefix@
25+
exec_prefix = @exec_prefix@
26+
bindir = @bindir@
27+
libdir ?= @libdir@
28+
incdir = @includedir@/btrfs
29+
udevdir = @UDEVDIR@
30+
udevruledir = ${udevdir}/rules.d
31+
32+
# external libs required by various binaries; for btrfs-foo,
33+
# specify btrfs_foo_libs = <list of libs>; see $($(subst...)) rules in Makefile
34+
btrfs_convert_libs = @EXT2FS_LIBS@ @COM_ERR_LIBS@
35+
36+
MAKEFILE_INC_INCLUDED = yes

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ AC_SUBST([LIBBTRFS_PATCHLEVEL])
198198
AC_CONFIG_HEADERS([config.h])
199199

200200
AC_CONFIG_FILES([
201-
Makefile
201+
Makefile.inc
202202
Documentation/Makefile
203203
version.h
204204
])

0 commit comments

Comments
 (0)