xref: /netbsd/external/bsd/flex/dist/src/Makefile.am (revision d6563c0d)
1AM_YFLAGS = -d
2AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\"
3LIBS = @LIBS@
4
5m4 = @M4@
6
7bin_PROGRAMS = flex
8if ENABLE_BOOTSTRAP
9noinst_PROGRAMS = stage1flex
10endif
11
12if ENABLE_LIBFL
13lib_LTLIBRARIES = libfl.la
14endif
15libfl_la_SOURCES = \
16	libmain.c \
17	libyywrap.c
18libfl_la_LDFLAGS = -version-info @SHARED_VERSION_INFO@
19
20stage1flex_SOURCES = \
21	scan.l \
22	$(COMMON_SOURCES)
23
24if CROSS
25stage1flex_LDADD =
26stage1flex_SOURCES += \
27		      ../lib/malloc.c \
28		      ../lib/realloc.c
29stage1flex_LINK = $(LIBTOOL) --tag=CC --mode=link $(CC_FOR_BUILD) \
30		  $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@
31
32$(stage1flex_OBJECTS): CC=$(CC_FOR_BUILD)
33$(stage1flex_OBJECTS): CFLAGS=$(CFLAGS_FOR_BUILD)
34$(stage1flex_OBJECTS): CPP=$(CPP_FOR_BUILD)
35$(stage1flex_OBJECTS): CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
36$(stage1flex_OBJECTS): LDFLAGS=$(LDFLAGS_FOR_BUILD)
37else
38stage1flex_LDADD = $(LDADD)
39stage1flex_LINK = $(LINK)
40stage1flex_CFLAGS = $(AM_CFLAGS)
41endif
42
43flex_SOURCES = \
44	$(COMMON_SOURCES)
45
46nodist_flex_SOURCES = \
47	stage1scan.c
48
49flex_CFLAGS = $(AM_CFLAGS) $(WARNINGFLAGS)
50
51COMMON_SOURCES = \
52	buf.c \
53	ccl.c \
54	dfa.c \
55	ecs.c \
56	filter.c \
57	flexdef.h \
58	flexint.h \
59	gen.c \
60	main.c \
61	misc.c \
62	nfa.c \
63	options.c \
64	options.h \
65	parse.y \
66	regex.c \
67	scanflags.c \
68	scanopt.c \
69	scanopt.h \
70	skel.c \
71	sym.c \
72	tables.c \
73	tables.h \
74	tables_shared.c \
75	tables_shared.h \
76	tblcmp.c \
77	version.h \
78	yylex.c
79
80LDADD = $(LIBOBJS) @LIBINTL@
81
82include_HEADERS = \
83	FlexLexer.h
84
85EXTRA_DIST = \
86	flex.skl \
87	mkskel.sh \
88	gettext.h
89
90CLEANFILES = stage1scan.c stage1flex$(EXEEXT)
91
92MAINTAINERCLEANFILES = skel.c
93
94skel.c: flex.skl mkskel.sh flexint.h tables_shared.h tables_shared.c
95	$(SHELL) $(srcdir)/mkskel.sh $(srcdir) $(m4) $(VERSION) > $@.tmp
96	mv $@.tmp $@
97
98if ENABLE_BOOTSTRAP
99stage1scan.c: scan.l stage1flex$(EXEEXT)
100	./stage1flex$(EXEEXT) $(AM_LFLAGS) $(LFLAGS) -o $@ $(srcdir)/scan.l
101else
102stage1scan.c: scan.c
103	sed 's|^\(#line .*\)"'`printf %s $< | sed 's|[][\\\\.*]|\\\\&|g'`'"|\1"$@"|g' $< > $@
104endif
105
106dist-hook: scan.l flex$(EXEEXT)
107	chmod u+w $(distdir)/scan.c && \
108	./flex$(EXEEXT) -o scan.c $< && \
109	mv scan.c $(distdir)
110
111# make needs to be told to make parse.h so that parallelized runs will
112# not fail.
113
114stage1flex-main.$(OBJEXT): parse.h
115flex-main.$(OBJEXT): parse.h
116
117stage1flex-yylex.$(OBJEXT): parse.h
118flex-yylex.$(OBJEXT): parse.h
119
120stage1flex-scan.$(OBJEXT): parse.h
121flex-stage1scan.$(OBJEXT): parse.h
122
123# Run GNU indent on sources. Don't run this unless all the sources compile cleanly.
124#
125# Whole idea:
126#   1. Check for .indent.pro, otherwise indent will use unknown
127#      settings, or worse, the GNU defaults.)
128#   2. Check that this is GNU indent.
129#   3. Make sure to process only the NON-generated .c and .h files.
130#   4. Run indent twice per file. The first time is a test.
131#      Otherwise, indent overwrites your file even if it fails!
132indentfiles = \
133	buf.c \
134	ccl.c \
135	dfa.c \
136	ecs.c \
137	scanflags.c \
138	filter.c \
139	flexdef.h \
140	gen.c \
141	libmain.c \
142	libyywrap.c \
143	main.c \
144	misc.c \
145	nfa.c \
146	options.c \
147	options.h \
148	regex.c \
149	scanopt.c \
150	scanopt.h \
151	sym.c \
152	tables.c \
153	tables.h \
154	tables_shared.c \
155	tables_shared.h \
156	tblcmp.c
157
158indent: $(top_srcdir)/.indent.pro
159	cd $(top_srcdir) && \
160	for f in $(indentfiles); do \
161		f=src/$$f; \
162		echo indenting $$f; \
163		INDENT_PROFILE=.indent.pro $(INDENT) <$$f >/dev/null && \
164		INDENT_PROFILE=.indent.pro $(INDENT) $$f || \
165		echo $$f FAILED to indent; \
166	done;
167
168.PHONY: indent
169