1#
2# This contains final targets and should be included at the end of any
3# NWGNUmakefile file
4#
5
6#
7# If we are going to create an nlm, make sure we have assigned variables to
8# use during the link.
9#
10ifndef NLM_NAME
11NLM_NAME = $(TARGET_nlm)
12endif
13
14ifndef NLM_DESCRIPTION
15NLM_DESCRIPTION = $(NLM_NAME)
16endif
17
18ifndef NLM_THREAD_NAME
19NLM_THREAD_NAME = $(NLM_NAME) Thread
20endif
21
22ifndef NLM_SCREEN_NAME
23NLM_SCREEN_NAME = DEFAULT
24endif
25
26ifndef NLM_COPYRIGHT
27NLM_COPYRIGHT = Licensed under the Apache License, Version 2.0
28endif
29
30ifeq "$(NLM_FLAGS)" ""
31NLM_FLAGS = AUTOUNLOAD, PSEUDOPREEMPTION
32endif
33
34ifeq "$(NLM_STACK_SIZE)" ""
35NLM_STACK_SIZE = 65536
36endif
37
38ifeq "$(NLM_ENTRY_SYM)" ""
39NLM_ENTRY_SYM = _LibCPrelude
40endif
41
42ifeq "$(NLM_EXIT_SYM)" ""
43NLM_EXIT_SYM = _LibCPostlude
44endif
45
46ifeq "$(NLM_VERSION)" ""
47NLM_VERSION = $(VERSION)
48endif
49
50#
51# Create dependency lists based on the files available
52#
53
54STANDARD_DEPENDS	= \
55				$(APBUILD)/NWGNUhead.inc \
56				$(APBUILD)/NWGNUenvironment.inc \
57				$(APBUILD)/NWGNUtail.inc \
58				$(CUSTOM_INI) \
59				$(EOLIST)
60
61CCOPT_DEPENDS	= $(STANDARD_DEPENDS)
62
63$(NLM_NAME)_LINKOPT_DEPENDS	= \
64				$(TARGET_lib) \
65				$(STANDARD_DEPENDS) \
66				$(VERSION_INC) \
67				$(EOLIST)
68
69ifeq "$(words $(strip $(TARGET_lib)))" "1"
70LIB_NAME			= $(basename $(notdir $(TARGET_lib)))
71$(LIB_NAME)_LIBLST_DEPENDS	= \
72				$(FILES_lib_objs) \
73				$(STANDARD_DEPENDS) \
74				$(CUSTOM_INI) \
75				$(EOLIST)
76endif
77
78ifeq "$(wildcard NWGNU$(LIB_NAME))" "NWGNU$(LIB_NAME)"
79$(LIB_NAME)_LIBLST_DEPENDS	+= NWGNU$(LIB_NAME)
80CCOPT_DEPENDS	+= NWGNU$(LIB_NAME)
81else
82CCOPT_DEPENDS	+= NWGNUmakefile
83endif
84
85ifeq "$(wildcard NWGNU$(NLM_NAME))" "NWGNU$(NLM_NAME)"
86$(NLM_NAME)_LINKOPT_DEPENDS	+= NWGNU$(NLM_NAME)
87CCOPT_DEPENDS	+= NWGNU$(NLM_NAME)
88else
89CCOPT_DEPENDS	+= NWGNUmakefile
90endif
91
92CPPOPT_DEPENDS	= $(CCOPT_DEPENDS)
93
94#
95# Generic compiler rules
96#
97
98ifneq "$(MAKECMDGOALS)" "clean"
99ifneq "$(findstring clobber_,$(MAKECMDGOALS))" "clobber_"
100$(APBUILD)/NWGNUversion.inc: $(APBUILD)/nw_ver.awk $(SRC)/include/ap_release.h
101	@echo $(DL)GEN  $@$(DL)
102	$(AWK) -f $^ $(SRC)/.svn/all-wcprops > $@
103
104-include $(APBUILD)/NWGNUversion.inc
105
106ifneq "$(strip $(VERSION_STR))" ""
107VERSION_INC = $(APBUILD)/NWGNUversion.inc
108else
109VERSION		= 2,4,0
110VERSION_STR	= 2.4.0
111VERSION_MAJMIN	= 24
112endif
113endif
114endif
115ifeq "$(USE_SVNREV)" "1"
116ifneq "$(strip $(SVN_REVISION))" ""
117CFLAGS	+= -DAP_SERVER_ADD_STRING=\"$(SVN_REVISION)\"
118endif
119endif
120
121
122ifeq "$(words $(strip $(TARGET_nlm)))" "1"
123
124$(OBJDIR)/%.o: %.c $(OBJDIR)/$(NLM_NAME)_cc.opt
125	@echo $(DL)CC   $<$(DL)
126	$(CC) -o $@ $< @$(word 2, $^)
127
128$(OBJDIR)/$(NLM_NAME)_cc.opt: $(CCOPT_DEPENDS)
129	$(call DEL,$@)
130	@echo $(DL)GEN  $@$(DL)
131ifneq "$(strip $(CFLAGS))" ""
132	@echo $(DL)$(CFLAGS)$(DL)>> $@
133endif
134ifneq "$(strip $(XCFLAGS))" ""
135	@echo $(DL)$(XCFLAGS)$(DL)>> $@
136endif
137ifneq "$(strip $(XINCDIRS))" ""
138	@echo $(DL)$(foreach xincdir,$(strip $(subst ;,$(SPACE),$(XINCDIRS))),-I$(xincdir))$(DL)>> $@
139endif
140ifneq "$(strip $(INCDIRS))" ""
141	@echo $(DL)$(foreach incdir,$(strip $(subst ;,$(SPACE),$(INCDIRS))),-I$(incdir))$(DL)>> $@
142endif
143ifneq "$(strip $(DEFINES))" ""
144	@echo $(DL)$(DEFINES)$(DL)>> $@
145endif
146ifneq "$(strip $(XDEFINES))" ""
147	@echo $(DL)$(XDEFINES)$(DL)>> $@
148endif
149
150$(OBJDIR)/%.o: %.cpp $(OBJDIR)/$(NLM_NAME)_cpp.opt
151	@echo $(DL)CC   $<$(DL)
152	$(CC) -o $@ $< @$(word 2, $^)
153
154$(OBJDIR)/$(NLM_NAME)_cpp.opt: $(CPPOPT_DEPENDS)
155	$(call DEL,$@)
156	@echo $(DL)GEN  $@$(DL)
157ifneq "$(strip $(CFLAGS))" ""
158	@echo $(DL)$(CFLAGS)$(DL)>> $@
159endif
160ifneq "$(strip $(XCFLAGS))" ""
161	@echo $(DL)$(XCFLAGS)$(DL)>> $@
162endif
163ifneq "$(strip $(XINCDIRS))" ""
164	@echo $(DL)$(foreach xincdir,$(strip $(subst ;,$(SPACE),$(XINCDIRS))),-I$(xincdir))$(DL)>> $@
165endif
166ifneq "$(strip $(INCDIRS))" ""
167	@echo $(DL)$(foreach incdir,$(strip $(subst ;,$(SPACE),$(INCDIRS))),-I$(incdir))$(DL)>> $@
168endif
169ifneq "$(strip $(DEFINES))" ""
170	@echo $(DL)$(DEFINES)$(DL)>> $@
171endif
172ifneq "$(strip $(XDEFINES))" ""
173	@echo $(DL)$(XDEFINES)$(DL)>> $@
174endif
175
176endif # one target nlm
177
178#
179# Rules to build libraries
180#
181
182# If we only have one target library then build it
183
184ifeq "$(words $(strip $(TARGET_lib)))" "1"
185
186$(TARGET_lib) : $(OBJDIR)/$(LIB_NAME)_lib.lst
187	$(call DEL,$@)
188	@echo $(DL)AR   $@$(DL)
189	$(LIB) -o $@ @$<
190
191$(OBJDIR)/$(LIB_NAME)_lib.lst: $($(LIB_NAME)_LIBLST_DEPENDS)
192	$(call DEL,$@)
193ifneq "$(strip $(FILES_lib_objs))" ""
194	@echo $(DL)GEN  $@$(DL)
195	@echo $(DL)$(FILES_lib_objs)$(DL)>> $@
196endif
197
198else # We must have more than one target library so load the individual makefiles
199
200$(OBJDIR)/%.lib: NWGNU% $(STANDARD_DEPENDS) FORCE
201	@echo $(DL)Calling $<$(DL)
202	$(MAKE) -f $< $(MAKECMDGOALS) RELEASE=$(RELEASE)
203
204endif
205
206#
207# Rules to build nlms.
208#
209
210# If we only have one target NLM then build it
211ifeq "$(words $(strip $(TARGET_nlm)))" "1"
212
213$(TARGET_nlm) : $(FILES_nlm_objs) $(FILES_nlm_libs) $(OBJDIR)/$(NLM_NAME)_link.opt
214	@echo $(DL)LINK $@$(DL)
215	$(LINK) @$(OBJDIR)/$(NLM_NAME)_link.opt
216
217# This will force the link option file to be rebuilt if we change the
218# corresponding makefile
219
220$(OBJDIR)/$(NLM_NAME)_link.opt : $($(NLM_NAME)_LINKOPT_DEPENDS)
221	$(call DEL,$@)
222	$(call DEL,$(@:.opt=.def))
223	@echo $(DL)GEN  $@$(DL)
224	@echo $(DL)-warnings off$(DL)>> $@
225	@echo $(DL)-zerobss$(DL)>> $@
226	@echo $(DL)-o $(TARGET_nlm)$(DL)>> $@
227ifneq "$(FILE_nlm_copyright)" ""
228	@$(CAT) $(FILE_nlm_copyright)>> $@
229endif
230ifeq "$(RELEASE)" "debug"
231	@echo $(DL)-g$(DL)>> $@
232	@echo $(DL)-sym internal$(DL)>> $@
233	@echo $(DL)-sym codeview4$(DL)>> $@
234	@echo $(DL)-osym $(OBJDIR)/$(NLM_NAME).sym$(DL)>> $@
235else
236	@echo $(DL)-sym internal$(DL)>> $@
237endif
238	@echo $(DL)-l $(SRC)/$(OBJDIR)$(DL)>> $@
239	@echo $(DL)-l $(HTTPD)/$(OBJDIR)$(DL)>> $@
240	@echo $(DL)-l $(SERVER)/$(OBJDIR)$(DL)>> $@
241	@echo $(DL)-l $(STDMOD)/$(OBJDIR)$(DL)>> $@
242	@echo $(DL)-l $(NWOS)/$(OBJDIR)$(DL)>> $@
243	@echo $(DL)-l $(NWOS)$(DL)>> $@
244	@echo $(DL)-l $(APR)/$(OBJDIR)$(DL)>> $@
245	@echo $(DL)-l $(APR)$(DL)>> $@
246	@echo $(DL)-l $(APRUTIL)/$(OBJDIR)$(DL)>> $@
247	@echo $(DL)-l $(PCRE)/$(OBJDIR)$(DL)>> $@
248	@echo $(DL)-l "$(METROWERKS)/Novell Support/Metrowerks Support/Libraries/Runtime"$(DL)>> $@
249	@echo $(DL)-l "$(METROWERKS)/Novell Support/Metrowerks Support/Libraries/MSL C++"$(DL)>> $@
250ifneq "$(IPV6)" ""
251	@echo $(DL)-l $(NOVELLLIBC)/include/winsock/IPV6$(DL)>> $@
252endif
253	@echo $(DL)-l $(NOVELLLIBC)/imports$(DL)>> $@
254ifneq "$(LDAPSDK)" ""
255	@echo $(DL)-l $(LDAPSDK)/imports$(DL)>> $@
256endif
257	@echo $(DL)-l $(APULDAP)/$(OBJDIR)$(DL)>> $@
258	@echo $(DL)-l $(XML)/$(OBJDIR)$(DL)>> $@
259	@echo $(DL)-l $(SRC)/$(OBJDIR)$(DL)>> $@
260	@echo $(DL)-nodefaults$(DL)>> $@
261	@echo $(DL)-map $(OBJDIR)/$(NLM_NAME).map$(DL)>> $@
262ifneq "$(strip $(XLFLAGS))" ""
263	@echo $(DL)$(XLFLAGS)$(DL)>> $@
264endif
265ifneq "$(strip $(FILES_nlm_objs))" ""
266	@echo $(DL)$(foreach objfile,$(strip $(FILES_nlm_objs)),$(objfile))$(DL)>> $@
267endif
268ifneq "$(FILES_nlm_libs)" ""
269	@echo $(DL)$(foreach libfile, $(notdir $(strip $(FILES_nlm_libs))),-l$(libfile))$(DL)>> $@
270endif
271	@echo $(DL)-commandfile $(@:.opt=.def)$(DL)>> $@
272	@echo $(DL)# Do not edit this file - it is created by make!$(DL)> $(@:.opt=.def)
273	@echo $(DL)# All your changes will be lost!!$(DL)>> $(@:.opt=.def)
274ifneq "$(FILE_nlm_msg)" ""
275	@echo $(DL)Messages $(FILE_nlm_msg)$(DL)>> $(@:.opt=.def)
276endif
277ifneq "$(FILE_nlm_hlp)" ""
278	@echo $(DL)Help $(FILE_nlm_hlp)$(DL)>> $(@:.opt=.def)
279endif
280ifeq "$(FILE_nlm_copyright)" ""
281	@echo $(DL)copyright "$(NLM_COPYRIGHT)"$(DL)>> $(@:.opt=.def)
282endif
283	@echo $(DL)description "$(NLM_DESCRIPTION)"$(DL)>> $(@:.opt=.def)
284	@echo $(DL)threadname "$(NLM_THREAD_NAME)"$(DL)>> $(@:.opt=.def)
285	@echo $(DL)screenname "$(NLM_SCREEN_NAME)"$(DL)>> $(@:.opt=.def)
286	@echo $(DL)stacksize $(subst K,000,$(subst k,K,$(strip $(NLM_STACK_SIZE))))$(DL)>> $(@:.opt=.def)
287	@echo $(DL)version $(NLM_VERSION) $(DL)>> $(@:.opt=.def)
288	@echo $(DL)start $(NLM_ENTRY_SYM)$(DL)>> $(@:.opt=.def)
289	@echo $(DL)exit $(NLM_EXIT_SYM)$(DL)>> $(@:.opt=.def)
290ifneq "$(NLM_CHECK_SYM)" ""
291	@echo $(DL)check $(NLM_CHECK_SYM)$(DL)>> $(@:.opt=.def)
292endif
293	@echo $(DL)$(strip $(NLM_FLAGS))$(DL)>> $(@:.opt=.def)
294ifneq "$(FILES_nlm_modules)" ""
295	@echo $(DL)module $(foreach module,$(subst $(SPACE),$(COMMA),$(strip $(FILES_nlm_modules))),$(module))$(DL)>> $(@:.opt=.def)
296endif
297ifneq "$(FILES_nlm_Ximports)" ""
298	@echo $(DL)import $(foreach import,$(subst $(SPACE),$(COMMA),$(strip $(FILES_nlm_Ximports))),$(import))$(DL)>> $(@:.opt=.def)
299endif
300ifneq "$(FILES_nlm_exports)" ""
301	@echo $(DL)export $(foreach export,$(subst $(SPACE),$(COMMA),$(strip $(FILES_nlm_exports))),$(export))$(DL)>> $(@:.opt=.def)
302endif
303# if APACHE_UNIPROC is defined, don't include XDCData
304ifndef APACHE_UNIPROC
305ifneq "$(string $(XDCDATA))" ""
306	@echo $(DL)xdcdata $(XDCDATA)$(DL)>> $(@:.opt=.def)
307else
308	@echo $(DL)xdcdata apache.xdc$(DL)>> $(@:.opt=.def)
309endif
310endif
311
312else # more than one target so look for individual makefiles.
313
314# Only include these if NO_LICENSE_FILE isn't set to prevent excessive
315# recursion
316
317ifndef NO_LICENSE_FILE
318
319$(OBJDIR)/%.nlm: NWGNU% $($(NLM_NAME)_LINKOPT_DEPENDS) FORCE
320	@echo $(DL)Calling $<$(DL)
321	$(MAKE) -f $< $(MAKECMDGOALS) RELEASE=$(RELEASE)
322	@$(ECHONL)
323
324else
325
326$(TARGET_nlm):
327
328endif # NO_LICENSE_FILE
329
330endif
331
332