aboutsummaryrefslogtreecommitdiffstats
path: root/lib/megaco/src/flex/Makefile.in
blob: cb1d7d2a5cd8e65d8062073f138aee1c69e100c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
# 
# %CopyrightBegin%
#
# Copyright Ericsson AB 2001-2011. All Rights Reserved.
#
# The contents of this file are subject to the Erlang Public License,
# Version 1.1, (the "License"); you may not use this file except in
# compliance with the License. You should have received a copy of the
# Erlang Public License along with this software. If not, it can be
# retrieved online at http://www.erlang.org/.
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and limitations
# under the License.
#
# %CopyrightEnd%

include $(ERL_TOP)/make/target.mk

EBIN = ../../ebin
MEGACO_INCLUDEDIR = ../../include

include $(ERL_TOP)/make/$(TARGET)/otp.mk

# ----------------------------------------------------
# Application version
# ----------------------------------------------------
include ../../vsn.mk
VSN=$(MEGACO_VSN)

# ----------------------------------------------------
# Dynamic Erlang Driver
# ----------------------------------------------------
HAVE_USABLE_OTP_DED_MK = @HAVE_USABLE_OTP_DED_MK@

ifeq ($(HAVE_USABLE_OTP_DED_MK),yes)
# otp_ded.mk will be used on R13B04 and later
include $(ERL_TOP)/make/$(TARGET)/otp_ded.mk
else
# megacos configure provide the info instead
DED_CC				= @CC@
DED__NOWARN_NOTHR_CFLAGS	= @DED_CFLAGS@
DED_THR_DEFS			= @DED_THR_DEFS@
DED_LD				= @DED_LD@
DED_LDFLAGS			= @DED_LDFLAGS@
DED_INCLUDES			= @DED_INCLUDES@
DED_EXT				= so
endif

# ----------------------------------------------------
# The following variables differ on different systems, we set
# reasonable defaults, if something different is needed it should
# be set for that system only.
# ----------------------------------------------------

FLEX_VSN = $(shell flex --version)

TMP_CFLAGS  = $(DED__NOWARN_NOTHR_CFLAGS) @OTP_EXTRA_FLAGS@
ifeq ($(TYPE),valgrind)
CFLAGS = $(subst -O2, , $(TMP_CFLAGS)) -DVALGRIND
else
CFLAGS = $(TMP_CFLAGS)
endif
CC      = $(DED_CC)
CFLAGS_MT = $(CFLAGS) $(DED_THR_DEFS)
LD      = $(DED_LD)
LDFLAGS = $(DED_LDFLAGS)
LEX     = @LEX@
LEXLIB  = @LEXLIB@
PERL    = @PERL@
ERLANG_OSTYPE = @ERLANG_OSTYPE@

# Shall we build the flex scanner or not.
# We assume that it does not exist on windows...
ifeq ($(ENABLE_MEGACO_FLEX_SCANNER),)
ifeq ($(findstring win32,$(TARGET)), win32)
ENABLE_MEGACO_FLEX_SCANNER = false
ENABLE_REENTRANT_MEGACO_FLEX_SCANNER = false
else
ENABLE_MEGACO_FLEX_SCANNER = @ENABLE_MEGACO_FLEX_SCANNER@
ENABLE_REENTRANT_MEGACO_FLEX_SCANNER = @ENABLE_REENTRANT_MEGACO_FLEX_SCANNER@
endif
endif
ERL_COMPILE_FLAGS += -DENABLE_MEGACO_FLEX_SCANNER=$(ENABLE_MEGACO_FLEX_SCANNER)

ifeq ($(ENABLE_REENTRANT_MEGACO_FLEX_SCANNER),true)
CFLAGS_MT += -DMEGACO_REENTRANT_FLEX_SCANNER
MT_LEX_FLAGS += -R
ERL_COMPILE_FLAGS += -DMEGACO_REENTRANT_FLEX_SCANNER=true
else
ERL_COMPILE_FLAGS += -DMEGACO_REENTRANT_FLEX_SCANNER=false
endif

