grub2: bring back build of aros-side grub2 tools
[AROS.git] / tools / flexcat / src / Makefile
blobe88aba20d9bcdf021ba0c5283b912ea6a4040987
1 #/***************************************************************************
3 # $Id$
5 # Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski
6 # Copyright (C) 2002-2010 by the 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
128 # path definitions
129 CDUP = /
130 CDTHIS=
132 # override some variables for non-native builds (cross-compiler)
133 ifneq ($(HOST), AmigaOS)
134 ifneq ($(HOST), AmigaOS4)
135 ifneq ($(HOST), MorphOS)
137 # when we end up here this is either a unix or Aros host
138 # so lets use unix kind of commands
139 RM = rm -f
140 RMDIR = rm -rf
141 MKDIR = mkdir -p
142 CHMOD = chmod 755
143 CP = cp -f
145 CDUP = ../
146 CDTHIS= ./
148 endif
149 endif
151 ###########################################################################
152 # CPU and DEBUG can be defined outside, defaults to above
153 # using e.g. "make DEBUG= CPU=-mcpu=603e" produces optimized non-debug
154 # PPC-603e version
156 # OPTFLAGS are disabled by DEBUG normally!
158 # ignored warnings are:
159 # none - because we want to compile with -Wall all the time
161 # target definition
162 TARGET = $(BINDIR)/flexcat$(EXE)
164 # Common Directories
165 PREFIX = $(CDTHIS)
166 LOCALE = $(PREFIX)$(CDUP)locale
167 TOOLS = $(PREFIX)tools
168 LIB = $(PREFIX)lib/$(OS)
169 OBJDIR = .obj_$(OS)
170 DEPDIR = .dep_$(OS)
171 BINDIR = bin_$(OS)
172 VPATH = $(OBJDIR)
173 GCCVER = 4
175 # Common compiler/linker flags
176 WARN = -W -Wall -Wwrite-strings -Wpointer-arith -Wsign-compare #-Wunreachable-code
177 OPTFLAGS = -O3 -fomit-frame-pointer -fno-strict-aliasing
178 DEBUG = -DDEBUG -fno-omit-frame-pointer #-O0
179 DEBUGSYM = -g -gstabs
180 CFLAGS = -I. -I./include $(CPU) $(WARN) $(OPTFLAGS) $(DEBUG) $(DEBUGSYM)
181 LDFLAGS = $(CPU) $(DEBUGSYM)
182 LDLIBS = -L$(LIB)
184 # different options per target OS
185 ifeq ($(OS), os4)
187 ##############################
188 # AmigaOS4
190 # Compiler/link/strip commands
191 ifneq ($(HOST), AmigaOS4)
192 CC = ppc-amigaos-gcc
193 STRIP = ppc-amigaos-strip
194 OBJDUMP = ppc-amigaos-objdump
195 endif
197 # Compiler/Linker flags
198 CRT = newlib
199 CPU = -mcpu=powerpc -mstrict-align
200 WARN += -Wdeclaration-after-statement -Wdisabled-optimization -Wshadow
201 REDEFINE = -DCoerceMethod=ICoerceMethod -DDoMethod=IDoMethod \
202 -DDoSuperMethod=IDoSuperMethod -DDoSuperMethodA=IDoSuperMethodA
203 CFLAGS += -mcrt=$(CRT) -D__USE_INLINE__ -D__NEW_TIMEVAL_DEFINITION_USED__ \
204 $(REDEFINE) -Wa,-mregnames -DAMIGA
205 LDFLAGS += -mcrt=$(CRT)
206 LDLIBS += -lauto -lunix
207 CDUP = ../
208 CDTHIS = ./
210 SYSDEPOBJS = locale.o \
211 getft.o \
212 openlibs.o
214 else
215 ifeq ($(OS), os3)
217 ##############################
218 # AmigaOS3
220 # Compiler/link/strip commands
221 ifneq ($(HOST), AmigaOS)
222 CC = m68k-amigaos-gcc
223 STRIP = m68k-amigaos-strip
224 OBJDUMP = m68k-amigaos-objdump
225 endif
227 # Compiler/Linker flags
228 CPU = -m68020-60 -msoft-float
229 CFLAGS += -I./include/netinclude -DNO_INLINE_STDARG -D__amigaos3__ -DAMIGA
230 LDFLAGS += -noixemul
231 LDLIBS += -lamiga
232 GCCVER = 2
234 SYSDEPOBJS = locale.o \
235 getft.o \
236 openlibs.o \
237 strptime.o \
238 vastubs.o
240 else
241 ifeq ($(OS), mos)
243 ##############################
244 # MorphOS
246 # Compiler/link/strip commands
247 ifneq ($(HOST), MorphOS)
248 CC = ppc-morphos-gcc
249 STRIP = ppc-morphos-strip
250 OBJDUMP = ppc-morphos-objdump
251 endif
253 # Compiler/Linker flags
254 CPU = -mcpu=powerpc
255 CFLAGS += -noixemul -I./include/netinclude -DAMIGA
256 LDFLAGS += -noixemul
257 LDLIBS += -lauto -lcodesets
258 GCCVER = 2
260 SYSDEPOBJS = locale.o \
261 asprintf.o \
262 vasprintf.o \
263 openlibs.o \
264 strptime.o \
266 else
267 ifeq ($(OS), aros-i386)
269 ##############################
270 # AROS (i386)
272 ifneq ($(HOST), AROS)
273 CC = i386-aros-gcc
274 STRIP = i386-aros-strip
275 OBJDUMP = i386-aros-objdump
276 endif
278 # Compiler/Linker flags
279 OPTFLAGS = -O2 -fomit-frame-pointer
280 CFLAGS += -Wno-pointer-sign -DNO_INLINE_STDARG -D__BSD_VISIBLE=1 -DAMIGA
281 LDLIBS += -lamiga -larossupport -larosc
283 SYSDEPOBJS = locale.o \
284 getft.o \
285 asprintf.o \
286 vasprintf.o \
287 vastubs.o \
288 openlibs.o
290 else
291 ifeq ($(OS), aros-ppc)
293 ##############################
294 # AROS (PPC)
296 ifneq ($(HOST), AROS)
297 CC = ppc-aros-gcc
298 STRIP = ppc-aros-strip
299 OBJDUMP = ppc-aros-objdump
300 endif
302 # Compiler/Linker flags
303 OPTFLAGS = -O2 -fomit-frame-pointer
304 CFLAGS += -Wno-pointer-sign -DNO_INLINE_STDARG -D__BSD_VISIBLE=1 -DAMIGA
305 LDLIBS += -lamiga -larossupport -larosc
307 SYSDEPOBJS = locale.o \
308 getft.o \
309 asprintf.o \
310 vasprintf.o \
311 vastubs.o \
312 openlibs.o
314 else
315 ifeq ($(OS), aros-x86_64)
317 ##############################
318 # AROS (x86_64)
320 ifneq ($(HOST), AROS)
321 CC = x86_64-aros-gcc
322 STRIP = x86_64-aros-strip
323 OBJDUMP = x86_64-aros-objdump
324 endif
326 # Compiler/Linker flags
327 OPTFLAGS = -O2 -fomit-frame-pointer
328 CFLAGS += -Wno-pointer-sign -DNO_INLINE_STDARG -D__BSD_VISIBLE=1 -DAMIGA
329 LDLIBS += -lamiga -larossupport -larosc
331 SYSDEPOBJS = locale.o \
332 getft.o \
333 asprintf.o \
334 vasprintf.o \
335 vastubs.o \
336 openlibs.o
338 else
339 ifeq ($(OS), aros-arm)
341 ##############################
342 # AROS (arm)
344 ifneq ($(HOST), AROS)
345 CC = arm-aros-gcc
346 STRIP = arm-aros-strip
347 OBJDUMP = arm-aros-objdump
348 endif
350 # Compiler/Linker flags
351 OPTFLAGS = -O2 -fomit-frame-pointer
352 CFLAGS += -Wno-pointer-sign -DNO_INLINE_STDARG -D__BSD_VISIBLE=1 -DAMIGA
353 LDLIBS += -lamiga -larossupport -larosc
355 SYSDEPOBJS = locale.o \
356 getft.o \
357 asprintf.o \
358 vasprintf.o \
359 vastubs.o \
360 openlibs.o
362 else
363 ifeq ($(OS), mingw32)
365 ##############################
366 # Windows (mingw32)
368 ifneq ($(HOST), Windows)
369 CC = i586-mingw32msvc-gcc
370 STRIP = i586-mingw32msvc-strip
371 OBJDUMP = i586-mingw32msvc-objdump
372 endif
374 # Compiler/Linker flags
375 EXE = .exe
376 OPTFLAGS = -O2 -fomit-frame-pointer
377 LDFLAGS =
379 SYSDEPOBJS = locale_other.o \
380 asprintf.o \
381 vasprintf.o \
382 strptime.o
384 else
385 ifeq ($(OS), unix)
387 ##############################
388 # Linux (unix)
390 ifneq ($(HOST), Linux)
391 CC = x86_64-linux-gnu-gcc
392 STRIP = x86_64-linux-gnu-strip
393 OBJDUMP = x86_64-linux-gnu-objdump
394 endif
396 # Compiler/Linker flags
397 OPTFLAGS = -O2 -fomit-frame-pointer
398 CFLAGS += -m32 -D_GNU_SOURCE
399 LDFLAGS = -m32
401 SYSDEPOBJS = locale_other.o
403 endif
404 endif
405 endif
406 endif
407 endif
408 endif
409 endif
410 endif
411 endif
412 endif
414 ###########################################################################
415 # Here starts all stuff that is common for all target platforms and
416 # hosts.
418 CATFILES = FlexCat_cat.h \
419 FlexCat_cat_other.h \
420 locale.c \
421 locale_other.c
423 OBJS = main.o \
424 createcat.o \
425 createcatsrc.o \
426 createct.o \
427 globals.o \
428 readprefs.o \
429 scancd.o \
430 scanct.o \
431 scanpo.o \
432 showfuncs.o \
433 swapfuncs.o \
434 utils.o \
435 $(SYSDEPOBJS)
437 CATALOGS = $(patsubst %.po,%.catalog,$(wildcard locale/*.po))
439 .PHONY: all
440 all: $(OBJDIR) $(BINDIR) $(DEPDIR) $(TARGET)
442 # for making a release we compile ALL target with no debug
443 release:
444 @echo " CC $<"
445 make OS=os4 clean
446 make OS=os4 DEBUG=
447 @echo " CC $<"
448 make OS=os3 clean
449 make OS=os3 DEBUG=
450 @echo " CC $<"
451 make OS=mos clean
452 make OS=mos DEBUG=
453 @echo " CC $<"
454 make OS=aros-i386 clean
455 make OS=aros-i386 DEBUG=
456 @echo " CC $<"
457 make OS=aros-ppc clean
458 make OS=aros-ppc DEBUG=
459 @echo " CC $<"
460 make OS=aros-x86_64 clean
461 make OS=aros-x86_64 DEBUG=
462 @echo " CC $<"
463 make OS=unix clean
464 make OS=unix DEBUG=
465 @echo " CC $<"
466 make OS=mingw32 clean
467 make OS=mingw32 DEBUG=
469 # make the object directories
470 $(OBJDIR):
471 @echo " MK $@"
472 @$(MKDIR) $(OBJDIR)
474 # make the binary directory
475 $(BINDIR):
476 @echo " MK $@"
477 @$(MKDIR) $(BINDIR)
479 # make the dependency directory
480 $(DEPDIR):
481 @echo " MK $@"
482 @$(MKDIR) $(DEPDIR)
484 # for compiling single .c files
485 $(OBJDIR)/%.o: %.c
486 @echo " CC $<"
487 ifeq ($(GCCVER), 2)
488 @$(CC) -MM -MG -o $(DEPDIR)/$(subst .c,.d,$<) $(CFLAGS) $<
489 @$(SED) -i 's,^.*\.o:,$@:,g' $(DEPDIR)/$(subst .c,.d,$<)
490 else
491 @$(CC) -MM -MP -MT '$@' -MF $(DEPDIR)/$(subst .c,.d,$<) $(CFLAGS) $<
492 endif
493 @$(CC) $(CFLAGS) -c $< -o $@
495 $(TARGET): $(CATFILES) $(addprefix $(OBJDIR)/,$(OBJS))
496 @echo " LD $@.debug"
497 @$(CC) $(LDFLAGS) -o $@.debug $(addprefix $(OBJDIR)/,$(OBJS)) $(LDLIBS) -Wl,--cref,-M,-Map=$@.map
498 @echo " LD $@"
499 @$(STRIP) --preserve-dates -R.comment -R.sdata2 -S -o $@ $@.debug
500 @$(CHMOD) $@
502 locale.c: locale/FlexCat.pot sd/NoAutoC_c.sd
503 @echo " FC $@"
504 @$(FLEXCAT) locale/FlexCat.pot locale.c=sd/NoAutoC_c.sd
506 FlexCat_cat.h: locale/FlexCat.pot sd/NoAutoC_h.sd
507 @echo " FC $@"
508 @$(FLEXCAT) locale/FlexCat.pot FlexCat_cat.h=sd/NoAutoC_h.sd
510 locale_other.c: locale/FlexCat.pot sd/Hardcode_c.sd
511 @echo " FC $@"
512 @$(FLEXCAT) locale/FlexCat.pot locale_other.c=sd/Hardcode_c.sd
514 FlexCat_cat_other.h: locale/FlexCat.pot sd/Hardcode_h.sd
515 @echo " FC $@"
516 @$(FLEXCAT) locale/FlexCat.pot FlexCat_cat_other.h=sd/Hardcode_h.sd
518 locale/%.catalog: locale/%.po
519 @echo " MK $@"
520 @$(FLEXCAT) POFILE $< CATALOG $@
522 .IGNORE: $(CATALOGS)
524 catalogs: $(CATALOGS)
526 .PHONY: clean
527 clean:
528 -$(RM) $(addprefix $(OBJDIR)/,$(OBJS))
529 -$(RM) $(BINDIR)/$(FLEXCAT)$(EXE)
530 -$(RM) ../doc/*.guide
532 .PHONY: cleanall
533 cleanall: clean
534 -$(RM) FlexCat_cat.h
535 -$(RM) FlexCat_cat_other.h
536 -$(RM) locale.c
537 -$(RM) locale_other.c
538 -$(RM) locale/*.catalog
539 -$(RMDIR) $(OBJDIR)
541 .PHONY: doc
542 doc:
543 $(MAKEINFO) ../doc/FlexCat_german.texinfo --amiga-39 --fill-column 76 --output ../doc/FlexCat_deutsch.guide
544 $(MAKEINFO) ../doc/FlexCat_english.texinfo --amiga-39 --fill-column 76 --output ../doc/FlexCat_english.guide
545 $(MAKEINFO) ../doc/FlexCat_spanish.texinfo --amiga-39 --fill-column 76 --output ../doc/FlexCat_espaƱol.guide
546 $(MAKEINFO) ../doc/FlexCat_swedish.texinfo --amiga-39 --fill-column 76 --output ../doc/FlexCat_svenska.guide
548 ## DEPENDENCY INCLUDE #################
550 -include $(OBJS:%.o=$(DEPDIR)/%.d)