Dave Anderson <anderson(a)redhat.com> writes:
Anyway, I've been tinkering with the extensions/Makefile to do
such
a thing, and have a crude addition that does just that, although
it does the compile of all "new" C files every time whether they
need it or not -- via the additional "contrib" target:
30c30
< all: link_defs $(OBJECTS)
---
> all: link_defs $(OBJECTS) contrib
43a44,50
> contrib:
> @for CFILE in `/bin/ls *.c | grep -v echo.c | grep -v dminfo.c
> | grep -v
sial.c`; do \
> OUTPUT=`echo $$CFILE | cut -d. -f1`.so; \
> echo "gcc -nostartfiles -shared -rdynamic -o $$OUTPUT
> $$CFILE -fPIC
-D$(TARGET) $(TARGET_CFLAGS)"; \
> gcc -nostartfiles -shared -rdynamic -o $$OUTPUT $$CFILE
> -fPIC -D$(TARGET)
$(TARGET_CFLAGS); \
> done
>
It prevents the re-compilation of echo.c and dminfo.c, and of Luc
Chouinard's upcoming sial.c extension module. (SIAL is an alternative
crash extension mechanism -- more on that when it's available...)
Anyway, I've tried screwing around with the Makefile to use a generic
*.so target, using $@, $(basename ...) and so on, but I'm not a Makefile
master, and I cannot quite get it quite right, although I'm sure it can
be done.
So if anybody out there can do it cleaner than the "contrib" target above,
I'd like to take a look.
Try this.
Cheers,
Jeff
--- crash-4.0/extensions/Makefile.orig 2007-09-20 16:35:36.000000000 -0400
+++ crash-4.0/extensions/Makefile 2007-09-20 16:35:42.000000000 -0400
@@ -26,18 +26,15 @@
# - create a compile stanza below, typically using "echo.so" as
# a base template.
#
+CONTRIB_SRC := $(wildcard *.c)
+CONTRIB_SO := $(patsubst %.c,%.so,$(wildcard *.c))
-all: link_defs $(OBJECTS)
+all: link_defs $(OBJECTS) $(CONTRIB_SO)
link_defs:
@if [ ! -f defs.h ]; then \
ln -s ../defs.h; fi
-echo.so: ../defs.h echo.c
- gcc -nostartfiles -shared -rdynamic -o echo.so echo.c -fPIC \
- -D$(TARGET) $(TARGET_CFLAGS)
-
-dminfo.so: ../defs.h dminfo.c
- gcc -nostartfiles -shared -rdynamic -o dminfo.so dminfo.c -fPIC \
- -D$(TARGET) $(TARGET_CFLAGS)
-
+$(CONTRIB_SO): $(CONTRIB_SRC)
+ gcc -nostartfiles -shared -rdynamic -o $@ $< -fPIC \
+ -D$(TARGET) $(TARGET_CFLAGS)