# Shall the library be built with line-number checks or without
ifeq ($(ENABLE_MEGACO_FLEX_SCANNER_LINENO),)
# This is not really needed in this case (since we don't support
# this for windows), but just to ensure that the variable _has_ 
# a value...
ifeq ($(findstring win32,$(TARGET)), win32)
ENABLE_MEGACO_FLEX_SCANNER_LINENO = true
else
ENABLE_MEGACO_FLEX_SCANNER_LINENO = @ENABLE_MEGACO_FLEX_SCANNER_LINENO@
endif
endif

PRIVDIR = ../../priv
LIBDIR  = $(PRIVDIR)/lib/$(TARGET)
OBJDIR  = $(PRIVDIR)/obj/$(TARGET)

# ----------------------------------------------------
# Release directory specification
# ----------------------------------------------------
RELSYSDIR = $(RELEASE_PATH)/lib/megaco-$(VSN)


# ----------------------------------------------------
# Target Specs
# ----------------------------------------------------

include modules.mk

ERL_FILES = $(MODULES:%=%.erl)	

TARGET_FILES =  \
	$(MODULES:%=$(EBIN)/%.$(EMULATOR))

FLEX_SRC   = $(FLEX_MODULES:%=%.flex.src)
FLEX_FILES = $(STD_DRV).flex $(MT_DRV).flex

C_TARGETS  = $(STD_DRV).c $(MT_DRV).c


# ----------------------------------------------------
# Misc Macros
# ----------------------------------------------------

STD_DRV_NAME=-DMEGACO_DRV_NAME=\"$(STD_DRV)\"
MT_DRV_NAME=-DMEGACO_DRV_NAME=\"$(MT_DRV)\"

ifeq ($(findstring win32,$(TARGET)), win32)
FLEX_SCANNER_SO = 
SOLIBS = $(FLEX_SCANNER_SO)
else
FLEX_SCANNER_SO = $(LIBDIR)/$(STD_DRV).$(DED_EXT) 
FLEX_SCANNER_MT_SO = $(LIBDIR)/$(MT_DRV).$(DED_EXT) 
SOLIBS = $(FLEX_SCANNER_SO) $(FLEX_SCANNER_MT_SO) 
endif


# ----------------------------------------------------
# FLAGS
# ----------------------------------------------------
ifeq ($(TYPE),debug)
ERL_COMPILE_FLAGS += -Ddebug
endif

include ../app/megaco.mk

ERL_COMPILE_FLAGS += \
	$(MEGACO_ERL_COMPILE_FLAGS) \
	-I../../include

ifeq ($(MFS_DEBUG),true)
CFLAGS += -DMFS_DEBUG=true
endif

ifeq ($(MFS_FLEX_PERF),true)
STD_LEX_FLAGS += -p
MT_LEX_FLAGS += -p
endif

ifeq ($(MFS_FLEX_DEBUG),true)
CFLAGS += -DMFS_FLEX_DEBUG=1
STD_LEX_FLAGS += -d
MT_LEX_FLAGS += -d
else
CFLAGS += -DMFS_FLEX_DEBUG=0
endif

CFLAGS += $(DED_INCLUDES) -I$(ERL_TOP)/erts/$(TARGET) $(DRV_FLAGS) -funroll-loops -Wall

#ifneq ($(FLEX_VSN),)
#CFLAGS += -DFLEX_VERSION="$(FLEX_VSN)"
#else
#CFLAGS += -DFLEX_VERSION=unknown
#endif

ifeq ($(ENABLE_MEGACO_FLEX_SCANNER_LINENO),true)
CFLAGS += -DMEGACO_LINENO
STD_LEX_FLAGS += -Ca
MT_LEX_FLAGS += -Ca
ifeq ($(ENABLE_REENTRANT_MEGACO_FLEX_SCANNER),true)
MT_LEX_FLAGS += --yylineno
endif
else
CFLAGS += -DMEGACO_TOKENCNT
STD_LEX_FLAGS += -Cfe
MT_LEX_FLAGS += -Cfe
endif



