xref: /illumos-gate/usr/src/boot/libsa/Makefile.inc (revision 3fe455549728ac525df3be56130ad8e075d645d7)
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# Copyright 2024 MNX Cloud, Inc.
16#
17
18#
19# Notes:
20# - We don't use the libc strerror/sys_errlist because the string table is
21#   quite large.
22#
23
24# standalone components and stuff we have modified locally
25SRCS +=	$(ZLIB)/gzguts.h $(ZLIB)/zutil.h
26SRCS += $(SASRC)/__main.c $(SASRC)/abort.c $(SASRC)/assert.c
27SRCS +=	$(SASRC)/bcd.c $(SASRC)/environment.c
28SRCS += $(SASRC)/getopt.c $(SASRC)/random.c
29SRCS += $(SASRC)/sbrk.c $(SASRC)/twiddle.c
30SRCS += $(SASRC)/zalloc.c $(SASRC)/zalloc_malloc.c
31
32OBJECTS += __main.o abort.o assert.o bcd.o environment.o \
33	getopt.o gets.o globals.o pager.o panic.o printf.o \
34	strdup.o strerror.o strtol.o strtoll.o strtoul.o strtoull.o random.o \
35	sbrk.o twiddle.o zalloc.o zalloc_malloc.o
36
37# private (pruned) versions of libc string functions
38SRCS +=	$(SASRC)/strcasecmp.c
39OBJECTS += strcasecmp.o
40
41# from libc
42SRCS += $(SASRC)/ntoh.c
43OBJECTS += ntoh.o
44
45# string functions from libc
46SRCS +=	$(SASRC)/string/bcmp.c $(SASRC)/string/bcopy.c
47SRCS +=	$(SASRC)/string/bzero.c $(SASRC)/string/ffs.c
48SRCS +=	$(SASRC)/string/fls.c $(SASRC)/string/memccpy.c
49SRCS +=	$(SASRC)/string/memchr.c $(SASRC)/string/memcmp.c
50SRCS +=	$(SASRC)/string/memcpy.c $(SASRC)/string/memmove.c
51SRCS +=	$(SASRC)/string/memset.c $(SASRC)/string/strcat.c
52SRCS +=	$(SASRC)/string/strchr.c $(SASRC)/string/strcmp.c
53SRCS +=	$(SASRC)/string/strcpy.c $(SASRC)/string/stpcpy.c
54SRCS +=	$(SASRC)/string/stpncpy.c $(SASRC)/string/strcspn.c
55SRCS +=	$(SASRC)/string/strlcat.c $(SASRC)/string/strlcpy.c
56SRCS +=	$(SASRC)/string/strlen.c $(SASRC)/string/strncat.c
57SRCS +=	$(SASRC)/string/strncmp.c $(SASRC)/string/strncpy.c
58SRCS +=	$(SASRC)/string/strpbrk.c $(SASRC)/string/strrchr.c
59SRCS +=	$(SASRC)/string/strsep.c $(SASRC)/string/strspn.c
60SRCS +=	$(SASRC)/string/strstr.c $(SASRC)/string/strtok.c
61SRCS +=	$(SASRC)/string/swab.c $(SASRC)/string/strnlen.c
62
63SRCS += $(SASRC)/qdivrem.c
64
65OBJECTS += bcmp.o bcopy.o bzero.o ffs.o fls.o \
66	memccpy.o memchr.o memcmp.o memcpy.o memmove.o memset.o \
67	qdivrem.o strcat.o strchr.o strcmp.o strcpy.o stpcpy.o stpncpy.o \
68	strcspn.o strlcat.o strlcpy.o strlen.o strncat.o strncmp.o strncpy.o \
69	strpbrk.o strrchr.o strsep.o strspn.o strstr.o strtok.o swab.o \
70	strnlen.o
71
72# uuid functions from libc
73SRCS += $(SASRC)/uuid/uuid_create_nil.c
74SRCS += $(SASRC)/uuid/uuid_equal.c
75SRCS += $(SASRC)/uuid/uuid_is_nil.c
76
77SRCS += $(SASRC)/uuid_from_string.c
78SRCS += $(SASRC)/uuid_to_string.c
79
80OBJECTS += uuid_create_nil.o uuid_equal.o uuid_from_string.o uuid_is_nil.o \
81	uuid_to_string.o
82
83# too hairy
84objs/_inflate.o := SMATCH=off
85pics/_inflate.o := SMATCH=off
86
87# decompression functionality from zlib
88objs/adler32.o := CPPFLAGS += -I$(ZLIB)
89pics/adler32.o := CPPFLAGS += -I$(ZLIB)
90objs/crc32.o := CPPFLAGS += -I$(ZLIB)
91pics/crc32.o := CPPFLAGS += -I$(ZLIB)
92objs/_infback.o := CPPFLAGS += -I$(ZLIB)
93pics/_infback.o := CPPFLAGS += -I$(ZLIB)
94objs/_infback.o pics/_infback.o: libstand_zutil.h libstand_gzguts.h
95objs/_inffast.o := CPPFLAGS += -I$(ZLIB)
96pics/_inffast.o := CPPFLAGS += -I$(ZLIB)
97objs/_inffast.o pics/_inffast.o: libstand_zutil.h libstand_gzguts.h
98objs/_inflate.o := CPPFLAGS += -I$(ZLIB)
99pics/_inflate.o := CPPFLAGS += -I$(ZLIB)
100objs/_inflate.o pics/_inflate.o: libstand_zutil.h libstand_gzguts.h
101objs/_inftrees.o := CPPFLAGS += -I$(ZLIB)
102pics/_inftrees.o := CPPFLAGS += -I$(ZLIB)
103objs/_inftrees.o pics/_inftrees.o: libstand_zutil.h libstand_gzguts.h
104objs/_zutil.o := CPPFLAGS += -I$(ZLIB)
105pics/_zutil.o := CPPFLAGS += -I$(ZLIB)
106objs/_zutil.o pics/_zutil.o: libstand_zutil.h libstand_gzguts.h
107objs/gzipfs.o := CPPFLAGS += -I$(ZLIB)
108pics/gzipfs.o := CPPFLAGS += -I$(ZLIB)
109objs/gzip.o := CPPFLAGS += -I$(ZLIB)
110pics/gzip.o := CPPFLAGS += -I$(ZLIB)
111
112SRCS +=	$(ZLIB)/adler32.c $(ZLIB)/crc32.c \
113	libstand_zutil.h libstand_gzguts.h
114OBJECTS += adler32.o crc32.o
115
116_infback.c: $(ZLIB)/infback.c
117	sed -e "s|zutil\.h|libstand_zutil.h|" \
118	    -e "s|gzguts\.h|libstand_gzguts.h|" \
119	    $^ > $@
120_inffast.c: $(ZLIB)/inffast.c
121	sed -e "s|zutil\.h|libstand_zutil.h|" \
122	    -e "s|gzguts\.h|libstand_gzguts.h|" \
123	    $^ > $@
124_inflate.c: $(ZLIB)/inflate.c
125	sed -e "s|zutil\.h|libstand_zutil.h|" \
126	    -e "s|gzguts\.h|libstand_gzguts.h|" \
127	    $^ > $@
128_inftrees.c: $(ZLIB)/inftrees.c
129	sed -e "s|zutil\.h|libstand_zutil.h|" \
130	    -e "s|gzguts\.h|libstand_gzguts.h|" \
131	    $^ > $@
132_zutil.c: $(ZLIB)/zutil.c
133	sed -e "s|zutil\.h|libstand_zutil.h|" \
134	    -e "s|gzguts\.h|libstand_gzguts.h|" \
135	    $^ > $@
136
137SRCS +=	_infback.c _inffast.c _inflate.c _inftrees.c _zutil.c
138OBJECTS += _infback.o _inffast.o _inflate.o _inftrees.o _zutil.o
139CLEANFILES += _infback.c _inffast.c _inflate.c _inftrees.c _zutil.c
140
141# depend on stand.h being able to be included multiple times
142libstand_zutil.h: $(ZLIB)/zutil.h
143	sed -e 's|<fcntl.h>|"stand.h"|' \
144	    -e 's|<stddef.h>|"stand.h"|' \
145	    -e 's|<string.h>|"stand.h"|' \
146	    -e 's|<stdio.h>|"stand.h"|' \
147	    -e 's|<stdlib.h>|"stand.h"|' \
148	    $^ > $@
149
150libstand_gzguts.h: $(ZLIB)/gzguts.h
151	sed -e 's|<fcntl.h>|"stand.h"|' \
152	    -e 's|<stddef.h>|"stand.h"|' \
153	    -e 's|<string.h>|"stand.h"|' \
154	    -e 's|<stdio.h>|"stand.h"|' \
155	    -e 's|<stdlib.h>|"stand.h"|' \
156	    $^ > $@
157
158CLEANFILES += libstand_zutil.h libstand_gzguts.h
159
160# lz4 decompression functionality
161pics/lz4.o := CPPFLAGS += -I$(LZ4)
162objs/lz4.o := CPPFLAGS += -I$(LZ4)
163SRCS += $(LZ4)/lz4.c
164OBJECTS += lz4.o
165
166# io routines
167SRCS +=	$(SASRC)/closeall.c $(SASRC)/dev.c \
168	$(SASRC)/ioctl.c $(SASRC)/nullfs.c \
169	$(SASRC)/stat.c $(SASRC)/fstat.c $(SASRC)/close.c \
170	$(SASRC)/lseek.c $(SASRC)/open.c $(SASRC)/read.c \
171	$(SASRC)/write.c $(SASRC)/readdir.c
172
173OBJECTS += closeall.o dev.o ioctl.o nullfs.o stat.o fstat.o close.o lseek.o \
174	open.o read.o write.o readdir.o
175
176# SMBios routines
177SRCS += smbios.c
178OBJECTS += smbios.o
179# Export serial numbers, UUID, and asset tag from loader.
180# Use little-endian UUID format as defined in SMBIOS 2.6.
181pics/smbios.o := CPPFLAGS += -DSMBIOS_SERIAL_NUMBERS -DSMBIOS_LITTLE_ENDIAN_UUID
182objs/smbios.o := CPPFLAGS += -DSMBIOS_SERIAL_NUMBERS -DSMBIOS_LITTLE_ENDIAN_UUID
183
184# network routines
185SRCS +=	$(SASRC)/arp.c $(SASRC)/ether.c $(SASRC)/ip.c \
186	$(SASRC)/inet_ntoa.c $(SASRC)/in_cksum.c \
187	$(SASRC)/net.c $(SASRC)/udp.c $(SASRC)/netif.c \
188	$(SASRC)/rpc.c
189OBJECTS += arp.o ether.o ip.o inet_ntoa.o in_cksum.o net.o udp.o netif.o rpc.o
190
191# network info services:
192SRCS +=	$(SASRC)/bootp.c $(SASRC)/rarp.c \
193	$(SASRC)/bootparam.c
194OBJECTS += bootp.o rarp.o bootparam.o
195
196# boot filesystems
197SRCS +=	$(SASRC)/ufs.c
198SRCS += $(SASRC)/nfs.c
199SRCS += $(SASRC)/cd9660.c
200SRCS += $(SASRC)/tftp.c
201SRCS += $(SASRC)/gzipfs.c
202SRCS += $(SASRC)/dosfs.c
203OBJECTS += ufs.o
204OBJECTS += nfs.o
205OBJECTS += cd9660.o
206OBJECTS += tftp.o
207OBJECTS += gzipfs.o
208OBJECTS += dosfs.o
209
210# utility
211SRCS += $(SRC)/common/util/explicit_bzero.c
212SRCS += $(SRC)/common/util/memmem.c
213OBJECTS += explicit_bzero.o
214OBJECTS += memmem.o
215