mkmi.m4 5.76 KB
Newer Older
Per Cederqvist's avatar
Per Cederqvist committed
1
dnl $Id: mkmi.m4,v 1.6 1994/04/05 07:52:29 ceder Exp $
Per Cederqvist's avatar
Per Cederqvist committed
2
dnl Create Makefile.in from Makefile.src
Per Cederqvist's avatar
Per Cederqvist committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
dnl Copyright (C) 1993, 1994  Lysator Academic Computer Association.
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2, or (at your option)
dnl any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
dnl
dnl Please mail bug reports to bug-lyskom@lysator.liu.se. 
Per Cederqvist's avatar
Per Cederqvist committed
20
21
dnl
changequote([,])dnl
Per Cederqvist's avatar
Per Cederqvist committed
22
define([LK_QUOTE],[[[$1]]])dnl
Per Cederqvist's avatar
Per Cederqvist committed
23
24
25
26
27
28
29
30
31
32
33
34
dnl
dnl LK_descend(cmd, deps, localcmd) expands to
dnl
dnl	.PHONY: cmd
dnl	cmd: deps
dnl	localcmd
dnl		[code to perform cmd in $SUBDIRS]
dnl
dnl localcmd should typically be empty or contain commands to perform
dnl cmd in the current directory.  All lines in localcmd should begin
dnl with a tab.
dnl
35
define([LK_descend], [[.PHONY: $1
Per Cederqvist's avatar
Per Cederqvist committed
36
$1: $2
37
$3	@for i in DuMmY $(SUBDIRS); do \
Per Cederqvist's avatar
Per Cederqvist committed
38
		if test -f $$i/Makefile ; then \
39
40
			echo making $1 in directory $$i; \
			if (cd ./$$i; $(MAKE) $1); \
Per Cederqvist's avatar
Per Cederqvist committed
41
42
43
44
45
			then true; else exit 1; fi ; \
		else true; fi; \
	done
]])dnl
dnl
46
define([LK_cmd],[[	$1
Per Cederqvist's avatar
Per Cederqvist committed
47
48
49
50
51
]])dnl
define([domostlyclean],[LK_cmd([$(RM) $(GENERIC-MOSTLYCLEAN)])])dnl
define([doclean],)dnl
define([dodistclean],[LK_cmd([$(RM) $(GENERIC-DISTCLEAN)])])dnl
define([dorealclean],)dnl
52
define([dopure],[LK_cmd([$(RM) $(GENERIC-PURE)])])dnl
Per Cederqvist's avatar
Per Cederqvist committed
53
54
define([LK_CLEAN],[dnl
[# Output from LK_CLEAN
55
56
GENERIC-MOSTLYCLEAN = *.o lib*.a core Makefile.in2
GENERIC-PURE = Makefile.in configure
Per Cederqvist's avatar
Per Cederqvist committed
57
GENERIC-DISTCLEAN = *~ .\#* TAGS dependencies Makefile]
58
59
60
61
62
LK_descend([mostlyclean],[domostlyclean])
LK_descend([clean],[doclean])
LK_descend([distclean],[dodistclean])
LK_descend([realclean],[dorealclean])
LK_descend([pure],[dopure])
Per Cederqvist's avatar
Per Cederqvist committed
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
[dopure: dorealclean]
dopure
[dorealclean: dodistclean]
dorealclean
[dodistclean: doclean]
dodistclean
[doclean: domostlyclean]
doclean
[domostlyclean:]
domostlyclean
[# End output from LK_CLEAN]]
)dnl End of LK_CLEAN
dnl
define([dodepend],)dnl
define([predepend],)dnl
dnl
Per Cederqvist's avatar
Per Cederqvist committed
79
80
81
define([LK_ALL_C_DEPEND],
[define([dodepend],
    [LK_cmd([$(CC) $(DEPENDFLAG) $(ALL_CFLAGS) $(srcdir)/*.c $(C_SPECIALS) \
Per Cederqvist's avatar
Per Cederqvist committed
82
83
84
85
86
87
		>dependencies])])dnl
define([predepend],[[$(C_SPECIALS)]])])dnl
dnl
define([LK_DEPEND],[[dependencies:
	touch dependencies]

88
LK_descend([depend],predepend,dodepend)])dnl end LK_DEPEND
Per Cederqvist's avatar
Per Cederqvist committed
89
90
dnl
define([LK_INSTALL_HDRS],
91
92
[[INSTALL-HDRS = $1
HDRS-DIR =$(INCLUDEDIR)$2]
Per Cederqvist's avatar
Per Cederqvist committed
93
94
95
96
define([doincludes],
[[	test -d $(HDRS-DIR) || $(MKDIR) $(HDRS-DIR)
	for i in $(INSTALL-HDRS) ; \
	do if ( cmp $(srcdir)/$$i $(HDRS-DIR)/$$i 2>/dev/null ) ; then\
97
             true; else\
Per Cederqvist's avatar
Per Cederqvist committed
98
		$(RM) $(HDRS-DIR)/$$i;\
99
100
101
102
		if $(INSTALL_DATA) $(srcdir)/$$i $(HDRS-DIR)/$$i;\
		then true ; else exit 1; fi; fi;\
	done
]])dnl end of doincludes
Per Cederqvist's avatar
Per Cederqvist committed
103
104
])dnl end of LK_INSTALL_HDRS
dnl
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
define([preincludes],)dnl
define([LK_INSTALL_BUILT_HDRS],
[[INSTALL-HDRS = $1
HDRS-DIR =$(INCLUDEDIR)$2]
define([preincludes],[[$(INSTALL-HDRS)]])dnl
define([doincludes],
[[	test -d $(HDRS-DIR) || $(MKDIR) $(HDRS-DIR)
	for i in $(INSTALL-HDRS) ; \
	do if ( cmp $$i $(HDRS-DIR)/$$i 2>/dev/null ) ; then\
             true; else\
		$(RM) $(HDRS-DIR)/$$i;\
		if $(INSTALL_DATA) $$i $(HDRS-DIR)/$$i;\
		then true ; else exit 1; fi; fi;\
	done
]])dnl end of doincludes
])dnl end of LK_INSTALL_BUILT_HDRS
dnl
define([doincludes],)dnl
define([dolibraries],)dnl
define([prelibraries],)dnl
define([LK_STD_LIBS],
	[errprint(__file__:__line__:[ Use LK_STD_LIB, not LK_STD_LIB])
	m4exit(1)])dnl
Per Cederqvist's avatar
Per Cederqvist committed
128
define([LK_STD_LIB],
129
130
[[LIBNAME = $1
LIBOBJS = $2
Per Cederqvist's avatar
Per Cederqvist committed
131

132
133
134
$(LIBNAME): $(LIBOBJS)
	$(AR) $(ARFLAGS) $]][[@ $]][[?
	$(RANLIB) $]][[@]
Per Cederqvist's avatar
Per Cederqvist committed
135
136
137
define([dolibraries],
[[	$(RM) $(LIBDIR)/$(LIBNAME)
	cp $(LIBNAME) $(LIBDIR)/$(LIBNAME)
138
139
	$(TOUCHLIB) $(LIBDIR)/$(LIBNAME)
]])dnl end of dolibraries
Per Cederqvist's avatar
Per Cederqvist committed
140
141
define([prelibraries],[[$(LIBNAME)]])dnl end of prelibraries
])dnl end of LK_STD_LIB
142
143
dnl
define([prebinaries],)dnl
Per Cederqvist's avatar
Per Cederqvist committed
144
define([dobinaries],)dnl
145
146
define([preinstall],)dnl
define([doinstall],)dnl
Per Cederqvist's avatar
Per Cederqvist committed
147
define([LK_DESCEND],dnl
148
149
[LK_descend([includes],preincludes,doincludes)
LK_descend([libraries],prelibraries,dolibraries)
Per Cederqvist's avatar
Per Cederqvist committed
150
LK_descend([binaries],prebinaries,dobinaries)
151
LK_descend([install],preinstall,doinstall)
Per Cederqvist's avatar
Per Cederqvist committed
152
153
154
LK_DEPEND
LK_CLEAN])dnl end of LK_DESCEND
dnl
Per Cederqvist's avatar
Per Cederqvist committed
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
define([LK_SCRIPTS],
[[SCRIPTS = $1
]define([dobinaries],
[[	for i in $(SCRIPTS); do \
	    sed -e s+@ETCDIR@+$(etcdir)+ -e s+@BINDIR@+$(bindir)+ \
		$(srcdir)/$$i.sh > $$i;\
	    chmod +x $$i;\
	done
]])dnl end dobinaries
define([doinstall],
[[	for i in $(SCRIPTS); do \
	    $(INSTALL_PROGRAM) $$i $(bindir); \
	done
]])dnl end doinstall
])dnl end LK_SCRIPTS
Per Cederqvist's avatar
Per Cederqvist committed
170
dnl
171
172
173
dnl LK_STD(alldep)
dnl	alldep defaults to libraries
dnl
Per Cederqvist's avatar
Per Cederqvist committed
174
define([LK_STD],[[# Begin LK_STD
175
176
srcdir = @srcdir@
VPATH = @srcdir@
Per Cederqvist's avatar
Per Cederqvist committed
177
178
SHELL = /bin/sh

179
180
all: $1]ifelse($#,0,[[libraries]])[

Per Cederqvist's avatar
Per Cederqvist committed
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
AWK = @AWK@
CC = @CC@
CFLAGS = @CFLAGS@
ALL_CFLAGS = @INCLUDE_CURRENT@ -I@srcdir@ -I@BUILDTOPDIR@/include \
	-I@BUILDTOPDIR@/include/server $(DEFS) $(CFLAGS)

DEPENDFLAG = @DEPENDFLAG@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
LEX = @LEX@
MKDIR = mkdir
RANLIB = @RANLIB@
RM = rm -f
SED = @SED@
SYMLINK = @LN_S@
TOUCHLIB = @RANLIB@
YACC = @YACC@

INCLUDEDIR = @BUILDTOPDIR@/include
LIBDIR = @BUILDTOPDIR@/lib
prefix = /usr/lyskom
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
dbdir = $(exec_prefix)/db
etcdir = $(exec_prefix)/etc
coredir = $(exec_prefix)/cores

DEFS = @DEFS@
LDFLAGS = @LDFLAGS@
SCRIPTDIR = @SRCTOPDIR@/scripts

.c.o:
	$(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<
215
# END section from LK_STD
Per Cederqvist's avatar
Per Cederqvist committed
216
]])dnl LK_STD