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: codesets.c 92 2007-12-18 11:37:55Z damato $
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
125 # override some variables for non-native builds (cross-compiler)
126 ifneq ($(HOST
), AmigaOS
)
127 ifneq ($(HOST
), AmigaOS4
)
128 ifneq ($(HOST
), MorphOS
)
130 # when we end up here this is either a unix or Aros host
131 # so lets use unix kind of commands
145 ###########################################################################
146 # CPU and DEBUG can be defined outside, defaults to above
147 # using e.g. "make DEBUG= CPU=-mcpu=603e" produces optimized non-debug
150 # OPTFLAGS are disabled by DEBUG normally!
152 # ignored warnings are:
153 # none - because we want to compile with -Wall all the time
162 TARGET
= $(BINDIR
)/libcodesets.a
164 # Common compiler/linker flags
165 WARN
= -W
-Wall
-Wwrite-strings
-Wpointer-arith
-Wsign-compare
166 OPTFLAGS
= -O3
-fomit-frame-pointer
-funroll-loops
168 DEBUGSYM
= -g
-gstabs
169 CFLAGS
= -I.
-I..
/include $(CPU
) $(WARN
) $(OPTFLAGS
) $(DEBUG
) $(DEBUGSYM
) $(USER_CFLAGS
)
170 LDFLAGS
= $(CPU
) $(DEBUGSYM
) -nostartfiles
173 # different options per target OS
176 ##############################
179 # Compiler/link/strip commands
180 ifneq ($(HOST
), AmigaOS4
)
182 STRIP
= ppc-amigaos-strip
183 OBJDUMP
= ppc-amigaos-objdump
185 RANLIB
= ppc-amigaos-ranlib
188 # Compiler/Linker flags
191 WARN
+= -Wdeclaration-after-statement
-Wdisabled-optimization
193 CFLAGS
+= -mcrt
=$(CRT
) -D__USE_INLINE__
-D__NEW_TIMEVAL_DEFINITION_USED__ \
194 $(REDEFINE
) -Wa
,-mregnames
195 LDFLAGS
+= -mcrt
=$(CRT
)
200 ##############################
203 # Compiler/link/strip commands
204 ifneq ($(HOST
), AmigaOS
)
205 CC
= m68k-amigaos-gcc
206 STRIP
= m68k-amigaos-strip
207 OBJDUMP
= m68k-amigaos-objdump
209 RANLIB
= m68k-amigaos-ranlib
212 # Compiler/Linker flags
213 CPU
= -m68020-60
-msoft-float
221 ##############################
224 # Compiler/link/strip commands
225 ifneq ($(HOST
), MorphOS
)
227 STRIP
= ppc-morphos-strip
228 OBJDUMP
= ppc-morphos-objdump
230 RANLIB
= ppc-morphos-ranlib
233 # Compiler/Linker flags
240 ifeq ($(OS
), aros-i386
)
242 ##############################
245 ifneq ($(HOST
), AROS
)
247 STRIP
= i386-aros-strip
248 OBJDUMP
= i386-aros-objdump
250 RANLIB
= i386-aros-ranlib
254 OBJS
= autoinit-aros.o
256 # Compiler/Linker flags
257 CFLAGS
+= -Wno-pointer-sign
261 ifeq ($(OS
), aros-ppc
)
263 ##############################
266 ifneq ($(HOST
), AROS
)
268 STRIP
= ppc-aros-strip
269 OBJDUMP
= ppc-aros-objdump
271 RANLIB
= ppc-aros-ranlib
274 # Compiler/Linker flags
275 CFLAGS
+= -Wno-pointer-sign
279 ifeq ($(OS
), aros-x86_64
)
281 ##############################
284 ifneq ($(HOST
), AROS
)
286 STRIP
= x86_64-aros-strip
287 OBJDUMP
= x86_64-aros-objdump
289 RANLIB
= x86_64-ranlib
292 # Compiler/Linker flags
293 CFLAGS
+= -Wno-pointer-sign
303 ###########################################################################
304 # Here starts all stuff that is common for all target platforms and
312 all: $(BINDIR
) $(OBJDIR
) $(TARGET
)
314 # make the object directories
319 # make the object directories
324 # for compiling single .c files
327 @
$(CC
) $(CFLAGS
) -c
$< -o
$(OBJDIR
)/$@
329 # for linking the target
332 @
$(AR
) -r
$@
$(addprefix $(OBJDIR
)/,$(OBJS
))
335 # for creating a .dump file
338 -$(OBJDUMP
) --section-headers
--all-headers
--reloc
--disassemble-all
$(TARGET
).debug
> $(TARGET
).dump
343 -$(RM
) $(TARGET
) $(TARGET
).debug
$(TARGET
).map
$(addprefix $(OBJDIR
)/,$(OBJS
)) $(M68KSTUBS
)
345 # clean all including .obj directory
350 # clean all stuff, including our autotools
355 ## DEPENDENCY GENERATION ##############
358 @echo
"WARNING: Makefile.dep missing. Please run 'make depend'"
362 @echo
" MK Makefile.dep"
363 @echo
"# AUTOGENERATED! DO NOT EDIT!!!" >Makefile.dep
364 @
$(CC
) -MM
$(CFLAGS
) $(patsubst %.o
,%.c
, $(OBJS
)) >>Makefile.dep
365 @echo
"# AUTOGENERATED! DO NOT EDIT!!!" >>Makefile.dep
367 ## DEPENDENCY INCLUDE #################
369 -include Makefile.dep