revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / codesets / developer / examples / Makefile
blob146122aed1230de2e2f4b9daccc8a0fdf567bfc5
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 CC = gcc
115 STRIP = strip
116 OBJDUMP = objdump
118 # path definitions
119 CDUP = /
120 CDTHIS=
122 # override some variables for non-native builds (cross-compiler)
123 ifneq ($(HOST), AmigaOS)
124 ifneq ($(HOST), AmigaOS4)
125 ifneq ($(HOST), MorphOS)
127 # when we end up here this is either a unix or Aros host
128 # so lets use unix kind of commands
129 RM = rm -f
130 RMDIR = rm -rf
131 MKDIR = mkdir -p
132 CHMOD = chmod 755
134 CDUP = ../
135 CDTHIS= ./
137 endif
138 endif
139 endif
141 ###########################################################################
142 # CPU and DEBUG can be defined outside, defaults to above
143 # using e.g. "make DEBUG= CPU=-mcpu=603e" produces optimized non-debug
144 # PPC-603e version
146 # OPTFLAGS are disabled by DEBUG normally!
148 # ignored warnings are:
149 # none - because we want to compile with -Wall all the time
151 # Common Directories
152 PREFIX = $(CDTHIS)
153 OBJDIR = .obj_$(OS)
154 BINDIR = bin_$(OS)
155 VPATH = $(OBJDIR)
157 # target definition
158 TARGET = $(BINDIR)/b64d \
159 $(BINDIR)/b64e \
160 $(BINDIR)/UTF8ToStrHook \
161 $(BINDIR)/DetectCodeset \
162 $(BINDIR)/demo1 \
163 $(BINDIR)/Convert
165 # Common compiler/linker flags
166 WARN = -W -Wall -Wwrite-strings -Wpointer-arith -Wsign-compare
167 OPTFLAGS = -O3 -fomit-frame-pointer -funroll-loops
168 DEBUG = -DDEBUG -O0
169 DEBUGSYM = -g -gstabs
170 CFLAGS = -I. -I../include -I../../include $(CPU) $(WARN) $(OPTFLAGS) $(DEBUG) $(DEBUGSYM) $(USER_CFLAGS)
171 LDFLAGS = $(CPU) $(DEBUGSYM)
172 LDLIBS =
174 # different options per target OS
175 ifeq ($(OS), os4)
177 ##############################
178 # AmigaOS4
180 # Compiler/link/strip commands
181 ifneq ($(HOST), AmigaOS4)
182 CC = ppc-amigaos-gcc
183 STRIP = ppc-amigaos-strip
184 OBJDUMP = ppc-amigaos-objdump
185 endif
187 # Compiler/Linker flags
188 CRT = newlib
189 CPU = -mcpu=powerpc
190 WARN += -Wdeclaration-after-statement -Wdisabled-optimization
191 REDEFINE =
192 CFLAGS += -mcrt=$(CRT) -D__USE_INLINE__ -D__NEW_TIMEVAL_DEFINITION_USED__ \
193 $(REDEFINE) -Wa,-mregnames
194 LDFLAGS += -mcrt=$(CRT)
196 else
197 ifeq ($(OS), os3)
199 ##############################
200 # AmigaOS3
202 # Compiler/link/strip commands
203 ifneq ($(HOST), AmigaOS)
204 CC = m68k-amigaos-gcc
205 STRIP = m68k-amigaos-strip
206 OBJDUMP = m68k-amigaos-objdump
207 endif
209 # Compiler/Linker flags
210 CPU = -m68020-60 -msoft-float
211 CFLAGS += -noixemul
212 LDFLAGS += -noixemul
213 LDLIBS += -ldebug -lmui
214 NOINLINE = -DNO_INLINE_STDARG
216 else
217 ifeq ($(OS), mos)
219 ##############################
220 # MorphOS
222 # Compiler/link/strip commands
223 ifneq ($(HOST), MorphOS)
224 CC = ppc-morphos-gcc
225 STRIP = ppc-morphos-strip
226 OBJDUMP = ppc-morphos-objdump
227 endif
229 # Compiler/Linker flags
230 CPU = -mcpu=powerpc
231 CFLAGS += -noixemul -DUSE_INLINE_STDARG
232 LDFLAGS += -noixemul
233 LDLIBS += -ldebug
234 NOINLINE = -DNO_PPCINLINE_STDARG
236 else
237 ifeq ($(OS), aros-i386)
239 ##############################
240 # AROS (i386)
242 ifneq ($(HOST), AROS)
243 CC = i386-aros-gcc
244 STRIP = i386-aros-strip
245 OBJDUMP = i386-aros-objdump
246 endif
248 # Compiler/Linker flags
249 OPTFLAGS = -O2 -fomit-frame-pointer -funroll-loops
250 CFLAGS += -Wno-pointer-sign
251 LDLIBS += -lmui
253 else
254 ifeq ($(OS), aros-ppc)
256 ##############################
257 # AROS (PPC)
259 ifneq ($(HOST), AROS)
260 CC = ppc-aros-gcc
261 STRIP = ppc-aros-strip
262 OBJDUMP = ppc-aros-objdump
263 endif
265 # Compiler/Linker flags
266 OPTFLAGS = -O2 -fomit-frame-pointer -funroll-loops
267 CFLAGS += -Wno-pointer-sign
268 LDLIBS += -lmui
270 else
271 ifeq ($(OS), aros-x86_64)
273 ##############################
274 # AROS (x86_64)
276 ifneq ($(HOST), AROS)
277 CC = x86_64-aros-gcc
278 STRIP = x86_64-aros-strip
279 OBJDUMP = x86_64-aros-objdump
280 endif
282 # Compiler/Linker flags
283 OPTFLAGS = -O2 -fomit-frame-pointer -funroll-loops
284 CFLAGS += -Wno-pointer-sign
285 LDLIBS += -lmui
287 endif
288 endif
289 endif
290 endif
291 endif
292 endif
294 ###########################################################################
295 # Here starts all stuff that is common for all target platforms and
296 # hosts.
298 # main target
299 .PHONY: all
300 all: $(BINDIR) $(OBJDIR) $(TARGET)
302 # for making a release we compile ALL target with no debug
303 release:
304 @echo " CC $<"
305 make OS=os4 clean
306 make OS=os4 DEBUG=
307 @echo " CC $<"
308 make OS=os3 clean
309 make OS=os3 DEBUG=
310 @echo " CC $<"
311 make OS=mos clean
312 make OS=mos DEBUG=
313 @echo " CC $<"
314 make OS=aros-i386 clean
315 make OS=aros-i386 DEBUG=
316 @echo " CC $<"
317 make OS=aros-ppc clean
318 make OS=aros-ppc DEBUG=
319 @echo " CC $<"
320 make OS=aros-x86_64 clean
321 make OS=aros-x86_64 DEBUG=
323 # make the object directories
324 $(OBJDIR):
325 @echo " MK $@"
326 @$(MKDIR) $(OBJDIR)
328 # make the object directories
329 $(BINDIR):
330 @echo " MK $@"
331 @$(MKDIR) $(BINDIR)
333 # for compiling single .c files
334 $(OBJDIR)/%.o: %.c
335 @echo " CC $<"
336 @$(CC) $(CFLAGS) -c $< -o $@
338 # for linking the target
339 $(BINDIR)/b64d: $(OBJDIR)/b64d.o
340 @echo " LD $@"
341 @$(CC) $(LDFLAGS) -o $@.debug $< $(LDLIBS)
342 @$(STRIP) --preserve-dates -R.comment -R.sdata2 -S -o $@ $@.debug
343 @$(CHMOD) $@
345 $(BINDIR)/b64e: $(OBJDIR)/b64e.o
346 @echo " LD $@"
347 @$(CC) $(LDFLAGS) -o $@.debug $< $(LDLIBS)
348 @$(STRIP) --preserve-dates -R.comment -R.sdata2 -S -o $@ $@.debug
349 @$(CHMOD) $@
351 $(BINDIR)/UTF8ToStrHook: $(OBJDIR)/UTF8ToStrHook.o
352 @echo " LD $@"
353 @$(CC) $(LDFLAGS) -o $@.debug $< $(LDLIBS)
354 @$(STRIP) --preserve-dates -R.comment -R.sdata2 -S -o $@ $@.debug
355 @$(CHMOD) $@
357 $(BINDIR)/DetectCodeset: $(OBJDIR)/DetectCodeset.o
358 @echo " LD $@"
359 @$(CC) $(LDFLAGS) -o $@.debug $< $(LDLIBS)
360 @$(STRIP) --preserve-dates -R.comment -R.sdata2 -S -o $@ $@.debug
362 $(BINDIR)/demo1: demo1.c vastubs.c
363 @echo " CC demo1.c"
364 @$(CC) $(CFLAGS) $(NOINLINE) -c demo1.c -o $(OBJDIR)/demo1.o
365 @echo " CC vastubs.c"
366 @$(CC) $(CFLAGS) $(NOINLINE) -c vastubs.c -o $(OBJDIR)/vastubs.o
367 @echo " LD $@"
368 @$(CC) $(LDFLAGS) -o $@.debug $(OBJDIR)/demo1.o $(OBJDIR)/vastubs.o $(LDLIBS)
369 @$(STRIP) --preserve-dates -R.comment -R.sdata2 -S -o $@ $@.debug
370 @$(CHMOD) $@
372 $(BINDIR)/Convert: $(OBJDIR)/Convert.o
373 @echo " LD $@"
374 @$(CC) $(LDFLAGS) -o $@.debug $< $(LDLIBS)
375 @$(STRIP) --preserve-dates -R.comment -R.sdata2 -S -o $@ $@.debug
376 @$(CHMOD) $@
378 # cleanup target
379 .PHONY: clean
380 clean:
381 -$(RM) $(TARGET) $(OBJDIR)/*.o
383 # clean all including .obj directory
384 .PHONY: cleanall
385 cleanall: clean
386 -$(RMDIR) $(OBJDIR)
388 # clean all stuff, including our autotools
389 .PHONY: distclean
390 distclean: cleanall
391 -$(RMDIR) $(BINDIR)