Is there a way to cd in to directory like ~/.local/share/sxwm then use doas make install and return back to the scripts to continued where i left of because my scripts is automatic.
I depends on how cheesy you want the scripting to be.
You"could" just add the add the cd and doas make within the original script then cd back to where you want.
Again, this is a down n dirty way to do it but doable
Script as bash? Python?
Bash has
cd <somewhere> then
<do your stuff there>, then
cd -, which returns you to dir where you were.
You can't just run in as root? There is not much information here, but there are several ways to attack such a problem including SUID, chrooting the script, using su
The traditional means of doing this is to break the make file with make into a compile command and an install command where the install command is expected to be run with sudo or doas.
A bit vague, but I'm assuming you want to make install in a specified directory.
doas make install -C /sample-directory
Source: make man page.