# ----------------------------------------------------
# Targets
# ----------------------------------------------------

ifeq ($(ENABLE_MEGACO_FLEX_SCANNER),true)
debug opt: $(TARGET_FILES) $(C_TARGETS) solibs
else
debug opt: $(TARGET_FILES) 
endif

clean:
	rm -f $(TARGET_FILES) 
	rm -f $(FLEX_FILES) 
	rm -f $(C_TARGETS) 
	rm -f $(SOLIBS) 
	rm -f errs core *~

docs:

info:
	@echo "ENABLE_MEGACO_FLEX_SCANNER           = $(ENABLE_MEGACO_FLEX_SCANNER)"
	@echo "ENABLE_MEGACO_FLEX_SCANNER_LINENO    = $(ENABLE_MEGACO_FLEX_SCANNER_LINENO)"
	@echo "ENABLE_REENTRANT_MEGACO_FLEX_SCANNER = $(ENABLE_REENTRANT_MEGACO_FLEX_SCANNER)"
	@echo ""
	@echo "FLEX_VSN     = $(FLEX_VSN)"
	@echo ""
	@echo "CFLAGS       = $(CFLAGS)"
	@echo "CFLAGS_MT    = $(CFLAGS_MT)"
	@echo "DRV_FLAGS    = $(DRV_FLAGS)"
	@echo "STD_LEX_FLAGS = $(STD_LEX_FLAGS)"
	@echo "MT_LEX_FLAGS  = $(MT_LEX_FLAGS)"
	@echo ""
	@echo "MODULES      = $(MODULES)"
	@echo "ERL_FILES    = $(ERL_FILES)"
	@echo "TARGET_FILES = $(TARGET_FILES)"
	@echo ""
	@echo "FLEX_MODULES = $(FLEX_MODULES)"
	@echo "FLEX_SRC     = $(FLEX_SRC)"
	@echo "FLEX_FILES   = $(FLEX_FILES)"
	@echo ""
	@echo "C_TARGETS    = $(C_TARGETS)"
	@echo ""
	@echo "LIBDIR       = $(LIBDIR)"
	@echo "LEXLIB       = $(LEXLIB)"
	@echo ""
	@echo "STD_DRV      = $(STD_DRV)"
	@echo "MT_DRV       = $(MT_DRV)"
	@echo ""
	@echo "STD_DRV_NAME = $(STD_DRV_NAME)"
	@echo "MT_DRV_NAME  = $(MT_DRV_NAME)"
	@echo ""
	@echo "SOLIBS       = $(SOLIBS)"


# ----------------------------------------------------
# Release Target
# ---------------------------------------------------- 
include $(ERL_TOP)/make/otp_release_targets.mk


release_spec: opt
	$(INSTALL_DIR)  "$(RELSYSDIR)/ebin"
	$(INSTALL_DIR)  "$(RELSYSDIR)/src"
	$(INSTALL_DIR)  "$(RELSYSDIR)/src/flex"
	$(INSTALL_DIR)  "$(RELSYSDIR)/priv/lib"
	$(INSTALL_DIR)  "$(RELSYSDIR)/include"
	$(INSTALL_DATA) $(ERL_FILES) $(INTERNAL_HRL_FILES) "$(RELSYSDIR)/src/flex"
	$(INSTALL_DATA) $(TARGET_FILES) "$(RELSYSDIR)/ebin"
ifeq ($(ENABLE_MEGACO_FLEX_SCANNER),true)
	$(INSTALL_DATA) $(FLEX_FILES) $(C_TARGETS) "$(RELSYSDIR)/src/flex"
	$(INSTALL_PROGRAM) $(SOLIBS) "$(RELSYSDIR)/priv/lib"
endif


release_docs_spec:

