
#1 0/nothing=nothing,1=remove_platform_64_flag  2 remove

cp Makefile mk

#headers, first are default, second are our input
#\-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
#without \-DSTDC_HEADERS=1
#\-DHAVE_STDDEF_H=1 \-DHAVE_ERRNO_H=1 \-DHAVE_ERRNO_LOCATION=1 \-DHAVE_FCNTL_H=1 \-DHAVE_STDIO_H=1 \-DHAVE__GETREENT=1 \-DHAVE_STDLIB_H=1 \-DHAVE_STRING_H=1 \-DHAVE_MEMMEM=1 \-DHAVE_UNISTD_H=1 \-DHAVE_TIME_H=1 \-DHAVE_SYS_STAT_H=1 \-DHAVE_CURSES_H=1
#c only headers \-DHAVE_STDBOOL_H=1
# OTHER_CURSES MKDIR_1ARG _KEY_BACKSPACE
#
a=`grep "^DEFS =" mk`
echo ${a} | grep --color "HAVE"
b=`echo ${a} | sed "s/-DHAVE_[^_]*_H=1//g; s/-DHAVE_[^_]*_[^_]*_H=1//g; s/-DHAVE_MEMMEM=1//g;"`
#
c="edor_CPPFLAGS ="
n=`grep "^${c}" -n Makefile | grep -o "^[^:]*"`
if [ -n "${n}" ]; then #on c flags will be commented
	#here when cpp flags
	grep --color "${c}" mk
	sed -i "${n}s/.*/${c}/" mk
	grep --color "${c}" mk

	echo ${b} | grep --color "USE_FS"
	b=`echo ${b} | sed "s/-DUSE_FS=1//g"`
fi
if [ "${1}" = "1" ]; then #rare test, if wanting 32
	echo ${b} | grep --color "\-DSIZEOF_INT_P=8"
	b=`echo ${b} | sed "s/\-DSIZEOF_INT_P=8/\-DSIZEOF_INT_P=4/g"`
	echo ${b} | grep --color "\-DSIZEOF_LONG=8"
	b=`echo ${b} | sed "s/\-DSIZEOF_LONG=8/\-DSIZEOF_LONG=4/g"`
fi
a=$(echo ${a} | sed 's/\\/\\\\/g')
b=$(echo ${b} | sed 's/\\/\\\\/g')
#
sed -i "0,/^${a}/s/^${a}/${b}/" mk #is only one

cat mk | grep "^DEFS"

/bin/bash ./mh && if [ -n "${2}" ]; then rm mk; fi
