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