xref: /illumos-gate/usr/src/boot/libsa/Makefile.inc (revision 08855964b9970604433f7b19dcd71cf5af5e5f14)
1#
2# This file and its contents are supplied under the terms of the
3# Common Development and Distribution License ("CDDL"), version 1.0.
4# You may only use this file in accordance with the terms of version
5# 1.0 of the CDDL.
6#
7# A full copy of the text of the CDDL should have accompanied this
8# source.  A copy of the CDDL is also available via the Internet at
9# http://www.illumos.org/license/CDDL.
10#
11
12#
13# Copyright 2016 Toomas Soome <tsoome@me.com>
14# Copyright 2019 Joyent, Inc.
15#
16
17#
18# Notes:
19# - We don't use the libc strerror/sys_errlist because the string table is
20#   quite large.
21#
22
23# standalone components and stuff we have modified locally
24SRCS +=	$(ZLIB)/gzguts.h $(ZLIB)/zutil.h
25SRCS += $(SASRC)/__main.c $(SASRC)/abort.c $(SASRC)/assert.c
26SRCS +=	$(SASRC)/bcd.c $(SASRC)/environment.c
27SRCS += $(SASRC)/getopt.c $(SASRC)/random.c
28SRCS += $(SASRC)/sbrk.c $(SASRC)/twiddle.c
29SRCS += $(SASRC)/zalloc.c $(SASRC)/zalloc_malloc.c
30
31OBJECTS += __main.o abort.o assert.o bcd.o environment.o \
32	getopt.o gets.o globals.o pager.o panic.o printf.o \
33	strdup.o strerror.o strtol.o strtoll.o strtoul.o strtoull.o random.o \
34	sbrk.o twiddle.o zalloc.o zalloc_malloc.o
35
36# private (pruned) versions of libc string functions
37SRCS +=	$(SASRC)/strcasecmp.c
38OBJECTS += strcasecmp.o
39
40# from libc
41SRCS += $(SASRC)/ntoh.c
42OBJECTS += ntoh.o
43
44# string functions from libc
45SRCS +=	$(SASRC)/string/bcmp.c $(SASRC)/string/bcopy.c
46SRCS +=	$(SASRC)/string/bzero.c $(SASRC)/string/ffs.c
47SRCS +=	$(SASRC)/string/fls.c $(SASRC)/string/memccpy.c
48SRCS +=	$(SASRC)/string/memchr.c $(SASRC)/string/memcmp.c
49SRCS +=	$(SASRC)/string/memcpy.c $(SASRC)/string/memmove.c
50SRCS +=	$(SASRC)/string/memset.c $(SASRC)/string/strcat.c
51SRCS +=	$(SASRC)/string/strchr.c $(SASRC)/string/strcmp.c
52SRCS +=	$(SASRC)/string/strcpy.c $(SASRC)/string/stpcpy.c
53SRCS +=	$(SASRC)/string/stpncpy.c $(SASRC)/string/strcspn.c
54SRCS +=	$(SASRC)/string/strlcat.c $(SASRC)/string/strlcpy.c
55SRCS +=	$(SASRC)/string/strlen.c $(SASRC)/string/strncat.c
56SRCS +=	$(SASRC)/string/strncmp.c $(SASRC)/string/strncpy.c
57SRCS +=	$(SASRC)/string/strpbrk.c $(SASRC)/string/strrchr.c
58SRCS +=	$(SASRC)/string/strsep.c $(SASRC)/string/strspn.c
59SRCS +=	$(SASRC)/string/strstr.c $(SASRC)/string/strtok.c
60SRCS +=	$(SASRC)/string/swab.c $(SASRC)/string/strnlen.c
61
62SRCS += $(SASRC)/qdivrem.c
63
64OBJECTS += bcmp.o bcopy.o bzero.o ffs.o fls.o \
65	memccpy.o memchr.o memcmp.o memcpy.o memmove.o memset.o \
66	qdivrem.o strcat.o strchr.o strcmp.o strcpy.o stpcpy.o stpncpy.o \
67	strcspn.o strlcat.o strlcpy.o strlen.o strncat.o strncmp.o strncpy.o \
68	strpbrk.o strrchr.o strsep.o strspn.o strstr.o strtok.o swab.o \
69	strnlen.o
70
71# uuid functions from libc
72SRCS += $(SASRC)/uuid/uuid_create_nil.c
73SRCS += $(SASRC)/uuid/uuid_equal.c
74SRCS += $(SASRC)/uuid/uuid_is_nil.c
75
76SRCS += $(SASRC)/uuid_from_string.c
77SRCS += $(SASRC)/uuid_to_string.c
78
79OBJECTS += uuid_create_nil.o uuid_equal.o uuid_from_string.o uuid_is_nil.o \
80	uuid_to_string.o
81
82# decompression functionality from libbz2
83# NOTE: to actually test this functionality after libbz2 upgrade compile
84# loader(8) with LOADER_BZIP2_SUPPORT defined
85objs/_bzlib.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS
86objs/_bzlib.o := CPPFLAGS += -I$(SRC)/common/bzip2
87objs/_bzlib.o: libstand_bzlib_private.h
88pics/_bzlib.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS
89pics/_bzlib.o := CPPFLAGS += -I$(SRC)/common/bzip2
90pics/_bzlib.o: libstand_bzlib_private.h
91objs/_crctable.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS
92objs/_crctable.o := CPPFLAGS += -I$(SRC)/common/bzip2
93objs/_crctable.o: libstand_bzlib_private.h
94pics/_crctable.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS
95pics/_crctable.o := CPPFLAGS += -I$(SRC)/common/bzip2
96pics/_crctable.o: libstand_bzlib_private.h
97objs/_decompress.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS
98objs/_decompress.o := CPPFLAGS += -I$(SRC)/common/bzip2
99objs/_decompress.o: libstand_bzlib_private.h
100pics/_decompress.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS
101pics/_decompress.o := CPPFLAGS += -I$(SRC)/common/bzip2
102pics/_decompress.o: libstand_bzlib_private.h
103objs/_huffman.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS
104objs/_huffman.o := CPPFLAGS += -I$(SRC)/common/bzip2
105objs/_huffman.o: libstand_bzlib_private.h
106pics/_huffman.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS
107pics/_huffman.o := CPPFLAGS += -I$(SRC)/common/bzip2
108pics/_huffman.o: libstand_bzlib_private.h
109objs/_randtable.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS
110objs/_randtable.o := CPPFLAGS += -I$(SRC)/common/bzip2
111objs/_randtable.o: libstand_bzlib_private.h
112pics/_randtable.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS
113pics/_randtable.o := CPPFLAGS += -I$(SRC)/common/bzip2
114pics/_randtable.o: libstand_bzlib_private.h
115objs/bzipfs.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS
116objs/bzipfs.o := CPPFLAGS += -I$(SRC)/common/bzip2
117objs/bzipfs.o: libstand_bzlib_private.h
118pics/bzipfs.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS
119pics/bzipfs.o := CPPFLAGS += -I$(SRC)/common/bzip2
120pics/bzipfs.o: libstand_bzlib_private.h
121SRCS +=	libstand_bzlib_private.h
122
123# too hairy
124objs/_inflate.o := SMATCH=off
125pics/_inflate.o := SMATCH=off
126
127SRCS +=	_bzlib.c _crctable.c _decompress.c _huffman.c _randtable.c
128OBJECTS += _bzlib.o _crctable.o _decompress.o _huffman.o _randtable.o
129CLEANFILES += _bzlib.c _crctable.c _decompress.c _huffman.c _randtable.c
130
131_bzlib.c: $(SRC)/common/bzip2/bzlib.c
132	sed "s|bzlib_private\.h|libstand_bzlib_private.h|" $^ > $@
133
134_crctable.c: $(SRC)/common/bzip2/crctable.c
135	sed "s|bzlib_private\.h|libstand_bzlib_private.h|" $^ > $@
136
137_decompress.c: $(SRC)/common/bzip2/decompress.c
138	sed "s|bzlib_private\.h|libstand_bzlib_private.h|" $^ > $@
139
140_huffman.c: $(SRC)/common/bzip2/huffman.c
141	sed "s|bzlib_private\.h|libstand_bzlib_private.h|" $^ > $@
142
143_randtable.c: $(SRC)/common/bzip2/randtable.c
144	sed "s|bzlib_private\.h|libstand_bzlib_private.h|" $^ > $@
145
146CLEANFILES += libstand_bzlib_private.h
147libstand_bzlib_private.h: $(SRC)/common/bzip2/bzlib_private.h
148	sed -e 's|<stdlib.h>|"stand.h"|' $^ > $@
149
150# decompression functionality from zlib
151objs/adler32.o := CPPFLAGS += -I$(ZLIB)
152pics/adler32.o := CPPFLAGS += -I$(ZLIB)
153objs/crc32.o := CPPFLAGS += -I$(ZLIB)
154pics/crc32.o := CPPFLAGS += -I$(ZLIB)
155objs/_infback.o := CPPFLAGS += -I$(ZLIB)
156pics/_infback.o := CPPFLAGS += -I$(ZLIB)
157objs/_infback.o pics/_infback.o: libstand_zutil.h libstand_gzguts.h
158objs/_inffast.o := CPPFLAGS += -I$(ZLIB)
159pics/_inffast.o := CPPFLAGS += -I$(ZLIB)
160objs/_inffast.o pics/_inffast.o: libstand_zutil.h libstand_gzguts.h
161objs/_inflate.o := CPPFLAGS += -I$(ZLIB)
162pics/_inflate.o := CPPFLAGS += -I$(ZLIB)
163objs/_inflate.o pics/_inflate.o: libstand_zutil.h libstand_gzguts.h
164objs/_inftrees.o := CPPFLAGS += -I$(ZLIB)
165pics/_inftrees.o := CPPFLAGS += -I$(ZLIB)
166objs/_inftrees.o pics/_inftrees.o: libstand_zutil.h libstand_gzguts.h
167objs/_zutil.o := CPPFLAGS += -I$(ZLIB)
168pics/_zutil.o := CPPFLAGS += -I$(ZLIB)
169objs/_zutil.o pics/_zutil.o: libstand_zutil.h libstand_gzguts.h
170objs/gzipfs.o := CPPFLAGS += -I$(ZLIB)
171pics/gzipfs.o := CPPFLAGS += -I$(ZLIB)
172objs/gzip.o := CPPFLAGS += -I$(ZLIB)
173pics/gzip.o := CPPFLAGS += -I$(ZLIB)
174
175SRCS +=	$(ZLIB)/adler32.c $(ZLIB)/crc32.c \
176	libstand_zutil.h libstand_gzguts.h
177OBJECTS += adler32.o crc32.o
178
179_infback.c: $(ZLIB)/infback.c
180	sed -e "s|zutil\.h|libstand_zutil.h|" \
181	    -e "s|gzguts\.h|libstand_gzguts.h|" \
182	    $^ > $@
183_inffast.c: $(ZLIB)/inffast.c
184	sed -e "s|zutil\.h|libstand_zutil.h|" \
185	    -e "s|gzguts\.h|libstand_gzguts.h|" \
186	    $^ > $@
187_inflate.c: $(ZLIB)/inflate.c
188	sed -e "s|zutil\.h|libstand_zutil.h|" \
189	    -e "s|gzguts\.h|libstand_gzguts.h|" \
190	    $^ > $@
191_inftrees.c: $(ZLIB)/inftrees.c
192	sed -e "s|zutil\.h|libstand_zutil.h|" \
193	    -e "s|gzguts\.h|libstand_gzguts.h|" \
194	    $^ > $@
195_zutil.c: $(ZLIB)/zutil.c
196	sed -e "s|zutil\.h|libstand_zutil.h|" \
197	    -e "s|gzguts\.h|libstand_gzguts.h|" \
198	    $^ > $@
199
200SRCS +=	_infback.c _inffast.c _inflate.c _inftrees.c _zutil.c
201OBJECTS += _infback.o _inffast.o _inflate.o _inftrees.o _zutil.o
202CLEANFILES += _infback.c _inffast.c _inflate.c _inftrees.c _zutil.c
203
204# depend on stand.h being able to be included multiple times
205libstand_zutil.h: $(ZLIB)/zutil.h
206	sed -e 's|<fcntl.h>|"stand.h"|' \
207	    -e 's|<stddef.h>|"stand.h"|' \
208	    -e 's|<string.h>|"stand.h"|' \
209	    -e 's|<stdio.h>|"stand.h"|' \
210	    -e 's|<stdlib.h>|"stand.h"|' \
211	    $^ > $@
212
213libstand_gzguts.h: $(ZLIB)/gzguts.h
214	sed -e 's|<fcntl.h>|"stand.h"|' \
215	    -e 's|<stddef.h>|"stand.h"|' \
216	    -e 's|<string.h>|"stand.h"|' \
217	    -e 's|<stdio.h>|"stand.h"|' \
218	    -e 's|<stdlib.h>|"stand.h"|' \
219	    $^ > $@
220
221CLEANFILES += libstand_zutil.h libstand_gzguts.h
222
223# lz4 decompression functionality
224pics/lz4.o := CPPFLAGS += -I$(LZ4)
225objs/lz4.o := CPPFLAGS += -I$(LZ4)
226SRCS += $(LZ4)/lz4.c
227OBJECTS += lz4.o
228
229# io routines
230SRCS +=	$(SASRC)/closeall.c $(SASRC)/dev.c \
231	$(SASRC)/ioctl.c $(SASRC)/nullfs.c \
232	$(SASRC)/stat.c $(SASRC)/fstat.c $(SASRC)/close.c \
233	$(SASRC)/lseek.c $(SASRC)/open.c $(SASRC)/read.c \
234	$(SASRC)/write.c $(SASRC)/readdir.c
235
236OBJECTS += closeall.o dev.o ioctl.o nullfs.o stat.o fstat.o close.o lseek.o \
237	open.o read.o write.o readdir.o
238
239# SMBios routines
240SRCS += smbios.c
241OBJECTS += smbios.o
242# Export serial numbers, UUID, and asset tag from loader.
243# Use little-endian UUID format as defined in SMBIOS 2.6.
244pics/smbios.o := CPPFLAGS += -DSMBIOS_SERIAL_NUMBERS -DSMBIOS_LITTLE_ENDIAN_UUID
245objs/smbios.o := CPPFLAGS += -DSMBIOS_SERIAL_NUMBERS -DSMBIOS_LITTLE_ENDIAN_UUID
246
247# network routines
248SRCS +=	$(SASRC)/arp.c $(SASRC)/ether.c $(SASRC)/ip.c \
249	$(SASRC)/inet_ntoa.c $(SASRC)/in_cksum.c \
250	$(SASRC)/net.c $(SASRC)/udp.c $(SASRC)/netif.c \
251	$(SASRC)/rpc.c
252OBJECTS += arp.o ether.o ip.o inet_ntoa.o in_cksum.o net.o udp.o netif.o rpc.o
253
254# network info services:
255SRCS +=	$(SASRC)/bootp.c $(SASRC)/rarp.c \
256	$(SASRC)/bootparam.c
257OBJECTS += bootp.o rarp.o bootparam.o
258
259# boot filesystems
260SRCS +=	$(SASRC)/ufs.c
261SRCS += $(SASRC)/nfs.c
262SRCS += $(SASRC)/cd9660.c
263SRCS += $(SASRC)/tftp.c
264SRCS += $(SASRC)/gzipfs.c
265SRCS += $(SASRC)/bzipfs.c
266SRCS += $(SASRC)/dosfs.c
267OBJECTS += ufs.o
268OBJECTS += nfs.o
269OBJECTS += cd9660.o
270OBJECTS += tftp.o
271OBJECTS += gzipfs.o
272OBJECTS += bzipfs.o
273OBJECTS += dosfs.o
274
275# utility
276SRCS += $(SRC)/common/util/explicit_bzero.c
277SRCS += $(SRC)/common/util/memmem.c
278OBJECTS += explicit_bzero.o
279OBJECTS += memmem.o
280