grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / codesets / src / Makefile
blob6b149925d7142e61cbd4e74d4b4db223d3edd34c
1 #/***************************************************************************
3 # codesets.library - Amiga shared library for handling different codesets
4 # Copyright (C) 2001-2005 by Alfonso [alfie] Ranieri <alforan@tin.it>.
5 # Copyright (C) 2005-2014 codesets.library 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 # codesets.library project: http://sourceforge.net/projects/codesetslib/
19 # Most of the code included in this file was relicensed from GPL to LGPL
20 # from the source code of SimpleMail (http://www.sf.net/projects/simplemail)
21 # with full permissions by its authors.
23 # $Id$
25 #***************************************************************************/
27 ###########################################################################
28 # This makefile is a very generic one. It tries to identify both, the host
29 # and the target operating system for which YAM should be compiled.
30 # However, this auto-detection can be easily overridden by directly
31 # specifying an option on the commandline while calling 'make'.
33 # Example:
35 # # to explicitly compile for AmigaOS3
36 # > make OS=os3
38 # # to compile for AmigaOS4 but without debugging
39 # > make OS=os4 DEBUG=
42 #############################################
43 # find out the HOST operating system
44 # on which this makefile is run
45 HOST ?= $(shell uname)
46 ifeq ($(HOST), AmigaOS)
47 ifeq ($(shell uname -m), powerpc)
48 HOST = AmigaOS4
49 endif
50 ifeq ($(shell uname -m), ppc)
51 HOST = AmigaOS4
52 endif
53 endif
55 # if no host is identifed (no uname tool)
56 # we assume a AmigaOS build
57 ifeq ($(HOST),)
58 HOST = AmigaOS
59 endif
61 #############################################
62 # now we find out the target OS for
63 # which we are going to compile YAM in case
64 # the caller didn't yet define OS himself
65 ifndef (OS)
66 ifeq ($(HOST), AmigaOS4)
67 OS = os4
68 else
69 ifeq ($(HOST), AmigaOS)
70 OS = os3
71 else
72 ifeq ($(HOST), MorphOS)
73 OS = mos
74 else
75 ifeq ($(HOST), AROS)
76 # now we find out which CPU system aros will be used
77 ifeq ($(shell uname -m), powerpc)
78 OS = aros-ppc
79 endif
80 ifeq ($(shell uname -m), ppc)
81 OS = aros-ppc
82 endif
83 ifeq ($(shell uname -m), i386)
84 OS = aros-i386
85 endif
86 ifeq ($(shell uname -m), i686)
87 OS = aros-i686
88 endif
89 ifeq ($(shell uname -m), x86_64)
90 OS = aros-x86_64
91 endif
92 else
93 OS = os4
94 endif
95 endif
96 endif
97 endif
98 endif
100 #############################################
101 # define common commands we use in this
102 # makefile. Please note that each of them
103 # might be overridden on the commandline.
105 # common commands
106 FLEX = flex
107 FC = flexcat
108 EXPR = expr
109 DATE = date
110 RM = delete force
111 RMDIR = delete force all
112 MKDIR = makedir
113 CHMOD = protect FLAGS=rwed
114 SED = sed
115 CP = copy
116 CC = gcc
117 STRIP = strip
118 OBJDUMP = objdump
120 # path definitions
121 CDUP = /
122 CDTHIS=
124 # override some variables for non-native builds (cross-compiler)
125 ifneq ($(HOST), AmigaOS)
126 ifneq ($(HOST), AmigaOS4)
127 ifneq ($(HOST), MorphOS)
129 # when we end up here this is either a unix or Aros host
130 # so lets use unix kind of commands
131 RM = rm -f
132 RMDIR = rm -rf
133 MKDIR = mkdir -p
134 CHMOD = chmod 755
135 CP = cp -f
137 CDUP = ../
138 CDTHIS= ./
140 endif
141 endif
142 endif
144 ###########################################################################
145 # CPU and DEBUG can be defined outside, defaults to above
146 # using e.g. "make DEBUG= CPU=-mcpu=603e" produces optimized non-debug
147 # PPC-603e version
149 # OPTFLAGS are disabled by DEBUG normally!
151 # ignored warnings are:
152 # none - because we want to compile with -Wall all the time
154 # Common Directories
155 PREFIX = $(CDTHIS)
156 OBJDIR = .obj_$(OS)
157 BINDIR = bin_$(OS)
158 VPATH = $(OBJDIR)
159 DEPFILE = Makefile.dep
161 # target definition
162 TARGET = $(BINDIR)/codesets.library
164 # Common compiler/linker flags
165 WARN = -W -Wall -Wwrite-strings -Wpointer-arith -Wsign-compare
166 OPTFLAGS = -O3 -fomit-frame-pointer
167 DEBUG = -DDEBUG -O0
168 DEBUGSYM = -g -gstabs
169 CFLAGS = -I. -I../include $(CPU) $(WARN) $(OPTFLAGS) $(DEBUG) $(DEBUGSYM) $(USER_CFLAGS)
170 LDFLAGS = $(CPU) $(DEBUGSYM) -nostartfiles
171 LDLIBS =
173 OBJS = libinit.o \
174 init.o \
175 utils.o \
176 base64.o \
177 convertUTF.o \
178 codesets.o \
179 codepages.o \
180 debug.o
182 # different options per target OS
183 ifeq ($(OS), os4)
185 ##############################
186 # AmigaOS4
188 # Compiler/link/strip commands
189 ifneq ($(HOST), AmigaOS4)
190 CC = ppc-amigaos-gcc
191 STRIP = ppc-amigaos-strip
192 OBJDUMP = ppc-amigaos-objdump
193 endif
195 # Compiler/Linker flags
196 CRT = newlib
197 CPU = -mcpu=powerpc
198 WARN += -Wdeclaration-after-statement -Wdisabled-optimization
199 REDEFINE =
200 CFLAGS += -mcrt=$(CRT) -D__USE_INLINE__ -D__NEW_TIMEVAL_DEFINITION_USED__ \
201 $(REDEFINE) -Wa,-mregnames
202 LDFLAGS += -mcrt=$(CRT)
204 # additional object files required
205 OBJS += codesets_68k.o
207 else
208 ifeq ($(OS), os3)
210 ##############################
211 # AmigaOS3
213 # Compiler/link/strip commands
214 ifneq ($(HOST), AmigaOS)
215 CC = m68k-amigaos-gcc
216 STRIP = m68k-amigaos-strip
217 OBJDUMP = m68k-amigaos-objdump
218 endif
220 # Compiler/Linker flags
221 CPU = -m68020-60 -msoft-float -D__amigaos3__
222 CFLAGS += -noixemul
223 LDFLAGS += -noixemul
224 LDLIBS += -ldebug
226 else
227 ifeq ($(OS), mos)
229 ##############################
230 # MorphOS
232 # Compiler/link/strip commands
233 ifneq ($(HOST), MorphOS)
234 CC = ppc-morphos-gcc
235 STRIP = ppc-morphos-strip
236 OBJDUMP = ppc-morphos-objdump
237 endif
239 # Compiler/Linker flags
240 CPU = -mcpu=powerpc
241 CFLAGS += -noixemul
242 LDFLAGS += -noixemul
243 LDLIBS += -ldebug
245 # additional object files required
246 OBJS += stubs-morphos.o
248 else
249 ifeq ($(OS), aros-i386)
251 ##############################
252 # AROS (i386)
254 ifneq ($(HOST), AROS)
255 CC = i386-aros-gcc
256 STRIP = i386-aros-strip
257 OBJDUMP = i386-aros-objdump
258 endif
260 # Compiler/Linker flags
261 OPTFLAGS = -O2 -fomit-frame-pointer
262 CFLAGS += -Wno-pointer-sign
263 LDLIBS += -lrom
265 else
266 ifeq ($(OS), aros-ppc)
268 ##############################
269 # AROS (PPC)
271 ifneq ($(HOST), AROS)
272 CC = ppc-aros-gcc
273 STRIP = ppc-aros-strip
274 OBJDUMP = ppc-aros-objdump
275 endif
277 # Compiler/Linker flags
278 OPTFLAGS = -O2 -fomit-frame-pointer
279 CFLAGS += -Wno-pointer-sign
280 LDLIBS += -lrom
282 else
283 ifeq ($(OS), aros-x86_64)
285 ##############################
286 # AROS (x86_64)
288 ifneq ($(HOST), AROS)
289 CC = x86_64-aros-gcc
290 STRIP = x86_64-aros-strip
291 OBJDUMP = x86_64-aros-objdump
292 endif
294 # Compiler/Linker flags
295 OPTFLAGS = -O2 -fomit-frame-pointer
296 CFLAGS += -Wno-pointer-sign
297 LDLIBS += -lrom
299 endif
300 endif
301 endif
302 endif
303 endif
304 endif
306 ###########################################################################
307 # Here starts all stuff that is common for all target platforms and
308 # hosts.
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) $(TARGET)
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 object directories
348 $(BINDIR):
349 @echo " MK $@"
350 @$(MKDIR) $(BINDIR)
352 # for compiling single .c files
353 $(OBJDIR)/%.o: %.c
354 @echo " CC $<"
355 @$(CC) $(CFLAGS) -c $< -o $@
357 # for linking the target
358 $(TARGET): $(addprefix $(OBJDIR)/,$(OBJS))
359 @echo " LD $@.debug"
360 @$(CC) $(LDFLAGS) -o $@.debug $(addprefix $(OBJDIR)/,$(OBJS)) $(LDLIBS) -Wl,--cref,-M,-Map=$@.map
361 @echo " LD $@"
362 @$(STRIP) --preserve-dates -R.comment -R.sdata2 -S -o $@ $@.debug
363 @$(CHMOD) $@
365 # for creating a .dump file
366 .PHONY: dump
367 dump:
368 -$(OBJDUMP) --section-headers --all-headers --reloc --disassemble-all $(TARGET).debug > $(TARGET).dump
370 # cleanup target
371 .PHONY: clean
372 clean:
373 -$(RM) $(TARGET) $(TARGET).debug $(TARGET).map $(addprefix $(OBJDIR)/,$(OBJS))
375 # clean all including .obj directory
376 .PHONY: cleanall
377 cleanall: clean
378 -$(RMDIR) $(OBJDIR)
380 # clean all stuff, including our autotools
381 .PHONY: distclean
382 distclean: cleanall
383 -$(RMDIR) $(BINDIR)
385 #install the newly built library to LIBS:
386 .PHONY: install
387 install: all
388 -$(CP) $(TARGET) LIBS:
390 ## DEPENDENCY GENERATION ##############
392 .PHONY: depend
393 depend:
394 @echo " MK $(DEPFILE)"
395 @echo "# AUTOGENERATED! DO NOT EDIT!!!" >$(DEPFILE)
396 @$(CC) -MM -MG $(CFLAGS) $(wildcard *.c) >>$(DEPFILE)
397 @echo "# AUTOGENERATED! DO NOT EDIT!!!" >>$(DEPFILE)
398 @$(SED) -i 's,^\(.*\)\.o:,$$\(OBJDIR\)/\1.o:,g' $(DEPFILE)
400 # include dependencies file
401 -include $(DEPFILE)