grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / classes / zune / betterstring / mcc / hotkeystring / Makefile
blob199a685d0ff116fc73a971cd4ae183a05d0e87c4
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 # 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)/HotkeyString.mcc
160 TESTTARGET= $(BINDIR)/HotkeyString-Test
162 # Common compiler/linker flags
163 WARN = -W -Wall -Wwrite-strings -Wpointer-arith -Wsign-compare
164 OPTFLAGS = -O3 -fomit-frame-pointer -funroll-loops
165 DEBUG = -DDEBUG -O0
166 DEBUGSYM = -g -gstabs
167 CFLAGS = -I. -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 HandleInput.o \
180 Debug.o
182 TOBJS = HotkeyString-Test.o
184 MCCOBJS = $(addprefix $(OBJDIR)/,$(LOBJS)) $(addprefix $(OBJDIR)/,$(COBJS))
185 TESTOBJS = $(addprefix $(OBJDIR)/,$(COBJS)) $(addprefix $(OBJDIR)/,$(TOBJS))
187 # different options per target OS
188 ifeq ($(OS), os4)
190 ##############################
191 # AmigaOS4
193 # Compiler/link/strip commands
194 ifneq ($(HOST), AmigaOS4)
195 CC = ppc-amigaos-gcc
196 STRIP = ppc-amigaos-strip
197 OBJDUMP = ppc-amigaos-objdump
198 endif
200 # Compiler/Linker flags
201 CRT = newlib
202 CPU = -mcpu=powerpc
203 WARN += -Wdeclaration-after-statement -Wdisabled-optimization
204 CFLAGS += -mcrt=$(CRT) -D__USE_INLINE__ -D__NEW_TIMEVAL_DEFINITION_USED__ \
205 -DNO_PPCINLINE_STDARG -Wa,-mregnames
206 LDFLAGS += -mcrt=$(CRT)
208 # additional object files required
209 M68KSTUBS = $(OBJDIR)/mccclass_68k.o
211 else
212 ifeq ($(OS), os3)
214 ##############################
215 # AmigaOS3
217 # Compiler/link/strip commands
218 ifneq ($(HOST), AmigaOS)
219 CC = m68k-amigaos-gcc
220 STRIP = m68k-amigaos-strip
221 OBJDUMP = m68k-amigaos-objdump
222 endif
224 # Compiler/Linker flags
225 CPU = -m68020-60 -msoft-float
226 CFLAGS += -noixemul -DNO_INLINE_STDARG -D__amigaos3__
227 LDFLAGS += -noixemul
228 LDLIBS += -ldebug -lmui
230 # additional object files required
231 COBJS += vastubs.o
233 else
234 ifeq ($(OS), mos)
236 ##############################
237 # MorphOS
239 # Compiler/link/strip commands
240 ifneq ($(HOST), MorphOS)
241 CC = ppc-morphos-gcc
242 STRIP = ppc-morphos-strip
243 OBJDUMP = ppc-morphos-objdump
244 endif
246 # Compiler/Linker flags
247 CPU = -mcpu=powerpc
248 CFLAGS += -noixemul -DNO_PPCINLINE_STDARG
249 LDFLAGS += -noixemul
250 LDLIBS += -ldebug
252 else
253 ifeq ($(OS), aros-i386)
255 ##############################
256 # AROS (i386)
258 ifneq ($(HOST), AROS)
259 CC = i386-aros-gcc
260 STRIP = i386-aros-strip
261 OBJDUMP = i386-aros-objdump
262 endif
264 # Compiler/Linker flags
265 OPTFLAGS = -O2 -fomit-frame-pointer -funroll-loops
266 CFLAGS += -Wno-pointer-sign -DNO_INLINE_STDARG
267 LDLIBS += -larossupport -lrom -lmui
269 else
270 ifeq ($(OS), aros-ppc)
272 ##############################
273 # AROS (PPC)
275 ifneq ($(HOST), AROS)
276 CC = ppc-aros-gcc
277 STRIP = ppc-aros-strip
278 OBJDUMP = ppc-aros-objdump
279 endif
281 # Compiler/Linker flags
282 OPTFLAGS = -O2 -fomit-frame-pointer -funroll-loops
283 CFLAGS += -Wno-pointer-sign -DNO_INLINE_STDARG
284 LDLIBS += -larossupport -lrom -lmui
286 else
287 ifeq ($(OS), aros-x86_64)
289 ##############################
290 # AROS (x86_64)
292 ifneq ($(HOST), AROS)
293 CC = x86_64-aros-gcc
294 STRIP = x86_64-aros-strip
295 OBJDUMP = x86_64-aros-objdump
296 endif
298 # Compiler/Linker flags
299 OPTFLAGS = -O2 -fomit-frame-pointer -funroll-loops
300 CFLAGS += -Wno-pointer-sign -DNO_INLINE_STDARG
301 LDLIBS += -larossupport -lrom -lmui
303 endif
304 endif
305 endif
306 endif
307 endif
308 endif
310 # main target
311 .PHONY: all
312 ifeq ($(wildcard $(DEPFILE)),$(DEPFILE))
313 # great, we have a dependecies file, let's make our target
314 all: $(BINDIR) $(OBJDIR) $(M68KSTUBS) $(TARGET) $(TESTTARGET)
315 else
316 # no dependecies, create it and then call make again
317 all: depend
318 @make --no-print-directory all
319 endif
321 # for making a release we compile ALL target with no debug
322 release:
323 @echo " CC $@"
324 make OS=os4 clean
325 make OS=os4 DEBUG=
326 @echo " CC $@"
327 make OS=os3 clean
328 make OS=os3 DEBUG=
329 @echo " CC $@"
330 make OS=mos clean
331 make OS=mos DEBUG=
332 @echo " CC $@"
333 make OS=aros-i386 clean
334 make OS=aros-i386 DEBUG=
335 @echo " CC $@"
336 make OS=aros-ppc clean
337 make OS=aros-ppc DEBUG=
338 @echo " CC $@"
339 make OS=aros-x86_64 clean
340 make OS=aros-x86_64 DEBUG=
342 # make the object directories
343 $(OBJDIR):
344 @echo " MK $@"
345 @$(MKDIR) $(OBJDIR)
347 # make the binary directories
348 $(BINDIR):
349 @echo " MKDIR $@"
350 @$(MKDIR) $(BINDIR)
352 # for compiling single .c files
353 $(OBJDIR)/%.o: %.c
354 @echo " CC $<"
355 @$(CC) $(CFLAGS) $< -o $@
357 $(OBJDIR)/mccclass_68k.o: ../../include/mccclass_68k.c
358 @echo " CC $<"
359 @$(CC) $(CFLAGS) $< -o $@
361 # for linking the target
362 $(TARGET): $(M68KSTUBS) $(MCCOBJS)
363 @echo " LD $@.debug"
364 @$(CC) -nostartfiles $(LDFLAGS) -o $@.debug $(MCCOBJS) $(M68KSTUBS) $(LDLIBS) -Wl,--cref,-M,-Map=$@.map
365 @echo " LD $@"
366 @$(STRIP) --preserve-dates -R.comment -R.sdata2 -S -o $@ $@.debug
368 # for linking the target
369 $(TESTTARGET): $(TESTOBJS)
370 @echo " LD $@"
371 @$(CC) $(LDFLAGS) -o $@.debug $(TESTOBJS) $(LDLIBS) -Wl,--cref,-M,-Map=$@.map
372 @$(STRIP) --preserve-dates -R.comment -R.sdata2 -S -o $@ $@.debug
374 .PHONY: dump
375 dump:
376 -$(OBJDUMP) --section-headers --all-headers --reloc --disassemble-all $(TARGET) > $(TARGET).dump
378 .PHONY: clean
379 clean:
380 -$(RM) $(TARGET) $(TARGET).debug $(TARGET).map
381 -$(RM) $(TESTTARGET) $(TESTTARGET).debug $(TESTTARGET).map
382 -$(RM) $(MCCOBJS) $(TESTOBJS) $(M68KSTUBS)
384 .PHONY: distclean
385 distclean: clean
386 -$(RMDIR) $(OBJDIR)
387 -$(RMDIR) $(BINDIR)
389 # install
390 .PHONY: install
391 install: all
392 @echo " IN $(TARGET)"
393 @$(CP) $(TARGET) $(DESTDIR)
395 .PHONY: help
396 help:
397 @echo "Cleaning targets:"
398 @echo " clean - Cleanup working directory for clean compile"
399 @echo " distclean - Also cleanup autogenerated files"
400 @echo ""
401 @echo "Other generic targets:"
402 @echo " all - Build $(TARGET)"
403 @echo " catalogs - Build all available catalogs"
404 @echo ""
405 @echo "Install targets:"
406 @echo " install - Install $(TARGET) into $(DESTDIR)"
407 @echo ""
408 @echo "Parameters:"
409 @echo " make OS=os3|os4|mos|aros-i386|aros-i686|aros-ppc|aros-x86_64"
410 @echo " make DEBUG= : build $(TARGET) without debugging information"
411 @echo ""
413 ## DEPENDENCY GENERATION ##############
415 .PHONY: depend
416 depend:
417 @echo " MK $(DEPFILE)"
418 @echo "# AUTOGENERATED! DO NOT EDIT!!!" >$(DEPFILE)
419 @$(CC) -MM -MG $(CFLAGS) $(wildcard *.c) >>$(DEPFILE)
420 @echo "# AUTOGENERATED! DO NOT EDIT!!!" >>$(DEPFILE)
421 @$(SED) -i 's,^\(.*\)\.o:,$$\(OBJDIR\)/\1.o:,g' $(DEPFILE)
423 # include dependencies file
424 -include $(DEPFILE)