# megaco_flex_scanner_drv.flex: megaco_flex_scanner_drv.flex.src
# ifeq ($(ENABLE_MEGACO_FLEX_SCANNER_LINENO),true)
# ifeq ($(ENABLE_REENTRANT_MEGACO_FLEX_SCANNER),true)
# 	@printf "\treentrant [flex] scanner lineno enabled\n"
# 	$(PERL) -p -e \
#           's/%FLEX_VERSION%/$(FLEX_VSN)/ ;  \
#            s/%MEGACO_YY_LINENO_OPTION%/%option yylineno/ ;  \
#            s/%MEGACO_YY_REENTRANT_OPTION%/%option reentrant/ ;  \
#            s/%MEGACO_DUMMY_DECL_YY_LINENO%/\/* static int yylineno = 1; *\//' \
#            < $< > $@
# else
# 	@printf "\tnon-reentrant [flex] scanner lineno enabled\n"
# 	$(PERL) -p -e \
#           's/%FLEX_VERSION%/$(FLEX_VSN)/ ;  \
#            s/%MEGACO_YY_LINENO_OPTION%/%option yylineno/ ;  \
#            s/%MEGACO_YY_REENTRANT_OPTION%/\/\* %option reentrant \*\// ; \
#            s/%MEGACO_DUMMY_DECL_YY_LINENO%/\/* static int yylineno = 1; *\//' \
#            < $< > $@
# endif
# else
# ifeq ($(ENABLE_REENTRANT_MEGACO_FLEX_SCANNER),true)
# 	@printf "\treentrant [flex] scanner lineno disabled\n"
# 	$(PERL) -p -e \
#           's/%FLEX_VERSION%/$(FLEX_VSN)/ ;  \
#            s/%MEGACO_YY_LINENO_OPTION%/\/\* %option yylineno \*\// ; \
#            s/%MEGACO_YY_REENTRANT_OPTION%/%option reentrant/ ;  \
#            s/%MEGACO_DUMMY_DECL_YY_LINENO%/\/* static int yylineno = 1; - REENTRANT SCANNER*\//' \
#            < $< > $@
# else
# 	@printf "\tnon-reentrant [flex] scanner lineno disabled\n"
# 	$(PERL) -p -e \
#           's/%FLEX_VERSION%/$(FLEX_VSN)/ ;  \
#            s/%MEGACO_YY_LINENO_OPTION%/\/\* %option yylineno \*\// ; \
#            s/%MEGACO_YY_REENTRANT_OPTION%/\/\* %option reentrant \*\// ; \
#            s/%MEGACO_DUMMY_DECL_YY_LINENO%/static int yylineno = 1;/' \
#            < $< > $@
# endif
# endif
# 

$(STD_DRV).flex: megaco_flex_scanner_drv.flex.src
ifeq ($(ENABLE_MEGACO_FLEX_SCANNER_LINENO),true)
	@printf "std [flex] scanner - lineno enabled\n"
	$(PERL) -p -e \
          's/%FLEX_VERSION%/$(FLEX_VSN)/ ;  \
           s/%MEGACO_YY_LINENO_OPTION%/%option yylineno/ ;  \
           s/%MEGACO_YY_REENTRANT_OPTION%/\/\* %option reentrant \*\// ; \
           s/%MEGACO_DUMMY_DECL_YY_LINENO%/\/* static int yylineno = 1; *\//' \
           < $< > $@
else
	@printf "std [flex] scanner - lineno disabled\n"
	$(PERL) -p -e \
          's/%FLEX_VERSION%/$(FLEX_VSN)/ ;  \
           s/%MEGACO_YY_LINENO_OPTION%/\/\* %option yylineno \*\// ; \
           s/%MEGACO_YY_REENTRANT_OPTION%/\/\* %option reentrant \*\// ; \
           s/%MEGACO_DUMMY_DECL_YY_LINENO%/static int yylineno = 1;/' \
           < $< > $@
endif

