profan_path="../../GitHub/profanOS"

CFLAGS="-m32 -nostdinc -I$profan_path/include/zlibs -Iprofan_extra -DHAVE_CONFIG_H -Isrc -Iinclude/X11 -Iinclude -Isrc/xcms -Isrc/xkb -Isrc/xlibi18n -D_DEFAULT_SOURCE -D_BSD_SOURCE -DHAS_FCHOWN \
-DHAS_STICKY_DIR_BIT -DMALLOC_0_RETURNS_NULL -Wall -Wpointer-arith -Wmissing-declarations -Wformat=2 -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wbad-function-cast \
-Wold-style-definition -Wdeclaration-after-statement -Wunused -Wuninitialized -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -Wlogical-op -Werror=implicit \
-Werror=nonnull -Werror=init-self -Werror=main -Werror=missing-braces -Werror=sequence-point -Werror=return-type -Werror=trigraphs -Werror=array-bounds -Werror=write-strings \
-Werror=address -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -fno-strict-aliasing -fno-pie -fno-stack-protector"

rm -Rf out
mkdir out

for e in $(find src -maxdepth 1 -name "*.c")
do
output=out/$(basename $e .c).o
echo $e
gcc $CFLAGS -c $e -o $output 
done

gcc -shared -nostdlib -m32 -o libX11.so out/*.o
