Thanks.
The Makefile looks like it's missing dependencies for the
neslib target. I would suggest:
Code:
neslib: $(OBJS)
$(AR) a runtime.lib $(OBJS)
You can replace the second
$(OBJS) with
*.o if you want, but that may or may not be a wise idea. What this will do is make it so that any time someone does
make neslib, it will build the relevant .o files (referenced by the OBJS variable) first (if they don't exist).
An example of a working dependency list would be like this:
Code:
OBJS= main.o boards.o output.o chip_w83792d.o chip_w83793g.o chip_x6dva.o
all: bsdhwmon
bsdhwmon: ${OBJS}
${CC} ${CFLAGS} -o ${.TARGET} ${.ALLSRC}
${OBJS}: global.h
${CC} ${CFLAGS} -c ${.PREFIX}.c
In English:
bsdhwmon (the final executable) is dependent upon the .o files mentioned in OBJS. The OBJS themselves are dependent upon global.h (i.e. in case I update global.h all the .o files should be recompiled), and to recompile those .o files,
cc $CFLAGS -c {objectname_minus_the_.o_part}.c will be run. The final executable build (linking) is done via
cc $CFLAGS -o bsdhwmon {all the .o files}In BSD make,
$.ALLSRC is the same as
$>, and
$.TARGET is the same as
$@. Not sure if GNU make has those alternate names as well, but I find them to be much easier to read.
Example run:
Code:
$ make
cc -O2 -pipe -fno-omit-frame-pointer -march=core2 -Werror -Wall -Wformat-security -fno-inline -c main.c
cc -O2 -pipe -fno-omit-frame-pointer -march=core2 -Werror -Wall -Wformat-security -fno-inline -c boards.c
cc -O2 -pipe -fno-omit-frame-pointer -march=core2 -Werror -Wall -Wformat-security -fno-inline -c output.c
cc -O2 -pipe -fno-omit-frame-pointer -march=core2 -Werror -Wall -Wformat-security -fno-inline -c chip_w83792d.c
cc -O2 -pipe -fno-omit-frame-pointer -march=core2 -Werror -Wall -Wformat-security -fno-inline -c chip_w83793g.c
cc -O2 -pipe -fno-omit-frame-pointer -march=core2 -Werror -Wall -Wformat-security -fno-inline -c chip_x6dva.c
cc -O2 -pipe -fno-omit-frame-pointer -march=core2 -Werror -Wall -Wformat-security -fno-inline -o bsdhwmon main.o boards.o output.o chip_w83792d.o chip_w83793g.o chip_x6dva.o
There are also some "magic" target names, like doing something like this:
Code:
%.o: %.c global.h
${CC} ${CFLAGS} -c ${.ALLSRC}
Which would make all the relevant .o files dependent upon their .c file equivalents, a well as global.h. See
"Makefile.3" for an explanation. Lots of people use this methodology.
Anyway, you may also want to add runtime.lib as a dependency for some other target (possibly "all" ?), and then make a runtime.lib target which does the right thing there. Then there's no more "make neslib" necessity -- instead "make" just does it all for you -- it all depends on what you want, of course.
Make sense? Sorry if it's a bit confusing. :-)