Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Non-recursive makefiles #652

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
62 changes: 42 additions & 20 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,46 @@
*.sig
stamp-*

# Backup files generated by various editors
*.orig
*.rej
*.sig
*.tar.gz
*.tar.lz
*~
.deps
.libs
ABOUT-NLS
ChangeLog
Makefile

# 'autoscan' log files
/autoscan.log
/configure.scan

# Files generated by Autotools
/ABOUT-NLS
/ChangeLog
/aclocal.m4
/autom4te.cache/
/build-aux/
/configure
/m4/
Makefile.in
aclocal.m4
autom4te.cache
autoscan.log
build-aux/
config.log
config.status
configure
configure.scan
flex-*/
libtool
m4/
stamp-*

# Files generated by 'configure'
/config.cache
/config.log
/config.status
/libtool
Makefile

# Built object files and support files
/flex
/flex.exe
/libfl.la
/stage1bin/
/stage1flex
/stage1flex.exe
*.lo
*.o
*.obj
.deps/
.libs/

# Distribution tarballs and directory
/flex-*/
*.tar.gz
*.tar.lz
47 changes: 33 additions & 14 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -47,33 +47,37 @@ dist_noinst_SCRIPTS = \
po/update_linguas.sh

SUBDIRS = \
src \
doc \
examples \
. \
po \
tests \
tools
tests

MOSTLYCLEANFILES =

CLEANFILES =

indentfiles =

include doc/local.mk
include examples/local.mk
include src/local.mk
include tools/local.mk

# Convenience targets to build libfl only
# These are actually wrappers around automake- and libtool-generated targets

libfl:
cd src && $(MAKE) $(AM_MAKEFLAGS) libfl.la libfl.pc
libfl: libfl.la src/libfl.pc

install-libfl:
cd src && \
$(MAKE) $(AM_MAKEFLAGS) lib_LTLIBRARIES=libfl.la \
pkgconfig_DATA=libfl.pc install-libLTLIBRARIES install-pkgconfigDATA
pkgconfig_DATA=src/libfl.pc install-libLTLIBRARIES install-pkgconfigDATA

uninstall-libfl:
cd src && \
$(MAKE) $(AM_MAKEFLAGS) \
lib_LTLIBRARIES=libfl.la pkgconfig_DATA=libfl.pc \
lib_LTLIBRARIES=libfl.la pkgconfig_DATA=src/libfl.pc \
uninstall-libLTLIBRARIES uninstall-pkgconfigDATA

# libfl.pc is cleaned via 'distclean' target
clean-libfl:
cd src && \
$(MAKE) $(AM_MAKEFLAGS) lib_LTLIBRARIES=libfl.la clean-libLTLIBRARIES \
clean-libtool

Expand All @@ -84,8 +88,23 @@ ChangeLog: $(srcdir)/tools/git2cl
$(srcdir)/tools/git2cl > $@ \
; fi

indent:
cd src && $(MAKE) $(AM_MAKEFLAGS) indent
# Run GNU indent on sources. Don't run this unless all the sources compile cleanly.
#
# Whole idea:
# 1. Check for .indent.pro, otherwise indent will use unknown
# settings, or worse, the GNU defaults.)
# 2. Check that this is GNU indent.
# 3. Make sure to process only the NON-generated .c and .h files.
# 4. Run indent twice per file. The first time is a test.
# Otherwise, indent overwrites your file even if it fails!

indent: .indent.pro
for f in $(indentfiles); do \
echo indenting $$f; \
INDENT_PROFILE=.indent.pro $(INDENT) <$$f >/dev/null && \
INDENT_PROFILE=.indent.pro $(INDENT) $$f || \
echo $$f FAILED to indent; \
done;

install-exec-hook:
cd $(DESTDIR)$(bindir) && \
Expand Down
10 changes: 4 additions & 6 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ AC_PATH_PROG([HELP2MAN], help2man, [\${top_srcdir}/build-aux/missing help2man])
AC_MSG_WARN(help2man: program not found: building man page will not work)
)

AM_CONDITIONAL([AUTO_BUILD_MAN_PAGE],
[test "$HELP2MAN" != "\${top_srcdir}/build-aux/missing help2man" &&
{ test "x$enable_bootstrap" = xyes || test "$cross_compiling" = no; }])

