c3d/build

Configurable output

revmischa opened this issue · 4 comments

The build products seem to go in a weird (to me place). I'd like libraries, executables to just be output in the directory where the makefile/product is defined. I'm not clear on how to achieve this.

c3d commented

The simplest way would be to use make OBJROOT=$(PWD). Or if you want something that is slightly more encapsulated, use something like make OBJROOT=$(PWD)/.build.

In general, if you want the build output to go to /some/specific/path, you can use make OBJROOT=/some/specific/path. Note that the path must be absolute, relative paths won't work well if you have libraries.

c3d commented

Also note that if you want to preserve a per-target structure, you can use BUILD_OBJECTS instead of OBJROOT.

With make OBJROOT=$(PWD)/.build, the .build directory looks like:

.build
├── build
│   ├── CONFIG_CHECK_clearenv.c
│   ├── CONFIG_CHECK_clearenv.c.err
│   ├── CONFIG_CHECK_sbrk.c
│   ├── CONFIG_CHECK_sbrk.c.err
│   ├── CONFIG_CHECK_sbrk.c.exe
│   ├── CONFIG_CHECK_sbrk.c.out
│   ├── CONFIG_HAVE_iostream.cpp
│   ├── CONFIG_HAVE_iostream.cpp.err
│   ├── CONFIG_HAVE_iostream.cpp.exe
│   ├── CONFIG_HAVE_iostream.cpp.exe.dSYM
│   │   └── Contents
│   │       ├── Info.plist
│   │       └── Resources
│   │           └── DWARF
│   │               └── CONFIG_HAVE_iostream.cpp.exe
│   ├── CONFIG_HAVE_iostream.cpp.out
│   ├── CONFIG_HAVE_nonexistent.c
│   ├── CONFIG_HAVE_nonexistent.c.err
│   ├── CONFIG_HAVE_stdio.c
│   ├── CONFIG_HAVE_stdio.c.err
│   ├── CONFIG_HAVE_stdio.c.exe
│   ├── CONFIG_HAVE_stdio.c.exe.dSYM
│   │   └── Contents
│   │       ├── Info.plist
│   │       └── Resources
│   │           └── DWARF
│   │               └── CONFIG_HAVE_stdio.c.exe
│   ├── CONFIG_HAVE_stdio.c.out
│   ├── CONFIG_HAVE_sys.sl.improbable.c
│   ├── CONFIG_HAVE_sys.sl.improbable.c.err
│   ├── CONFIG_HAVE_sys.sl.time.c
│   ├── CONFIG_HAVE_sys.sl.time.c.err
│   ├── CONFIG_HAVE_sys.sl.time.c.exe
│   ├── CONFIG_HAVE_sys.sl.time.c.exe.dSYM
│   │   └── Contents
│   │       ├── Info.plist
│   │       └── Resources
│   │           └── DWARF
│   │               └── CONFIG_HAVE_sys.sl.time.c.exe
│   ├── CONFIG_HAVE_sys.sl.time.c.out
│   ├── CONFIG_HAVE_unistd.c
│   ├── CONFIG_HAVE_unistd.c.err
│   ├── CONFIG_HAVE_unistd.c.exe
│   ├── CONFIG_HAVE_unistd.c.exe.dSYM
│   │   └── Contents
│   │       ├── Info.plist
│   │       └── Resources
│   │           └── DWARF
│   │               └── CONFIG_HAVE_unistd.c.exe
│   ├── CONFIG_HAVE_unistd.c.out
│   ├── CONFIG_LIBm.c
│   ├── CONFIG_LIBm.c.err
│   ├── CONFIG_LIBm.c.exe
│   ├── CONFIG_LIBoony.c
│   ├── CONFIG_LIBoony.c.err
│   ├── HAVE_.lt.iostream.gt.
│   ├── HAVE_.lt.nonexistent.h.gt.
│   ├── HAVE_.lt.stdio.h.gt.
│   ├── HAVE_.lt.sys.sl.improbable.h.gt.
│   ├── HAVE_.lt.sys.sl.time.h.gt.
│   ├── HAVE_.lt.unistd.h.gt.
│   ├── HAVE_clearenv
│   ├── HAVE_libm
│   ├── HAVE_liboony
│   ├── HAVE_sbrk
│   ├── hello.cpp.o
│   ├── hello.cpp.o.d
│   ├── hello.deps
│   ├── lib1
│   │   ├── lib1.c.o
│   │   ├── lib1.c.o.d
│   │   └── lib1.deps
│   └── lib2
│       ├── lib2.c.o
│       ├── lib2.c.o.d
│       └── lib2.deps
├── hello
├── lib1.a
└── lib2.a

