Merged in v 26.12.
[AROS-Contrib.git] / mui / classes / thebar / mcc / button / Makefile
blob8357b36a0d7b4ed83524f3bd138de6ed654bb505
1 #/***************************************************************************
3 # TheBar.mcc - Next Generation Toolbar MUI Custom Class
4 # Copyright (C) 2003-2005 Alfonso Ranieri
5 # Copyright (C) 2005-2009 by TheBar.mcc 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 # TheBar class Support Site: http://www.sf.net/projects/thebar
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 this app 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)/TheButton.mcc
160 TESTTARGET= $(BINDIR)/TheButton-Test
162 # Common compiler/linker flags
163 WARN = -W -Wall -Wwrite-strings -Wpointer-arith -Wsign-compare
164 OPTFLAGS = -O3 -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 MCCOBJS = library.o \
177 utils.o \
178 brc1.o \
179 scale.o \
180 build.o \
181 class.o \
182 debug.o
184 OBJS = $(addprefix $(OBJDIR)/,$(MCCOBJS))
186 # different options per target OS
187 ifeq ($(OS), os4)
189 ##############################
190 # AmigaOS4
192 # Compiler/link/strip commands
193 ifneq ($(HOST), AmigaOS4)
194 CC = ppc-amigaos-gcc
195 STRIP = ppc-amigaos-strip
196 OBJDUMP = ppc-amigaos-objdump
197 endif
199 # Compiler/Linker flags
200 CRT = newlib
201 CPU = -mcpu=powerpc
202 WARN += -Wdeclaration-after-statement -Wdisabled-optimization
203 CFLAGS += -mcrt=$(CRT) -D__USE_INLINE__ -D__NEW_TIMEVAL_DEFINITION_USED__ \
204 -DNO_PPCINLINE_STDARG -Wa,-mregnames
205 LDFLAGS += -mcrt=$(CRT)
207 # additional object files required
208 M68KSTUBS = $(OBJDIR)/mccclass_68k.o
210 else
211 ifeq ($(OS), os3)
213 ##############################
214 # AmigaOS3
216 # Compiler/link/strip commands
217 ifneq ($(HOST), AmigaOS)
218 CC = m68k-amigaos-gcc
219 STRIP = m68k-amigaos-strip
220 OBJDUMP = m68k-amigaos-objdump
221 endif
223 # Compiler/Linker flags
224 CPU = -m68020-60 -msoft-float
225 CFLAGS += -noixemul -DNO_INLINE_STDARG -D__amigaos3__
226 LDFLAGS += -noixemul
227 LDLIBS += -ldebug -lmui
229 # additional object files required
230 MCCOBJS += SetPatch.o \
231 vastubs.o
233 else
234 ifeq ($(OS), mos)
236 ##############################
237 # MorphOS
239 DESTDIR = SYS:Classes/MUI
241 # Compiler/link/strip commands
242 ifneq ($(HOST), MorphOS)
243 CC = ppc-morphos-gcc
244 STRIP = ppc-morphos-strip
245 OBJDUMP = ppc-morphos-objdump
246 endif
248 # Compiler/Linker flags
249 CPU = -mcpu=powerpc
250 CFLAGS += -noixemul -DNO_PPCINLINE_STDARG
251 LDFLAGS += -noixemul
252 LDLIBS += -ldebug
254 else
255 ifeq ($(OS), aros-i386)
257 ##############################
258 # AROS (i386)
260 DESTDIR = SYS:Classes/Zune
262 ifneq ($(HOST), AROS)
263 CC = i386-aros-gcc
264 STRIP = i386-aros-strip
265 OBJDUMP = i386-aros-objdump
266 endif
268 # Compiler/Linker flags
269 CFLAGS += -Wno-pointer-sign -DNO_INLINE_STDARG
270 LDLIBS += -larossupport -lrom -lmui
272 else
273 ifeq ($(OS), aros-ppc)
275 ##############################
276 # AROS (PPC)
278 DESTDIR = SYS:Classes/Zune
280 ifneq ($(HOST), AROS)
281 CC = ppc-aros-gcc
282 STRIP = ppc-aros-strip
283 OBJDUMP = ppc-aros-objdump
284 endif
286 # Compiler/Linker flags
287 CFLAGS += -Wno-pointer-sign -DNO_INLINE_STDARG
288 LDLIBS += -larossupport -lrom -lmui
290 else
291 ifeq ($(OS), aros-x86_64)
293 ##############################
294 # AROS (x86_64)
296 DESTDIR = SYS:Classes/Zune
298 ifneq ($(HOST), AROS)
299 CC = x86_64-aros-gcc
300 STRIP = x86_64-aros-strip
301 OBJDUMP = x86_64-aros-objdump
302 endif
304 # Compiler/Linker flags
305 CFLAGS += -Wno-pointer-sign -DNO_INLINE_STDARG
306 LDLIBS += -larossupport -lrom -lmui
308 endif
309 endif
310 endif
311 endif
312 endif
313 endif
315 ###########################################################################
316 # Here starts all stuff that is common for all target platforms and
317 # hosts.
319 # main target
320 .PHONY: all
321 ifeq ($(wildcard $(DEPFILE)),$(DEPFILE))
322 # great, we have a dependecies file, let's make our target
323 all: $(BINDIR) $(OBJDIR) $(M68KSTUBS) $(TARGET)
324 else
325 # no dependecies, create it and then call make again
326 all: depend
327 @make --no-print-directory all
328 endif
330 # for making a release we compile ALL target with no debug
331 release:
332 @echo " CC $<"
333 make OS=os4 clean
334 make OS=os4 DEBUG=
335 @echo " CC $<"
336 make OS=os3 clean
337 make OS=os3 DEBUG=
338 @echo " CC $<"
339 make OS=mos clean
340 make OS=mos DEBUG=
341 @echo " CC $<"
342 make OS=aros-i386 clean
343 make OS=aros-i386 DEBUG=
344 @echo " CC $<"
345 make OS=aros-ppc clean
346 make OS=aros-ppc DEBUG=
347 @echo " CC $<"
348 make OS=aros-x86_64 clean
349 make OS=aros-x86_64 DEBUG=
351 # make the object directories
352 $(OBJDIR):
353 @echo " MK $@"
354 @$(MKDIR) $(OBJDIR)
356 # make the binary directories
357 $(BINDIR):
358 @echo " MK $@"
359 @$(MKDIR) $(BINDIR)
361 # for compiling single .c files
362 $(OBJDIR)/%.o: %.c
363 @echo " CC $<"
364 @$(CC) $(CFLAGS) $< -o $@
366 $(OBJDIR)/mccclass_68k.o: ../../include/mccclass_68k.c
367 @echo " CC $<"
368 @$(CC) $(CFLAGS) $< -o $@
370 # for linking the target
371 $(TARGET): $(M68KSTUBS) $(OBJS)
372 @echo " LD $@.debug"
373 @$(CC) -nostartfiles $(LDFLAGS) -o $@.debug $(OBJS) $(M68KSTUBS) $(LDLIBS) -Wl,--cref,-M,-Map=$@.map
374 @echo " LD $@"
375 @$(STRIP) --preserve-dates -R.comment -R.sdata2 -S -o $@ $@.debug
377 # for linking the target
378 $(TESTTARGET): $(TESTOBJS)
379 @echo " LD $@.debug"
380 @$(CC) $(LDFLAGS) -o $@.debug $(TESTOBJS) $(LDLIBS) -Wl,--cref,-M,-Map=$@.map
381 @echo " LD $@"
382 @$(STRIP) --preserve-dates -R.comment -R.sdata2 -S -o $@ $@.debug
384 $(OBJDIR)/library.o: library.c ../../include/mccinit.c \
385 ../../include/mui/TheBar_mcc.h private.h version.h
387 .PHONY: dump
388 dump:
389 -$(OBJDUMP) --section-headers --all-headers --reloc --disassemble-all $(TARGET) > $(TARGET).dump
391 .PHONY: clean
392 clean:
393 -$(RM) $(TARGET) $(TARGET).debug $(TARGET).map
394 -$(RM) $(TESTTARGET) $(TESTTARGET).debug $(TESTTARGET).map
395 -$(RM) $(OBJS) $(M68KSTUBS)
397 .PHONY: distclean
398 distclean: clean
399 -$(RM) locale.h
400 -$(RM) $(LOCALE)/*.catalog
401 -$(RMDIR) $(OBJDIR)
402 -$(RMDIR) $(BINDIR)
404 # install
405 .PHONY: install
406 install: all
407 @echo " IN $(TARGET)"
408 @$(CP) $(TARGET) $(DESTDIR)
410 .PHONY: help
411 help:
412 @echo "Cleaning targets:"
413 @echo " clean - Cleanup working directory for clean compile"
414 @echo " distclean - Also cleanup autogenerated files"
415 @echo ""
416 @echo "Other generic targets:"
417 @echo " all - Build $(TARGET)"
418 @echo " catalogs - Build all available catalogs"
419 @echo ""
420 @echo "Install targets:"
421 @echo " install - Install $(TARGET) into $(DESTDIR)"
422 @echo ""
423 @echo "Parameters:"
424 @echo " make OS=os3|os4|mos|aros-i386|aros-i686|aros-ppc|aros-x86_64"
425 @echo " make DEBUG= : build $(TARGET) without debugging information"
426 @echo ""
428 ## DEPENDENCY GENERATION ##############
430 .PHONY: depend
431 depend:
432 @echo " MK $(DEPFILE)"
433 @echo "# AUTOGENERATED! DO NOT EDIT!!!" >$(DEPFILE)
434 @$(CC) -MM -MG $(CFLAGS) $(wildcard *.c) >>$(DEPFILE)
435 @echo "# AUTOGENERATED! DO NOT EDIT!!!" >>$(DEPFILE)
436 @$(SED) -i 's,^\(.*\)\.o:,$$\(OBJDIR\)/\1.o:,g' $(DEPFILE)
438 # include dependencies file
439 -include $(DEPFILE)