
#1 remove

cp Makefile mk

#replace common headers that are coming from a script
a="\-DHAVE_STDIO_H=1 \-DHAVE_STDLIB_H=1 \-DHAVE_STRING_H=1 \-DHAVE_INTTYPES_H=1 \-DHAVE_STDINT_H=1 \-DHAVE_STRINGS_H=1 \-DHAVE_SYS_STAT_H=1 \-DHAVE_SYS_TYPES_H=1 \-DHAVE_UNISTD_H=1 \-DSTDC_HEADERS=1"
grep --color "${a}" mk
sed -i "s/${a}//g" mk
grep --color "${a}" mk

#replace our headers
a="\-DHAVE_LIBGEN_H=1 \-DHAVE_FCNTL_H=1 \-DHAVE_PTHREAD_H=1 \-DHAVE_STDLIB_H=1 \-DHAVE_STRING_H=1 \-DHAVE_TIME_H=1 \-DHAVE_UNISTD_H=1 \-DHAVE_OPENSSL_SSL_H=1 \-DHAVE_NETDB_H=1 \-DHAVE_NETINET_IN_H=1 \-DHAVE_SIGNAL_H=1 \-DHAVE_SYS_SOCKET_H=1 \-DHAVE_STDIO_H=1 \-DHAVE_GETDELIM=1 \-DHAVE_SYS_STAT_H=1 \-DFN_G_MEMDUP2=1 \-DHAVE_GTK_GTK_H=1"
grep --color "${a}" mk
sed -i "s/${a}//g" mk
grep --color "${a}" mk

a="sirc_CPPFLAGS ="
n=`grep "^${a}" -n Makefile | grep -o "^[^:]*"`
if [ -n "${n}" ]; then
	#here when cpp flags
	grep --color "${a}" mk
	sed -i "${n}s/.*/${a}/" mk
	grep --color "${a}" mk
else
	#replace c only headers
	a="\-DHAVE_STDBOOL_H=1 \-DHAVE_STDDEF_H=1"
	grep --color "${a}" mk
	sed -i "s/${a}//g" mk
	grep --color "${a}" mk
fi

make -f mk && if [ -n "${1}" ]; then rm mk; fi
