1#
2# Makemod.in.in
3#
4# Copyright (c) 1995-1997 Richard Coleman
5# All rights reserved.
6#
7# Permission is hereby granted, without written agreement and without
8# license or royalty fees, to use, copy, modify, and distribute this
9# software and to distribute modified versions of this software for any
10# purpose, provided that the above copyright notice and the following
11# two paragraphs appear in all copies of this software.
12#
13# In no event shall Richard Coleman or the Zsh Development Group be liable
14# to any party for direct, indirect, special, incidental, or consequential
15# damages arising out of the use of this software and its documentation,
16# even if Richard Coleman and the Zsh Development Group have been advised of
17# the possibility of such damage.
18#
19# Richard Coleman and the Zsh Development Group specifically disclaim any
20# warranties, including, but not limited to, the implied warranties of
21# merchantability and fitness for a particular purpose.  The software
22# provided hereunder is on an "as is" basis, and Richard Coleman and the
23# Zsh Development Group have no obligation to provide maintenance,
24# support, updates, enhancements, or modifications.
25#
26
27# ========== OVERRIDABLE VARIABLES ==========
28
29# subdir is done by mkmakemod.sh
30# dir_top is done by mkmakemod.sh
31# SUBDIRS is done by mkmakemod.sh
32
33@VERSION_MK@
34
35# source/build directories
36VPATH           = @srcdir@
37sdir            = @srcdir@
38sdir_top        = @top_srcdir@
39INSTALL         = @INSTALL@
40
41@DEFS_MK@
42
43sdir_src      = $(sdir_top)/Src
44dir_src       = $(dir_top)/Src
45
46# ========== COMPILATION RULES ==========
47
48DNCFLAGS =
49
50COMPILE     = $(CC) -c -I. -I$(dir_top)/Src -I$(sdir_top)/Src -I$(sdir_top)/Src/Zle -I$(sdir) $(CPPFLAGS) $(DEFS) $(CFLAGS) $(D@L@CFLAGS)
51DLCOMPILE   = $(CC) -c -I. -I$(dir_top)/Src -I$(sdir_top)/Src -I$(sdir_top)/Src/Zle -I$(sdir) $(CPPFLAGS) $(DEFS) -DMODULE $(CFLAGS) $(DLCFLAGS)
52LINK        = $(CC) $(LDFLAGS) $(EXELDFLAGS) $(EXTRA_LDFLAGS) -o $@
53DLLINK      = $(DLLD) $(LDFLAGS) $(LIBLDFLAGS) $(DLLDFLAGS) -o $@
54
55KNR_OBJ=.o
56KNROBJ=._foo_
57
58ANSIOBJ=.o
59ANSI_OBJ=._foo_
60
61.SUFFIXES: .c .$(DL_EXT) ..o .._foo_ .o ._foo_ .syms .pro .epro
62
63.c$(ANSI@U@OBJ):
64	$(COMPILE) -o $@ $<
65	@rm -f $(dir_src)/stamp-modobjs
66
67.c$(KNR@U@OBJ):
68	@ANSI2KNR@ $< > $@.c
69	$(COMPILE) -o $@ $@.c
70	rm -f $@.c
71	@rm -f $(dir_src)/stamp-modobjs
72
73.c.$(ANSI@U@OBJ):
74	$(DLCOMPILE) -o $@ $<
75
76.c.$(KNR@U@OBJ):
77	@ANSI2KNR@ $< > $@.c
78	$(DLCOMPILE) -o $@ $@.c
79	rm -f $@.c
80
81.c.syms:
82	$(AWK) -f $(sdir_src)/makepro.awk $< $(subdir) > $@
83
84.syms.epro:
85	(echo '/* Generated automatically */'; sed -n '/^E/{s/^E//;p;}' < $<) \
86		> $@
87	(echo '/* Generated automatically */'; sed -n '/^L/{s/^L//;p;}' < $<) \
88		> `echo $@ | sed 's/\.epro$$/.pro/'`
89
90PROTODEPS = $(sdir_src)/makepro.awk
91
92# ========== DEPENDENCIES FOR BUILDING ==========
93
94all: modobjs modules
95.PHONY: all
96
97modobjs: $(MODOBJS)
98modules: $(MODULES)
99headers: $(MDHS)
100proto: $(PROTOS)
101.PHONY: modobjs modules headers proto
102
103prep:
104	@case $(sdir_top) in \
105	    /*) top_srcdir=$(sdir_top) ;; \
106	    *) top_srcdir=$(subdir)/$(sdir_top) ;; \
107	esac; \
108	export top_srcdir; \
109	cd $(dir_top) || exit 1; \
110	subdirs='$(SUBDIRS)'; \
111	for subdir in $$subdirs; do \
112	    dir=$(subdir)/$$subdir; \
113	    test -d $$dir || mkdir $$dir; \
114	    $(SHELL) $$top_srcdir/Src/mkmakemod.sh $$dir Makefile || exit 1; \
115	    ( cd $$dir && $(MAKE) $(MAKEDEFS) $@ ) || exit 1; \
116	done
117.PHONY: prep
118
119headers: $(dir_src)/modules.stamp
120$(dir_src)/modules.stamp: $(MDDS)
121	$(MAKE) -f $(makefile) $(MAKEDEFS) prep
122	echo 'timestamp for *.mdd files' > $@
123.PHONY: headers
124
125FORCE:
126.PHONY: FORCE
127
128# ========== DEPENDENCIES FOR INSTALLING ==========
129
130install: install.bin install.modules
131uninstall: uninstall.bin uninstall.modules
132.PHONY: install uninstall
133
134install.bin: install.bin-here
135uninstall.bin: uninstall.bin-here
136install.modules: install.modules-here
137uninstall.modules: uninstall.modules-here
138.PHONY: install.bin uninstall.bin install.modules uninstall.modules
139
140install.bin-here uninstall.bin-here:
141install.modules-here uninstall.modules-here:
142.PHONY: install.bin-here install.modules-here
143
144# ========== DEPENDENCIES FOR CLEANUP ==========
145
146@CLEAN_MK@
147
148mostlyclean-here:
149	rm -f *.o *.export *.$(DL_EXT)
150.PHONY: mostlyclean-here
151
152clean-here:
153	rm -f *.o.c *.syms *.pro *.epro *.mdh *.mdhi *.mdhs *.mdh.tmp
154.PHONY: clean-here
155
156distclean-here:
157	rm -f $(makefile) $(makefile).in
158.PHONY: distclean-here
159
160# ========== RECURSIVE MAKES ==========
161
162install.bin uninstall.bin install.modules uninstall.modules \
163modobjs modules headers proto:
164	@subdirs='$(SUBDIRS)'; for subdir in $$subdirs; do \
165	  ( cd $$subdir && $(MAKE) $(MAKEDEFS) $@ ) || exit 1; \
166	done
167
168# ========== DEPENDENCIES FOR MAINTENANCE ==========
169
170$(makefile): $(makefile).in $(dir_top)/config.status
171	@case $(sdir_top) in \
172	    /*) top_srcdir=$(sdir_top) ;; \
173	    *) top_srcdir=$(subdir)/$(sdir_top) ;; \
174	esac; \
175	export top_srcdir; \
176	echo 'cd $(dir_top) && $(SHELL)' \
177	    '$$top_srcdir/Src/mkmakemod.sh -m $(subdir) $(makefile)'; \
178	cd $(dir_top) && \
179	    $(SHELL) $$top_srcdir/Src/mkmakemod.sh -m $(subdir) $(makefile)
180
181$(makefile).in: $(sdir_src)/mkmakemod.sh $(sdir_src)/Makemod.in.in $(MDDS) \
182	$(dir_top)/config.modules
183	@case $(sdir_top) in \
184	    /*) top_srcdir=$(sdir_top) ;; \
185	    *) top_srcdir=$(subdir)/$(sdir_top) ;; \
186	esac; \
187	export top_srcdir; \
188	echo 'cd $(dir_top) && $(SHELL)' \
189	    '$$top_srcdir/Src/mkmakemod.sh -i $(subdir) $(makefile)'; \
190	cd $(dir_top) && \
191	    $(SHELL) $$top_srcdir/Src/mkmakemod.sh -i $(subdir) $(makefile)
192
193