1 # Gnu Makefile for Win32 target
2 # for use with MingW32 gcc or Metrowerks CodeWarrior compiler
3 # use with: make -f Makefile [help|all|clean|dev|devclean|dist|distclean]
4 #
5 # $id: $
6 #
8 DESCR = Round Robin Database Tool
9 COPYR = Copyright (c) 1997-2007 by Tobias Oetiker
10 WWWURL = http://www.rrdtool.org/
11 ICON = $(PROOT)/favicon.ico
13 # You can set the default font used in graphs.
14 # If not set here RRD defaults to DejaVuSansMono-Roman.ttf
15 #RRD_DEFAULT_FONT = "arial.ttf"
16 #RRD_DEFAULT_FONT = "VeraMono.ttf"
18 # Vertical label angle: 90.0 (default) or 270.0
19 RRDGRAPH_YLEGEND_ANGLE = 90.0
21 # Set to one if you want to have piecharts.
22 WITH_PIECHART = 0
24 # Set the extension used for rrdcgi.
25 ifndef CGIEXT
26 CGIEXT = exe
27 endif
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 DLLs.
34 # Edit the path below to point to your libpng sources or set environment var.
35 ifndef LIBPNG
36 LIBPNG = $(LIBBASE)/libpng-1.2.16
37 endif
38 # Edit the path below to point to your freetype sources or set environment var.
39 ifndef LIBFT2
40 #LIBFT2 = $(LIBBASE)/freetype-2.3.4
41 LIBFT2 = $(LIBBASE)/../mingw32/freetype-2.3.4
42 endif
43 # Edit the path below to point to your libart sources or set environment var.
44 ifndef LIBART
45 LIBART = $(LIBBASE)/libart_lgpl-2.3.17
46 endif
47 # Edit the path below to point to your zlib sources or set environment var.
48 ifndef ZLIBSDK
49 ZLIBSDK = $(LIBBASE)/zlib-1.2.3
50 endif
52 # Edit the path below to point to your distribution folder.
53 ifndef DISTDIR
54 DISTDIR = rrdtool-$(RRD_VERSION_STR)-w32
55 endif
56 DISTARC = $(DISTDIR).zip
58 # Edit the path below to point to your distribution folder.
59 ifndef DEVLDIR
60 DEVLDIR = rrdtool-$(RRD_VERSION_STR)-sdk-w32
61 endif
62 DEVLARC = $(DEVLDIR).zip
64 # whatever...
65 NO_NULL_REALLOC = 1
67 # The following line defines your compiler.
68 ifdef METROWERKS
69 CC = mwcc
70 else
71 CC = gcc
72 endif
73 # RM = rm -f
74 CP = cp -afv
75 # Here you can find a native Win32 binary of the original awk:
76 # http://www.gknw.net/development/prgtools/awk.zip
77 AWK = awk
78 ZIP = zip -qzr9
80 # must be equal to DEBUG or NDEBUG
81 DB = NDEBUG
82 # DB = DEBUG
83 # Optimization: -O<n> or debugging: -g
84 ifeq ($(DB),NDEBUG)
85 OPT = -O2
86 OBJDIR = release
87 else
88 OPT = -g
89 OBJDIR = debug
90 endif
92 # Project root
93 PROOT = ..
95 # Include the version info retrieved from source.
96 -include $(OBJDIR)/version.inc
98 # Global flags for all compilers
99 CFLAGS = $(OPT) -D$(DB) -DHAVE_CONFIG_H
101 ifeq ($(CC),mwcc)
102 LD = mwld
103 RC = mwwinrc
104 LDFLAGS = -nostdlib
105 AR = $(LD)
106 ARFLAGS = -type library -w nocmdline $(OBJS) -o
107 LIBEXT = lib
108 LIBPATH += -lr "$(METROWERKS)/MSL" -lr "$(METROWERKS)/Win32-x86 Support"
109 LDLIBS += -lkernel32.lib -luser32.lib
110 LDLIBS += -lMSL_Runtime_x86.lib -lMSL_C_x86.lib -lMSL_Extras_x86.lib
111 RCFLAGS =
112 CFLAGS += -DWIN32
113 CFLAGS += -nostdinc -gccinc -msgstyle gcc -inline off -opt nointrinsics -proc 586
114 CFLAGS += -ir "$(METROWERKS)/MSL" -ir "$(METROWERKS)/Win32-x86 Support"
115 CFLAGS += -w on,nounused,nounusedexpr # -ansi strict
116 else
117 LD = gcc
118 RC = windres
119 LDFLAGS = -s
120 AR = ar
121 ARFLAGS = -cq
122 LIBEXT = a
123 RCFLAGS = -O coff -i
124 CFLAGS += -fno-strict-aliasing
125 CFLAGS += -Wall -Wno-unused # -pedantic
126 endif
128 ifeq ($(findstring msys,$(OSTYPE)),msys)
129 DL = '
130 DS = /
131 else
132 DS = \\
133 endif
135 ifndef DESCR
136 DESCR = $(notdir $(@:.rc=)) Command Extension
137 endif
138 DESCR += - $(CC) build
140 INCLUDES += -I$(PROOT) -I$(PROOT)/src -I$(LIBPNG) -I$(LIBFT2)/include -I$(LIBART) -I$(ZLIBSDK)
142 CFLAGS += $(INCLUDES)
144 vpath %.c $(PROOT)/src $(LIBPNG) $(LIBART)/libart_lgpl $(ZLIBSDK)
146 RRDLIBOBJS = \
147 $(OBJDIR)/rrd_afm.o \
148 $(OBJDIR)/rrd_afm_data.o \
149 $(OBJDIR)/rrd_create.o \
150 $(OBJDIR)/rrd_diff.o \
151 $(OBJDIR)/rrd_dump.o \
152 $(OBJDIR)/rrd_error.o \
153 $(OBJDIR)/rrd_fetch.o \
154 $(OBJDIR)/rrd_first.o \
155 $(OBJDIR)/rrd_format.o \
156 $(OBJDIR)/rrd_gfx.o \
157 $(OBJDIR)/rrd_graph.o \
158 $(OBJDIR)/rrd_graph_helper.o \
159 $(OBJDIR)/rrd_hw.o \
160 $(OBJDIR)/rrd_info.o \
161 $(OBJDIR)/rrd_last.o \
162 $(OBJDIR)/rrd_lastupdate.o \
163 $(OBJDIR)/rrd_nan_inf.o \
164 $(OBJDIR)/rrd_open.o \
165 $(OBJDIR)/rrd_resize.o \
166 $(OBJDIR)/rrd_restore.o \
167 $(OBJDIR)/rrd_rpncalc.o \
168 $(OBJDIR)/rrd_tune.o \
169 $(OBJDIR)/rrd_update.o \
170 $(OBJDIR)/rrd_version.o \
171 $(OBJDIR)/rrd_xport.o \
172 $(OBJDIR)/rrd_thread_safe_nt.o \
173 $(EOLIST)
175 XLIBOBJS = \
176 $(OBJDIR)/rrd_getopt.o \
177 $(OBJDIR)/rrd_getopt1.o \
178 $(OBJDIR)/art_rgba_svp.o \
179 $(OBJDIR)/hash_32.o \
180 $(OBJDIR)/parsetime.o \
181 $(OBJDIR)/pngsize.o \
182 $(OBJDIR)/strftime.o \
183 $(EOLIST)
185 PNGLIBOBJS = \
186 $(OBJDIR)/png.o \
187 $(OBJDIR)/pngerror.o \
188 $(OBJDIR)/pngget.o \
189 $(OBJDIR)/pngmem.o \
190 $(OBJDIR)/pngpread.o \
191 $(OBJDIR)/pngread.o \
192 $(OBJDIR)/pngrio.o \
193 $(OBJDIR)/pngrtran.o \
194 $(OBJDIR)/pngrutil.o \
195 $(OBJDIR)/pngset.o \
196 $(OBJDIR)/pngtrans.o \
197 $(OBJDIR)/pngwio.o \
198 $(OBJDIR)/pngwrite.o \
199 $(OBJDIR)/pngwtran.o \
200 $(OBJDIR)/pngwutil.o \
201 $(EOLIST)
202 ifeq "$(wildcard $(LIBPNG)/pnggccrd.c)" "$(LIBPNG)/pnggccrd.c"
203 PNGLIBOBJS += \
204 $(OBJDIR)/pnggccrd.o \
205 $(OBJDIR)/pngvcrd.o \
206 $(EOLIST)
207 endif
209 ZLIBOBJS = \
210 $(OBJDIR)/adler32.o \
211 $(OBJDIR)/compress.o \
212 $(OBJDIR)/crc32.o \
213 $(OBJDIR)/deflate.o \
214 $(OBJDIR)/inflate.o \
215 $(OBJDIR)/inffast.o \
216 $(OBJDIR)/inftrees.o \
217 $(OBJDIR)/trees.o \
218 $(OBJDIR)/zutil.o \
219 $(EOLIST)
220 ifeq "$(wildcard $(ZLIBSDK)/infblock.c)" "$(ZLIBSDK)/infblock.c"
221 ZLIBOBJS += \
222 $(OBJDIR)/infblock.o \
223 $(OBJDIR)/infcodes.o \
224 $(OBJDIR)/infutil.o \
225 $(EOLIST)
226 endif
228 ARTLIBOBJS = \
229 $(patsubst $(LIBART)/libart_lgpl/%.c,$(OBJDIR)/%.o,$(wildcard $(LIBART)/libart_lgpl/art_*.c))
231 OBJS := $(RRDLIBOBJS) $(XLIBOBJS) $(PNGLIBOBJS) $(ARTLIBOBJS) $(ZLIBOBJS)
232 OBJCGI := $(OBJS) $(OBJDIR)/rrd_cgi.o
233 OBJTOOL := $(OBJS) $(OBJDIR)/rrd_tool.o
235 LDLIBS += $(LIBFT2)/objs/freetype.$(LIBEXT)
238 all: rrdtool rrdcgi
240 rrdtool: $(OBJDIR) $(PROOT)/rrd_config.h $(OBJDIR)/rrdtool.exe
241 rrdcgi: $(OBJDIR) $(PROOT)/rrd_config.h $(OBJDIR)/rrdcgi.$(CGIEXT)
242 librrd: $(OBJDIR) $(PROOT)/rrd_config.h $(OBJDIR)/librrd.$(LIBEXT)
244 FORCE: ;
246 dist: all $(DISTDIR) $(DISTDIR)/readme.txt
247 @-$(CP) $(OBJDIR)/rrdcgi.$(CGIEXT) $(DISTDIR)
248 @-$(CP) $(OBJDIR)/rrdtool.exe $(DISTDIR)
249 @-$(CP) $(PROOT)/src/*.ttf $(DISTDIR)
250 @-$(CP) $(PROOT)/CHANGES $(DISTDIR)
251 @-$(CP) $(PROOT)/COPYING $(DISTDIR)
252 @-$(CP) $(PROOT)/COPYRIGHT $(DISTDIR)
253 @-$(CP) $(PROOT)/NEWS $(DISTDIR)
254 @-$(CP) $(PROOT)/README $(DISTDIR)
255 @echo Creating $(DISTARC)
256 @$(ZIP) $(DISTARC) $(DISTDIR)/* < $(DISTDIR)/readme.txt
258 dev: librrd $(DEVLDIR) $(DEVLDIR)/readme.txt
259 @-mkdir $(DEVLDIR)$(DS)include
260 @-mkdir $(DEVLDIR)$(DS)lib
261 @-mkdir $(DEVLDIR)$(DS)src
262 @-$(CP) $(OBJDIR)/librrd.$(LIBEXT) $(DEVLDIR)/lib
263 @-$(CP) $(PROOT)/rrd_config.h $(DEVLDIR)/include
264 @-$(CP) $(PROOT)/src/rrd.h $(DEVLDIR)/include
265 @-$(CP) $(PROOT)/src/*.ttf $(DEVLDIR)/src
266 @-$(CP) $(PROOT)/CHANGES $(DEVLDIR)
267 @-$(CP) $(PROOT)/COPYING $(DEVLDIR)
268 @-$(CP) $(PROOT)/COPYRIGHT $(DEVLDIR)
269 @-$(CP) $(PROOT)/NEWS $(DEVLDIR)
270 @-$(CP) $(PROOT)/README $(DEVLDIR)
271 @echo Creating $(DEVLARC)
272 @$(ZIP) $(DEVLARC) $(DEVLDIR)/* < $(DEVLDIR)/readme.txt
274 clean:
275 -$(RM) -r $(OBJDIR)
276 -$(RM) $(PROOT)/rrd_config.h
278 distclean: clean
279 -$(RM) -r $(DISTDIR)
280 -$(RM) $(DISTARC)
282 devclean: clean
283 -$(RM) -r $(DEVLDIR)
284 -$(RM) $(DEVLARC)
286 $(OBJDIR):
287 @mkdir $@
289 $(DISTDIR):
290 @mkdir $@
292 $(DEVLDIR):
293 @mkdir $@
295 $(OBJDIR)/version.inc: $(PROOT)/configure.ac $(OBJDIR) $(PROOT)/src/get_ver.awk
296 @echo Creating $@
297 @$(AWK) -f $(PROOT)/src/get_ver.awk $< > $@
299 $(OBJDIR)/%.o: %.c
300 @echo Compiling $<
301 @$(CC) $(CFLAGS) -c $< -o $@
303 $(OBJDIR)/rrdcgi.$(CGIEXT): $(OBJCGI) $(OBJDIR)/rrdcgi.res
304 @echo Linking $@
305 @-$(RM) $@
306 @$(LD) $(LDFLAGS) $^ -o $@ $(LIBPATH) $(LDLIBS)
308 $(OBJDIR)/rrdtool.exe: $(OBJTOOL) $(OBJDIR)/rrdtool.res
309 @echo Linking $@
310 @-$(RM) $@
311 @$(LD) $(LDFLAGS) $^ -o $@ $(LIBPATH) $(LDLIBS)
313 $(OBJDIR)/librrd.$(LIBEXT): $(OBJS)
314 @echo Creating $@
315 @-$(RM) $@
316 @$(AR) $(ARFLAGS) $@ $^
318 $(OBJDIR)/%.res: $(OBJDIR)/%.rc
319 @echo Creating $@
320 @$(RC) $(RCFLAGS) $< -o $@
322 $(OBJDIR)/%.rc: Makefile $(OBJDIR)/version.inc
323 @echo $(DL)1 VERSIONINFO$(DL) > $@
324 @echo $(DL) FILEVERSION $(RRD_VERSION),0$(DL) >> $@
325 @echo $(DL) PRODUCTVERSION $(RRD_VERSION),0$(DL) >> $@
326 @echo $(DL) FILEFLAGSMASK 0x3fL$(DL) >> $@
327 @echo $(DL) FILEOS 0x40004L$(DL) >> $@
328 @echo $(DL) FILEFLAGS 0x0L$(DL) >> $@
329 @echo $(DL) FILETYPE 0x1L$(DL) >> $@
330 @echo $(DL) FILESUBTYPE 0x0L$(DL) >> $@
331 @echo $(DL)BEGIN$(DL) >> $@
332 @echo $(DL) BLOCK "StringFileInfo"$(DL) >> $@
333 @echo $(DL) BEGIN$(DL) >> $@
334 @echo $(DL) BLOCK "040904E4"$(DL) >> $@
335 @echo $(DL) BEGIN$(DL) >> $@
336 @echo $(DL) VALUE "LegalCopyright","$(COPYR)\0"$(DL) >> $@
337 ifdef COMPANY
338 @echo $(DL) VALUE "CompanyName","$(COMPANY)\0"$(DL) >> $@
339 endif
340 @echo $(DL) VALUE "ProductName","$(notdir $(@:.rc=.exe))\0"$(DL) >> $@
341 @echo $(DL) VALUE "ProductVersion","$(RRD_VERSION_STR)\0"$(DL) >> $@
342 @echo $(DL) VALUE "License","Released under GPL.\0"$(DL) >> $@
343 @echo $(DL) VALUE "FileDescription","$(DESCR)\0"$(DL) >> $@
344 @echo $(DL) VALUE "FileVersion","$(RRD_VERSION_STR)\0"$(DL) >> $@
345 @echo $(DL) VALUE "InternalName","$(notdir $(@:.rc=))\0"$(DL) >> $@
346 @echo $(DL) VALUE "OriginalFilename","$(notdir $(@:.rc=.exe))\0"$(DL) >> $@
347 @echo $(DL) VALUE "WWW","$(WWWURL)\0"$(DL) >> $@
348 @echo $(DL) END$(DL) >> $@
349 @echo $(DL) END$(DL) >> $@
350 @echo $(DL) BLOCK "VarFileInfo"$(DL) >> $@
351 @echo $(DL) BEGIN$(DL) >> $@
352 @echo $(DL) VALUE "Translation", 0x409, 1252$(DL) >> $@
353 @echo $(DL) END$(DL) >> $@
354 @echo $(DL)END$(DL) >> $@
355 ifdef ICON
356 @echo $(DL)10 ICON DISCARDABLE "$(ICON)"$(DL) >> $@
357 endif
359 $(PROOT)/rrd_config.h: FORCE Makefile $(OBJDIR)/version.inc
360 @echo Creating $@
361 @echo $(DL)/* $(notdir $@) for Win32 target.$(DL) > $@
362 @echo $(DL)** Do not edit this file - it is created by make!$(DL) >> $@
363 @echo $(DL)** All your changes will be lost!!$(DL) >> $@
364 @echo $(DL)*/$(DL) >> $@
365 @echo $(DL)#ifndef WIN32$(DL) >> $@
366 @echo $(DL)#error This $(notdir $@) is created for Win32 platform!$(DL) >> $@
367 @echo $(DL)#endif$(DL) >> $@
368 @echo $(DL)#ifndef RRD_CONFIG_H$(DL) >> $@
369 @echo $(DL)#define RRD_CONFIG_H$(DL) >> $@
370 @echo $(DL)#define OS "i586-pc-Win32"$(DL) >> $@
371 @echo $(DL)#define PACKAGE_VERSION "$(RRD_VERSION_STR)"$(DL) >> $@
372 @echo $(DL)#define PACKAGE_BUGREPORT "tobi@oetiker.ch"$(DL) >> $@
373 @echo $(DL)#define NUMVERS $(RRD_NUMVERS)$(DL) >> $@
374 @echo $(DL)#define HAVE_ASSERT_H 1$(DL) >> $@
375 @echo $(DL)#define HAVE_DLFCN_H 1$(DL) >> $@
376 @echo $(DL)#define HAVE_DLOPEN 1$(DL) >> $@
377 @echo $(DL)#define HAVE_ERRNO_H 1$(DL) >> $@
378 @echo $(DL)#define HAVE_FCNTL_H 1$(DL) >> $@
379 @echo $(DL)#define HAVE_FIONBIO 1$(DL) >> $@
380 @echo $(DL)#define HAVE_INTTYPES_H 1$(DL) >> $@
381 @echo $(DL)#define HAVE_LIMITS_H 1$(DL) >> $@
382 @echo $(DL)#define HAVE_LONGLONG 1$(DL) >> $@
383 @echo $(DL)#define HAVE_LOCALE_H 1$(DL) >> $@
384 @echo $(DL)#define HAVE_MALLOC_H 1$(DL) >> $@
385 @echo $(DL)#define HAVE_MATH_H 1$(DL) >> $@
386 @echo $(DL)#define HAVE_MBSTOWCS 1$(DL) >> $@
387 @echo $(DL)#define HAVE_SETJMP_H 1$(DL) >> $@
388 @echo $(DL)#define HAVE_SNPRINTF 1$(DL) >> $@
389 @echo $(DL)#define HAVE_STDARG_H 1$(DL) >> $@
390 @echo $(DL)#define HAVE_STDDEF_H 1$(DL) >> $@
391 @echo $(DL)#define HAVE_STDINT_H 1$(DL) >> $@
392 @echo $(DL)#define HAVE_STDLIB_H 1$(DL) >> $@
393 @echo $(DL)#define HAVE_STRCASECMP 1$(DL) >> $@
394 @echo $(DL)#define HAVE_STRDUP 1$(DL) >> $@
395 @echo $(DL)#define HAVE_STRFTIME 1$(DL) >> $@
396 @echo $(DL)#define HAVE_STRING_H 1$(DL) >> $@
397 @echo $(DL)#define HAVE_STRLCAT 1$(DL) >> $@
398 @echo $(DL)#define HAVE_STRLCPY 1$(DL) >> $@
399 @echo $(DL)#define HAVE_STRSTR 1$(DL) >> $@
400 @echo $(DL)#define HAVE_SYS_PARAM_H 1$(DL) >> $@
401 @echo $(DL)#define HAVE_SYS_STAT_H 1$(DL) >> $@
402 @echo $(DL)#define HAVE_SYS_TIME_H 1$(DL) >> $@
403 @echo $(DL)#define HAVE_TIME_H 1$(DL) >> $@
404 @echo $(DL)#define HAVE_VSNPRINTF 1$(DL) >> $@
405 @echo $(DL)#define STDC_HEADERS 1$(DL) >> $@
406 @echo $(DL)#define TIME_WITH_SYS_TIME 1$(DL) >> $@
407 @echo $(DL)#define HAVE_ZLIB_H 1$(DL) >> $@
408 @echo $(DL)#define HAVE_LIBZ 1$(DL) >> $@
409 ifdef NO_NULL_REALLOC
410 @echo $(DL)#define NO_NULL_REALLOC 1$(DL) >> $@
411 @echo $(DL)#define rrd_realloc(a,b) ( (a) == NULL ? malloc( (b) ) : realloc( (a) , (b) ))$(DL) >> $@
412 else
413 @echo $(DL)#define rrd_realloc(a,b) realloc((a), (b))$(DL) >> $@
414 endif
415 ifdef RRD_DEFAULT_FONT
416 @echo $(DL)#define RRD_DEFAULT_FONT $(RRD_DEFAULT_FONT)$(DL) >> $@
417 endif
418 @echo $(DL)#define RRDGRAPH_YLEGEND_ANGLE $(RRDGRAPH_YLEGEND_ANGLE)$(DL) >> $@
419 @echo $(DL)#define strftime strftime_$(DL) >> $@
420 ifdef WITH_PIECHART
421 @echo $(DL)#define WITH_PIECHART $(WITH_PIECHART)$(DL) >> $@
422 endif
423 @echo $(DL)#endif /* RRD_CONFIG_H */$(DL) >> $@
425 $(DISTDIR)/readme.txt: Makefile
426 @echo Creating $@
427 @echo $(DL)This is a binary distribution for Win32 platform.$(DL) > $@
428 @echo $(DL)RRDTool version $(RRD_VERSION_STR)$(DL) >> $@
429 @echo $(DL)Please download the complete RRDTool package for$(DL) >> $@
430 @echo $(DL)any further documentation:$(DL) >> $@
431 @echo $(DL)$(WWWURL)$(DL) >> $@
433 $(DEVLDIR)/readme.txt: Makefile
434 @echo Creating $@
435 @echo $(DL)This is a development distribution for Win32 platform.$(DL) > $@
436 @echo $(DL)RRDTool version $(RRD_VERSION_STR)$(DL) >> $@
437 @echo $(DL)Please download the complete RRDTool package for$(DL) >> $@
438 @echo $(DL)any further documentation:$(DL) >> $@
439 @echo $(DL)$(WWWURL)$(DL) >> $@
441 help:
442 @echo $(DL)===========================================================$(DL)
443 @echo $(DL)libpng Source = $(LIBPNG)$(DL)
444 @echo $(DL)libart Source = $(LIBART)$(DL)
445 @echo $(DL)Freetype 2 SDK = $(LIBFT2)$(DL)
446 @echo $(DL)Zlib SDK = $(ZLIBSDK)$(DL)
447 @echo $(DL)===========================================================$(DL)
448 @echo $(DL)RRDTool $(RRD_VERSION_STR) - available targets are:$(DL)
449 @echo $(DL)$(MAKE) all$(DL)
450 @echo $(DL)$(MAKE) rrdtool$(DL)
451 @echo $(DL)$(MAKE) rrdcgi$(DL)
452 @echo $(DL)$(MAKE) librrd$(DL)
453 @echo $(DL)$(MAKE) clean$(DL)
454 @echo $(DL)$(MAKE) dev$(DL)
455 @echo $(DL)$(MAKE) devclean$(DL)
456 @echo $(DL)$(MAKE) dist$(DL)
457 @echo $(DL)$(MAKE) distclean$(DL)
458 @echo $(DL)===========================================================$(DL)