AC_PATH_PROGS([TEXI2DVI], [gtexi2dvi texi2dvi], [\${top_srcdir}/build-aux/missing texi2dvi])
AS_IF([test "$TEXI2DVI" = "\${top_srcdir}/build-aux/missing texi2dvi"],
AC_MSG_WARN(texi2dvi: program not found: building pdf version of manual will not work)
Expand Down Expand Up @@ -215,14 +219,8 @@ AS_IF([test "$cross_compiling" = yes],

AC_CONFIG_FILES(
Makefile
doc/Makefile
examples/Makefile
examples/fastwc/Makefile
examples/manual/Makefile
po/Makefile.in
src/libfl.pc
src/Makefile
tools/Makefile
tests/Makefile
)

Expand Down
3 changes: 0 additions & 3 deletions doc/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,3 @@ flex.ps
version.texi
flex.html
flex.t2p

flex
flex.exe
51 changes: 0 additions & 51 deletions doc/Makefile.am

This file was deleted.

76 changes: 76 additions & 0 deletions doc/local.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
if CROSS
FLEX_FOR_DOC = stage1bin/flex
else
FLEX_FOR_DOC = flex
endif

TEXI2DVI = @TEXI2DVI@ -I $(srcdir)/examples/manual/
TEXI2PDF = @TEXI2PDF@ -I $(srcdir)/examples/manual/

info_TEXINFOS = doc/flex.texi
AM_MAKEINFOFLAGS = -I $(srcdir)/examples/manual/
dist_man_MANS = doc/flex.1
MAINTAINERCLEANFILES = doc/flex.1

CLEANFILES += \
doc/*.aux \
doc/*.cp \
doc/*.cps \
doc/*.fn \
doc/*.fns \
doc/*.hk \
doc/*.hks \
doc/*.ky \
doc/*.log \
doc/*.op \
doc/*.ops \
doc/*.pg \
doc/*.toc \
doc/*.tp \
doc/*.tps \
doc/*.vr \
doc/*.vrs \
doc/flex

# Use a fixed program name, without extension (such as ".exe"), for man
# page generation. 'help2man' strips directory prefix from the usage
# string, but not file extensions.
#
# Note: Do NOT run the '$(FLEX_FOR_DOC)$(BUILD_EXEEXT)' target in
# another instance of 'make'! The scanner code also depends on the
# target and two 'make' instances may contest building the same file.

if AUTO_BUILD_MAN_PAGE
doc/flex.1: $(FLEX_FOR_DOC)$(BUILD_EXEEXT)
$(MKDIR_P) doc
$(HELP2MAN) \
--name='$(PACKAGE_NAME)' \
--section=1 \
--source='The Flex Project' \
--manual='Programming' \
--output=$@ \
./$(FLEX_FOR_DOC)
else
doc/flex.1: $(srcdir)/configure.ac $(srcdir)/src/cpp-flex.skl $(srcdir)/src/options.c $(srcdir)/src/options.h
@option_text=''; \
{ test '$(FLEX_FOR_DOC)' = flex || \
: $${option_text=" with --enable-bootstrap'"}; }; \
echo "error: flex man page outdated; please install help2man and rerun 'configure'$${option_text}" 1>&2;
@false
endif

distclean-local: distclean-local-doc

# Clean the man page in the build directory only if it is not the
# source directory.

distclean-local-doc:
test '$(srcdir)' = . || { \
if mv -f $(srcdir)/doc/flex.1 $(srcdir)/doc/flex.1.tmp; then \
s=0; else s=$$? || :; fi; \
rm -f doc/flex.1 || :; \
test "$$s" -ne 0 || \
mv -f $(srcdir)/doc/flex.1.tmp $(srcdir)/doc/flex.1; \
}

.PHONY: distclean-local-doc
16 changes: 8 additions & 8 deletions examples/fastwc/Makefile.am → examples/fastwc/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.

EXTRA_DIST = \
wc5.l \
wc4.l \
wc3.l \
wc2.l \
wc1.l \
mywc.c \
README
EXTRA_DIST += \
examples/fastwc/wc5.l \
examples/fastwc/wc4.l \
examples/fastwc/wc3.l \
examples/fastwc/wc2.l \
examples/fastwc/wc1.l \
examples/fastwc/mywc.c \
examples/fastwc/README
13 changes: 6 additions & 7 deletions examples/Makefile.am → examples/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.

EXTRA_DIST = \
testxxLexer.l \
debflex.awk \
README
EXTRA_DIST += \
examples/testxxLexer.l \
examples/debflex.awk \
examples/README

SUBDIRS = \
manual \
fastwc
include examples/fastwc/local.mk
include examples/manual/local.mk
Loading