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-2009 by 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
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
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
148 # OPTFLAGS are disabled by DEBUG normally!
150 # ignored warnings are:
151 # none - because we want to compile with -Wall all the time
160 TARGET
= $(BINDIR
)/codesets.library
162 # Common compiler/linker flags
163 WARN
= -W
-Wall
-Wwrite-strings
-Wpointer-arith
-Wsign-compare
164 OPTFLAGS
= -O3
-fomit-frame-pointer
-funroll-loops
167 CFLAGS
= -I.
-I..
/include $(CPU
) $(WARN
) $(OPTFLAGS
) $(DEBUG
) $(DEBUGSYM
) $(USER_CFLAGS
)
168 LDFLAGS
= $(CPU
) $(DEBUGSYM
) -nostartfiles
171 # different options per target OS
174 ##############################
177 # Compiler/link/strip commands
178 ifneq ($(HOST
), AmigaOS4
)
180 STRIP
= ppc-amigaos-strip
181 OBJDUMP
= ppc-amigaos-objdump
184 # Compiler/Linker flags
187 WARN
+= -Wdeclaration-after-statement
-Wdisabled-optimization
189 CFLAGS
+= -mcrt
=$(CRT
) -D__USE_INLINE__
-D__NEW_TIMEVAL_DEFINITION_USED__ \
190 $(REDEFINE
) -Wa
,-mregnames
191 LDFLAGS
+= -mcrt
=$(CRT
)
193 # additional object files required
194 OBJS
= stubs-amigaos4.o
195 M68KSTUBS
= $(OBJDIR
)/codesets_68k.o
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
210 # Compiler/Linker flags
211 CPU
= -m68020-60
-msoft-float
219 ##############################
222 # Compiler/link/strip commands
223 ifneq ($(HOST
), MorphOS
)
225 STRIP
= ppc-morphos-strip
226 OBJDUMP
= ppc-morphos-objdump
229 # Compiler/Linker flags
235 OBJS
= stubs-morphos.o
238 ifeq ($(OS
), aros-i386
)
240 ##############################
243 ifneq ($(HOST
), AROS
)
245 STRIP
= i386-aros-strip
246 OBJDUMP
= i386-aros-objdump
249 # Compiler/Linker flags
250 CFLAGS
+= -Wno-pointer-sign
254 ifeq ($(OS
), aros-ppc
)
256 ##############################
259 ifneq ($(HOST
), AROS
)
261 STRIP
= ppc-aros-strip
262 OBJDUMP
= ppc-aros-objdump
265 # Compiler/Linker flags
266 CFLAGS
+= -Wno-pointer-sign
270 ifeq ($(OS
), aros-x86_64
)
272 ##############################
275 ifneq ($(HOST
), AROS
)
277 STRIP
= x86_64-aros-strip
278 OBJDUMP
= x86_64-aros-objdump
281 # Compiler/Linker flags
282 CFLAGS
+= -Wno-pointer-sign
292 ###########################################################################
293 # Here starts all stuff that is common for all target platforms and
307 all: $(BINDIR
) $(OBJDIR
) $(TARGET
)
309 # make the object directories
314 # make the object directories
319 # for compiling single .c files
322 @
$(CC
) $(CFLAGS
) -c
$< -o
$(OBJDIR
)/$@
324 # for linking the target
325 $(TARGET
): $(M68KSTUBS
) $(OBJS
)
327 @
$(CC
) $(LDFLAGS
) -o
$@.debug
$(addprefix $(OBJDIR
)/,$(OBJS
)) $(M68KSTUBS
) $(LDLIBS
) -Wl
,--cref
,-M
,-Map
=$@.map
329 @
$(STRIP
) --preserve-dates
-R.comment
-R.sdata2
-S
-o
$@
$@.debug
332 # for creating a .dump file
335 -$(OBJDUMP
) --section-headers
--all-headers
--reloc
--disassemble-all
$(TARGET
).debug
> $(TARGET
).dump
340 -$(RM
) $(TARGET
) $(TARGET
).debug
$(TARGET
).map
$(addprefix $(OBJDIR
)/,$(OBJS
)) $(M68KSTUBS
)
342 # clean all including .obj directory
347 # clean all stuff, including our autotools
352 #install the newly built library to LIBS:
355 -$(CP
) $(TARGET
) LIBS
:
357 ## SPECIAL COMPILE RULES ##############
359 $(OBJDIR
)/codesets_68k.o
: ..
/include/codesets_68k.c
361 @
$(CC
) $(CFLAGS
) -c
$< -o
$@
363 ## DEPENDENCY GENERATION ##############
366 @echo
"WARNING: Makefile.dep missing. Please run 'make depend'"
370 @echo
" MK Makefile.dep"
371 @echo
"# AUTOGENERATED! DO NOT EDIT!!!" >Makefile.dep
372 @
$(CC
) -MM
$(CFLAGS
) $(patsubst %.o
,%.c
, $(OBJS
)) >>Makefile.dep
373 @echo
"# AUTOGENERATED! DO NOT EDIT!!!" >>Makefile.dep
375 ## DEPENDENCY INCLUDE #################
377 -include Makefile.dep