Skip to content

Commit

Permalink
build: reduce autoconf input files from 32 to 2
Browse files Browse the repository at this point in the history
Configure summary: autoconf essentially only parses configure.ac and
generates the configure script (that is, the "./configure" shell
script).  The latter is what actually checks what is available on the
system and internally sets the value of the output variables.  It then,
for every filename foo in AC_CONFIG_FILES (and for every output variable
name BAR in AC_SUBST), reads foo.in, replaces every occurrence of
`@BAR@` with the value of the shell variable `$BAR` and generates the
file foo from the result.  After this, configure is finished and `make`
could be executed to start the build.

Now that (as of netblue30#5140) all output variables are only defined on
config.mk.in and on config.sh.in, there is no need to generate any
makefile nor any other mkfile or shell script at configure time.  So
rename every "Makefile.in" to "Makefile", mkdeb.sh.in to mkdeb.sh,
src/common.mk.in to src/common.mk and leave just config.mk and config.sh
as the files to be generated at configure time.

This allows editing and committing all makefiles directly, without
potentially having to run ./configure in between.

Commands used to rename the makefiles:

    $ git ls-files -z -- '*Makefile.in' | xargs -0 -I '{}' sh -c \
      "git mv '{}' \"\$(dirname '{}')/Makefile\""

Additionally, from my (rudimentary) testing, this commit reduces the
time it takes to run ./configure by about 20~25% (using ext4 on an HDD)
compared to commit 72ece92 ("Transmission fixes: drop private-lib
(netblue30#5213)", 2022-06-22).  Commands used for benchmarking each commit:

    $ : >time_configure && ./configure && make distclean &&
      for i in $(seq 1 10); do
      { time -p ./configure; } 2>>time_configure; done
    $ grep real time_configure |
      awk '{ total += $2 } END { print total/NR }'
  • Loading branch information
kmk3 committed Jun 25, 2022
1 parent 72ece92 commit 38e5303
Show file tree
Hide file tree
Showing 34 changed files with 10 additions and 112 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
.directory
*.man
.vscode
Makefile
autom4te.cache/
config.log
config.mk
Expand All @@ -25,7 +24,6 @@ firejail.1
firemon.1
firecfg.1
jailcheck.1
mkdeb.sh
src/fnettrace-dns/fnettrace-dns
src/fnettrace-sni/fnettrace-sni
src/firejail/firejail
Expand Down Expand Up @@ -57,7 +55,6 @@ seccomp.64
seccomp.block_secondary
seccomp.mdwx
seccomp.mdwx.32
src/common.mk
aclocal.m4
__pycache__
*.pyc
Expand Down
10 changes: 4 additions & 6 deletions Makefile.in → Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ distclean: clean
$(MAKE) -C $$dir distclean; \
done
$(MAKE) -C test distclean
rm -fr Makefile autom4te.cache config.log config.mk config.sh config.status src/common.mk mkdeb.sh
rm -fr autom4te.cache config.log config.mk config.sh config.status

realinstall:
# firejail executable
Expand Down Expand Up @@ -189,7 +189,7 @@ uninstall:

DISTFILES = \
COPYING \
Makefile.in \
Makefile \
README \
RELNOTES \
config.mk.in \
Expand All @@ -200,20 +200,18 @@ contrib \
etc \
install.sh \
m4 \
mkdeb.sh.in \
mkdeb.sh \
mketc.sh \
mkman.sh \
platform \
src

DISTFILES_TEST = test/Makefile.in test/apps test/apps-x11 test/apps-x11-xorg test/root test/private-lib test/fnetfilter test/fcopy test/environment test/profiles test/utils test/compile test/filters test/network test/fs test/sysutils test/chroot
DISTFILES_TEST = test/Makefile test/apps test/apps-x11 test/apps-x11-xorg test/root test/private-lib test/fnetfilter test/fcopy test/environment test/profiles test/utils test/compile test/filters test/network test/fs test/sysutils test/chroot

dist:
mv config.sh config.sh.old
mv config.status config.status.old
mv mkdeb.sh mkdeb.sh.old
make distclean
mv mkdeb.sh.old mkdeb.sh
mv config.status.old config.status
mv config.sh.old config.sh
rm -fr $(NAME)-$(VERSION) $(NAME)-$(VERSION).tar.xz
Expand Down
39 changes: 1 addition & 38 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -4085,9 +4085,7 @@ if test "$prefix" = /usr; then
test "$sysconfdir" = '${prefix}/etc' && sysconfdir="/etc"
fi
ac_config_files="$ac_config_files mkdeb.sh"
ac_config_files="$ac_config_files Makefile config.mk config.sh src/bash_completion/Makefile src/common.mk src/fbuilder/Makefile src/fcopy/Makefile src/fids/Makefile src/firecfg/Makefile src/firejail/Makefile src/firemon/Makefile src/fldd/Makefile src/fnet/Makefile src/fnetfilter/Makefile src/fnettrace-dns/Makefile src/fnettrace-sni/Makefile src/fnettrace/Makefile src/fsec-optimize/Makefile src/fsec-print/Makefile src/fseccomp/Makefile src/ftee/Makefile src/fzenity/Makefile src/jailcheck/Makefile src/lib/Makefile src/libpostexecseccomp/Makefile src/libtrace/Makefile src/libtracelog/Makefile src/man/Makefile src/profstats/Makefile src/zsh_completion/Makefile test/Makefile"
ac_config_files="$ac_config_files config.mk config.sh"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
Expand Down Expand Up @@ -4795,38 +4793,8 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
for ac_config_target in $ac_config_targets
do
case $ac_config_target in
"mkdeb.sh") CONFIG_FILES="$CONFIG_FILES mkdeb.sh" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"config.mk") CONFIG_FILES="$CONFIG_FILES config.mk" ;;
"config.sh") CONFIG_FILES="$CONFIG_FILES config.sh" ;;
"src/bash_completion/Makefile") CONFIG_FILES="$CONFIG_FILES src/bash_completion/Makefile" ;;
"src/common.mk") CONFIG_FILES="$CONFIG_FILES src/common.mk" ;;
"src/fbuilder/Makefile") CONFIG_FILES="$CONFIG_FILES src/fbuilder/Makefile" ;;
"src/fcopy/Makefile") CONFIG_FILES="$CONFIG_FILES src/fcopy/Makefile" ;;
"src/fids/Makefile") CONFIG_FILES="$CONFIG_FILES src/fids/Makefile" ;;
"src/firecfg/Makefile") CONFIG_FILES="$CONFIG_FILES src/firecfg/Makefile" ;;
"src/firejail/Makefile") CONFIG_FILES="$CONFIG_FILES src/firejail/Makefile" ;;
"src/firemon/Makefile") CONFIG_FILES="$CONFIG_FILES src/firemon/Makefile" ;;
"src/fldd/Makefile") CONFIG_FILES="$CONFIG_FILES src/fldd/Makefile" ;;
"src/fnet/Makefile") CONFIG_FILES="$CONFIG_FILES src/fnet/Makefile" ;;
"src/fnetfilter/Makefile") CONFIG_FILES="$CONFIG_FILES src/fnetfilter/Makefile" ;;
"src/fnettrace-dns/Makefile") CONFIG_FILES="$CONFIG_FILES src/fnettrace-dns/Makefile" ;;
"src/fnettrace-sni/Makefile") CONFIG_FILES="$CONFIG_FILES src/fnettrace-sni/Makefile" ;;
"src/fnettrace/Makefile") CONFIG_FILES="$CONFIG_FILES src/fnettrace/Makefile" ;;
"src/fsec-optimize/Makefile") CONFIG_FILES="$CONFIG_FILES src/fsec-optimize/Makefile" ;;
"src/fsec-print/Makefile") CONFIG_FILES="$CONFIG_FILES src/fsec-print/Makefile" ;;
"src/fseccomp/Makefile") CONFIG_FILES="$CONFIG_FILES src/fseccomp/Makefile" ;;
"src/ftee/Makefile") CONFIG_FILES="$CONFIG_FILES src/ftee/Makefile" ;;
"src/fzenity/Makefile") CONFIG_FILES="$CONFIG_FILES src/fzenity/Makefile" ;;
"src/jailcheck/Makefile") CONFIG_FILES="$CONFIG_FILES src/jailcheck/Makefile" ;;
"src/lib/Makefile") CONFIG_FILES="$CONFIG_FILES src/lib/Makefile" ;;
"src/libpostexecseccomp/Makefile") CONFIG_FILES="$CONFIG_FILES src/libpostexecseccomp/Makefile" ;;
"src/libtrace/Makefile") CONFIG_FILES="$CONFIG_FILES src/libtrace/Makefile" ;;
"src/libtracelog/Makefile") CONFIG_FILES="$CONFIG_FILES src/libtracelog/Makefile" ;;
"src/man/Makefile") CONFIG_FILES="$CONFIG_FILES src/man/Makefile" ;;
"src/profstats/Makefile") CONFIG_FILES="$CONFIG_FILES src/profstats/Makefile" ;;
"src/zsh_completion/Makefile") CONFIG_FILES="$CONFIG_FILES src/zsh_completion/Makefile" ;;
"test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac
Expand Down Expand Up @@ -5240,11 +5208,6 @@ which seems to be undefined. Please make sure it is defined" >&2;}
esac
case $ac_file$ac_mode in
"mkdeb.sh":F) chmod +x mkdeb.sh ;;
esac
done # for ac_tag
Expand Down
35 changes: 1 addition & 34 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -282,40 +282,7 @@ if test "$prefix" = /usr; then
test "$sysconfdir" = '${prefix}/etc' && sysconfdir="/etc"
fi