With make BUILD_OBJECTS=$(PWD)/.build, there will be an additional macosx-clang/opt path so that builds for different values of BUILDENV and different targets will go at different places:

.build/
└── macosx-clang
    └── opt
        ├── build
        │   ├── CONFIG_CHECK_clearenv.c
        │   ├── CONFIG_CHECK_clearenv.c.err
        │   ├── CONFIG_CHECK_sbrk.c
        │   ├── CONFIG_CHECK_sbrk.c.err
        │   ├── CONFIG_CHECK_sbrk.c.exe
        │   ├── CONFIG_CHECK_sbrk.c.out
        │   ├── CONFIG_HAVE_iostream.cpp
        │   ├── CONFIG_HAVE_iostream.cpp.err
        │   ├── CONFIG_HAVE_iostream.cpp.exe
        │   ├── CONFIG_HAVE_iostream.cpp.exe.dSYM
        │   │   └── Contents
        │   │       ├── Info.plist
        │   │       └── Resources
        │   │           └── DWARF
        │   │               └── CONFIG_HAVE_iostream.cpp.exe
        │   ├── CONFIG_HAVE_iostream.cpp.out
        │   ├── CONFIG_HAVE_nonexistent.c
        │   ├── CONFIG_HAVE_nonexistent.c.err
        │   ├── CONFIG_HAVE_stdio.c
        │   ├── CONFIG_HAVE_stdio.c.err
        │   ├── CONFIG_HAVE_stdio.c.exe
        │   ├── CONFIG_HAVE_stdio.c.exe.dSYM
        │   │   └── Contents
        │   │       ├── Info.plist
        │   │       └── Resources
        │   │           └── DWARF
        │   │               └── CONFIG_HAVE_stdio.c.exe
        │   ├── CONFIG_HAVE_stdio.c.out
        │   ├── CONFIG_HAVE_sys.sl.improbable.c
        │   ├── CONFIG_HAVE_sys.sl.improbable.c.err
        │   ├── CONFIG_HAVE_sys.sl.time.c
        │   ├── CONFIG_HAVE_sys.sl.time.c.err
        │   ├── CONFIG_HAVE_sys.sl.time.c.exe
        │   ├── CONFIG_HAVE_sys.sl.time.c.exe.dSYM
        │   │   └── Contents
        │   │       ├── Info.plist
        │   │       └── Resources
        │   │           └── DWARF
        │   │               └── CONFIG_HAVE_sys.sl.time.c.exe
        │   ├── CONFIG_HAVE_sys.sl.time.c.out
        │   ├── CONFIG_HAVE_unistd.c
        │   ├── CONFIG_HAVE_unistd.c.err
        │   ├── CONFIG_HAVE_unistd.c.exe
        │   ├── CONFIG_HAVE_unistd.c.exe.dSYM
        │   │   └── Contents
        │   │       ├── Info.plist
        │   │       └── Resources
        │   │           └── DWARF
        │   │               └── CONFIG_HAVE_unistd.c.exe
        │   ├── CONFIG_HAVE_unistd.c.out
        │   ├── CONFIG_LIBm.c
        │   ├── CONFIG_LIBm.c.err
        │   ├── CONFIG_LIBm.c.exe
        │   ├── CONFIG_LIBoony.c
        │   ├── CONFIG_LIBoony.c.err
        │   ├── HAVE_.lt.iostream.gt.
        │   ├── HAVE_.lt.nonexistent.h.gt.
        │   ├── HAVE_.lt.stdio.h.gt.
        │   ├── HAVE_.lt.sys.sl.improbable.h.gt.
        │   ├── HAVE_.lt.sys.sl.time.h.gt.
        │   ├── HAVE_.lt.unistd.h.gt.
        │   ├── HAVE_clearenv
        │   ├── HAVE_libm
        │   ├── HAVE_liboony
        │   ├── HAVE_sbrk
        │   ├── hello.cpp.o
        │   ├── hello.cpp.o.d
        │   ├── hello.deps
        │   ├── lib1
        │   │   ├── lib1.c.o
        │   │   ├── lib1.c.o.d
        │   │   └── lib1.deps
        │   └── lib2
        │       ├── lib2.c.o
        │       ├── lib2.c.o.d
        │       └── lib2.deps
        ├── hello
        ├── lib1.a
        └── lib2.a

c3d commented

I close this topic for now, but please feel free to reopen if you think there would be a better way to do it. Thanks for your comments.

Sorry, what I want is ONLY the EXECUTABLES to go in some directory I specify.
If I want someone to check out my code from github, build it, and run an executable, I want the executable to be in some handy top-level directory or the root directory itself. They don't care about the object files or digging through the strange and unpredictable

.build/
└── macosx-clang
    └── opt
        ├── build

directory structure. They just want to run the freaking binary.