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
24 SRCS= $(ZLIB)/gzguts.h $(ZLIB)/zutil.h
25 SRCS += $(SASRC)/__main.c $(SASRC)/assert.c
26 SRCS += $(SASRC)/bcd.c $(SASRC)/environment.c
27 SRCS += $(SASRC)/getopt.c $(SASRC)/strtol.c
28 SRCS += $(SASRC)/strtoul.c $(SASRC)/random.c
29 SRCS += $(SASRC)/sbrk.c $(SASRC)/twiddle.c
30 SRCS += $(SASRC)/zalloc.c $(SASRC)/zalloc_malloc.c
31
32 OBJS= __main.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 strtoul.o random.o \
35 sbrk.o twiddle.o zalloc.o zalloc_malloc.o
36
37 # private (pruned) versions of libc string functions
38 SRCS += $(SASRC)/strcasecmp.c
39 OBJS += strcasecmp.o
40
41 # from libc
42 SRCS += $(LIBSRC)/libc/net/ntoh.c
43 OBJS += ntoh.o
44
45 # string functions from libc
46 SRCS += $(LIBSRC)/libc/string/bcmp.c $(LIBSRC)/libc/string/bcopy.c
47 SRCS += $(LIBSRC)/libc/string/bzero.c $(LIBSRC)/libc/string/ffs.c
48 SRCS += $(LIBSRC)/libc/string/fls.c $(LIBSRC)/libc/string/memccpy.c
49 SRCS += $(LIBSRC)/libc/string/memchr.c $(LIBSRC)/libc/string/memcmp.c
50 SRCS += $(LIBSRC)/libc/string/memcpy.c $(LIBSRC)/libc/string/memmove.c
51 SRCS += $(LIBSRC)/libc/string/memset.c $(LIBSRC)/libc/string/strcat.c
52 SRCS += $(LIBSRC)/libc/string/strchr.c $(LIBSRC)/libc/string/strcmp.c
53 SRCS += $(LIBSRC)/libc/string/strcpy.c $(LIBSRC)/libc/string/stpcpy.c
54 SRCS += $(LIBSRC)/libc/string/stpncpy.c $(LIBSRC)/libc/string/strcspn.c
55 SRCS += $(LIBSRC)/libc/string/strlcat.c $(LIBSRC)/libc/string/strlcpy.c
56 SRCS += $(LIBSRC)/libc/string/strlen.c $(LIBSRC)/libc/string/strncat.c
57 SRCS += $(LIBSRC)/libc/string/strncmp.c $(LIBSRC)/libc/string/strncpy.c
58 SRCS += $(LIBSRC)/libc/string/strpbrk.c $(LIBSRC)/libc/string/strrchr.c
59 SRCS += $(LIBSRC)/libc/string/strsep.c $(LIBSRC)/libc/string/strspn.c
60 SRCS += $(LIBSRC)/libc/string/strstr.c $(LIBSRC)/libc/string/strtok.c
61 SRCS += $(LIBSRC)/libc/string/swab.c
62
63 SRCS += $(SASRC)/qdivrem.c
64
65 OBJS += 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
71 # uuid functions from libc
72 SRCS += $(LIBSRC)/libc/uuid/uuid_create_nil.c
73 SRCS += $(LIBSRC)/libc/uuid/uuid_equal.c
74 SRCS += $(LIBSRC)/libc/uuid/uuid_is_nil.c
75
76 SRCS += $(SASRC)/uuid_from_string.c
77 SRCS += $(SASRC)/uuid_to_string.c
78
79 OBJS += 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
85 _bzlib.o _crctable.o _decompress.o _huffman.o _randtable.o bzipfs.o \
86 := CFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS
87 SRCS += libstand_bzlib_private.h
88
89 # too hairy
90 _inflate.o := SMATCH=off
91
92 SRCS += _bzlib.c _crctable.c _decompress.c _huffman.c _randtable.c
93 OBJS += _bzlib.o _crctable.o _decompress.o _huffman.o _randtable.o
94 CLEANFILES += _bzlib.c _crctable.c _decompress.c _huffman.c _randtable.c
95
96 _bzlib.c: $(SRC)/common/bzip2/bzlib.c
97 sed "s|bzlib_private\.h|libstand_bzlib_private.h|" $^ > $@
98
99 _crctable.c: $(SRC)/common/bzip2/crctable.c
100 sed "s|bzlib_private\.h|libstand_bzlib_private.h|" $^ > $@
101
102 _decompress.c: $(SRC)/common/bzip2/decompress.c
103 sed "s|bzlib_private\.h|libstand_bzlib_private.h|" $^ > $@
104
105 _huffman.c: $(SRC)/common/bzip2/huffman.c
106 sed "s|bzlib_private\.h|libstand_bzlib_private.h|" $^ > $@
107
108 _randtable.c: $(SRC)/common/bzip2/randtable.c
109 sed "s|bzlib_private\.h|libstand_bzlib_private.h|" $^ > $@
110
111 CLEANFILES += libstand_bzlib_private.h
112 libstand_bzlib_private.h: $(SRC)/common/bzip2/bzlib_private.h
113 sed -e 's|<stdlib.h>|"stand.h"|' $^ > $@
114
115 # decompression functionality from zlib
116 adler32.o crc32.o _infback.o _inffast.o _inflate.o _inftrees.o _zutil.o \
117 gzipfs.o gzip.o := CPPFLAGS += -I$(ZLIB)
118 SRCS += $(ZLIB)/adler32.c $(ZLIB)/crc32.c \
119 libstand_zutil.h libstand_gzguts.h
120 OBJS += adler32.o crc32.o
121
122 _infback.c: $(ZLIB)/infback.c
123 sed -e "s|zutil\.h|libstand_zutil.h|" \
124 -e "s|gzguts\.h|libstand_gzguts.h|" \
125 $^ > $@
126 _inffast.c: $(ZLIB)/inffast.c
127 sed -e "s|zutil\.h|libstand_zutil.h|" \
128 -e "s|gzguts\.h|libstand_gzguts.h|" \
129 $^ > $@
130 _inflate.c: $(ZLIB)/inflate.c
131 sed -e "s|zutil\.h|libstand_zutil.h|" \
132 -e "s|gzguts\.h|libstand_gzguts.h|" \
133 $^ > $@
134 _inftrees.c: $(ZLIB)/inftrees.c
135 sed -e "s|zutil\.h|libstand_zutil.h|" \
136 -e "s|gzguts\.h|libstand_gzguts.h|" \
137 $^ > $@
138 _zutil.c: $(ZLIB)/zutil.c
139 sed -e "s|zutil\.h|libstand_zutil.h|" \
140 -e "s|gzguts\.h|libstand_gzguts.h|" \
141 $^ > $@
142
143 SRCS += _infback.c _inffast.c _inflate.c _inftrees.c _zutil.c
144 OBJS += _infback.o _inffast.o _inflate.o _inftrees.o _zutil.o
145 CLEANFILES += _infback.c _inffast.c _inflate.c _inftrees.c _zutil.c
146
147 # depend on stand.h being able to be included multiple times
148 libstand_zutil.h: $(ZLIB)/zutil.h
149 sed -e 's|<fcntl.h>|"stand.h"|' \
150 -e 's|<stddef.h>|"stand.h"|' \
151 -e 's|<string.h>|"stand.h"|' \
152 -e 's|<stdio.h>|"stand.h"|' \
153 -e 's|<stdlib.h>|"stand.h"|' \
154 $^ > $@
155
156 libstand_gzguts.h: $(ZLIB)/gzguts.h
157 sed -e 's|<fcntl.h>|"stand.h"|' \
158 -e 's|<stddef.h>|"stand.h"|' \
159 -e 's|<string.h>|"stand.h"|' \
160 -e 's|<stdio.h>|"stand.h"|' \
161 -e 's|<stdlib.h>|"stand.h"|' \
162 $^ > $@
163
164 CLEANFILES += libstand_zutil.h libstand_gzguts.h
165
166 # io routines
167 SRCS += $(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
173 OBJS += 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 # network routines
177 SRCS += $(SASRC)/arp.c $(SASRC)/ether.c $(SASRC)/ip.c \
178 $(SASRC)/inet_ntoa.c $(SASRC)/in_cksum.c \
179 $(SASRC)/net.c $(SASRC)/udp.c $(SASRC)/netif.c \
180 $(SASRC)/rpc.c
181 OBJS += arp.o ether.o ip.o inet_ntoa.o in_cksum.o net.o udp.o netif.o rpc.o
182
183 # network info services:
184 SRCS += $(SASRC)/bootp.c $(SASRC)/rarp.c \
185 $(SASRC)/bootparam.c
186 OBJS += bootp.o rarp.o bootparam.o
187
188 # boot filesystems
189 SRCS += $(SASRC)/ufs.c
190 SRCS += $(SASRC)/nfs.c
191 SRCS += $(SASRC)/cd9660.c
192 SRCS += $(SASRC)/tftp.c
193 SRCS += $(SASRC)/gzipfs.c
194 SRCS += $(SASRC)/bzipfs.c
195 SRCS += $(SASRC)/dosfs.c
196 OBJS += ufs.o
197 OBJS += nfs.o
198 OBJS += cd9660.o
199 OBJS += tftp.o
200 OBJS += gzipfs.o
201 OBJS += bzipfs.o
202 OBJS += dosfs.o
203 #
204 .PARALLEL: