when dropping into user mode make sure endian is set
[AROS.git] / workbench / classes / zune / betterstring / mcc / Makefile
blob086e04da353e4eae6f6b98bd50568098360c6ff9
1 #/***************************************************************************
3 # BetterString.mcc - A better String gadget MUI Custom Class
4 # Copyright (C) 1997-2000 Allan Odgaard
5 # Copyright (C) 2005-2009 by BetterString.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 # BetterString class Support Site: http://www.sf.net/projects/bstring-mcc/
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 # override commands for native builds
117 ifeq ($(HOST), AmigaOS4)
118 # AmigaOS4 host
119 RM = delete force
120 RMDIR = delete force all
121 MKDIR = makedir
122 DATE = gdate
123 else
124 ifeq ($(HOST), AmigaOS)
125 # AmigaOS3 host
126 RM = delete force
127 RMDIR = delete force all
128 MKDIR = makedir
129 else
130 ifeq ($(HOST), MorphOS)
131 # MorphOS host
132 RM = delete force
133 RMDIR = delete force all
134 MKDIR = makedir
135 endif
136 endif
137 endif
139 # path definitions
140 CDUP = /
141 CDTHIS=
143 # override some variables for non-native builds (cross-compiler)
144 ifneq ($(HOST), AmigaOS)
145 ifneq ($(HOST), AmigaOS4)
146 ifneq ($(HOST), MorphOS)
148 # when we end up here this is either a unix or Aros host
149 # so lets use unix kind of commands
150 RM = rm -f
151 RMDIR = rm -rf
152 MKDIR = mkdir -p
153 CHMOD = chmod 755
154 CP = cp -f
156 CDUP = ../
157 CDTHIS= ./
159 endif
160 endif
161 endif
163 ###########################################################################
164 # CPU and DEBUG can be defined outside, defaults to above
165 # using e.g. "make DEBUG= CPU=-mcpu=603e" produces optimized non-debug
166 # PPC-603e version
168 # OPTFLAGS are disabled by DEBUG normally!
170 # ignored warnings are:
171 # none - because we want to compile with -Wall all the time
173 # Common Directories
174 PREFIX = $(CDTHIS)
175 OBJDIR = .obj_$(OS)
176 BINDIR = bin_$(OS)
177 VPATH = $(OBJDIR)
178 DEPFILE = Makefile.dep
179 DESTDIR = MUI:Libs/MUI
181 # target definition
182 TARGET = $(BINDIR)/BetterString.mcc
183 TESTTARGET= $(BINDIR)/BetterString-Test
185 # Common compiler/linker flags
186 WARN = -W -Wall -Wwrite-strings -Wpointer-arith -Wsign-compare
187 OPTFLAGS = -O3 -fomit-frame-pointer
188 DEBUG = -DDEBUG -O0
189 DEBUGSYM = -g -gstabs
190 CFLAGS = -I. -I../mcp -I../include $(CPU) $(WARN) $(OPTFLAGS) \
191 $(DEBUG) $(DEBUGSYM) $(USER_CFLAGS) -c
192 LDFLAGS = $(CPU) $(DEBUGSYM)
193 LDLIBS =
195 ###########################################################################
196 # object files definition
199 LOBJS = library.o
201 COBJS = AllocBitMap.o \
202 AllocFunctions.o \
203 ClipboardServer.o \
204 Dispatcher.o \
205 FileNameCompl.o \
206 GetSetAttrs.o \
207 HandleInput.o \
208 InitConfig.o \
209 Pointer.o \
210 PrintString.o \
211 Debug.o
213 TOBJS = BetterString-Test.o
215 MCCOBJS = $(addprefix $(OBJDIR)/,$(LOBJS)) $(addprefix $(OBJDIR)/,$(COBJS))
216 TESTOBJS = $(addprefix $(OBJDIR)/,$(COBJS)) $(addprefix $(OBJDIR)/,$(TOBJS))
218 # different options per target OS
219 ifeq ($(OS), os4)
221 ##############################
222 # AmigaOS4
224 # Compiler/link/strip commands
225 ifneq ($(HOST), AmigaOS4)
226 CC = ppc-amigaos-gcc
227 STRIP = ppc-amigaos-strip
228 OBJDUMP = ppc-amigaos-objdump
229 endif
231 # Compiler/Linker flags
232 CRT = newlib
233 CPU = -mcpu=powerpc
234 WARN += -Wdeclaration-after-statement -Wdisabled-optimization
235 CFLAGS += -mcrt=$(CRT) -D__USE_INLINE__ -D__NEW_TIMEVAL_DEFINITION_USED__ \
236 -DNO_PPCINLINE_STDARG -Wa,-mregnames
237 LDFLAGS += -mcrt=$(CRT)
239 # additional object files required
240 M68KSTUBS = $(OBJDIR)/mccclass_68k.o
242 else
243 ifeq ($(OS), os3)
245 ##############################
246 # AmigaOS3
248 # Compiler/link/strip commands
249 ifneq ($(HOST), AmigaOS)
250 CC = m68k-amigaos-gcc
251 STRIP = m68k-amigaos-strip
252 OBJDUMP = m68k-amigaos-objdump
253 endif
255 # Compiler/Linker flags
256 CPU = -m68020-60 -msoft-float
257 CFLAGS += -noixemul -DNO_INLINE_STDARG -D__amigaos3__
258 LDFLAGS += -noixemul
259 LDLIBS += -ldebug -lmui
261 # additional object files required
262 COBJS += vastubs.o
264 else
265 ifeq ($(OS), mos)
267 ##############################
268 # MorphOS
270 # Compiler/link/strip commands
271 ifneq ($(HOST), MorphOS)
272 CC = ppc-morphos-gcc
273 STRIP = ppc-morphos-strip
274 OBJDUMP = ppc-morphos-objdump
275 endif
277 # Compiler/Linker flags
278 CPU = -mcpu=powerpc
279 CFLAGS += -noixemul -DNO_PPCINLINE_STDARG
280 LDFLAGS += -noixemul
281 LDLIBS += -ldebug
283 else
284 ifeq ($(OS), aros-i386)
286 ##############################
287 # AROS (i386)
289 ifneq ($(HOST), AROS)
290 CC = i386-aros-gcc
291 STRIP = i386-aros-strip
292 OBJDUMP = i386-aros-objdump
293 endif
295 # Compiler/Linker flags
296 OPTFLAGS = -O2 -fomit-frame-pointer
297 CFLAGS += -Wno-pointer-sign -DNO_INLINE_STDARG
298 LDLIBS += -larossupport -lrom -lmui
300 else
301 ifeq ($(OS), aros-ppc)
303 ##############################
304 # AROS (PPC)
306 ifneq ($(HOST), AROS)
307 CC = ppc-aros-gcc
308 STRIP = ppc-aros-strip
309 OBJDUMP = ppc-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 else
318 ifeq ($(OS), aros-x86_64)
320 ##############################
321 # AROS (x86_64)
323 ifneq ($(HOST), AROS)
324 CC = x86_64-aros-gcc
325 STRIP = x86_64-aros-strip
326 OBJDUMP = x86_64-aros-objdump
327 endif
329 # Compiler/Linker flags
330 OPTFLAGS = -O2 -fomit-frame-pointer
331 CFLAGS += -Wno-pointer-sign -DNO_INLINE_STDARG
332 LDLIBS += -larossupport -lrom -lmui
334 endif
335 endif
336 endif
337 endif
338 endif
339 endif
341 # main target
342 .PHONY: all
343 ifeq ($(wildcard $(DEPFILE)),$(DEPFILE))
344 # great, we have a dependecies file, let's make our target
345 all: $(BINDIR) $(OBJDIR) $(M68KSTUBS) $(TARGET) $(TESTTARGET)
346 else
347 # no dependecies, create it and then call make again
348 all: depend
349 @make --no-print-directory all
350 endif
352 # for making a release we compile ALL target with no debug
353 release:
354 @echo " CC $<"
355 make OS=os4 clean
356 make OS=os4 DEBUG=
357 @echo " CC $<"
358 make OS=os3 clean
359 make OS=os3 DEBUG=
360 @echo " CC $<"
361 make OS=mos clean
362 make OS=mos DEBUG=
363 @echo " CC $<"
364 make OS=aros-i386 clean
365 make OS=aros-i386 DEBUG=
366 @echo " CC $<"
367 make OS=aros-ppc clean
368 make OS=aros-ppc DEBUG=
369 @echo " CC $<"
370 make OS=aros-x86_64 clean
371 make OS=aros-x86_64 DEBUG=
373 # make the object directories
374 $(OBJDIR):
375 @echo " MK $@"
376 @$(MKDIR) $(OBJDIR)
378 # make the binary directories
379 $(BINDIR):
380 @echo " MK $@"
381 @$(MKDIR) $(BINDIR)
383 # for compiling single .c files
384 $(OBJDIR)/%.o: %.c
385 @echo " CC $<"
386 @$(CC) $(CFLAGS) $< -o $@
388 $(OBJDIR)/mccclass_68k.o: ../include/mccclass_68k.c
389 @echo " CC $<"
390 @$(CC) $(CFLAGS) $< -o $@
392 # for linking the target
393 $(TARGET): $(M68KSTUBS) $(MCCOBJS)
394 @echo " LD $@.debug"
395 @$(CC) -nostartfiles $(LDFLAGS) -o $@.debug $(MCCOBJS) $(M68KSTUBS) $(LDLIBS) -Wl,--cref,-M,-Map=$@.map
396 @echo " LD $@"
397 @$(STRIP) --preserve-dates -R.comment -R.sdata2 -S -o $@ $@.debug
399 # for linking the target
400 $(TESTTARGET): $(TESTOBJS)
401 @echo " LD $@.debug"
402 @$(CC) $(LDFLAGS) -o $@.debug $(TESTOBJS) $(LDLIBS) -Wl,--cref,-M,-Map=$@.map
403 @echo " LD $@"
404 @$(STRIP) --preserve-dates -R.comment -R.sdata2 -S -o $@ $@.debug
406 .PHONY: dump
407 dump:
408 -$(OBJDUMP) --section-headers --all-headers --reloc --disassemble-all $(TARGET) > $(TARGET).dump
409 -$(OBJDUMP) --section-headers --all-headers --reloc --disassemble-all $(TESTTARGET) > $(TESTTARGET).dump
411 .PHONY: clean
412 clean:
413 -$(RM) $(TARGET) $(TARGET).debug $(TARGET).map
414 -$(RM) $(TESTTARGET) $(TESTTARGET).debug $(TESTTARGET).map
415 -$(RM) $(MCCOBJS) $(TESTOBJS) $(M68KSTUBS)
417 .PHONY: distclean
418 distclean: clean
419 -$(RMDIR) $(OBJDIR)
420 -$(RMDIR) $(BINDIR)
422 # install
423 .PHONY: install
424 install: all
425 @echo " IN $(TARGET)"
426 @$(CP) $(TARGET) $(DESTDIR)
428 .PHONY: help
429 help:
430 @echo "Cleaning targets:"
431 @echo " clean - Cleanup working directory for clean compile"
432 @echo " distclean - Also cleanup autogenerated files"
433 @echo ""
434 @echo "Other generic targets:"
435 @echo " all - Build $(TARGET)"
436 @echo " catalogs - Build all available catalogs"
437 @echo ""
438 @echo "Install targets:"
439 @echo " install - Install $(TARGET) into $(DESTDIR)"
440 @echo ""
441 @echo "Parameters:"
442 @echo " make OS=os3|os4|mos|aros-i386|aros-i686|aros-ppc|aros-x86_64"
443 @echo " make DEBUG= : build $(TARGET) without debugging information"
444 @echo ""
446 ## DEPENDENCY GENERATION ##############
448 .PHONY: depend
449 depend:
450 @echo " MK $(DEPFILE)"
451 @echo "# AUTOGENERATED! DO NOT EDIT!!!" >$(DEPFILE)
452 @$(CC) -MM -MG $(CFLAGS) $(wildcard *.c) >>$(DEPFILE)
453 @echo "# AUTOGENERATED! DO NOT EDIT!!!" >>$(DEPFILE)
454 @$(SED) -i 's,^\(.*\)\.o:,$$\(OBJDIR\)/\1.o:,g' $(DEPFILE)
456 # include dependencies file
457 -include $(DEPFILE)