easiest way to do simultaneous builds with different options from same dir?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

easiest way to do simultaneous builds with different options from same dir?

Britton Kerin
I'm frequently rebuilding and uploading both ends of a tx/rx system
and it's just slow enough to be annoying.  I'd like to rebuild the Tx
and Rx ends in parallel but they need different build options for the
same sources.

I'm guessing the easiest approach is to do cp -r or so from a script
and run make from there, and the tree is small enough that that will
probably work ok, but I'm curious if anyone has a trick to do it in
place somehow to avoid the cp and full rebuild of everything?
Something like automagically injecting $$ into all non-phony targets
or something?

Thanks,
Britton

_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: easiest way to do simultaneous builds with different options from same dir?

Basin Ilya
Hi Britton.

Assuming you have a Makefile like this:

    all: test.o
   
    clean:
    rm -rf *.o
   
    .PHONY: all clean

You can create two empty directories and perform make in each by setting VPATH and build flags:

    $ make -f ../src/Makefile CFLAGS=-DBUILD_1 VPATH=../src
    cc -DBUILD_1   -c -o test.o ../src/test.c

The output file will be created in current dir, but the source will be found in ../src

The existing Makefile may be written so that not everything works with VPATH.

Or Better migrate to Autotools and use VPATH builds.


04.07.2018 23:08, Britton Kerin пишет:

> I'm frequently rebuilding and uploading both ends of a tx/rx system
> and it's just slow enough to be annoying.  I'd like to rebuild the Tx
> and Rx ends in parallel but they need different build options for the
> same sources.
>
> I'm guessing the easiest approach is to do cp -r or so from a script
> and run make from there, and the tree is small enough that that will
> probably work ok, but I'm curious if anyone has a trick to do it in
> place somehow to avoid the cp and full rebuild of everything?
> Something like automagically injecting $$ into all non-phony targets
> or something?
>
> Thanks,
> Britton
>
> _______________________________________________
> Help-make mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/help-make
>

_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

easiest way to do simultaneous builds with different options from same dir?

thutt
In reply to this post by Britton Kerin
Britton Kerin writes:
 > I'm frequently rebuilding and uploading both ends of a tx/rx system
 > and it's just slow enough to be annoying.  I'd like to rebuild the Tx
 > and Rx ends in parallel but they need different build options for the
 > same sources.
 >
 > I'm guessing the easiest approach is to do cp -r or so from a script
 > and run make from there, and the tree is small enough that that will
 > probably work ok, but I'm curious if anyone has a trick to do it in
 > place somehow to avoid the cp and full rebuild of everything?
 > Something like automagically injecting $$ into all non-phony targets
 > or something?

 Although you haven't provided a lot of information, I will assume
 that Tx & Rx are both building in the shared source directories.
 This prevents parallel builds because the object files will collide.

 If this is the case, I suggest building in different directories and
 using VPATH to teach Make how to find the sources.

 Alternatively, you can keep the same basic Make structure, but add a
 variable that causes build output to go to a different directory for
 Tx and Rx.

thutt
--
My serverless microservice runs in the blockchain.

_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: easiest way to do simultaneous builds with different options from same dir?

Sébastien Hinderer
In reply to this post by Britton Kerin
Hi Britton,

You may want to give RX and TX object files different names. Assuming a
source module foo.c that will be compiled twice, once for RX and once
for TX, you would call the generated object files foo_rx.c and foo_tx.c.
Then, you could have different rules with different flags to build the
different object files and all that would work in parallel, like this:

%_rx.o: %.c
        $(CC) $(CFLAGS) -o $@ $<

%_tx.o: %.c
        $(CC) $(CFLAGS) -o $@ $<

Things can even be made more sophisticated with macros, target-specific
variables etc. but I think you could start with that and elaborate only
if you really need it.

hth,

Sébastien.

_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make