1#
2# Makefile for lib/ss
3#
4
5srcdir = @srcdir@
6top_srcdir = @top_srcdir@
7VPATH = @srcdir@
8top_builddir = ../..
9my_dir = lib/ss
10INSTALL = @INSTALL@
11DLOPEN_LIB = @DLOPEN_LIB@
12
13@MCONFIG@
14
15LIBRARY= libss
16LIBDIR= ss
17
18ELF_VERSION = 2.0
19ELF_SO_VERSION = 2
20ELF_IMAGE = libss
21ELF_MYDIR = ss
22ELF_INSTALL_DIR = $(root_libdir)
23ELF_OTHER_LIBS = -lcom_err $(DLOPEN_LIB)
24
25BSDLIB_VERSION = 1.0
26BSDLIB_IMAGE = libss
27BSDLIB_MYDIR = ss
28BSDLIB_INSTALL_DIR = $(root_libdir)
29
30TAGS=etags
31COMPILE_ET=../et/compile_et --build-tree
32MK_CMDS=_SS_DIR_OVERRIDE=. ./mk_cmds
33
34.c.o:
35	$(E) "	CC $<"
36	$(Q) $(CC) $(ALL_CFLAGS) -c $<
37	$(Q) $(CHECK_CMD) $(ALL_CFLAGS) $<
38@PROFILE_CMT@	$(Q) $(CC) $(ALL_CFLAGS) -g -pg -o profiled/$*.o -c $<
39@CHECKER_CMT@	$(Q) $(CC) $(ALL_CFLAGS) -checker -g -o checker/$*.o -c $<
40@ELF_CMT@	$(Q) $(CC) $(ALL_CFLAGS) -DSHARED_ELF_LIB -fPIC -o elfshared/$*.o -c $<
41@BSDLIB_CMT@	$(Q) $(CC) $(ALL_CFLAGS) $(BSDLIB_PIC_FLAG) -o pic/$*.o -c $<
42
43# for the library
44
45# with ss_err.o first, ss_err.h should get rebuilt first too.  should not
46# be relying on this, though.
47OBJS=	ss_err.o \
48	std_rqs.o \
49	invocation.o help.o \
50	execute_cmd.o listen.o parse.o error.o prompt.o \
51	request_tbl.o list_rqs.o pager.o requests.o \
52	data.o get_readline.o
53
54SRCS=	$(srcdir)/invocation.c $(srcdir)/help.c \
55	$(srcdir)/execute_cmd.c $(srcdir)/listen.c $(srcdir)/parse.c \
56	$(srcdir)/error.c $(srcdir)/prompt.c $(srcdir)/request_tbl.c \
57	$(srcdir)/list_rqs.c $(srcdir)/pager.c $(srcdir)/requests.c \
58	$(srcdir)/data.c $(srcdir)/get_readline.c
59
60all:: mk_cmds
61
62@MAKEFILE_LIBRARY@
63@MAKEFILE_ELF@
64@MAKEFILE_BSDLIB@
65@MAKEFILE_PROFILE@
66@MAKEFILE_CHECKER@
67
68CODE= $(SRCS) $(MKCMDSFILES)
69
70MKCMDSOBJS=	mk_cmds.o utils.o options.o ct.tab.o cmd_tbl.lex.o
71
72MKCMDSFILES=	mk_cmds.c utils.c options.c ct.y cmd_tbl.lex.l
73
74MKCMDSCSRCS=	mk_cmds.c utils.c options.c ct.tab.c cmd_tbl.lex.c
75
76
77HFILES=	ss.h ss_internal.h
78SHARE_FILES= ct_c.awk ct_c.sed
79
80INSTALL_HFILES=	ss.h
81
82# for 'tags' and dependencies
83
84CFILES=	$(SRCS) $(MKCMDSCSRCS) test_ss.c
85
86# for building archives
87
88FILES=	$(SRCS) $(MKCMDSFILES) $(HFILES) \
89	ss_err.et std_rqs.ct Makefile \
90	test_ss.c ss
91
92all::	libss.a ss.pc # libss_p.a lint
93
94std_rqs.c: std_rqs.ct mk_cmds
95	$(E) "	MK_CMDS $@"
96	$(Q) DIR=$(srcdir) $(MK_CMDS) $(srcdir)/std_rqs.ct
97
98std_rqs.o: ss_err.h
99
100test_cmd.c: test_cmd.ct mk_cmds
101	$(E) "	MK_CMDS $@"
102	$(Q) DIR=$(srcdir) $(MK_CMDS) $(srcdir)/test_cmd.ct
103
104ss_err.c ss_err.h: ss_err.et
105	$(E) "	COMPILE_ET ss_err.et"
106	$(Q) $(COMPILE_ET) $(srcdir)/ss_err.et
107
108ct.tab.c ct.tab.h: ct.y
109	$(RM) -f ct.tab.* y.*
110	$(YACC) -d $(srcdir)/ct.y
111	$(MV) -f y.tab.c ct.tab.c
112	$(MV) -f y.tab.h ct.tab.h
113
114#libss.o:	$(OBJS)
115#	$(LD) -r -s -o $@ $(OBJS)
116#	$(CHMOD) -x $@
117
118mk_cmds: $(DEP_SUBSTITUTE) $(srcdir)/mk_cmds.sh.in
119	$(E) "	SUBST $@"
120	$(Q) $(SUBSTITUTE) $(srcdir)/mk_cmds.sh.in mk_cmds
121	$(Q) $(CHMOD) +x mk_cmds
122
123ss.pc: $(srcdir)/ss.pc.in $(top_builddir)/config.status
124	$(E) "	CONFIG.STATUS $@"
125	$(Q) cd $(top_builddir); CONFIG_FILES=lib/ss/ss.pc ./config.status
126
127installdirs::
128	$(E) "	MKINSTALLDIRS $(libdir) $(includedir)/ss $(datadir)/ss $(bindir)"
129	$(Q) $(MKINSTALLDIRS) $(DESTDIR)$(libdir) \
130		$(DESTDIR)$(includedir)/ss $(DESTDIR)$(datadir)/ss \
131		$(DESTDIR)$(bindir) $(DESTDIR)$(libdir)/pkgconfig
132
133install:: libss.a $(INSTALL_HFILES) installdirs ss_err.h mk_cmds ss.pc
134	$(E) "	INSTALL_DATA $(DESTDIR)$(libdir)/libss.a"
135	$(Q) $(INSTALL_DATA) libss.a $(DESTDIR)$(libdir)/libss.a
136	-$(Q) $(RANLIB) $(DESTDIR)$(libdir)/libss.a
137	$(Q) $(CHMOD) $(LIBMODE) $(DESTDIR)$(libdir)/libss.a
138	$(Q) $(RM) -f $(DESTDIR)$(includedir)/ss/*
139	$(Q) for i in $(INSTALL_HFILES); do \
140		echo "	INSTALL_DATA $(DESTDIR)$(includedir)/ss/$$i"; \
141		$(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(includedir)/ss/$$i; \
142	done
143	$(E) "	INSTALL_DATA $(includedir)/ss/ss_err.h"
144	$(Q) $(INSTALL_DATA) ss_err.h $(DESTDIR)$(includedir)/ss/ss_err.h
145	$(Q) for i in $(SHARE_FILES); do \
146		echo "	INSTALL_DATA $(DESTDIR)$(datadir)/ss/$$i"; \
147		$(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(datadir)/ss/$$i; \
148	done
149	$(E) "	INSTALL $(bindir)/mk_cmds"
150	$(Q) $(INSTALL) mk_cmds $(DESTDIR)$(bindir)/mk_cmds
151	$(E) "	INSTALL_DATA $(man1dir)/mk_cmds.1"
152	$(Q) $(INSTALL_DATA) $(srcdir)/mk_cmds.1 $(DESTDIR)$(man1dir)/mk_cmds.1
153	$(E) "	INSTALL_DATA $(libdir)/pkgconfig/ss.pc"
154	$(Q) $(INSTALL_DATA) ss.pc $(DESTDIR)$(libdir)/pkgconfig/ss.pc
155
156uninstall::
157	$(RM) -f $(DESTDIR)$(libdir)/libss.a $(DESTDIR)$(bindir)/mk_cmds \
158		$(DESTDIR)$(libdir)/pkgconfig/ss.pc \
159		$(DESTDIR)$(man1dir)/mk_cmds.1
160	$(RM) -rf $(DESTDIR)$(includedir)/ss $(DESTDIR)$(datadir)/ss
161
162test_ss: test_ss.o test_cmd.o $(DEPLIBSS) $(DEPLIBCOM_ERR)
163	$(E) "	LD $@"
164	$(Q) $(CC) -o $@ test_ss.o test_cmd.o $(ALL_CFLAGS) \
165		$(LIBSS) $(LIBCOM_ERR)
166
167check:: all test_ss
168	$(E) "	RUN TEST test_ss"
169	-@(LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./test_ss -f $(srcdir)/test_script > test_out 2>&1; exit 0)
170	$(Q) if diff test_out $(srcdir)/test_script_expected > test.diff; then \
171		true ; else echo "Regression test for ss library failed!"; exit 1 ; fi
172
173clean::
174	$(RM) -f ../libss.a libss.a mk_cmds ss_err.h ss_err.c std_rqs.c \
175		tst_cmds.c test_ss test_out test.diff *.o *~ \#* *.bak core \
176		test_cmd.c
177
178mostlyclean:: clean
179distclean:: clean
180	$(RM) -f .depend Makefile ss.pc \
181		$(srcdir)/TAGS $(srcdir)/Makefile.in.old
182
183#
184# Hack to parallel makes recognize dependencies correctly.
185#
186$(top_builddir)/lib/ss/ss_err.h: ss_err.h
187
188$(OBJS): subdirs
189
190# +++ Dependency line eater +++
191#
192# Makefile dependencies follow.  This must be the last section in
193# the Makefile.in file
194#
195invocation.o: $(srcdir)/invocation.c $(top_builddir)/lib/config.h \
196 $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
197 $(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
198help.o: $(srcdir)/help.c $(top_builddir)/lib/config.h \
199 $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
200 $(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
201execute_cmd.o: $(srcdir)/execute_cmd.c $(top_builddir)/lib/config.h \
202 $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
203 $(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
204listen.o: $(srcdir)/listen.c $(top_builddir)/lib/config.h \
205 $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
206 $(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
207parse.o: $(srcdir)/parse.c $(top_builddir)/lib/config.h \
208 $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
209 $(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
210error.o: $(srcdir)/error.c $(top_builddir)/lib/config.h \
211 $(top_builddir)/lib/dirpaths.h $(top_srcdir)/lib/et/com_err.h \
212 $(srcdir)/ss_internal.h $(srcdir)/ss.h $(top_builddir)/lib/ss/ss_err.h
213prompt.o: $(srcdir)/prompt.c $(top_builddir)/lib/config.h \
214 $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
215 $(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
216request_tbl.o: $(srcdir)/request_tbl.c $(top_builddir)/lib/config.h \
217 $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
218 $(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
219list_rqs.o: $(srcdir)/list_rqs.c $(top_builddir)/lib/config.h \
220 $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
221 $(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
222pager.o: $(srcdir)/pager.c $(top_builddir)/lib/config.h \
223 $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
224 $(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
225requests.o: $(srcdir)/requests.c $(top_builddir)/lib/config.h \
226 $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
227 $(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
228data.o: $(srcdir)/data.c $(top_builddir)/lib/config.h \
229 $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
230 $(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
231get_readline.o: $(srcdir)/get_readline.c $(top_builddir)/lib/config.h \
232 $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
233 $(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
234