$(MT_DRV).flex: megaco_flex_scanner_drv.flex.src
ifeq ($(ENABLE_MEGACO_FLEX_SCANNER_LINENO),true)
ifeq ($(ENABLE_REENTRANT_MEGACO_FLEX_SCANNER),true)
	@printf "multi-threaded reentrant [flex] scanner - lineno enabled\n"
	$(PERL) -p -e \
          's/%FLEX_VERSION%/$(FLEX_VSN)/ ;  \
           s/%MEGACO_YY_LINENO_OPTION%/%option yylineno/ ;  \
           s/%MEGACO_YY_REENTRANT_OPTION%/%option reentrant/ ;  \
           s/%MEGACO_DUMMY_DECL_YY_LINENO%/\/* static int yylineno = 1; *\//' \
           < $< > $@
else
	@printf "multi-threaded non-reentrant [flex] scanner - lineno enabled\n"
	$(PERL) -p -e \
          's/%FLEX_VERSION%/$(FLEX_VSN)/ ;  \
           s/%MEGACO_YY_LINENO_OPTION%/%option yylineno/ ;  \
           s/%MEGACO_YY_REENTRANT_OPTION%/\/\* %option reentrant \*\// ; \
           s/%MEGACO_DUMMY_DECL_YY_LINENO%/\/* static int yylineno = 1; *\//' \
           < $< > $@
endif
else
ifeq ($(ENABLE_REENTRANT_MEGACO_FLEX_SCANNER),true)
	@printf "multi-threaded reentrant [flex] scanner - lineno disabled\n"
	$(PERL) -p -e \
          's/%FLEX_VERSION%/$(FLEX_VSN)/ ;  \
           s/%MEGACO_YY_LINENO_OPTION%/\/\* %option yylineno \*\// ; \
           s/%MEGACO_YY_REENTRANT_OPTION%/%option reentrant/ ;  \
           s/%MEGACO_DUMMY_DECL_YY_LINENO%/\/* static int yylineno = 1; - REENTRANT SCANNER*\//' \
           < $< > $@
else
	@printf "multi-threaded non-reentrant [flex] scanner - lineno disabled\n"
	$(PERL) -p -e \
          's/%FLEX_VERSION%/$(FLEX_VSN)/ ;  \
           s/%MEGACO_YY_LINENO_OPTION%/\/\* %option yylineno \*\// ; \
           s/%MEGACO_YY_REENTRANT_OPTION%/\/\* %option reentrant \*\// ; \
           s/%MEGACO_DUMMY_DECL_YY_LINENO%/static int yylineno = 1;/' \
           < $< > $@
endif
endif

# megaco_flex_scanner_drv.c: megaco_flex_scanner_drv.flex
# 	$(LEX) $(LEX_FLAGS) -P$* -o$@ $< 
$(STD_DRV).c: $(STD_DRV).flex
	$(LEX) $(STD_LEX_FLAGS) -P$* -o$@ $< 
$(MT_DRV).c: $(MT_DRV).flex
	$(LEX) $(MT_LEX_FLAGS) -P$* -o$@ $< 

_create_dirs := $(shell mkdir -p $(OBJDIR) $(LIBDIR))

solibs: $(SOLIBS) 

$(OBJDIR)/$(STD_DRV).o: $(STD_DRV).c 
	@echo "compiling std driver:"
	$(CC) -c $(STD_DRV_NAME) $(CFLAGS) -o $@ $< 

$(OBJDIR)/$(MT_DRV).o: $(MT_DRV).c 
	@echo "compiling multi-threaded driver:"
	$(CC) -c $(MT_DRV_NAME) $(CFLAGS_MT) -o $@ $<


# No need to link with -lfl as we have also defined %option noyywrap - 
# and having -lfl doesn't work under Darwin for some reason. - Sean
$(LIBDIR)/$(STD_DRV).$(DED_EXT): $(OBJDIR)/$(STD_DRV).o
	@echo "linking std driver:"
	$(LD) $(LDFLAGS) -o $@ $< 

$(LIBDIR)/$(MT_DRV).$(DED_EXT): $(OBJDIR)/$(MT_DRV).o
	@echo "linking multi-threaded driver:"
	$(LD) $(LDFLAGS) -o $@ $<