Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get rid of "compile" command #106

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

get rid of "compile" command #106

wants to merge 1 commit into from

Conversation

DerDakon
Copy link
Member

Let make handle all this. This also allows that one can directly call

make CC=something CFLAGS="-O2 -Wall"

This needs a "recent" version of GNU make (>= 4) or BSD make so the != syntax is supported. No idea what current MacOS ships.

@DerDakon DerDakon added this to the 1.9 milestone Oct 15, 2019
@DerDakon DerDakon added the build label Oct 15, 2019
Copy link
Member

@schmonz schmonz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm. The existing approach has the nice property of making an explicit dependency of the compile-time flags. If we give that up, what do we get in exchange?

@DerDakon
Copy link
Member Author

DerDakon commented Jan 2, 2020

You can build individual object files or targets with different CC flags as you like and are not forced to used the same ones on everything.

@josuah
Copy link

josuah commented Jun 14, 2020

Hmmm. The existing approach has the nice property of making an explicit dependency of the compile-time flags.

This sounds like a drawback for developers, and eventually packagers doing "tweak flags, recompile, tweak flags, recompile".

A workaround would be having a script that flush the flags to a file only if the file content differs, and use this file as a dependency of everything (like ./compile now). The effect is changing the mtime if the flags have changed, thus rebuilding everything in that case.

So in case we want to upgrade the build system while still keeping the correctness of the current one, it might be possible. Although that would require an extra script and could break patches.

@DerDakon DerDakon force-pushed the Dakon-compile branch 3 times, most recently from cab0583 to 912bcd1 Compare July 1, 2020 05:44
@DerDakon
Copy link
Member Author

DerDakon commented Jul 1, 2020

You can use conf-cc as always, and nothing will get lost. The Makefile will just additionally behave like every other Makefile out there and allow direct override. I doubt any packager would fall in a rebuild trap there, they usually start with a clean source tree for reproducability anyway.

Let make handle all this. This also allows that one can directly call

  make CC=something CFLAGS="-O2 -Wall"

For those that still modify conf-cc nothing will change as the Makefile will
read those values if no explicit CC has been set.
Copy link
Contributor

@mbhangui mbhangui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to avoid changing the entire Makefile for the compile command one can also modify make-compile.sh and make-load.sh

make-compile.sh

set $CC
shift
echo "if [ -n \"\$CC\" ] ; then"
echo "  " echo \""\$CC" \$CFLAGS $* -c '${1+"$@"}'\"
echo "  " exec "\$CC" \$CFLAGS $* -c '${1+"$@"}'
echo "else"
echo "  " echo \""$CC" -c '${1+"$@"}'\"
echo "  " exec "$CC" -c '${1+"$@"}'
echo "fi"

make-load.sh

set $CC
shift
echo "if [ -n \"\$CC\" ] ; then"
echo "  " echo \""\$CC" \$CFLAGS $* -c '${1+"$@"}'\"
echo "  " exec "\$CC" \$CFLAGS $* -c '${1+"$@"}'
echo "else"
echo "  " echo \""$CC" -c '${1+"$@"}'\"
echo "  " exec "$CC" -c '${1+"$@"}'
echo "fi"

conf-cc and conf-ld are honoured. e.g.

$ cat conf-cc
cc -O2 -Wall -Wshadow -O2 -fPIC -fno-strict-aliasing -I/usr/include/qmail -DLINUX

This will be used to compile .c files.

with this the compile script gets generated like this

$ cat compile 
#!/bin/sh
# WARNING: This file was auto-generated. Do not edit!
if [ -n "$CC" ] ; then
   echo "$CC $CFLAGS -O2 -Wall -Wshadow -O2 -fPIC -fno-strict-aliasing -I/usr/include/qmail -DLINUX -c ${1+"$@"}"
   exec $CC $CFLAGS -O2 -Wall -Wshadow -O2 -fPIC -fno-strict-aliasing -I/usr/include/qmail -DLINUX -c ${1+"$@"}
else
   echo "cc -O2 -Wall -Wshadow -O2 -fPIC -fno-strict-aliasing -I/usr/include/qmail -DLINUX -c ${1+"$@"}"
   exec cc -O2 -Wall -Wshadow -O2 -fPIC -fno-strict-aliasing -I/usr/include/qmail -DLINUX -c ${1+"$@"}
fi

@DerDakon
Copy link
Member Author

DerDakon commented Jul 4, 2020

My intention is actually the other way round: let make call CC directly so I can see the commands in the log afterwards. compile get's deleted, but the log is usually still there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants