-Move some modules from i386 to generic space.
[newos.git] / make.syscfg
bloba938379bdd58c019ea360f71def3243da50a56a4
2 # figure out a few things about the host build system
3 ifeq ($(HOSTTYPE),)
4         HOSTTYPE := $(shell uname -m)
5 endif
6 ifeq ($(OSTYPE),)
7         OSTYPE := $(shell uname -s | awk -F_ '{print $$1}' | tr A-Z a-z)
8 endif
9 ifeq ($(HOSTTYPE),i586)
10         HOSTTYPE := i386
11 endif
12 ifeq ($(HOSTTYPE),i686)
13         HOSTTYPE := i386
14 endif
15 ifeq ($(HOSTTYPE), )
16         HOSTTYPE := i386
17 endif
18 ifeq ($(findstring Macintosh,$(HOSTTYPE)),Macintosh)
19         HOSTTYPE := ppc
20 endif
21 ifeq ($(HOSTTYPE),macintosh)
22         ifeq ($(MACHTYPE),powerpc)
23                 HOSTTYPE := ppc
24         endif
25 endif
27 # allow for a specific PLATFORM to override ARCH
28 ifeq ($(PLATFORM),)
29         ifeq ($(ARCH),)
30                 #       by default, build for a i386-pc
31                 PLATFORM := pc
32         endif
33 endif
35 # some platforms only support one arch
36 ifeq ($(PLATFORM),pegasos)
37 ARCH := ppc
38 endif
39 ifeq ($(PLATFORM),mac)
40 ARCH := ppc
41 endif
42 ifeq ($(PLATFORM),pc)
43 ARCH := i386
44 endif
45 ifeq ($(PLATFORM),xbox)
46 ARCH := i386
47 endif
49 # build the TARGET variable
50 TARGET := $(ARCH)-$(PLATFORM)
52 # HOST_* is for local targets (tools)
53 HOST_CC := gcc
54 HOST_LD := $(LD)
55 HOST_AS := $(AS)
56 HOST_AR := $(AR)
57 HOST_OBJCOPY := objcopy
58 HOST_OBJDUMP := objdump
59 HOST_STRIP := strip
60 HOST_SIZE := size
62 # setup some local commands
63 ECHO := echo
64 AWK := awk
65 ifeq ($(OSTYPE),SunOS)
66         ECHO := /usr/ucb/echo
67         AWK := gawk
68 endif
69 ifeq ($(findstring solaris,$(OSTYPE)),solaris)
70         ECHO := /usr/ucb/echo
71         AWK := gawk
72 endif
74 # TOOLCHAIN_ARCH is usually ARCH, except in a few cases
75 TOOLCHAIN_ARCH := $(ARCH)
76 ifeq ($(ARCH),sh4)
77 TOOLCHAIN_ARCH := sh
78 endif
80 # try to detect if the user has ARCH-newos-gcc installed
82 #  NOTE:
83 #       the "| cat" below looks unnecesary, this is
84 #       to avoid a bug in liberty in certain versions
85 #       of gmake for BeOS
86 FOO := $(shell $(TOOLCHAIN_ARCH)-newos-gcc --version | cat)
87 ifneq ($(FOO),)
88 $(warning found newos toolchain!)
89         CC = $(TOOLCHAIN_ARCH)-newos-gcc
90         LD = $(TOOLCHAIN_ARCH)-newos-ld
91         AS = $(TOOLCHAIN_ARCH)-newos-as
92         AR = $(TOOLCHAIN_ARCH)-newos-ar
93         OBJCOPY = $(TOOLCHAIN_ARCH)-newos-objcopy
94         OBJDUMP = $(TOOLCHAIN_ARCH)-newos-objdump
95         STRIP = $(TOOLCHAIN_ARCH)-newos-strip
96         SIZE = $(TOOLCHAIN_ARCH)-newos-size
97 else
98 $(warning WARNING: custom newos toolchain not found!)
99 $(warning This build will probably fail miserably)
100 $(warning Download the appropriate toolchain for your build environment)
101 $(warning at http://newos.sourceforge.net/download.php)
102 CC = $(HOST_CC)
103 LD = $(HOST_LD)
104 AS = $(HOST_AS)
105 AR = $(HOST_AR)
106 OBJCOPY = $(HOST_OBJCOPY)
107 OBJDUMP = $(HOST_OBJDUMP)
108 STRIP = $(HOST_STRIP)
109 SIZE = $(HOST_SIZE)
110 endif
112 # set up some particular options for various architectures
113 ifeq ($(ARCH),i386)
114         GLOBAL_CFLAGS = -O2 -g
115         KERNEL_CFLAGS = -fno-pic
116         USER_CFLAGS = -fpic
117         GLOBAL_LDFLAGS = -g
118 endif
120 ifeq ($(ARCH),x86_64)
121         GLOBAL_CFLAGS = -O2 -g 
122         KERNEL_CFLAGS = -fpic
123         USER_CFLAGS = -fpic
124         GLOBAL_LDFLAGS = -g -m elf_x86_64
125 endif
127 ifeq ($(ARCH),ppc)
128         GLOBAL_CFLAGS = -fno-pic -O -D__PPC__ -mregnames
129         GLOBAL_LDFLAGS =
130 endif
132 ifeq ($(ARCH),ppc64)
133         GLOBAL_CFLAGS =
134         GLOBAL_LDFLAGS =
135 endif
137 ifeq ($(ARCH),arm)
138         GLOBAL_CFLAGS = -O2 -g
139         KERNEL_CFLAGS = -fno-pic
140         USER_CFLAGS = -fpic
141         GLOBAL_LDFLAGS =
142 endif
144 ifeq ($(ARCH),sh4)
145         GLOBAL_CFLAGS = -ml -m4-single-only -mhitachi -O1
146         KERNEL_CFLAGS = -fno-pic
147         USER_CFLAGS = -fpic
148         GLOBAL_LDFLAGS = -EL
149 endif
151 ifeq ($(ARCH),sparc64)
152         GLOBAL_CFLAGS =
153         GLOBAL_LDFLAGS =
154 endif
156 ifeq ($(ARCH),sparc)
157         GLOBAL_CFLAGS =
158         GLOBAL_LDFLAGS =
159 endif
161 ifeq ($(ARCH),m68k)
162         GLOBAL_CFLAGS = -O0 -g -m68040
163         KERNEL_CFLAGS = -fno-pic
164         USER_CFLAGS = -fpic
165         GLOBAL_LDFLAGS = -g
166 endif
168 ifeq ($(ARCH),alpha)
169         GLOBAL_CFLAGS =
170         GLOBAL_LDFLAGS =
171 endif
173 ifeq ($(ARCH),mips)
174         GLOBAL_CFLAGS = -fno-pic -mips4 -meb -G 0
175         GLOBAL_LDFLAGS =
176 endif
178 # check to see if we should use distcc and/or ccache
179 ifneq ($(USE_DISTCC),)
180 $(warning using distcc)
181         CC := distcc $(CC)
182 endif
184 ifneq ($(USE_CCACHE),)
185 $(warning using ccache)
186         CC := ccache $(CC)
187 endif
189 # these options are on for all architectures
190 GLOBAL_CFLAGS += -finline -fno-builtin
191 GLOBAL_CFLAGS += -Wall -W -Wno-multichar -Wno-unused-parameter -Wmissing-prototypes
192 GLOBAL_CFLAGS += -DNEWOS=1
193 GLOBAL_CFLAGS += -DARCH_$(ARCH)=1 -D__ARCH__=$(ARCH) -U$(ARCH)
194 GLOBAL_CFLAGS += -DPLATFORM_$(PLATFORM)=1
196 GLOBAL_CPPFLAGS = $(GLOBAL_CFLAGS)
198 GLOBAL_ASFLAGS += -D__ASSEMBLY__
200 # find libgcc
201 LIBGCC := -lgcc
202 LIBGCC_PATH := $(dir $(shell $(CC) $(GLOBAL_CFLAGS) -print-libgcc-file-name))
203 ifeq ($(ARCH),arm)
204 LIBGCC_PATH := /usr/local/arm-newos/lib/gcc-lib/arm-newos/3.3.3
205 endif
206 $(warning LIBGCC_PATH = $(LIBGCC_PATH))
207 ifneq ($(ARCH),sh4)
208 LIBGCC_INCLUDE += -I$(LIBGCC_PATH)/include
209 endif
212 # print some info
213 $(warning ARCH = $(ARCH))
214 $(warning PLATFORM = $(PLATFORM))
215 $(warning TARGET = $(TARGET))
217 # figure out where the build dir will be
218 BUILD_DIR = build/$(TARGET)
219 $(warning build dir will be $(BUILD_DIR))
220 $(shell mkdir -p $(BUILD_DIR))