“Norton Allen” <allen@huarp.harvard.edu> wrote in message
news:3BE97296.A9166386@huarp.harvard.edu…
Mario Charest wrote:
I’ve created a bfind program that has to be located somewhere in
the path. Works fine, but I would like to totaly get rid of the need
for an
external program or some sort of setup procedure.
Mario,
Hello Norton,
Why your aversion to setup? I’m just curious because it seems that
most source packages require some level of configuration, e.g.
./configure or something simpler.
I have to admit I didn’t consider using something like configure.
On the few programs I ported that used configure, it
never work right out of the box… Everytime I wanted to fix the config
setup
solve the issue, I was always repelled by the complexity.
I guess that is why my brain didn’t consider it as an option.
I’d say the closest thing to a standard approach would be to
create a shell script called Makefile.sh which writes out the
real Makefile. That has to be executed once before you run make.
Thanks to the participant of this thread I was able to do:
ROOTPATH = $(shell let cnt=0;
while [ ! -f $${common_dir}common.mk ]; do
export common_dir=…/$${common_dir}; let cnt=$${cnt}+1;
if test $${cnt} -eq 20 ; then exit 2; fi;
done;
echo $${common_dir} )
With GNU make, there is also a way to make the Makefile depend
on Makefile.sh, and actually restart, but I can’t tell you how
it’s done.
Right now I’m happy with the setup. The project consists of multiple
programs, each program reside at various level of directory in the source
tree.
It’s now possible to go in any program and run make, without any other
requirement then to run make. I like that!!! Program can live at any
level, or even be move from one level to another without a single
change.
The Makefile of each program looks like:
Specify root path (where common.mk is)
ROOTPATH = $(shell let cnt=0;
while [ ! -f $${common_dir}common.mk ]; do
export common_dir=…/$${common_dir}; let cnt=$${cnt}+1;
if test $${cnt} -eq 20 ; then exit 2; fi;
done;
echo $${common_dir} )
Specify target type
#################################################
DO NOT CHANGE AFTER THIS
#################################################
include $(ROOTPATH)/common.mk
All the magic is in common.mk, which is common to the whole project.
I have to thank Brian, I learned so much about the power of makefile
looking at his stuff… I just love dumping a c file in a directory and
have it included in the list of file to build automaticly, !!!