grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / classes / zune / nlist / nbitmap_mcc / Makefile
blobd9950d849a203be46d44c6ff55d5ee38f4db144d
1 #/***************************************************************************
3 # NBitmap.mcc - New Bitmap MUI Custom Class
4 # Copyright (C) 2006 by Daniel Allsopp
5 # Copyright (C) 2007 by NList Open Source Team
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # NList classes Support Site: http://www.sf.net/projects/nlist-classes
19 # $Id$
21 #***************************************************************************/
23 ###########################################################################
24 # This makefile is a very generic one. It tries to identify both, the host
25 # and the target operating system for which YAM should be compiled.
26 # However, this auto-detection can be easily overridden by directly
27 # specifying an option on the commandline while calling 'make'.
29 # Example:
31 # # to explicitly compile for AmigaOS3
32 # > make OS=os3
34 # # to compile for AmigaOS4 but with debugging
35 # > make OS=os4 DEBUG=
38 #############################################
39 # find out the HOST operating system
40 # on which this makefile is run
41 HOST ?= $(shell uname)
42 ifeq ($(HOST), AmigaOS)
43 ifeq ($(shell uname -m), powerpc)
44 HOST = AmigaOS4
45 endif
46 ifeq ($(shell uname -m), ppc)
47 HOST = AmigaOS4
48 endif
49 endif
51 # if no host is identifed (no uname tool)
52 # we assume a AmigaOS build
53 ifeq ($(HOST),)
54 HOST = AmigaOS
55 endif
57 #############################################
58 # now we find out the target OS for
59 # which we are going to compile YAM in case
60 # the caller didn't yet define OS himself
61 ifndef (OS)
62 ifeq ($(HOST), AmigaOS4)
63 OS = os4
64 else
65 ifeq ($(HOST), AmigaOS)
66 OS = os3
67 else
68 ifeq ($(HOST), MorphOS)
69 OS = mos
70 else
71 ifeq ($(HOST), AROS)
72 # now we find out which CPU system aros will be used
73 ifeq ($(shell uname -m), powerpc)
74 OS = aros-ppc
75 endif
76 ifeq ($(shell uname -m), ppc)
77 OS = aros-ppc
78 endif
79 ifeq ($(shell uname -m), i386)
80 OS = aros-i386
81 endif
82 ifeq ($(shell uname -m), i686)
83 OS = aros-i686
84 endif
85 ifeq ($(shell uname -m), x86_64)
86 OS = aros-x86_64
87 endif
88 else
89 OS = os4
90 endif
91 endif
92 endif
93 endif
94 endif
96 #############################################
97 # define common commands we use in this
98 # makefile. Please note that each of them
99 # might be overridden on the commandline.
101 # common commands
102 FLEX = flex
103 FC = flexcat
104 EXPR = expr
105 DATE = date
106 RM = delete force
107 RMDIR = delete force all
108 MKDIR = makedir
109 CHMOD = protect FLAGS=rwed
110 SED = sed
111 CP = copy
112 CC = gcc
113 STRIP = strip
114 OBJDUMP = objdump
116 # path definitions
117 CDUP = /
118 CDTHIS=
120 # override some variables for non-native builds (cross-compiler)
121 ifneq ($(HOST), AmigaOS)
122 ifneq ($(HOST), AmigaOS4)
123 ifneq ($(HOST), MorphOS)
125 # when we end up here this is either a unix or Aros host
126 # so lets use unix kind of commands
127 RM = rm -f
128 RMDIR = rm -rf
129 MKDIR = mkdir -p
130 CHMOD = chmod 755
131 CP = cp -f
133 CDUP = ../
134 CDTHIS= ./
136 endif
137 endif
138 endif
140 ###########################################################################
141 # CPU and DEBUG can be defined outside, defaults to above
142 # using e.g. "make DEBUG= CPU=-mcpu=603e" produces optimized non-debug
143 # PPC-603e version
145 # OPTFLAGS are disabled by DEBUG normally!
147 # ignored warnings are:
148 # none - because we want to compile with -Wall all the time
150 # Common Directories
151 PREFIX = $(CDTHIS)
152 OBJDIR = .obj_$(OS)
153 BINDIR = bin_$(OS)
154 VPATH = $(OBJDIR)
155 DEPFILE = Makefile.dep
156 DESTDIR = MUI:Libs/MUI
158 # target definition
159 TARGET = $(BINDIR)/NBitmap.mcc
160 TESTTARGET= $(BINDIR)/NBitmap-Test
162 # Common compiler/linker flags
163 WARN = -W -Wall -Wwrite-strings -Wpointer-arith -Wsign-compare
164 OPTFLAGS = -O3 -fno-omit-frame-pointer -fomit-frame-pointer
165 DEBUG = -DDEBUG -O0
166 DEBUGSYM = -g -gstabs
167 CFLAGS = -I. -I../include $(CPU) $(WARN) $(OPTFLAGS) \
168 $(DEBUG) $(DEBUGSYM) $(USER_CFLAGS) -c
169 LDFLAGS = $(CPU) $(DEBUGSYM)
170 LDLIBS =
172 ###########################################################################
173 # object files definition
176 LOBJS = library.o
178 COBJS = dispatcher.o \
179 NBitmap.o \
180 DitherImage.o \
181 Debug.o
183 TOBJS = NBitmap-Test.o
185 MCCOBJS = $(addprefix $(OBJDIR)/,$(LOBJS)) $(addprefix $(OBJDIR)/,$(COBJS))
186 TESTOBJS = $(addprefix $(OBJDIR)/,$(COBJS)) $(addprefix $(OBJDIR)/,$(TOBJS))
188 # different options per target OS
189 ifeq ($(OS), os4)
191 ##############################
192 # AmigaOS4
194 # Compiler/link/strip commands
195 ifneq ($(HOST), AmigaOS4)
196 CC = ppc-amigaos-gcc
197 STRIP = ppc-amigaos-strip
198 OBJDUMP = ppc-amigaos-objdump
199 endif
201 # Compiler/Linker flags
202 CRT = newlib
203 CPU = -mcpu=powerpc
204 WARN += -Wdeclaration-after-statement -Wdisabled-optimization
205 CFLAGS += -mcrt=$(CRT) -D__USE_INLINE__ -D__NEW_TIMEVAL_DEFINITION_USED__ \
206 -DNO_PPCINLINE_STDARG -Wa,-mregnames
207 LDFLAGS += -mcrt=$(CRT)
209 # additional object files required
210 M68KSTUBS = $(OBJDIR)/mccclass_68k.o
212 else
213 ifeq ($(OS), os3)
215 ##############################
216 # AmigaOS3
218 # Compiler/link/strip commands
219 ifneq ($(HOST), AmigaOS)
220 CC = m68k-amigaos-gcc
221 STRIP = m68k-amigaos-strip
222 OBJDUMP = m68k-amigaos-objdump
223 endif
225 # Compiler/Linker flags
226 CPU = -m68020-60 -msoft-float
227 CFLAGS += -noixemul -DNO_INLINE_STDARG -D__amigaos3__
228 LDFLAGS += -noixemul
229 LDLIBS += -ldebug -lmui
231 # additional object files required
232 COBJS += Chunky2Bitmap.o \
233 SetPatch.o \
234 WritePixelArray.o \
235 WritePixelArrayAlpha.o \
236 vastubs.o
238 else
239 ifeq ($(OS), mos)
241 ##############################
242 # MorphOS
244 # Compiler/link/strip commands
245 ifneq ($(HOST), MorphOS)
246 CC = ppc-morphos-gcc
247 STRIP = ppc-morphos-strip
248 OBJDUMP = ppc-morphos-objdump
249 endif
251 # Compiler/Linker flags
252 CPU = -mcpu=powerpc
253 CFLAGS += -noixemul -DNO_PPCINLINE_STDARG
254 LDFLAGS += -noixemul
255 LDLIBS += -ldebug
257 # additional object files required
258 COBJS += Chunky2Bitmap.o
260 else
261 ifeq ($(OS), aros-i386)
263 ##############################
264 # AROS (i386)
266 ifneq ($(HOST), AROS)
267 CC = i386-aros-gcc
268 STRIP = i386-aros-strip
269 OBJDUMP = i386-aros-objdump
270 endif
272 # Compiler/Linker flags
273 OPTFLAGS = -O2 -fomit-frame-pointer
274 CFLAGS += -Wno-pointer-sign -DNO_INLINE_STDARG
275 LDLIBS += -larossupport -lrom -lmui
277 # additional object files required
278 COBJS += Chunky2Bitmap.o
280 else
281 ifeq ($(OS), aros-ppc)
283 ##############################
284 # AROS (PPC)
286 ifneq ($(HOST), AROS)
287 CC = ppc-aros-gcc
288 STRIP = ppc-aros-strip
289 OBJDUMP = ppc-aros-objdump
290 endif
292 # Compiler/Linker flags
293 OPTFLAGS = -O2 -fomit-frame-pointer
294 CFLAGS += -Wno-pointer-sign -DNO_INLINE_STDARG
295 LDLIBS += -larossupport -lrom -lmui
297 # additional object files required
298 COBJS += Chunky2Bitmap.o
300 else
301 ifeq ($(OS), aros-x86_64)
303 ##############################
304 # AROS (x86_64)
306 ifneq ($(HOST), AROS)
307 CC = x86_64-aros-gcc
308 STRIP = x86_64-aros-strip
309 OBJDUMP = x86_64-aros-objdump
310 endif
312 # Compiler/Linker flags
313 OPTFLAGS = -O2 -fomit-frame-pointer
314 CFLAGS += -Wno-pointer-sign -DNO_INLINE_STDARG
315 LDLIBS += -larossupport -lrom -lmui
317 # additional object files required
318 COBJS += Chunky2Bitmap.o
320 endif
321 endif
322 endif
323 endif
324 endif
325 endif
327 # main target
328 .PHONY: all
329 ifeq ($(wildcard $(DEPFILE)),$(DEPFILE))
330 # great, we have a dependecies file, let's make our target
331 all: $(BINDIR) $(OBJDIR) $(M68KSTUBS) $(TARGET) $(TESTTARGET)
332 else
333 # no dependecies, create it and then call make again
334 all: depend
335 @make --no-print-directory all
336 endif
338 # for making a release we compile ALL target with no debug
339 release:
340 @echo " CC $<"
341 make OS=os4 clean
342 make OS=os4 DEBUG=
343 @echo " CC $<"
344 make OS=os3 clean
345 make OS=os3 DEBUG=
346 @echo " CC $<"
347 make OS=mos clean
348 make OS=mos DEBUG=
349 @echo " CC $<"
350 make OS=aros-i386 clean
351 make OS=aros-i386 DEBUG=
352 @echo " CC $<"
353 make OS=aros-ppc clean
354 make OS=aros-ppc DEBUG=
355 @echo " CC $<"
356 make OS=aros-x86_64 clean
357 make OS=aros-x86_64 DEBUG=
359 # make the object directories
360 $(OBJDIR):
361 @echo " MK $@"
362 @$(MKDIR) $(OBJDIR)
364 # make the binary directories
365 $(BINDIR):
366 @echo " MK $@"
367 @$(MKDIR) $(BINDIR)
369 # for compiling single .c files
370 $(OBJDIR)/%.o: %.c
371 @echo " CC $<"
372 @$(CC) $(CFLAGS) $< -o $@
374 $(OBJDIR)/mccclass_68k.o: ../include/mccclass_68k.c
375 @echo " CC $<"
376 @$(CC) $(CFLAGS) $< -o $@
378 # for linking the target
379 $(TARGET): $(M68KSTUBS) $(MCCOBJS)
380 @echo " LD $@.debug"
381 @$(CC) -nostartfiles $(LDFLAGS) -o $@.debug $(MCCOBJS) $(M68KSTUBS) $(LDLIBS) -Wl,--cref,-M,-Map=$@.map
382 @echo " LD $@"
383 @$(STRIP) --preserve-dates -R.comment -R.sdata2 -S -o $@ $@.debug
385 # for linking the target
386 $(TESTTARGET): $(TESTOBJS)
387 @echo " LD $@.debug"
388 @$(CC) $(LDFLAGS) -o $@.debug $(TESTOBJS) $(LDLIBS) -Wl,--cref,-M,-Map=$@.map
389 @echo " LD $@"
390 @$(STRIP) --preserve-dates -R.comment -R.sdata2 -S -o $@ $@.debug
392 .PHONY: dump
393 dump:
394 -$(OBJDUMP) --section-headers --all-headers --reloc --disassemble-all $(TARGET) >$(TARGET).dump
396 .PHONY: clean
397 clean:
398 -$(RM) $(TARGET) $(TARGET).debug $(TARGET).map
399 -$(RM) $(TESTTARGET) $(TESTTARGET).debug $(TESTTARGET).map
400 -$(RM) $(MCCOBJS) $(TESTOBJS) $(M68KSTUBS)
402 .PHONY: distclean
403 distclean: clean
404 -$(RMDIR) $(OBJDIR)
405 -$(RMDIR) $(BINDIR)
407 # install
408 .PHONY: install
409 install: all
410 @echo " IN $(TARGET)"
411 @$(CP) $(TARGET) $(DESTDIR)
413 .PHONY: help
414 help:
415 @echo "Cleaning targets:"
416 @echo " clean - Cleanup working directory for clean compile"
417 @echo " distclean - Also cleanup autogenerated files"
418 @echo ""
419 @echo "Other generic targets:"
420 @echo " all - Build $(TARGET)"
421 @echo " catalogs - Build all available catalogs"
422 @echo ""
423 @echo "Install targets:"
424 @echo " install - Install $(TARGET) into $(DESTDIR)"
425 @echo ""
426 @echo "Parameters:"
427 @echo " make OS=os3|os4|mos|aros-i386|aros-i686|aros-ppc|aros-x86_64"
428 @echo " make DEBUG= : build $(TARGET) without debugging information"
429 @echo ""
431 ## DEPENDENCY GENERATION ##############
433 .PHONY: depend
434 depend:
435 @echo " MK $(DEPFILE)"
436 @echo "# AUTOGENERATED! DO NOT EDIT!!!" >$(DEPFILE)
437 @$(CC) -MM -MG $(CFLAGS) $(wildcard *.c) >>$(DEPFILE)
438 @echo "# AUTOGENERATED! DO NOT EDIT!!!" >>$(DEPFILE)
439 @$(SED) -i 's,^\(.*\)\.o:,$$\(OBJDIR\)/\1.o:,g' $(DEPFILE)
441 # include dependencies file
442 -include $(DEPFILE)