| 141 |
Kevin |
1 |
#
|
|
|
2 |
# A simple Makefile to build 'esh'
|
|
|
3 |
#
|
|
|
4 |
LDFLAGS=
|
|
|
5 |
LDLIBS=-ll -ldl -lreadline -lcurses
|
|
|
6 |
# The use of -Wall, -Werror, and -Wmissing-prototypes is mandatory
|
|
|
7 |
# for this assignment
|
|
|
8 |
CFLAGS=-Wall -Werror -Wmissing-prototypes -g -fPIC
|
|
|
9 |
#YFLAGS=-v
|
|
|
10 |
|
|
|
11 |
LIB_OBJECTS=list.o esh-utils.o esh-sys-utils.o
|
|
|
12 |
OBJECTS=esh.o
|
|
|
13 |
HEADERS=list.h esh.h esh-sys-utils.h
|
|
|
14 |
PLUGINDIR=plugins
|
|
|
15 |
PLUGIN_C=$(wildcard $(PLUGINDIR)/*.c)
|
|
|
16 |
PLUGIN_SO=$(patsubst %.c,%.so,$(PLUGIN_C))
|
|
|
17 |
|
|
|
18 |
default: esh $(PLUGIN_SO)
|
|
|
19 |
|
|
|
20 |
# rules to build plugins
|
|
|
21 |
plugins/deadline.so: plugins/deadline.c
|
|
|
22 |
gcc -g -Wall -shared -fPIC -o $@ -IcJSONFiles \
|
|
|
23 |
$< libesh.a $(shell curl-config --libs) cJSONFiles/cJSON.c -lm
|
|
|
24 |
|
|
|
25 |
# The rules assume each plugin is in its own file
|
|
|
26 |
$(PLUGIN_SO): %.so : %.c
|
|
|
27 |
gcc -Wall -shared -fPIC -o $@ $< libesh.a
|
|
|
28 |
|
|
|
29 |
$(LIB_OBJECTS) : $(HEADERS)
|
|
|
30 |
|
|
|
31 |
# build scanner and parser
|
|
|
32 |
esh-grammar.o: esh-grammar.y esh-grammar.l
|
|
|
33 |
$(LEX) $(LFLAGS) $*.l
|
|
|
34 |
$(YACC) $(YFLAGS) $<
|
|
|
35 |
$(CC) -Dlint -c -o $@ $(CFLAGS) y.tab.c
|
|
|
36 |
rm -f y.tab.c lex.yy.c
|
|
|
37 |
|
|
|
38 |
# build the shell
|
|
|
39 |
esh: libesh.a $(OBJECTS) $(HEADERS) esh-grammar.o
|
|
|
40 |
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) esh-grammar.o $(OBJECTS) libesh.a $(LDLIBS)
|
|
|
41 |
|
|
|
42 |
# build the supporting library
|
|
|
43 |
libesh.a: $(LIB_OBJECTS)
|
|
|
44 |
ar cr $@ $(LIB_OBJECTS)
|
|
|
45 |
ranlib $@
|
|
|
46 |
|
|
|
47 |
clean:
|
|
|
48 |
rm -f $(OBJECTS) $(LIB_OBJECTS) esh esh-grammar.o \
|
|
|
49 |
$(PLUGIN_SO) core.* libesh.a tests/*.pyc
|