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.
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'.
35 # # to explicitly compile for AmigaOS3
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
)
50 ifeq ($(shell uname
-m
), ppc
)
55 # if no host is identifed (no uname tool)
56 # we assume a AmigaOS build
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
66 ifeq ($(HOST
), AmigaOS4
)
69 ifeq ($(HOST
), AmigaOS
)
72 ifeq ($(HOST
), MorphOS
)
76 # now we find out which CPU system aros will be used
77 ifeq ($(shell uname
-m
), powerpc
)
80 ifeq ($(shell uname
-m
), ppc
)
83 ifeq ($(shell uname
-m
), i386
)
86 ifeq ($(shell uname
-m
), i686
)
89 ifeq ($(shell uname
-m
), x86_64
)
100 #############################################
101 # define common commands we use in this
102 # makefile. Please note that each of them
103 # might be overridden on the commandline.
111 RMDIR
= delete
force all
113 CHMOD
= protect FLAGS
=rwed
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
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
149 # OPTFLAGS are disabled by DEBUG normally!
151 # ignored warnings are:
152 # none - because we want to compile with -Wall all the time
159 DEPFILE
= Makefile.dep
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
168 DEBUGSYM
= -g
-gstabs
169 CFLAGS
= -I.
-I..
/include $(CPU
) $(WARN
) $(OPTFLAGS
) $(DEBUG
) $(DEBUGSYM
) $(USER_CFLAGS
)
170 LDFLAGS
= $(CPU
) $(DEBUGSYM
) -nostartfiles
182 # different options per target OS
185 ##############################
188 # Compiler/link/strip commands
189 ifneq ($(HOST
), AmigaOS4
)
191 STRIP
= ppc-amigaos-strip
192 OBJDUMP
= ppc-amigaos-objdump
195 # Compiler/Linker flags
198 WARN
+= -Wdeclaration-after-statement
-Wdisabled-optimization
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
210 ##############################
213 # Compiler/link/strip commands
214 ifneq ($(HOST
), AmigaOS
)
215 CC
= m68k-amigaos-gcc
216 STRIP
= m68k-amigaos-strip
217 OBJDUMP
= m68k-amigaos-objdump
220 # Compiler/Linker flags
221 CPU
= -m68020-60
-msoft-float
-D__amigaos3__
229 ##############################
232 # Compiler/link/strip commands
233 ifneq ($(HOST
), MorphOS
)
235 STRIP
= ppc-morphos-strip
236 OBJDUMP
= ppc-morphos-objdump
239 # Compiler/Linker flags
245 # additional object files required
246 OBJS
+= stubs-morphos.o
249 ifeq ($(OS
), aros-i386
)
251 ##############################
254 ifneq ($(HOST
), AROS
)
256 STRIP
= i386-aros-strip
257 OBJDUMP
= i386-aros-objdump
260 # Compiler/Linker flags
261 OPTFLAGS
= -O2
-fomit-frame-pointer
262 CFLAGS
+= -Wno-pointer-sign
266 ifeq ($(OS
), aros-ppc
)
268 ##############################
271 ifneq ($(HOST
), AROS
)
273 STRIP
= ppc-aros-strip
274 OBJDUMP
= ppc-aros-objdump
277 # Compiler/Linker flags
278 OPTFLAGS
= -O2
-fomit-frame-pointer
279 CFLAGS
+= -Wno-pointer-sign
283 ifeq ($(OS
), aros-x86_64
)
285 ##############################
288 ifneq ($(HOST
), AROS
)
290 STRIP
= x86_64-aros-strip
291 OBJDUMP
= x86_64-aros-objdump
294 # Compiler/Linker flags
295 OPTFLAGS
= -O2
-fomit-frame-pointer
296 CFLAGS
+= -Wno-pointer-sign
306 ###########################################################################
307 # Here starts all stuff that is common for all target platforms and
312 ifeq ($(wildcard $(DEPFILE
)),$(DEPFILE
))
313 # great, we have a dependecies file, let's make our target
314 all: $(BINDIR
) $(OBJDIR
) $(TARGET
)
316 # no dependecies, create it and then call make again
318 @make
--no-print-directory
all
321 # for making a release we compile ALL target with no debug
333 make OS
=aros-i386
clean
334 make OS
=aros-i386 DEBUG
=
336 make OS
=aros-ppc
clean
337 make OS
=aros-ppc DEBUG
=
339 make OS
=aros-x86_64
clean
340 make OS
=aros-x86_64 DEBUG
=
342 # make the object directories
347 # make the object directories
352 # for compiling single .c files
355 @
$(CC
) $(CFLAGS
) -c
$< -o
$@
357 # for linking the target
358 $(TARGET
): $(addprefix $(OBJDIR
)/,$(OBJS
))
360 @
$(CC
) $(LDFLAGS
) -o
$@.debug
$(addprefix $(OBJDIR
)/,$(OBJS
)) $(LDLIBS
) -Wl
,--cref
,-M
,-Map
=$@.map
362 @
$(STRIP
) --preserve-dates
-R.comment
-R.sdata2
-S
-o
$@
$@.debug
365 # for creating a .dump file
368 -$(OBJDUMP
) --section-headers
--all-headers
--reloc
--disassemble-all
$(TARGET
).debug
> $(TARGET
).dump
373 -$(RM
) $(TARGET
) $(TARGET
).debug
$(TARGET
).map
$(addprefix $(OBJDIR
)/,$(OBJS
))
375 # clean all including .obj directory
380 # clean all stuff, including our autotools
385 #install the newly built library to LIBS:
388 -$(CP
) $(TARGET
) LIBS
:
390 ## DEPENDENCY GENERATION ##############
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