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 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
|
# 31oct17abu
# (c) Software Lab. Alexander Burger
bin = ../bin
lib = ../lib
ifeq ($(MAKECMDGOALS), arm64.android)
UNAME = Android
MACHINE = aarch64
else
ifeq ($(MAKECMDGOALS), arm64.linux)
UNAME = Linux
MACHINE = aarch64
else
ifeq ($(MAKECMDGOALS), x86-64.linux)
UNAME = Linux
MACHINE = x86_64
else
ifeq ($(MAKECMDGOALS), ppc64.linux)
UNAME = Linux
MACHINE = ppc64le
else
ifeq ($(MAKECMDGOALS), x86-64.freeBsd)
UNAME = FreeBSD
MACHINE = x86_64
else
ifeq ($(MAKECMDGOALS), x86-64.openBsd)
UNAME = OpenBSD
MACHINE = x86_64
else
ifeq ($(MAKECMDGOALS), x86-64.sunOs)
UNAME = SunOS
MACHINE = x86_64
else
UNAME = $(shell uname)
ifeq ($(MAKECMDGOALS), emu)
MACHINE = emu
else
MACHINE = $(shell uname -m)
endif
endif
endif
endif
endif
endif
endif
endif
SYS =
PIE =
FMT = .c
ARCH = emu
STRIP = :
OS ?=
LDFLAGS ?=
ifeq (Linux,$(OS))
ifeq ($(MACHINE), x86_64)
SYS = .linux
FMT = .s
ARCH = x86-64
AS = as
else
ifeq ($(MACHINE), ppc64)
SYS = .linux
FMT = .s
ARCH = ppc64
AS = as -mppc64 -a64
endif
endif
LD-MAIN = -Wl,--no-as-needed -rdynamic -lc -lm -ldl $(LDFLAGS)
LD-SHARED = -shared -export-dynamic $(LDFLAGS)
STRIP = :
else
ifeq (solaris,$(OS))
SYS = .sunOs
FMT = .s
ARCH = x86-64
AS = gas --64
LD-MAIN = -m64 -lc -lm -ldl -lsocket -lnsl $(LDFLAGS)
LD-SHARED = -m64 -shared $(LDFLAGS)
STRIP = :
else
ifeq (kopensolaris,$(OS))
SYS = .sunOs
FMT = .s
ARCH = x86-64
AS = gas --64
LD-MAIN = -m64 -lc -lm -ldl -lsocket -lnsl $(LDFLAGS)
LD-SHARED = -m64 -shared $(LDFLAGS)
STRIP = :
endif
endif
endif
ifeq (,$(OS))
ifeq ($(UNAME), Android)
OS = Android
SYS = .android
ifeq ($(MACHINE), aarch64)
FMT = .s
ARCH = arm64
AS = as
endif
else
ifeq ($(UNAME), Linux)
OS = Linux
ifeq ($(MACHINE), aarch64)
SYS = .linux
FMT = .s
ARCH = arm64
AS = as
else
ifeq ($(MACHINE), x86_64)
SYS = .linux
FMT = .s
ARCH = x86-64
ifeq ($(shell gcc -dumpspecs | grep -q no-pie ; echo $$?), 0)
PIE = -no-pie
endif
AS = as
else
ifeq ($(MACHINE), ppc64le)
SYS = .linux
FMT = .s
ARCH = ppc64
AS = as -mppc64 -a64 -mlittle
endif
endif
endif
LD-MAIN = -Wl,--no-as-needed -rdynamic -lc -lm -ldl
LD-SHARED = -shared -export-dynamic
STRIP = strip
else
ifeq ($(UNAME), FreeBSD)
OS = FreeBSD
SYS = .freeBsd
FMT = .s
ARCH = x86-64
AS = as
LD-MAIN = -Wl,--no-as-needed -rdynamic -lc -lm
LD-SHARED = -shared -rdynamic
STRIP = strip
else
ifeq ($(UNAME), OpenBSD)
OS = OpenBSD
SYS = .openBsd
FMT = .s
ARCH = x86-64
AS = as
LD-MAIN = -Wl,-nopie -rdynamic -lc -lm
LD-SHARED = -shared -rdynamic
STRIP = strip
else
ifeq ($(UNAME), SunOS)
OS = SunOS
SYS = .sunOs
FMT = .s
ARCH = x86-64
AS = gas --64
LD-MAIN = -m64 -lc -lm -ldl -lsocket -lnsl
LD-SHARED = -m64 -shared
STRIP = strip
endif
endif
endif
endif
endif
endif
baseFiles = version.l glob.l main.l \
gc.l apply.l flow.l sym.l subr.l big.l io.l db.l net.l err.l
sFiles = \
$(ARCH)$(SYS).base$(FMT) \
$(ARCH)$(SYS).ext$(FMT) \
$(ARCH)$(SYS).ht$(FMT)
all: picolisp
arm64.android: $(sFiles)
arm64.linux: $(sFiles)
x86-64.linux: $(sFiles)
ppc64.linux: $(sFiles)
x86-64.freeBsd: $(sFiles)
x86-64.openBsd: $(sFiles)
x86-64.sunOs: $(sFiles)
emu: picolisp
picolisp: $(bin)/picolisp $(lib)/ext $(lib)/ht
### Link ###
$(bin)/picolisp: $(ARCH)$(SYS).base.o
$(CC) -o $(bin)/picolisp $(ARCH)$(SYS).base.o $(LD-MAIN) $(PIE)
$(STRIP) $(bin)/picolisp
$(lib)/ext: $(ARCH)$(SYS).ext.o
$(CC) -o $(lib)/ext $(ARCH)$(SYS).ext.o $(LD-SHARED)
$(STRIP) $(lib)/ext
$(lib)/ht: $(ARCH)$(SYS).ht.o
$(CC) -o $(lib)/ht $(ARCH)$(SYS).ht.o $(LD-SHARED)
$(STRIP) $(lib)/ht
### Assemble ###
.s.o:
$(AS) -o $*.o $*.s
### Compile ###
sysdefs: sysdefs.c
$(CC) -o sysdefs -D_FILE_OFFSET_BITS=64 $(CFLAGS) sysdefs.c $(LD-MAIN)
$(STRIP) sysdefs
emu.base.o: sysdefs emu.base.c
$(CC) -c -O -fomit-frame-pointer -D_FILE_OFFSET_BITS=64 emu.base.c
.c.o:
$(CC) -c -O -fpic -fomit-frame-pointer -D_FILE_OFFSET_BITS=64 $*.c
### Translate ###
$(ARCH)$(SYS).base$(FMT): arch/$(ARCH).l defs.l $(baseFiles) sys/$(ARCH)$(SYS).code.l
./mkAsm $(ARCH) "$(SYS)" $(FMT) $(OS) base "" $(lib)/map $(baseFiles) sys/$(ARCH)$(SYS).code.l
$(ARCH)$(SYS).ext$(FMT): arch/$(ARCH).l defs.l ext.l $(ARCH)$(SYS).base$(FMT)
./mkAsm $(ARCH) "$(SYS)" $(FMT) $(OS) ext T "" ext.l
$(ARCH)$(SYS).ht$(FMT): arch/$(ARCH).l defs.l ht.l $(ARCH)$(SYS).base$(FMT)
./mkAsm $(ARCH) "$(SYS)" $(FMT) $(OS) ht T "" ht.l
### Clean up ###
clean:
rm -f emu.*.c *.s *.o *.symtab sysdefs
# vi:noet:ts=4:sw=4
|