1 # Gnu Makefile for NetWare target * 20-Aug-2005
2 # for use with gcc/nlmconv or Metrowerks CodeWarrior compiler
3 # use with: make -f Makefile.NetWare [all|clean|dist]
5 SOURCE = rrd_tool
6 #SOURCE = rrd_cgi
7 TARGET = $(subst _,,$(SOURCE))
8 DESCR = Round Robin Database Tool $(RRD_VERSION_STR)
9 COPYR = Copyright (c) 1997-2005 by Tobias Oetiker
10 #WWWURL = http://ee-staff.ethz.ch/~oetiker/webtools/rrdtool/
11 WWWURL = http://www.rrdtool.org/
12 MTSAFE = YES
13 #SCREEN = $(TARGET)
14 STACK = 49152
15 # Comment the line below if you dont want to load protected automatically.
16 #LDRING = 3
18 # Vertical label angle: 90.0 (default) or 270.0
19 RRDGRAPH_YLEGEND_ANGLE = 90.0
21 # Edit the path below to point to your Novell NDK.
22 ifndef NDKBASE
23 NDKBASE = c:/novell
24 endif
25 # Edit the path below to point to your install destination.
26 # INSTDIR = /mnt/sys/mrtg/rrd
27 INSTDIR = s:/mrtg/rrd
29 # Base for the lib sources
30 ifndef LIBBASE
31 LIBBASE = ..
32 endif
33 # All library code is statically linked to avoid problems with other lib NLMs.
34 # Edit the path below to point to your libgd sources or set environment var.
35 ifndef LIBGD
36 LIBGD = $(LIBBASE)/gd-2.0.33
37 endif
38 # Edit the path below to point to your libpng sources or set environment var.
39 ifndef LIBPNG
40 LIBPNG = $(LIBBASE)/libpng-1.2.8
41 endif
42 # Edit the path below to point to your freetype sources or set environment var.
43 ifndef LIBFT2
44 LIBFT2 = $(LIBBASE)/freetype-2.1.9
45 endif
46 # Edit the path below to point to your freetype sources or set environment var.
47 ifndef LIBART
48 LIBART = $(LIBBASE)/libart_lgpl-2.3.3
49 endif
50 # Edit the path below to point to your zlib sources or set environment var.
51 ifndef ZLIBSDK
52 ZLIBSDK = $(LIBBASE)/zlib-1.2.3
53 endif
54 # Edit the path below to point to your zlib sources or set environment var.
55 ifndef LIBCGI
56 #LIBCGI = $(LIBBASE)/cgilib-0.4
57 LIBCGI = d:/rrdtool-1.0.50/cgilib-0.4
58 endif
60 # Edit the var below to point to your lib architecture.
61 ifndef LIBARCH
62 # LIBARCH = CLIB
63 LIBARCH = LIBC
64 endif
66 # The following line defines your compiler.
67 ifdef METROWERKS
68 CC = mwccnlm
69 else
70 CC = gcc
71 endif
72 # RM = rm -f
73 CP = cp -fv
74 # if you want to mark the target as MTSAFE you will need a tool for
75 # generating the xdc data for the linker; here's a minimal tool:
76 # http://www.gknw.com/development/prgtools/mkxdc.zip
77 MPKXDC = mkxdc
79 # must be equal to DEBUG or NDEBUG
80 DB = NDEBUG
81 # DB = DEBUG
82 # Optimization: -O<n> or debugging: -g
83 ifeq ($(DB),NDEBUG)
84 OPT = -O2
85 OBJDIR = release
86 else
87 OPT = -g
88 OBJDIR = debug
89 endif
91 # Include the version info retrieved from source.
92 -include $(OBJDIR)/version.inc
94 # Global flags for all compilers
95 CFLAGS = $(OPT) -D$(DB) -nostdinc -DNETWARE -DN_PLAT_NLM -D_POSIX_SOURCE
96 CFLAGS += -DHAVE_CONFIG_H=1
97 #CFLAGS += -DHAVE_LIBPNG
99 CP = cp -af
101 ifeq ($(CC),mwccnlm)
102 LD = mwldnlm
103 LDFLAGS = -nostdlib $(PRELUDE) $(OBJS) $(LIBS) -o $(OBJDIR)/$(TARGET).nlm -commandfile
104 CFLAGS += -gccinc -inline off -opt nointrinsics -proc 586
105 CFLAGS += -relax_pointers
106 #CFLAGS += -w on,nounused,nounusedexpr -ansi strict
107 ifeq ($(LIBARCH),LIBC)
108 PRELUDE = $(SDK_LIBC)/imports/libcpre.o
109 CFLAGS += -align 4
110 else
111 PRELUDE = "$(METROWERKS)/Novell Support/libraries/runtime/prelude.obj"
112 CFLAGS += -include "$(METROWERKS)/Novell Support/headers/nlm_prefix.h"
113 CFLAGS += -align 1
114 endif
115 else
116 LD = nlmconv
117 LDFLAGS = -T
118 CFLAGS += -fno-builtin -fpack-struct -fpcc-struct-return
119 CFLAGS += -Wall -Wno-unused # -pedantic
120 ifeq ($(LIBARCH),LIBC)
121 PRELUDE = $(SDK_LIBC)/imports/libcpre.gcc.o
122 else
123 PRELUDE = $(NDK_ROOT)/pre/prelude.o
124 CFLAGS += -include $(NDKBASE)/nlmconv/genlm.h
125 endif
126 endif
128 ifeq ($(findstring linux,$(OSTYPE)),linux)
129 #include $(NDKBASE)/nlmconv/ncpfs.inc
130 DL = '
131 endif
133 ifeq ($(MTSAFE),YES)
134 XDCOPT = -n
135 endif
136 ifeq ($(MTSAFE),NO)
137 XDCOPT = -u
138 endif
139 ifdef XDCOPT
140 XDCDATA = $(OBJDIR)/$(TARGET).xdc
141 endif
142 ifndef COPYR
143 COPYR = Copyright (c) 2005 The Open Source Community.
144 endif
145 ifndef DESCR
146 DESCR = $(TARGET) Command Extension
147 endif
148 DESCR += ($(LIBARCH)) - $(CC) build
150 NDK_ROOT = $(NDKBASE)/ndk
151 SDK_CLIB = $(NDK_ROOT)/nwsdk
152 SDK_LIBC = $(NDK_ROOT)/libc
154 ifeq ($(LIBARCH),LIBC)
155 INCLUDES = -I$(SDK_LIBC)/include -I$(SDK_LIBC)/include/nks
156 else
157 INCLUDES = -I$(SDK_CLIB)/include/nlm -I$(SDK_CLIB)/include
158 endif
160 INCLUDES += -I. -I$(LIBGD) -I$(LIBPNG) -I$(LIBFT2)/include -I$(LIBART) -I$(ZLIBSDK)
161 ifeq ($(SOURCE),rrd_cgi)
162 INCLUDES += -I$(LIBCGI)
163 endif
165 CFLAGS += $(INCLUDES)
167 vpath %.c . $(LIBGD) $(LIBPNG) $(LIBART)/libart_lgpl $(ZLIBSDK) $(LIBCGI)
169 RRDLIBOBJS = \
170 $(OBJDIR)/rrd_afm.o \
171 $(OBJDIR)/rrd_afm_data.o \
172 $(OBJDIR)/rrd_create.o \
173 $(OBJDIR)/rrd_diff.o \
174 $(OBJDIR)/rrd_dump.o \
175 $(OBJDIR)/rrd_error.o \
176 $(OBJDIR)/rrd_fetch.o \
177 $(OBJDIR)/rrd_first.o \
178 $(OBJDIR)/rrd_format.o \
179 $(OBJDIR)/rrd_gfx.o \
180 $(OBJDIR)/rrd_graph.o \
181 $(OBJDIR)/rrd_graph_helper.o \
182 $(OBJDIR)/rrd_hw.o \
183 $(OBJDIR)/rrd_info.o \
184 $(OBJDIR)/rrd_last.o \
185 $(OBJDIR)/rrd_nan_inf.o \
186 $(OBJDIR)/rrd_open.o \
187 $(OBJDIR)/rrd_resize.o \
188 $(OBJDIR)/rrd_restore.o \
189 $(OBJDIR)/rrd_rpncalc.o \
190 $(OBJDIR)/rrd_tune.o \
191 $(OBJDIR)/rrd_update.o \
192 $(OBJDIR)/rrd_version.o \
193 $(OBJDIR)/rrd_xport.o \
194 $(OBJDIR)/rrd_thread_safe.o \
195 $(EOLIST)
197 XLIBOBJS = \
198 $(OBJDIR)/art_rgba_svp.o \
199 $(OBJDIR)/getopt.o \
200 $(OBJDIR)/getopt1.o \
201 $(OBJDIR)/hash_32.o \
202 $(OBJDIR)/parsetime.o \
203 $(OBJDIR)/pngsize.o \
204 $(EOLIST)
206 GD2LIBOBJS = \
207 $(OBJDIR)/gd.o \
208 $(OBJDIR)/gd_io.o \
209 $(OBJDIR)/gd_io_dp.o \
210 $(OBJDIR)/gd_io_file.o \
211 $(OBJDIR)/gd_io_ss.o \
212 $(OBJDIR)/gd_png.o \
213 $(OBJDIR)/gd_ss.o \
214 $(OBJDIR)/gdcache.o \
215 $(OBJDIR)/gdfonts.o \
216 $(OBJDIR)/gdhelpers.o \
217 $(OBJDIR)/gdtables.o \
218 $(EOLIST)
220 PNGLIBOBJS = \
221 $(OBJDIR)/png.o \
222 $(OBJDIR)/pngerror.o \
223 $(OBJDIR)/pngget.o \
224 $(OBJDIR)/pngmem.o \
225 $(OBJDIR)/pngpread.o \
226 $(OBJDIR)/pngread.o \
227 $(OBJDIR)/pngrio.o \
228 $(OBJDIR)/pngrtran.o \
229 $(OBJDIR)/pngrutil.o \
230 $(OBJDIR)/pngset.o \
231 $(OBJDIR)/pngtrans.o \
232 $(OBJDIR)/pngwio.o \
233 $(OBJDIR)/pngwrite.o \
234 $(OBJDIR)/pngwtran.o \
235 $(OBJDIR)/pngwutil.o \
236 $(EOLIST)
237 ifeq "$(wildcard $(LIBPNG)/pnggccrd.c)" "$(LIBPNG)/pnggccrd.c"
238 PNGLIBOBJS += \
239 $(OBJDIR)/pnggccrd.o \
240 $(OBJDIR)/pngvcrd.o \
241 $(EOLIST)
242 endif
244 ZLIBOBJS = \
245 $(OBJDIR)/adler32.o \
246 $(OBJDIR)/compress.o \
247 $(OBJDIR)/crc32.o \
248 $(OBJDIR)/deflate.o \
249 $(OBJDIR)/inflate.o \
250 $(OBJDIR)/inffast.o \
251 $(OBJDIR)/inftrees.o \
252 $(OBJDIR)/trees.o \
253 $(OBJDIR)/zutil.o \
254 $(EOLIST)
255 ifeq "$(wildcard $(ZLIBSDK)/infblock.c)" "$(ZLIBSDK)/infblock.c"
256 ZLIBOBJS += \
257 $(OBJDIR)/infblock.o \
258 $(OBJDIR)/infcodes.o \
259 $(OBJDIR)/infutil.o \
260 $(EOLIST)
261 endif
263 ARTLIBOBJS = \
264 $(patsubst $(LIBART)/libart_lgpl/%.c,$(OBJDIR)/%.o,$(wildcard $(LIBART)/libart_lgpl/art_*.c))
266 OBJS = $(RRDLIBOBJS) $(XLIBOBJS) $(GD2LIBOBJS) $(PNGLIBOBJS) $(ARTLIBOBJS) $(ZLIBOBJS)
267 ifeq ($(SOURCE),rrd_cgi)
268 OBJS += $(OBJDIR)/cgi.o
269 endif
270 OBJS += $(OBJDIR)/$(SOURCE).o
272 LIBS = $(LIBFT2)/builds/netware/libc/libft2.lib
275 all: $(OBJDIR) config.h $(OBJDIR)/$(TARGET).nlm
277 dist: all
278 -$(RM) $(OBJDIR)/*.o $(OBJDIR)/$(TARGET).map $(OBJDIR)/$(TARGET).ncv
279 -$(RM) $(OBJDIR)/$(TARGET).def $(XDCDATA)
280 -$(RM) config.h
282 install: all
283 @[ -d $(INSTDIR) ] || mkdir $(INSTDIR)
284 @$(CP) $(TARGET).nlm $(INSTDIR)
286 clean:
287 -$(RM) -r $(OBJDIR)
288 -$(RM) config.h
290 $(OBJDIR):
291 @mkdir $(OBJDIR)
293 $(OBJDIR)/%.o: %.c
294 @echo Compiling $<
295 @$(CC) $(CFLAGS) -c $< -o $@
297 $(OBJDIR)/version.inc: ../configure $(OBJDIR) get_ver.awk
298 @echo Creating $@
299 @awk -f get_ver.awk $< > $@
301 $(OBJDIR)/$(TARGET).nlm: $(OBJDIR) $(OBJS) $(OBJDIR)/version.inc $(OBJDIR)/$(TARGET).def $(XDCDATA)
302 @echo Linking $@
303 @-$(RM) $@
304 @$(LD) $(LDFLAGS) $(OBJDIR)/$(TARGET).def
306 $(OBJDIR)/%.xdc: Makefile.NetWare
307 @echo Creating $@
308 @$(MPKXDC) $(XDCOPT) $@
310 $(OBJDIR)/%.def: Makefile.NetWare $(OBJDIR)/version.inc
311 @echo $(DL)# DEF Linker File for use with gcc and nlmconv$(DL) > $@
312 @echo $(DL)# or with Codewarrior command line compiler.$(DL) >> $@
313 @echo $(DL)# Do not edit this file - it is created by make!$(DL) >> $@
314 @echo $(DL)# All your changes will be lost!!$(DL) >> $@
315 @echo $(DL)#$(DL) >> $@
316 @echo $(DL)copyright "$(COPYR)"$(DL) >> $@
317 @echo $(DL)description "$(DESCR)"$(DL) >> $@
318 @echo $(DL)version $(RRD_VERSION)$(DL) >> $@
319 ifdef NLMTYPE
320 @echo $(DL)type $(NLMTYPE)$(DL) >> $@
321 else
322 @echo $(DL)type 0$(DL) >> $@
323 endif
324 ifdef STACK
325 @echo $(DL)stack $(STACK)$(DL) >> $@
326 endif
327 @echo $(DL)threadname "$(TARGET)"$(DL) >> $@
328 ifdef SCREEN
329 @echo $(DL)screenname "$(SCREEN)"$(DL) >> $@
330 else
331 @echo $(DL)screenname "DEFAULT"$(DL) >> $@
332 endif
333 ifeq ($(DB),DEBUG)
334 @echo $(DL)debug$(DL) >> $@
335 endif
336 ifeq ($(LIBARCH),CLIB)
337 @echo $(DL)start _Prelude$(DL) >> $@
338 @echo $(DL)exit _Stop$(DL) >> $@
339 @echo $(DL)import @$(NDK_ROOT)/nwsdk/imports/clib.imp$(DL) >> $@
340 @echo $(DL)import @$(NDK_ROOT)/nwsdk/imports/threads.imp$(DL) >> $@
341 @echo $(DL)import @$(NDK_ROOT)/nwsdk/imports/nlmlib.imp$(DL) >> $@
342 @echo $(DL)module clib$(DL) >> $@
343 else
344 @echo $(DL)start _LibCPrelude$(DL) >> $@
345 @echo $(DL)exit _LibCPostlude$(DL) >> $@
346 @echo $(DL)check _LibCCheckUnload$(DL) >> $@
347 @echo $(DL)import @$(NDK_ROOT)/libc/imports/libc.imp$(DL) >> $@
348 @echo $(DL)import @$(NDK_ROOT)/libc/imports/netware.imp$(DL) >> $@
349 @echo $(DL)module libc$(DL) >> $@
350 @echo $(DL)pseudopreemption$(DL) >> $@
351 @echo $(DL)flag_on 64$(DL) >> $@
352 endif
353 ifeq ($(LDRING),0)
354 @echo $(DL)flag_on 16$(DL) >> $@
355 endif
356 ifeq ($(LDRING),3)
357 @echo $(DL)flag_on 512$(DL) >> $@
358 endif
359 ifdef XDCDATA
360 @echo $(DL)xdcdata $(XDCDATA)$(DL) >> $@
361 endif
362 ifeq ($(LD),nlmconv)
363 @echo $(DL)input $(OBJS) $(LIBS)$(DL) >> $@
364 @echo $(DL)input $(PRELUDE)$(DL) >> $@
365 @echo $(DL)output $(TARGET).nlm$(DL) >> $@
366 endif
368 config.h: Makefile.NetWare
369 @echo Creating $@
370 @echo $(DL)/* $@ for NetWare target.$(DL) > $@
371 @echo $(DL)** Do not edit this file - it is created by make!$(DL) >> $@
372 @echo $(DL)** All your changes will be lost!!$(DL) >> $@
373 @echo $(DL)*/$(DL) >> $@
374 @echo $(DL)#define OS "i586-pc-NetWare"$(DL) >> $@
375 @echo $(DL)#define PACKAGE_VERSION "$(RRD_VERSION_STR)"$(DL) >> $@
376 @echo $(DL)#define PACKAGE_BUGREPORT "tobi@oetiker.ch"$(DL) >> $@
377 @echo $(DL)#define NUMVERS $(RRD_NUMVERS)$(DL) >> $@
378 @echo $(DL)#define HAVE_ASSERT_H 1$(DL) >> $@
379 @echo $(DL)#define HAVE_DLFCN_H 1$(DL) >> $@
380 @echo $(DL)#define HAVE_DLOPEN 1$(DL) >> $@
381 @echo $(DL)#define HAVE_ERR_H 1$(DL) >> $@
382 @echo $(DL)#define HAVE_ERRNO_H 1$(DL) >> $@
383 @echo $(DL)#define HAVE_FCNTL_H 1$(DL) >> $@
384 @echo $(DL)#define HAVE_FIONBIO 1$(DL) >> $@
385 @echo $(DL)#define HAVE_FLOAT_H 1$(DL) >> $@
386 @echo $(DL)#define HAVE_GETTIMEOFDAY 1$(DL) >> $@
387 @echo $(DL)#define HAVE_INTTYPES_H 1$(DL) >> $@
388 @echo $(DL)#define HAVE_LIMITS_H 1$(DL) >> $@
389 @echo $(DL)#define HAVE_LONGLONG 1$(DL) >> $@
390 @echo $(DL)#define HAVE_LOCALE_H 1$(DL) >> $@
391 @echo $(DL)#define HAVE_MALLOC_H 1$(DL) >> $@
392 @echo $(DL)#define HAVE_MATH_H 1$(DL) >> $@
393 @echo $(DL)#define HAVE_MBSTOWCS 1$(DL) >> $@
394 @echo $(DL)#define HAVE_MEMMOVE 1$(DL) >> $@
395 @echo $(DL)#define HAVE_MKTIME 1$(DL) >> $@
396 @echo $(DL)#define HAVE_SELECT 1$(DL) >> $@
397 @echo $(DL)#define HAVE_SETLOCALE 1$(DL) >> $@
398 @echo $(DL)#define HAVE_SETJMP_H 1$(DL) >> $@
399 # @echo $(DL)#define HAVE_SIGNAL 1$(DL) >> $@
400 @echo $(DL)#define HAVE_SNPRINTF 1$(DL) >> $@
401 @echo $(DL)#define HAVE_STDARG_H 1$(DL) >> $@
402 @echo $(DL)#define HAVE_STDDEF_H 1$(DL) >> $@
403 @echo $(DL)#define HAVE_STDINT_H 1$(DL) >> $@
404 @echo $(DL)#define HAVE_STDLIB_H 1$(DL) >> $@
405 @echo $(DL)#define HAVE_STRCASECMP 1$(DL) >> $@
406 @echo $(DL)#define HAVE_STRDUP 1$(DL) >> $@
407 @echo $(DL)#define HAVE_STRFTIME 1$(DL) >> $@
408 @echo $(DL)#define HAVE_STRING_H 1$(DL) >> $@
409 @echo $(DL)#define HAVE_STRLCAT 1$(DL) >> $@
410 @echo $(DL)#define HAVE_STRLCPY 1$(DL) >> $@
411 @echo $(DL)#define HAVE_STRSTR 1$(DL) >> $@
412 @echo $(DL)#define HAVE_SYS_PARAM_H 1$(DL) >> $@
413 @echo $(DL)#define HAVE_SYS_SELECT_H 1$(DL) >> $@
414 @echo $(DL)#define HAVE_SYS_STAT_H 1$(DL) >> $@
415 @echo $(DL)#define HAVE_SYS_TIME_H 1$(DL) >> $@
416 @echo $(DL)#define HAVE_SYS_TYPES_H 1$(DL) >> $@
417 @echo $(DL)#define HAVE_TERMIOS_H 1$(DL) >> $@
418 @echo $(DL)#define HAVE_TIME_H 1$(DL) >> $@
419 @echo $(DL)#define HAVE_TZSET 1$(DL) >> $@
420 @echo $(DL)#define HAVE_UNAME 1$(DL) >> $@
421 @echo $(DL)#define HAVE_VPRINTF 1$(DL) >> $@
422 @echo $(DL)#define HAVE_UNISTD_H 1$(DL) >> $@
423 @echo $(DL)#define STDC_HEADERS 1$(DL) >> $@
424 @echo $(DL)#define TIME_WITH_SYS_TIME 1$(DL) >> $@
425 @echo $(DL)#define HAVE_ZLIB_H 1$(DL) >> $@
426 @echo $(DL)#define HAVE_LIBZ 1$(DL) >> $@
427 @echo $(DL)#define rrd_realloc(a,b) realloc((a), (b))$(DL) >> $@
428 # @echo $(DL)#define rrd_realloc(a,b) ( (a) == NULL ? malloc( (b) ) : realloc( (a) , (b) ))$(DL) >> $@
429 @echo $(DL)#define RRDGRAPH_YLEGEND_ANGLE $(RRDGRAPH_YLEGEND_ANGLE)$(DL) >> $@
430 @echo $(DL)#define RRD_DEFAULT_FONT "arial.ttf"$(DL) >> $@