-
Notifications
You must be signed in to change notification settings - Fork 4
/
MCONFIG
219 lines (159 loc) · 4.01 KB
/
MCONFIG
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# Copyright (C) 1999-2006 Konstantin Boldyshev <[email protected]>
#
# MCONFIG -- asmutils configuration stuff
#
# $Id: MCONFIG,v 1.21 2006/02/18 10:12:17 konst Exp $
#---------------------------------------------------------------------------#
# CONFIGURATION PARAMETERS
#---------------------------------------------------------------------------#
# Target operating system. Valid values are:
# LINUX FREEBSD OPENBSD NETBSD SOLARIS UNIXWARE BEOS ATHEOS
OS = LINUX
# Kernel version of target OS (1.2 = 12, 2.4 = 24, 3.6 = 36, etc)
# Note for Linux 2.6.11 (and above) users: if you experience segfault when
# running several utilities (e.g. chmod), set KERNEL to 26. This will force
# .bss section to be present in executable even if program doesn't need it.
# All this is needed only when ELF_MACROS are disabled.
# Up-to-date ld versions (at least 2.13.90.0.4) also force .bss section
# in executable even if it is not present in object file.
# So, if your ld always adds .bss - you can just forget about it.
KERNEL = 24
# Optimization method (SIZE/SPEED)
OPTIMIZE = SIZE
# System call convention (KERNEL/LIBC)
SYSCALL = KERNEL
# Target executable format (ELF/AOUT)
EXECUTABLE = ELF
# Use hacked ELF for smaller binaries (when possible)
# Disable if you have trouble running resulting executables.
ELF_MACROS = y
# Enable debug build
#DEBUG = y
# Write version stamp into executables
#STAMP = y
# Use custom startup code
# Enable along with SYSCALL=LIBC if gcc fails with -nostartfiles
# (when linker can't find some external symbols required by libc);
# you may also need this with OS=BEOS.
#STARTUP = y
#---------------------------------------------------------------#
# DO NOT EDIT BELOW #
#---------------------------------------------------------------#
VERSION = 0.18
${OS} = y
#
# force reasonable defaults for some OSes
#
ifdef OPENBSD
EXECUTABLE = AOUT
endif
#ifdef NETBSD
#ifneq ($(KERNEL),15)
#EXECUTABLE = AOUT
#else
#EXECUTABLE = ELF
#endif
#endif
ifdef BEOS
STARTUP = y
ELF_MACROS =
endif
#
${EXECUTABLE} = y
AS := nasm
LD := ld -melf_i386
CC := gcc -m32
MAKE := make
ASVER := $(shell $(AS) -v | cut -d ' ' -f 3)
#LDVER := $(shell $(LD) -v | cut -d ' ' -f 4)
CORRECT_ASVER = 0.98.39
#
# avoid using asmutils during the build process if PATH has '.'
#
MKDIR := $(shell which mkdir) -p
CHMOD := $(shell which chmod) +x
LN := $(shell which ln) -s
RM := $(shell which rm) -f
CP := $(shell which cp)
ifdef LINUX
CP += -a
else
CP += -Rp
endif
INSTALLDIR=../bin/$(OS)-$(KERNEL)
LDFLAGS :=
ASFLAGS := -w+orphan-labels -w+macro-params -i../inc/
DEFINES := -D__$(OS)__ -D__KERNEL__=$(KERNEL) -D__SYSCALL__=__S_$(SYSCALL)__\
-D__OPTIMIZE__=__O_$(OPTIMIZE)__ -D__$(EXECUTABLE)__
ifeq ($(OPTIMIZE),SIZE)
ASFLAGS += -O99v
endif
ifeq ($(SYSCALL),LIBC)
LD = gcc
ELF_MACROS =
ifndef STARTUP
LDFLAGS = -nostartfiles
endif
endif
ifdef DEBUG
ASFLAGS += -g
ELF_MACROS =
DEFINES += -DDEBUG
endif
ifdef BUILD_LIB
ELF_MACROS =
endif
ifdef STARTUP
DEFINES += -D__STARTUP__
endif
ifdef STAMP
DEFINES += -DSTAMP_VERSION="'asmutils $(VERSION)'" -DSTAMP_DATE="'$(shell date "+%d-%b-%Y %H:%M")'"
endif
ifndef ELF
ELF_MACROS =
endif
#
ifdef ELF_MACROS
ASFLAGS += -f bin
DEFINES += -D__ELF_MACROS__
%: %.asm
$(AS) $(ASFLAGS) $(DEFINES) $<
$(CHMOD) $*
else
ifdef AOUT
ASFLAGS += -f aoutb
STRIP = strip
ifdef BUILD_SRC
LDFLAGS += -e _start
endif
else
ASFLAGS += -f elf
ifndef DEBUG
LDFLAGS += -s
endif
STRIP = strip -R .note -R .comment
#STRIP = sstrip
endif
%.o: %.asm
$(AS) $(ASFLAGS) $(DEFINES) $<
%: %.o
$(LD) $(LDFLAGS) -o $* $<
ifndef DEBUG
$(STRIP) $*
endif
endif # ELF_MACROS
#
#
#
.PHONY: default all clean install
default: check_asver all
#
# check assembler version
#
check_asver:
ifneq ("$(ASVER)", "$(CORRECT_ASVER)")
@echo "------------------------------------------------------------------------------------"
@echo "WARNING: your $(AS) version $(ASVER) may miscompile asmutils, please use $(AS) $(CORRECT_ASVER)!"
@echo "------------------------------------------------------------------------------------"
# @false
endif