grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / classes / zune / nlist / demo / Makefile
blob05c0f82d5501dedbfea558183d56559c34ad304d
1 #/***************************************************************************
3 # NList classes
4 # Copyright (C) 2008 by NList Open Source Team
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # NList classes Support Site: http://www.sf.net/projects/nlist-classes
18 # $Id$
20 #***************************************************************************/
22 ###########################################################################
23 # This makefile is a very generic one. It tries to identify both, the host
24 # and the target operating system for which YAM should be compiled.
25 # However, this auto-detection can be easily overridden by directly
26 # specifying an option on the commandline while calling 'make'.
28 # Example:
30 # # to explicitly compile for AmigaOS3
31 # > make OS=os3
33 # # to compile for AmigaOS4 but with debugging
34 # > make OS=os4 DEBUG=
37 #############################################
38 # find out the HOST operating system
39 # on which this makefile is run
40 HOST ?= $(shell uname)
41 ifeq ($(HOST), AmigaOS)
42 ifeq ($(shell uname -m), powerpc)
43 HOST = AmigaOS4
44 endif
45 ifeq ($(shell uname -m), ppc)
46 HOST = AmigaOS4
47 endif
48 endif
50 # if no host is identifed (no uname tool)
51 # we assume a AmigaOS build
52 ifeq ($(HOST),)
53 HOST = AmigaOS
54 endif
56 #############################################
57 # now we find out the target OS for
58 # which we are going to compile YAM in case
59 # the caller didn't yet define OS himself
60 ifndef (OS)
61 ifeq ($(HOST), AmigaOS4)
62 OS = os4
63 else
64 ifeq ($(HOST), AmigaOS)
65 OS = os3
66 else
67 ifeq ($(HOST), MorphOS)
68 OS = mos
69 else
70 ifeq ($(HOST), AROS)
71 # now we find out which CPU system aros will be used
72 ifeq ($(shell uname -m), powerpc)
73 OS = aros-ppc
74 endif
75 ifeq ($(shell uname -m), ppc)
76 OS = aros-ppc
77 endif
78 ifeq ($(shell uname -m), i386)
79 OS = aros-i386
80 endif
81 ifeq ($(shell uname -m), i686)
82 OS = aros-i686
83 endif
84 ifeq ($(shell uname -m), x86_64)
85 OS = aros-x86_64
86 endif
87 else
88 OS = os4
89 endif
90 endif
91 endif
92 endif
93 endif
95 #############################################
96 # define common commands we use in this
97 # makefile. Please note that each of them
98 # might be overridden on the commandline.
100 # common commands
101 FLEX = flex
102 FC = flexcat
103 EXPR = expr
104 DATE = date
105 RM = delete force
106 RMDIR = delete force all
107 MKDIR = makedir
108 CHMOD = protect FLAGS=rwed
109 CP = copy
110 CC = gcc
111 STRIP = strip
112 OBJDUMP = objdump
114 # path definitions
115 CDUP = /
116 CDTHIS=
118 # override some variables for non-native builds (cross-compiler)
119 ifneq ($(HOST), AmigaOS)
120 ifneq ($(HOST), AmigaOS4)
121 ifneq ($(HOST), MorphOS)
123 # when we end up here this is either a unix or Aros host
124 # so lets use unix kind of commands
125 RM = rm -f
126 RMDIR = rm -rf
127 MKDIR = mkdir -p
128 CHMOD = chmod 755
129 CP = cp -f
131 CDUP = ../
132 CDTHIS= ./
134 endif
135 endif
136 endif
138 ###########################################################################
139 # CPU and DEBUG can be defined outside, defaults to above
140 # using e.g. "make DEBUG= CPU=-mcpu=603e" produces optimized non-debug
141 # PPC-603e version
143 # OPTFLAGS are disabled by DEBUG normally!
145 # ignored warnings are:
146 # none - because we want to compile with -Wall all the time
148 # Common Directories
149 PREFIX = $(CDTHIS)
150 OBJDIR = .obj_$(OS)
151 BINDIR = bin_$(OS)
152 VPATH = $(OBJDIR)
154 # target definition
155 NBITMAP_DEMO = $(BINDIR)/NBitmap-Demo
156 NLIST_DEMO = $(BINDIR)/NList-Demo
157 NLISTTREE_DEMO = $(BINDIR)/NListtree-Demo
159 # Common compiler/linker flags
160 WARN = -W -Wall -Wwrite-strings -Wpointer-arith -Wsign-compare
161 OPTFLAGS = -O3 -fomit-frame-pointer
162 DEBUG = -DDEBUG -O0
163 DEBUGSYM = -g -gstabs
164 CFLAGS = -I. -I../include $(CPU) $(WARN) $(OPTFLAGS) \
165 $(DEBUG) $(DEBUGSYM) $(USER_CFLAGS) -c
166 LDFLAGS = $(CPU) $(DEBUGSYM)
167 LDLIBS =
169 # different options per target OS
170 ifeq ($(OS), os4)
172 ##############################
173 # AmigaOS4
175 # Compiler/link/strip commands
176 ifneq ($(HOST), AmigaOS4)
177 CC = ppc-amigaos-gcc
178 STRIP = ppc-amigaos-strip
179 OBJDUMP = ppc-amigaos-objdump
180 endif
182 # Compiler/Linker flags
183 CRT = newlib
184 CPU = -mcpu=powerpc
185 WARN += -Wdeclaration-after-statement -Wdisabled-optimization
186 CFLAGS += -mcrt=$(CRT) -D__USE_INLINE__ -D__NEW_TIMEVAL_DEFINITION_USED__ \
187 -DNO_PPCINLINE_STDARG -Wa,-mregnames
188 LDFLAGS += -mcrt=$(CRT)
190 # additional object files required
191 M68KSTUBS = $(OBJDIR)/mccclass_68k.o
193 else
194 ifeq ($(OS), os3)
196 ##############################
197 # AmigaOS3
199 # Compiler/link/strip commands
200 ifneq ($(HOST), AmigaOS)
201 CC = m68k-amigaos-gcc
202 STRIP = m68k-amigaos-strip
203 OBJDUMP = m68k-amigaos-objdump
204 endif
206 # Compiler/Linker flags
207 CPU = -m68020-60 -msoft-float
208 CFLAGS += -noixemul -DNO_INLINE_STDARG
209 LDFLAGS += -noixemul
210 LDLIBS += -ldebug -lmui
212 else
213 ifeq ($(OS), mos)
215 ##############################
216 # MorphOS
218 # Compiler/link/strip commands
219 ifneq ($(HOST), MorphOS)
220 CC = ppc-morphos-gcc
221 STRIP = ppc-morphos-strip
222 OBJDUMP = ppc-morphos-objdump
223 endif
225 # Compiler/Linker flags
226 CPU = -mcpu=powerpc
227 CFLAGS += -noixemul -DNO_PPCINLINE_STDARG
228 LDFLAGS += -noixemul
229 LDLIBS += -ldebug
231 else
232 ifeq ($(OS), aros-i386)
234 ##############################
235 # AROS (i386)
237 ifneq ($(HOST), AROS)
238 CC = i386-aros-gcc
239 STRIP = i386-aros-strip
240 OBJDUMP = i386-aros-objdump
241 endif
243 # Compiler/Linker flags
244 CFLAGS += -Wno-pointer-sign -DNO_INLINE_STDARG
245 LDLIBS += -larossupport -lrom -lmui
247 else
248 ifeq ($(OS), aros-ppc)
250 ##############################
251 # AROS (PPC)
253 ifneq ($(HOST), AROS)
254 CC = ppc-aros-gcc
255 STRIP = ppc-aros-strip
256 OBJDUMP = ppc-aros-objdump
257 endif
259 # Compiler/Linker flags
260 CFLAGS += -Wno-pointer-sign -DNO_INLINE_STDARG
261 LDLIBS += -larossupport -lrom -lmui
263 else
264 ifeq ($(OS), aros-x86_64)
266 ##############################
267 # AROS (x86_64)
269 ifneq ($(HOST), AROS)
270 CC = x86_64-aros-gcc
271 STRIP = x86_64-aros-strip
272 OBJDUMP = x86_64-aros-objdump
273 endif
275 # Compiler/Linker flags
276 CFLAGS += -Wno-pointer-sign -DNO_INLINE_STDARG
277 LDLIBS += -larossupport -lrom -lmui
279 endif
280 endif
281 endif
282 endif
283 endif
284 endif
286 ###########################################################################
287 # Here starts all stuff that is common for all target platforms and
288 # hosts.
290 NBITMAP_OBJS = $(OBJDIR)/NBitmap-Demo.o \
291 $(OBJDIR)/vastubs.o
293 NLIST_OBJS = $(OBJDIR)/NList-Demo.o \
294 $(OBJDIR)/NList-Demo2.o \
295 $(OBJDIR)/NList-Demo3.o \
296 $(OBJDIR)/vastubs.o
298 NLISTTREE_OBJS = $(OBJDIR)/NListtree-Demo.o \
299 $(OBJDIR)/vastubs.o
301 # main target
302 .PHONY: all
303 all: $(BINDIR) $(OBJDIR) $(NBITMAP_DEMO) $(NLIST_DEMO) $(NLISTTREE_DEMO)
305 # for making a release we compile ALL target with no debug
306 release:
307 @echo " CC $<"
308 make OS=os4 clean
309 make OS=os4 DEBUG=
310 @echo " CC $<"
311 make OS=os3 clean
312 make OS=os3 DEBUG=
313 @echo " CC $<"
314 make OS=mos clean
315 make OS=mos DEBUG=
316 @echo " CC $<"
317 make OS=aros-i386 clean
318 make OS=aros-i386 DEBUG=
319 @echo " CC $<"
320 make OS=aros-ppc clean
321 make OS=aros-ppc DEBUG=
322 @echo " CC $<"
323 make OS=aros-x86_64 clean
324 make OS=aros-x86_64 DEBUG=
326 # make the object directories
327 $(OBJDIR):
328 @echo " MK $@"
329 @$(MKDIR) $(OBJDIR)
331 # make the binary directories
332 $(BINDIR):
333 @echo " MK $@"
334 @$(MKDIR) $(BINDIR)
336 # for compiling single .c files
337 $(OBJDIR)/%.o: %.c
338 @echo " CC $<"
339 @$(CC) $(CFLAGS) $< -o $@
341 $(OBJDIR)/mccclass_68k.o: ../include/mccclass_68k.c
342 @echo " CC $<"
343 @$(CC) $(CFLAGS) $< -o $@
345 # for linking the target
346 $(NBITMAP_DEMO): $(NBITMAP_OBJS)
347 @echo " LD $@.debug"
348 @$(CC) $(LDFLAGS) -o $@.debug $(NBITMAP_OBJS) $(LDLIBS) -Wl,--cref,-M,-Map=$@.map
349 @echo " LD $@"
350 @$(STRIP) --preserve-dates -R.comment -R.sdata2 -S -o $@ $@.debug
351 @$(CHMOD) $@
353 # for linking the target
354 $(NLIST_DEMO): $(NLIST_OBJS)
355 @echo " LD $@.debug"
356 @$(CC) $(LDFLAGS) -o $@.debug $(NLIST_OBJS) $(LDLIBS) -Wl,--cref,-M,-Map=$@.map
357 @echo " LD $@"
358 @$(STRIP) --preserve-dates -R.comment -R.sdata2 -S -o $@ $@.debug
359 @$(CHMOD) $@
361 # for linking the target
362 $(NLISTTREE_DEMO): $(NLISTTREE_OBJS)
363 @echo " LD $@.debug"
364 @$(CC) $(LDFLAGS) -o $@.debug $(NLISTTREE_OBJS) $(LDLIBS) -Wl,--cref,-M,-Map=$@.map
365 @echo " LD $@"
366 @$(STRIP) --preserve-dates -R.comment -R.sdata2 -S -o $@ $@.debug
367 @$(CHMOD) $@
371 .PHONY: clean
372 clean:
373 -$(RM) $(NBITMAP_DEMO) $(NBITMAP_DEMO).debug $(NBITMAP_DEMO).map
374 -$(RM) $(NLIST_DEMO) $(NLIST_DEMO).debug $(NLIST_DEMO).map
375 -$(RM) $(NLISTTREE_DEMO) $(NLISTTREE_DEMO).debug $(NLISTTREE_DEMO).map
376 -$(RM) $(NBITMAP_OBJS) $(NLIST_OBJS) $(NLISTTREE_OBJS)
378 .PHONY: distclean
379 distclean: clean
380 -$(RMDIR) $(OBJDIR)
381 -$(RMDIR) $(BINDIR)