AC_CONFIG_FILES([mkdeb.sh], [chmod +x mkdeb.sh])
AC_CONFIG_FILES([
Makefile
config.mk
config.sh
src/bash_completion/Makefile
src/common.mk
src/fbuilder/Makefile
src/fcopy/Makefile
src/fids/Makefile
src/firecfg/Makefile
src/firejail/Makefile
src/firemon/Makefile
src/fldd/Makefile
src/fnet/Makefile
src/fnetfilter/Makefile
src/fnettrace-dns/Makefile
src/fnettrace-sni/Makefile
src/fnettrace/Makefile
src/fsec-optimize/Makefile
src/fsec-print/Makefile
src/fseccomp/Makefile
src/ftee/Makefile
src/fzenity/Makefile
src/jailcheck/Makefile
src/lib/Makefile
src/libpostexecseccomp/Makefile
src/libtrace/Makefile
src/libtracelog/Makefile
src/man/Makefile
src/profstats/Makefile
src/zsh_completion/Makefile
test/Makefile
])
AC_CONFIG_FILES([config.mk config.sh])
AC_OUTPUT

cat <<EOF
Expand Down
8 changes: 4 additions & 4 deletions contrib/fj-mkdeb.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
def run(srcdir, args):
if srcdir: os.chdir(srcdir)

