forked from clicon/cligen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.in
250 lines (204 loc) · 7.64 KB
/
Makefile.in
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
#
# Makefile for cligen CLI generator.
#
# ***** BEGIN LICENSE BLOCK *****
#
# Copyright (C) 2001-2022 Olof Hagsand
#
# This file is part of CLIgen.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Alternatively, the contents of this file may be used under the terms of
# the GNU General Public License Version 2 or later (the "GPL"),
# in which case the provisions of the GPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of the GPL, and not to allow others to
# use your version of this file under the terms of Apache License version 2, indicate
# your decision by deleting the provisions above and replace them with the
# notice and other provisions required by the GPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the Apache License version 2 or the GPL.
#
# ***** END LICENSE BLOCK *****
prefix = @prefix@
datarootdir = @datarootdir@
exec_prefix = @exec_prefix@
bindir = @bindir@
libdir = @libdir@
srcdir = @srcdir@
# Force a cligen sub-directory
includedir = @includedir@/cligen
CC = @CC@
LINKAGE = @LINKAGE@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
ifeq ($(LINKAGE),dynamic)
CPPFLAGS += -fPIC
endif
SH_SUFFIX = @SH_SUFFIX@
LIBSTATIC_SUFFIX = @LIBSTATIC_SUFFIX@
LDFLAGS = @LDFLAGS@
ifneq ($(LINKAGE),dynamic)
# -rdynamic for using -ldl
LDFLAGS += -rdynamic
endif
LIBS = @LIBS@
INCLUDES = -I. -I@srcdir@ @INCLUDES@
HOST_VENDOR = @host_vendor@
INSTALL = @INSTALL@
INSTALL_LIB = @INSTALL@
INSTALL_DATA = @INSTALL@
INSTALL_PROGRAM = @INSTALL@
LN_S = @LN_S@
ifeq ($(HOST_VENDOR),apple)
INSTALLFLAGS =
else
INSTALLFLAGS = @INSTALLFLAGS@
endif
CLIGEN_VERSION = @CLIGEN_VERSION@
CLIGEN_MAJOR = @CLIGEN_VERSION_MAJOR@
CLIGEN_MINOR = @CLIGEN_VERSION_MINOR@
# Linker-name: libcligen.so
# so-name: libcligen.so.3
# real-name: libcligen.so.3.0
MYLIBDYNAMIC = libcligen$(SH_SUFFIX).$(CLIGEN_MAJOR).$(CLIGEN_MINOR)
MYLIBSO = libcligen$(SH_SUFFIX).$(CLIGEN_MAJOR)
MYLIBLINK = libcligen$(SH_SUFFIX)
MYLIBSTATIC = libcligen$(LIBSTATIC_SUFFIX)
SRC = cligen_object.c cligen_callback.c cligen_parsetree.c cligen_pt_head.c \
cligen_handle.c cligen_cv.c cligen_match.c cligen_result.c \
cligen_read.c cligen_io.c cligen_expand.c cligen_syntax.c \
cligen_print.c cligen_cvec.c cligen_buf.c cligen_util.c \
cligen_history.c cligen_regex.c cligen_getline.c build.c
INCS = cligen_cv.h cligen_cvec.h cligen_object.h cligen_callback.h cligen_handle.h \
cligen_parsetree.h cligen_pt_head.h cligen_result.h \
cligen_print.h cligen_read.h cligen_io.h cligen_expand.h \
cligen_syntax.h cligen_buf.h cligen_util.h cligen_history.h \
cligen_regex.h cligen.h
SRCDIR_INCS = $(addprefix $(srcdir)/,$(INCS))
OBJS = $(SRC:.c=.o)
APPS = cligen_hello cligen_file cligen_tutorial
YACC = @YACC@
LEX = @LEX@
all: cligen $(APPS)
ifeq ($(LINKAGE),dynamic)
all: $(MYLIBDYNAMIC)
else
all: $(MYSTATIC)
endif
.PHONY: TAGS test
TAGS:
find . -name '*.[chyl]' -print | etags -
# Run a clixon test container.
# Alt: cd test; ./all.sh
# CFLAGS/LINKAGE is for test_compile.sh for coverage
test:
(cd test && SKIPLIST="$(SKIPLIST)" CFLAGS="$(CFLAGS)" LINKAGE="$(LINKAGE)" ./all.sh)
distclean: clean
rm -f Makefile config.log config.status config.h TAGS .depend
rm -rf autom4te.cache build.c cligen_config.h
rm -rf doc
%.o : $(srcdir)/%.c
$(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $<
.c.o:
$(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $<
# Compute the length of the date command (and add some extra with XXX)
DATELEN = $(shell date +"%Y.%m.%d %H:%M by `whoami` on `hostname`XXXX"|wc -c)
# Should not be rebuilt on install, which causes root ownership of the lib in the build-dir
.PHONY: build.c
build.c:
echo "/* This file is generated from the CLIgen Makefile */" > build.c;
date +"const char CLIGEN_BUILDSTR[$(DATELEN)]=\"%Y.%m.%d %H:%M by `whoami` on `hostname`"\"\; >> build.c;
echo "const char CLIGEN_VERSION[64]=\"$(CLIGEN_VERSION)\""\; >> build.c;
# install-bin install-include
install: install-lib install-include
install-bin: $(APPS)
$(INSTALL) -m 0755 -d $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) -m 0755 $(APPS) $(DESTDIR)$(bindir)
ifeq ($(LINKAGE),dynamic)
install-lib: $(MYLIBDYNAMIC)
$(INSTALL) -m 0755 -d $(DESTDIR)$(libdir)
$(INSTALL) -m 0644 $(INSTALLFLAGS) $< $(DESTDIR)$(libdir)
(cd $(DESTDIR)$(libdir) && $(LN_S) -f $< $(MYLIBSO)) # -l:libcligen.so.3
(cd $(DESTDIR)$(libdir) && $(LN_S) -f $(MYLIBSO) $(MYLIBLINK)) # -l:libcligen.so
else
install-lib: $(MYLIBSTATIC)
$(INSTALL) -m 0755 -d $(DESTDIR)$(libdir)
$(INSTALL) -m 0644 $(INSTALLFLAGS) $< $(DESTDIR)$(libdir)
endif
# Installs include files in subdir called 'cligen'. Applications should include
# <cligen/cligen.h>
install-include: $(SRCDIR_INCS)
install -m 0755 -d $(DESTDIR)$(includedir)
$(INSTALL_DATA) $(SRCDIR_INCS) $(DESTDIR)$(includedir)
uninstall:
rm -f $(DESTDIR)$(libdir)/$(MYLIBDYNAMIC)
rm -f $(DESTDIR)$(libdir)/$(MYLIBSTATIC)
for i in $(INCS); do \
rm -f $(DESTDIR)$(includedir)/$$i; \
done
# CLIGEN parser src
YACC_SRC = cligen_parse.y
LEX_SRC = cligen_parsel
YACCOBJS := lex.cligen_parse.o cligen_parse.tab.o
clean:
rm -f $(APPS) $(OBJS) $(YACCOBJS)
rm -f $(MYLIBSTATIC) $(MYLIBDYNAMIC) $(MYLIBSO) $(MYLIBLINK)
rm -f *.tab.c *.tab.h *.tab.o
rm -f lex.*.c lex.*.o *.core cligen
rm -f *.gcda *.gcno *.gcov # coverage
%.c : %.y # cancel implicit yacc rule
%.c : %.l # cancel implicit lex rule
# top file parse
lex.cligen_parse.c : $(srcdir)/cligen_parse.l cligen_parse.tab.h
$(LEX) -Pcligen_parse $(srcdir)/cligen_parse.l # -d is debug
cligen_parse.tab.h: $(srcdir)/cligen_parse.y
$(YACC) -l -d -b cligen_parse -p cligen_parse $(srcdir)/cligen_parse.y # -t is debug
cligen_parse.tab.c: cligen_parse.tab.h
lex.cligen_parse.o : lex.cligen_parse.c cligen_parse.tab.h
$(CC) $(INCLUDES) $(CPPFLAGS) -DYY_NO_INPUT $(CFLAGS) -c $<
ifeq ($(LINKAGE),dynamic)
MYLIB=$(MYLIBDYNAMIC)
else
MYLIB=$(MYLIBSTATIC)
endif
# Applications
cligen_hello : $(srcdir)/cligen_hello.c cligen $(MYLIB)
$(CC) $(CPPFLAGS) $(CFLAGS) $(INCLUDES) $< $(LDFLAGS) $(LIBS) -o $@ $(MYLIB)
cligen_file : $(srcdir)/cligen_file.c cligen $(MYLIB)
$(CC) $(CPPFLAGS) $(CFLAGS) $(INCLUDES) $< $(LDFLAGS) $(LIBS) -o $@ $(MYLIB)
cligen_tutorial :$(srcdir)/cligen_tutorial.c cligen $(MYLIB)
$(CC) $(CPPFLAGS) $(CFLAGS) $(INCLUDES) $< $(LDFLAGS) $(LIBS) -o $@ $(MYLIB)
$(MYLIBDYNAMIC) : $(OBJS) $(YACCOBJS)
ifeq ($(HOST_VENDOR),apple)
$(CC) -shared -o $@ $(OBJS) $(YACCOBJS) $(LDFLAGS) -undefined dynamic_lookup -o $(MYLIB) $(LIBS)
else
$(CC) -shared -o $@ $(OBJS) $(YACCOBJS) $(LDFLAGS) -Wl,-soname=$(MYLIB) $(LIBS)
endif
# link-name is needed for application linking
$(MYLIBSO) : $(MYLIB)
$(MYLIBLINK) : $(MYLIB)
$(MYLIBSTATIC) : $(OBJS) $(YACCOBJS)
ar -crs $@ $(OBJS) $(YACCOBJS)
# recursive link to handle application include files, if you have not installed
# .h files in $(includefile)
cligen :
cd $(srcdir) && rm -rf $@ && ln -sf . $@
.PHONY: doc
doc :
doxygen Doxyfile
.PHONY: depend
depend:
$(CC) $(DEPENDFLAGS) @DEFS@ $(INCLUDES) $(CFLAGS) -MM $(SRC) cligen_file.c cligen_hello.c cligen_tutorial.c > .depend
#include .depend