revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / codesets / libcodesets / Makefile
blob26ad9f20629ba3d6e1266a2d531b10c0f4b57b61
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'.
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 CP = copy
115 CC = gcc
116 STRIP = strip
117 OBJDUMP = objdump
118 AR = ar
119 RANLIB = ranlib
121 # path definitions
122 CDUP = /
123 CDTHIS=
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
132 RM = rm -f
133 RMDIR = rm -rf
134 MKDIR = mkdir -p
135 CHMOD = chmod 755
136 CP = cp -f
138 CDUP = ../
139 CDTHIS= ./
141 endif
142 endif
143 endif
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
148 # PPC-603e version
150 # OPTFLAGS are disabled by DEBUG normally!
152 # ignored warnings are:
153 # none - because we want to compile with -Wall all the time
155 # Common Directories
156 PREFIX = $(CDTHIS)
157 OBJDIR = .obj_$(OS)
158 BINDIR = bin_$(OS)
159 VPATH = $(OBJDIR)
161 # target definition
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
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 # different options per target OS
174 ifeq ($(OS), os4)
176 ##############################
177 # AmigaOS4
179 # Compiler/link/strip commands
180 ifneq ($(HOST), AmigaOS4)
181 CC = ppc-amigaos-gcc
182 STRIP = ppc-amigaos-strip
183 OBJDUMP = ppc-amigaos-objdump
184 AR = ppc-amigaos-ar
185 RANLIB = ppc-amigaos-ranlib
186 endif
188 # Compiler/Linker flags
189 CRT = newlib
190 CPU = -mcpu=powerpc
191 WARN += -Wdeclaration-after-statement -Wdisabled-optimization
192 REDEFINE =
193 CFLAGS += -mcrt=$(CRT) -D__USE_INLINE__ -D__NEW_TIMEVAL_DEFINITION_USED__ \
194 $(REDEFINE) -Wa,-mregnames
195 LDFLAGS += -mcrt=$(CRT)
197 else
198 ifeq ($(OS), os3)
200 ##############################
201 # AmigaOS3
203 # Compiler/link/strip commands
204 ifneq ($(HOST), AmigaOS)
205 CC = m68k-amigaos-gcc
206 STRIP = m68k-amigaos-strip
207 OBJDUMP = m68k-amigaos-objdump
208 AR = m68k-amigaos-ar
209 RANLIB = m68k-amigaos-ranlib
210 endif
212 # Compiler/Linker flags
213 CPU = -m68020-60 -msoft-float
214 CFLAGS += -noixemul
215 LDFLAGS += -noixemul
216 LDLIBS += -ldebug
218 else
219 ifeq ($(OS), mos)
221 ##############################
222 # MorphOS
224 # Compiler/link/strip commands
225 ifneq ($(HOST), MorphOS)
226 CC = ppc-morphos-gcc
227 STRIP = ppc-morphos-strip
228 OBJDUMP = ppc-morphos-objdump
229 AR = ppc-morphos-ar
230 RANLIB = ppc-morphos-ranlib
231 endif
233 # Compiler/Linker flags
234 CPU = -mcpu=powerpc
235 CFLAGS += -noixemul
236 LDFLAGS += -noixemul
237 LDLIBS += -ldebug
239 else
240 ifeq ($(OS), aros-i386)
242 ##############################
243 # AROS (i386)
245 ifneq ($(HOST), AROS)
246 CC = i386-aros-gcc
247 STRIP = i386-aros-strip
248 OBJDUMP = i386-aros-objdump
249 AR = i386-aros-ar
250 RANLIB = i386-aros-ranlib
252 endif
254 OBJS = autoinit-aros.o
256 # Compiler/Linker flags
257 CFLAGS += -Wno-pointer-sign
258 LDLIBS += -lrom
260 else
261 ifeq ($(OS), aros-ppc)
263 ##############################
264 # AROS (PPC)
266 ifneq ($(HOST), AROS)
267 CC = ppc-aros-gcc
268 STRIP = ppc-aros-strip
269 OBJDUMP = ppc-aros-objdump
270 AR = ppc-aros-ar
271 RANLIB = ppc-aros-ranlib
272 endif
274 # Compiler/Linker flags
275 CFLAGS += -Wno-pointer-sign
276 LDLIBS += -lrom
278 else
279 ifeq ($(OS), aros-x86_64)
281 ##############################
282 # AROS (x86_64)
284 ifneq ($(HOST), AROS)
285 CC = x86_64-aros-gcc
286 STRIP = x86_64-aros-strip
287 OBJDUMP = x86_64-aros-objdump
288 AR = x86_64-ar
289 RANLIB = x86_64-ranlib
290 endif
292 # Compiler/Linker flags
293 CFLAGS += -Wno-pointer-sign
294 LDLIBS += -lrom
296 endif
297 endif
298 endif
299 endif
300 endif
301 endif
303 ###########################################################################
304 # Here starts all stuff that is common for all target platforms and
305 # hosts.
307 # TODO: add stubs
308 # OBJS +=
310 # main target
311 .PHONY: all
312 all: $(BINDIR) $(OBJDIR) $(TARGET)
314 # make the object directories
315 $(OBJDIR):
316 @echo " MK $@"
317 @$(MKDIR) $(OBJDIR)
319 # make the object directories
320 $(BINDIR):
321 @echo " MK $@"
322 @$(MKDIR) $(BINDIR)
324 # for compiling single .c files
325 %.o: %.c
326 @echo " CC $<"
327 @$(CC) $(CFLAGS) -c $< -o $(OBJDIR)/$@
329 # for linking the target
330 $(TARGET): $(OBJS)
331 @echo " AR $@"
332 @$(AR) -r $@ $(addprefix $(OBJDIR)/,$(OBJS))
333 @$(RANLIB) $@
335 # for creating a .dump file
336 .PHONY: dump
337 dump:
338 -$(OBJDUMP) --section-headers --all-headers --reloc --disassemble-all $(TARGET).debug > $(TARGET).dump
340 # cleanup target
341 .PHONY: clean
342 clean:
343 -$(RM) $(TARGET) $(TARGET).debug $(TARGET).map $(addprefix $(OBJDIR)/,$(OBJS)) $(M68KSTUBS)
345 # clean all including .obj directory
346 .PHONY: cleanall
347 cleanall: clean
348 -$(RMDIR) $(OBJDIR)
350 # clean all stuff, including our autotools
351 .PHONY: distclean
352 distclean: cleanall
353 -$(RMDIR) $(BINDIR)
355 ## DEPENDENCY GENERATION ##############
357 Makefile.dep: ;
358 @echo "WARNING: Makefile.dep missing. Please run 'make depend'"
360 .PHONY: depend
361 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