if not (os.path.isfile('./mkdeb.sh.in')):
if not (os.path.isfile('./mkdeb.sh')):
print('Error: Not a firejail source tree? Exiting.')
return 1

Expand All @@ -22,7 +22,7 @@ def run(srcdir, args):
# prefix should ALWAYS be /usr here. Discard user-set values
args.remove(a)

# Run configure to generate mkdeb.sh.
# Run configure to generate config.sh.
first_config = subprocess.call(['./configure', '--prefix=/usr'] + args)
if first_config != 0:
return first_config
Expand Down Expand Up @@ -62,9 +62,9 @@ def run(srcdir, args):
if not (srcdir):
# srcdir not manually specified, try to auto-detect
srcdir = os.path.dirname(os.path.abspath(sys.argv[0] + '/..'))
if not (os.path.isfile(srcdir + '/mkdeb.sh.in')):
if not (os.path.isfile(srcdir + '/mkdeb.sh')):
# Script is probably installed. Check the cwd.
if os.path.isfile('./mkdeb.sh.in'):
if os.path.isfile('./mkdeb.sh'):
srcdir = None
else:
print(
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ clean:

.PHONY: distclean
distclean: clean
rm -fr Makefile
File renamed without changes.
1 change: 0 additions & 1 deletion src/fbuilder/Makefile.in → src/fbuilder/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ clean:; rm -fr *.o fbuilder *.gcov *.gcda *.gcno *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
1 change: 0 additions & 1 deletion src/fcopy/Makefile.in → src/fcopy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ clean:; rm -fr *.o fcopy *.gcov *.gcda *.gcno *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
1 change: 0 additions & 1 deletion src/fids/Makefile.in → src/fids/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ clean:; rm -fr *.o fids *.gcov *.gcda *.gcno *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
1 change: 0 additions & 1 deletion src/firecfg/Makefile.in → src/firecfg/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ clean:; rm -fr *.o firecfg *.gcov *.gcda *.gcno *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
1 change: 0 additions & 1 deletion src/firejail/Makefile.in → src/firejail/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ clean:; rm -fr *.o firejail *.gcov *.gcda *.gcno *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
1 change: 0 additions & 1 deletion src/firemon/Makefile.in → src/firemon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ clean:; rm -fr *.o firemon *.gcov *.gcda *.gcno *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
1 change: 0 additions & 1 deletion src/fldd/Makefile.in → src/fldd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ clean:; rm -fr *.o fldd *.gcov *.gcda *.gcno *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
1 change: 0 additions & 1 deletion src/fnet/Makefile.in → src/fnet/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ clean:; rm -fr *.o fnet *.gcov *.gcda *.gcno *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
1 change: 0 additions & 1 deletion src/fnetfilter/Makefile.in → src/fnetfilter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ clean:; rm -fr *.o fnetfilter *.gcov *.gcda *.gcno *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ clean:; rm -fr *.o fnettrace-dns *.gcov *.gcda *.gcno *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ clean:; rm -fr *.o fnettrace-sni *.gcov *.gcda *.gcno *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
1 change: 0 additions & 1 deletion src/fnettrace/Makefile.in → src/fnettrace/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ clean:; rm -fr *.o fnettrace *.gcov *.gcda *.gcno *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ clean:; rm -fr *.o fsec-optimize *.gcov *.gcda *.gcno *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
1 change: 0 additions & 1 deletion src/fsec-print/Makefile.in → src/fsec-print/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ clean:; rm -fr *.o fsec-print *.gcov *.gcda *.gcno *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
1 change: 0 additions & 1 deletion src/fseccomp/Makefile.in → src/fseccomp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ clean:; rm -fr *.o fseccomp *.gcov *.gcda *.gcno *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
1 change: 0 additions & 1 deletion src/ftee/Makefile.in → src/ftee/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ clean:; rm -fr *.o ftee *.gcov *.gcda *.gcno *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
1 change: 0 additions & 1 deletion src/fzenity/Makefile.in → src/fzenity/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ clean:; rm -fr *.o fzenity *.gcov *.gcda *.gcno *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
1 change: 0 additions & 1 deletion src/jailcheck/Makefile.in → src/jailcheck/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ clean:; rm -fr *.o jailcheck *.gcov *.gcda *.gcno *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
1 change: 0 additions & 1 deletion src/lib/Makefile.in → src/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ clean:; rm -fr $(OBJS) *.gcov *.gcda *.gcno *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ clean:; rm -fr $(OBJS) libpostexecseccomp.so *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
1 change: 0 additions & 1 deletion src/libtrace/Makefile.in → src/libtrace/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ clean:; rm -fr $(OBJS) libtrace.so *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
1 change: 0 additions & 1 deletion src/libtracelog/Makefile.in → src/libtracelog/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ clean:; rm -fr $(OBJS) libtracelog.so *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
1 change: 0 additions & 1 deletion src/man/Makefile.in → src/man/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ clean:; rm -fr *.man

.PHONY: distclean
distclean: clean
rm -fr Makefile
1 change: 0 additions & 1 deletion src/profstats/Makefile.in → src/profstats/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ clean:; rm -fr *.o profstats *.gcov *.gcda *.gcno *.plist

.PHONY: distclean
distclean: clean
rm -fr Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ clean:

.PHONY: distclean
distclean: clean
rm -fr Makefile
1 change: 0 additions & 1 deletion test/Makefile.in → test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ clean:

.PHONY: distclean
distclean: clean
rm -f Makefile

0 comments on commit 38e5303

Please sign in to comment.