The Shulchan Aruch · Orach Chayim
אורח חיים תרל״הOrach Chayim 635
Siman 635 of 697 in Orach Chayim — 1 se'if
הלכות סוכהLaws of Sukkot· siman 635
Se’if 1א׳
סֻכָּה, אַף עַל פִּי שֶׁלֹּא נַעֲשֵׂית לְשֵׁם מִצְוָה, כְּשֵׁרָה; וְהוּא שֶׁתִּהְיֶה עֲשׂוּיָה לְצֵל, כְּגוֹן סֻכַּת גּוֹיִים, נָשִׁים, בְּהֵמָה, כּוּתִיִּים, רוֹעִים, קַיָּצִים, בֻּרְגָּנִין, שׁוֹמְרֵי שָׂדוֹת; אֲבָל סֻכָּה שֶׁנַּעֲשֵׂית מֵאֵלֶיהָ, פְּסוּלָה, לְפִי שֶׁלֹּא נַעֲשֵׂית לְצֵל. לְפִיכָךְ הַחוֹטֵט בְּגָדִישׁ וְעָשָׂהוּ סֻכָּה, אֵינָהּ סֻכָּה, שֶׁהֲרֵי לֹא עוֹמֵד גָּדִישׁ זֶה לְצֵל וּמַה שֶּׁעוֹשֶׂה אַחַר כָּךְ הָוֵי תַּעֲשֶׂה וְלֹא מִן הֶעָשׂוּי (טוּר). לְפִיכָךְ אִם עָשָׂה בִּתְחִלָּה כְּשֶׁנָּתַן שָׁם הַגָּדִישׁ חֲלַל טֶפַח בְּמֶשֶׁךְ שִׁבְעָה לְשֵׁם סֻכָּה, וְחָטַט בָּהּ אַחַר כָּךְ וְהִשְׁלִימָהּ לַעֲשָׂרָה, כְּשֵׁרָה, שֶׁהֲרֵי נַעֲשֵׂית סְכָךְ שֶׁלָּהּ לְצֵל; וְאִם הַגָּדִישׁ גָּדוֹל וְלֹא הִנִּיחַ אֶלָּא חֲלַל טֶפַח בְּמֶשֶׁךְ ז', וְשׁוּב חָקַק בָּהּ הַרְבֵּה וְעָשָׂה בָּהּ סֻכָּה גְּדוֹלָה, אֵינָהּ כְּשֵׁרָה כֻּלָּהּ עַל יְדֵי מֶשֶׁךְ שִׁבְעָה שֶׁהִנִּיחַ תְּחִלָּה; וְאִם חָקַק מִשְּׁנֵי צְדָדִים ד' אַמּוֹת יוֹתֵר עַל הַשִּׁבְעָה, אַף הַשִּׁבְעָה פְּסוּלָה, דִּסְכָךְ פָּסוּל פּוֹסֵל מִן הַצַּד בְּד' אַמּוֹת. הַגָּה: וְאֵין לַעֲשׂוֹת הַסְּכָךְ קֹדֶם שֶׁיַּעֲשֶׂה הַדְּפָנוֹת; וְאִם עָשָׂה טֶפַח סָמוּךְ לַסְּכָךְ, מֻתָּר לְסַכֵּךְ קֹדֶם שֶׁיַּעֲשֶׂה שְׁאָר הַדְּפָנוֹת, כְּמוֹ בְּחוֹטֵט בַּגָּדִישׁ. (הַגָּהוֹת מַיְמוֹנִי פ"ה).
A sukkah is valid even if it was not constructed specifically for the mitzvah. For example, the sukkah was built for shade, like those of the non-Jews, women, animals, Samaritans, Shephards, etc. However, a sukkah that was made of its own accord is invalid because it was not made for shade. Therefore, if someone hollows out a stack of grain and makes it into a sukkah it is not a sukkah, because this grain pile was not erected for shade (and what was done afterwards is 'made but not from something made') (Tur). Accordingly, were one to create a space one handbreadth [high] and seven [handbreadths] in area for the purpose of a sukkah, and afterwards hollow it out till it reached ten [handbreadths], it is kosher, since its s'chach was placed for the purpose of shade. If someone makes a big space and doesn't stop until the hole is one handbreadth [high] and seven [handbreadths] and then he digs out a lot and makes a big sukkah there, it is not valid at all. This is because he withdraws seven and doesn't stop from the beginning. If he digs from the two sides to increase the seven, even the seven is invalid as invalid s'chach invalidates from the side within four amot. Rema: One may not put on the s'chach before finishing the walls. But if he made one tefach and covered it with s'chach it is permitted to put s'chach on it before he makes the other walls, like a situation where one creates a space as above. (Hagahos Maimoni)
Shulchan Aruch, Orach Chayim — Torat Emet 363 edition, via Sefaria — public domain
English: Sefaria Community Translation — CC0