revert between 56095 -> 55830 in arch
[AROS.git] / tools / flexcat / src / Makefile
blob80163e5291eda0de0a1684f752ea19db35e1d2e8
1 #/***************************************************************************
3 # $Id$
5 # Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski
6 # Copyright (C) 2002-2015 FlexCat Open Source Team
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or (at
11 # your option) any later version.
13 # This program is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #***************************************************************************/
24 ###########################################################################
25 # This makefile is a very generic one. It tries to identify both, the host
26 # and the target operating system for which FlexCat should be compiled.
27 # However, this auto-detection can be easily overridden by directly
28 # specifying an option on the commandline while calling 'make'.
30 # Example:
32 # # to explicitly compile for AmigaOS3
33 # > make OS=os3
35 # # to compile for AmigaOS4 but without debugging
36 # > make OS=os4 DEBUG=
39 #############################################
40 # find out the HOST operating system
41 # on which this makefile is run
42 HOST ?= $(shell uname)
43 ifeq ($(HOST), AmigaOS)
44 ifeq ($(shell uname -m), powerpc)
45 HOST = AmigaOS4
46 endif
47 ifeq ($(shell uname -m), ppc)
48 HOST = AmigaOS4
49 endif
50 endif
52 # if no host is identifed (no uname tool)
53 # we assume a AmigaOS build
54 ifeq ($(HOST),)
55 HOST = AmigaOS
56 endif
58 #############################################
59 # now we find out the target OS for
60 # which we are going to compile YAM in case
61 # the caller didn't yet define OS himself
62 ifndef (OS)
63 ifeq ($(HOST), AmigaOS4)
64 OS = os4
65 else
66 ifeq ($(HOST), AmigaOS)
67 OS = os3
68 else
69 ifeq ($(HOST), MorphOS)
70 OS = mos
71 else
72 ifeq ($(HOST), Linux)
73 OS = unix
74 else
75 ifeq ($(HOST), Windows)
76 OS = mingw32
77 else
78 ifeq ($(HOST), AROS)
79 # now we find out which CPU system aros will be used
80 ifeq ($(shell uname -m), powerpc)
81 OS = aros-ppc
82 endif
83 ifeq ($(shell uname -m), ppc)
84 OS = aros-ppc
85 endif
86 ifeq ($(shell uname -m), i386)
87 OS = aros-i386
88 endif
89 ifeq ($(shell uname -m), i686)
90 OS = aros-i686
91 endif
92 ifeq ($(shell uname -m), x86_64)
93 OS = aros-x86_64
94 endif
95 ifeq ($(shell uname -m), arm)
96 OS = aros-arm
97 endif
98 else
99 OS = os4
100 endif
101 endif
102 endif
103 endif
104 endif
105 endif
106 endif
108 #############################################
109 # define common commands we use in this
110 # makefile. Please note that each of them
111 # might be overridden on the commandline.
113 # common commands
114 FLEXCAT = flexcat
115 EXPR = expr
116 DATE = date
117 RM = rm -f #delete force
118 RMDIR = rm -rf #delete force all
119 MKDIR = mkdir -p #makedir force
120 CHMOD = protect FLAGS=rwed
121 SED = sed
122 CP = copy
123 CC = gcc
124 STRIP = strip
125 OBJDUMP = objdump
126 MAKEINFO= makeinfo
127 TX = tx
129 # path definitions
130 CDUP = /
131 CDTHIS=
133 # override some variables for non-native builds (cross-compiler)
134 ifneq ($(HOST), AmigaOS)
135 ifneq ($(HOST), AmigaOS4)
136 ifneq ($(HOST), MorphOS)
138 # when we end up here this is either a unix or Aros host
139 # so lets use unix kind of commands
140 RM = rm -f
141 RMDIR = rm -rf
142 MKDIR = mkdir -p
143 CHMOD = chmod 755
144 CP = cp -f
146 CDUP = ../
147 CDTHIS= ./
149 endif
150 endif
152 ###########################################################################
153 # CPU and DEBUG can be defined outside, defaults to above
154 # using e.g. "make DEBUG= CPU=-mcpu=603e" produces optimized non-debug
155 # PPC-603e version
157 # OPTFLAGS are disabled by DEBUG normally!
159 # ignored warnings are:
160 # none - because we want to compile with -Wall all the time
162 # target definition
163 TARGET = $(BINDIR)/flexcat$(EXE)
165 # Common Directories
166 PREFIX = $(CDTHIS)
167 LOCALE = $(PREFIX)$(CDUP)locale
168 TOOLS = $(PREFIX)tools
169 LIB = $(PREFIX)lib/$(OS)
170 OBJDIR = .obj_$(OS)
171 DEPDIR = .dep_$(OS)
172 BINDIR = bin_$(OS)
173 VPATH = $(OBJDIR)
174 GCCVER = 4
176 # Common compiler/linker flags
177 WARN = -W -Wall -Wwrite-strings -Wpointer-arith -Wsign-compare #-Wunreachable-code
178 OPTFLAGS = -O3 -fomit-frame-pointer -fno-strict-aliasing
179 DEBUG = -DDEBUG -fno-omit-frame-pointer #-O0
180 DEBUGSYM = -g -gstabs
181 CFLAGS = -I. -I./include $(CPU) $(WARN) $(OPTFLAGS) $(DEBUG) $(DEBUGSYM)
182 LDFLAGS = $(CPU) $(DEBUGSYM)
183 LDLIBS = -L$(LIB)
185 # different options per target OS
186 ifeq ($(OS), os4)
188 ##############################
189 # AmigaOS4
191 # Compiler/link/strip commands
192 ifneq ($(HOST), AmigaOS4)
193 CC = ppc-amigaos-gcc
194 STRIP = ppc-amigaos-strip
195 OBJDUMP = ppc-amigaos-objdump
196 endif
198 # Compiler/Linker flags
199 CRT = newlib
200 CPU = -mcpu=powerpc -mstrict-align
201 WARN += -Wdeclaration-after-statement -Wdisabled-optimization -Wshadow
202 REDEFINE = -DCoerceMethod=ICoerceMethod -DDoMethod=IDoMethod \
203 -DDoSuperMethod=IDoSuperMethod -DDoSuperMethodA=IDoSuperMethodA
204 CFLAGS += -mcrt=$(CRT) -D__USE_INLINE__ -D__NEW_TIMEVAL_DEFINITION_USED__ \
205 $(REDEFINE) -Wa,-mregnames -DAMIGA
206 LDFLAGS += -mcrt=$(CRT)
207 LDLIBS += -lauto -lunix
208 CDUP = ../
209 CDTHIS = ./
211 SYSDEPOBJS = locale.o \
212 getft.o \
213 openlibs.o
215 else
216 ifeq ($(OS), os3)
218 ##############################
219 # AmigaOS3
221 # Compiler/link/strip commands
222 ifneq ($(HOST), AmigaOS)
223 CC = m68k-amigaos-gcc
224 STRIP = m68k-amigaos-strip
225 OBJDUMP = m68k-amigaos-objdump
226 endif
228 # Compiler/Linker flags
229 CPU = -m68020-60 -msoft-float
230 CFLAGS += -I./include/netinclude -DNO_INLINE_STDARG -D__amigaos3__ -DAMIGA
231 LDFLAGS += -noixemul
232 LDLIBS += -lamiga
233 GCCVER = 2
235 SYSDEPOBJS = locale.o \
236 getft.o \
237 openlibs.o \
238 strptime.o \
239 vastubs.o
241 else
242 ifeq ($(OS), mos)
244 ##############################
245 # MorphOS
247 # Compiler/link/strip commands
248 ifneq ($(HOST), MorphOS)
249 CC = ppc-morphos-gcc
250 STRIP = ppc-morphos-strip
251 OBJDUMP = ppc-morphos-objdump
252 endif
254 # Compiler/Linker flags
255 CPU = -mcpu=powerpc
256 CFLAGS += -noixemul -I./include/netinclude -DAMIGA
257 LDFLAGS += -noixemul
258 LDLIBS += -lauto -lcodesets
259 GCCVER = 2
261 SYSDEPOBJS = locale.o \
262 asprintf.o \
263 vasprintf.o \
264 openlibs.o \
265 strptime.o \
267 else
268 ifeq ($(OS), aros-i386)
270 ##############################
271 # AROS (i386)
273 ifneq ($(HOST), AROS)
274 CC = i386-aros-gcc
275 STRIP = i386-aros-strip
276 OBJDUMP = i386-aros-objdump
277 endif
279 # Compiler/Linker flags
280 OPTFLAGS = -O3 -fomit-frame-pointer
281 CFLAGS += -Wno-pointer-sign -DNO_INLINE_STDARG -D__BSD_VISIBLE=1 -DAMIGA
282 LDLIBS += -lamiga -larossupport -larosc
284 SYSDEPOBJS = locale.o \
285 getft.o \
286 asprintf.o \
287 vasprintf.o \
288 vastubs.o \
289 openlibs.o
291 else
292 ifeq ($(OS), aros-ppc)
294 ##############################
295 # AROS (PPC)
297 ifneq ($(HOST), AROS)
298 CC = ppc-aros-gcc
299 STRIP = ppc-aros-strip
300 OBJDUMP = ppc-aros-objdump
301 endif
303 # Compiler/Linker flags
304 OPTFLAGS = -O3 -fomit-frame-pointer
305 CFLAGS += -Wno-pointer-sign -DNO_INLINE_STDARG -D__BSD_VISIBLE=1 -DAMIGA
306 LDLIBS += -lamiga -larossupport -larosc
308 SYSDEPOBJS = locale.o \
309 getft.o \
310 asprintf.o \
311 vasprintf.o \
312 vastubs.o \
313 openlibs.o
315 else
316 ifeq ($(OS), aros-x86_64)
318 ##############################
319 # AROS (x86_64)
321 ifneq ($(HOST), AROS)
322 CC = x86_64-aros-gcc
323 STRIP = x86_64-aros-strip
324 OBJDUMP = x86_64-aros-objdump
325 endif
327 # Compiler/Linker flags
328 OPTFLAGS = -O3 -fomit-frame-pointer
329 CFLAGS += -Wno-pointer-sign -DNO_INLINE_STDARG -D__BSD_VISIBLE=1 -DAMIGA
330 LDLIBS += -lamiga -larossupport -larosc
332 SYSDEPOBJS = locale.o \
333 getft.o \
334 asprintf.o \
335 vasprintf.o \
336 vastubs.o \
337 openlibs.o
339 else
340 ifeq ($(OS), aros-arm)
342 ##############################
343 # AROS (arm)
345 ifneq ($(HOST), AROS)
346 CC = arm-aros-gcc
347 STRIP = arm-aros-strip
348 OBJDUMP = arm-aros-objdump
349 endif
351 # Compiler/Linker flags
352 OPTFLAGS = -O3 -fomit-frame-pointer
353 CFLAGS += -Wno-pointer-sign -DNO_INLINE_STDARG -D__BSD_VISIBLE=1 -DAMIGA
354 LDLIBS += -lamiga -larossupport -larosc
356 SYSDEPOBJS = locale.o \
357 getft.o \
358 asprintf.o \
359 vasprintf.o \
360 vastubs.o \
361 openlibs.o
363 else
364 ifeq ($(OS), mingw32)
366 ##############################
367 # Windows (mingw32)
369 ifneq ($(HOST), Windows)
370 CC = i686-w64-mingw32-gcc
371 STRIP = i686-w64-mingw32-strip
372 OBJDUMP = i686-w64-mingw32-objdump
373 endif
375 # Compiler/Linker flags
376 EXE = .exe
377 OPTFLAGS = -O3 -fomit-frame-pointer
378 CFLAGS += -I./include/mingw32
379 LDFLAGS =
380 LDLIBS += -liconv
382 SYSDEPOBJS = locale_other.o \
383 asprintf.o \
384 vasprintf.o \
385 strptime.o
387 else
388 ifeq ($(OS), unix)
390 ##############################
391 # Linux (unix)
393 ifneq ($(HOST), Linux)
394 CC = x86_64-linux-gnu-gcc
395 STRIP = x86_64-linux-gnu-strip
396 OBJDUMP = x86_64-linux-gnu-objdump
397 endif
399 # Compiler/Linker flags
400 OPTFLAGS = -O3 -fomit-frame-pointer
401 CFLAGS += -D_GNU_SOURCE
402 LDFLAGS =
404 SYSDEPOBJS = locale_other.o
406 endif
407 endif
408 endif
409 endif
410 endif
411 endif
412 endif
413 endif
414 endif
415 endif
417 ###########################################################################
418 # Here starts all stuff that is common for all target platforms and
419 # hosts.
421 CATFILES = FlexCat_cat.h \
422 FlexCat_cat_other.h \
423 locale.c \
424 locale_other.c
426 OBJS = main.o \
427 createcat.o \
428 createcatsrc.o \
429 createct.o \
430 globals.o \
431 readprefs.o \
432 scancd.o \
433 scanct.o \
434 scanpo.o \
435 showfuncs.o \
436 swapfuncs.o \
437 utils.o \
438 $(SYSDEPOBJS)
440 CATALOGS = $(patsubst %.po,%.catalog,$(wildcard locale/*.po))
442 .PHONY: all
443 all: $(OBJDIR) $(BINDIR) $(DEPDIR) $(TARGET)
445 # for making a release we compile ALL target with no debug
446 release:
447 @echo " CC $<"
448 make OS=os4 clean
449 make OS=os4 DEBUG=
450 @echo " CC $<"
451 make OS=os3 clean
452 make OS=os3 DEBUG=
453 @echo " CC $<"
454 make OS=mos clean
455 make OS=mos DEBUG=
456 @echo " CC $<"
457 make OS=aros-i386 clean
458 make OS=aros-i386 DEBUG=
459 @echo " CC $<"
460 make OS=aros-ppc clean
461 make OS=aros-ppc DEBUG=
462 @echo " CC $<"
463 make OS=aros-x86_64 clean
464 make OS=aros-x86_64 DEBUG=
465 @echo " CC $<"
466 make OS=unix clean
467 make OS=unix DEBUG=
468 @echo " CC $<"
469 make OS=mingw32 clean
470 make OS=mingw32 DEBUG=
472 # make the object directories
473 $(OBJDIR):
474 @echo " MK $@"
475 @$(MKDIR) $(OBJDIR)
477 # make the binary directory
478 $(BINDIR):
479 @echo " MK $@"
480 @$(MKDIR) $(BINDIR)
482 # make the dependency directory
483 $(DEPDIR):
484 @echo " MK $@"
485 @$(MKDIR) $(DEPDIR)
487 # for compiling single .c files
488 $(OBJDIR)/%.o: %.c
489 @echo " CC $<"
490 ifeq ($(GCCVER), 2)
491 @$(CC) -MM -MG -o $(DEPDIR)/$(subst .c,.d,$<) $(CFLAGS) $<
492 @$(SED) -i 's,^.*\.o:,$@:,g' $(DEPDIR)/$(subst .c,.d,$<)
493 else
494 @$(CC) -MM -MP -MT '$@' -MF $(DEPDIR)/$(subst .c,.d,$<) $(CFLAGS) $<
495 endif
496 @$(CC) $(CFLAGS) -c $< -o $@
498 $(TARGET): $(CATFILES) $(addprefix $(OBJDIR)/,$(OBJS))
499 @echo " LD $@.debug"
500 @$(CC) $(LDFLAGS) -o $@.debug $(addprefix $(OBJDIR)/,$(OBJS)) $(LDLIBS) -Wl,--cref,-M,-Map=$@.map
501 @echo " LD $@"
502 @$(STRIP) --preserve-dates -R.comment -R.sdata2 -S -o $@ $@.debug
503 @$(CHMOD) $@
505 locale.c: locale/FlexCat.pot sd/NoAutoC_c.sd
506 @echo " FC $@"
507 @$(FLEXCAT) locale/FlexCat.pot locale.c=sd/NoAutoC_c.sd
509 FlexCat_cat.h: locale/FlexCat.pot sd/NoAutoC_h.sd
510 @echo " FC $@"
511 @$(FLEXCAT) locale/FlexCat.pot FlexCat_cat.h=sd/NoAutoC_h.sd
513 locale_other.c: locale/FlexCat.pot sd/Hardcode_c.sd
514 @echo " FC $@"
515 @$(FLEXCAT) locale/FlexCat.pot locale_other.c=sd/Hardcode_c.sd
517 FlexCat_cat_other.h: locale/FlexCat.pot sd/Hardcode_h.sd
518 @echo " FC $@"
519 @$(FLEXCAT) locale/FlexCat.pot FlexCat_cat_other.h=sd/Hardcode_h.sd
521 locale/%.catalog: locale/%.po
522 @echo " MK $@"
523 @$(FLEXCAT) REVISION $(shell git rev-list --all --count $<) POFILE $< CATALOG $@
525 ## TRANSIFEX ##########################
527 .PHONY: txpull
528 txpull:
529 @$(TX) pull -a -f
531 .PHONY: txpush
532 txpush:
533 @$(TX) push -t
535 .IGNORE: $(CATALOGS)
536 catalogs: $(CATALOGS)
538 .PHONY: clean
539 clean:
540 -$(RM) $(addprefix $(OBJDIR)/,$(OBJS))
541 -$(RM) $(BINDIR)/$(FLEXCAT)$(EXE)
542 -$(RM) ../doc/*.guide
544 .PHONY: cleanall
545 cleanall: clean
546 -$(RM) FlexCat_cat.h
547 -$(RM) FlexCat_cat_other.h
548 -$(RM) locale.c
549 -$(RM) locale_other.c
550 -$(RM) locale/*.catalog
551 -$(RMDIR) $(OBJDIR)
553 .PHONY: doc
554 doc:
555 $(MAKEINFO) ../doc/FlexCat_german.texinfo --amiga-39 --fill-column 76 --output ../doc/FlexCat_deutsch.guide
556 $(MAKEINFO) ../doc/FlexCat_english.texinfo --amiga-39 --fill-column 76 --output ../doc/FlexCat_english.guide
557 $(MAKEINFO) ../doc/FlexCat_spanish.texinfo --amiga-39 --fill-column 76 --output ../doc/FlexCat_espaƱol.guide
558 $(MAKEINFO) ../doc/FlexCat_swedish.texinfo --amiga-39 --fill-column 76 --output ../doc/FlexCat_svenska.guide
560 ## DEPENDENCY INCLUDE #################
562 -include $(OBJS:%.o=$(DEPDIR)/%.d)