[BusyBox] bug#1100: trying to address recursive make

larry at doolittle.boa.org larry at doolittle.boa.org
Fri Feb 2 06:21:00 UTC 2001


It's _hard_ to deal with pristine source directories using VPATH
and recursive make.  Here is a start on one approach.  Anybody
with a better idea is welcome to show me how.

This version fails with relative BB_SRC_DIR.  It probably has
other defects, too.  But I was able to build with pristine
sources!

       - Larry

diff -ur /home/larry/cvs/busybox/Makefile bb/Makefile
--- /home/larry/cvs/busybox/Makefile	Thu Feb  1 17:07:17 2001
+++ bb/Makefile	Thu Feb  1 22:10:17 2001
@@ -103,21 +103,21 @@
 
 ifeq ($(strip $(DOLFS)),true)
     # For large file summit support
-    CFLAGS+=-D_FILE_OFFSET_BITS=64
+    CFLAGS_CONFIG+=-D_FILE_OFFSET_BITS=64
 endif
 ifeq ($(strip $(DODMALLOC)),true)
     # For testing mem leaks with dmalloc
-    CFLAGS+=-DDMALLOC
+    CFLAGS_CONFIG+=-DDMALLOC
     LIBRARIES = -ldmalloc
     # Force debug=true, since this is useless when not debugging...
     DODEBUG = true
 endif
 ifeq ($(strip $(DODEBUG)),true)
-    CFLAGS  += $(WARNINGS) -g -D_GNU_SOURCE
+    CFLAGS_CONFIG  += $(WARNINGS) -g -D_GNU_SOURCE
     LDFLAGS += -Wl,-warn-common
     STRIP    =
 else
-    CFLAGS  += $(WARNINGS) $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
+    CFLAGS_CONFIG  += $(WARNINGS) $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
     LDFLAGS += -s -Wl,-warn-common
     STRIP    = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
 endif
@@ -153,13 +153,14 @@
     VPATH = .:$(BB_SRC_DIR)
     CONFIG_LIST = $(addsuffix /Config.h,$(subst :, ,$(VPATH)))
     CONFIG_H    = $(word 1,$(shell ls -f -1 $(CONFIG_LIST) 2>/dev/null))
-    CFLAGS += -I- $(patsubst %,-I%,$(subst :, ,$(VPATH)))
+    INCFLAGS = -I- $(patsubst %,-I%,$(subst :, ,$(VPATH)))
+    CFLAGS += $(INCFLAGS)
 endif
 
 OBJECTS   = $(shell $(BB_SRC_DIR)/busybox.sh $(CONFIG_H) $(BB_SRC_DIR)) busybox.o messages.o usage.o utility.o
-CFLAGS    += $(CROSS_CFLAGS)
-CFLAGS    += -DBB_VER='"$(VERSION)"'
-CFLAGS    += -DBB_BT='"$(BUILDTIME)"'
+CFLAGS_CONFIG  += $(CROSS_CFLAGS)
+CFLAGS_CONFIG  += -DBB_VER='"$(VERSION)"'
+CFLAGS_CONFIG  += -DBB_BT='"$(BUILDTIME)"'
 ifdef BB_INIT_SCRIPT
     CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
 endif
@@ -174,7 +175,7 @@
 
 # Put user-supplied flags at the end, where they
 # have a chance of winning.
-CFLAGS += $(CFLAGS_EXTRA)
+CFLAGS += $(CFLAGS_CONFIG) $(CFLAGS_EXTRA)
 
 .EXPORT_ALL_VARIABLES:
 
@@ -241,7 +242,10 @@
 	$(STRIP)
 
 $(PWD_LIB):
-	$(MAKE) -eC pwd_grp
+	mkdir -p pwd_grp
+	@echo VPATH=.:$(BB_SRC_DIR)/pwd_grp
+	test -r pwd_grp/Makefile || PMO="-f $(BB_SRC_DIR)/pwd_grp/Makefile"; \
+	make $$PMO -C pwd_grp VPATH=.:$(BB_SRC_DIR)/pwd_grp
 
 busybox.links: Config.h applets.h
 	- $(BB_SRC_DIR)/busybox.mkll $(CONFIG_H) $(BB_SRC_DIR)/applets.h >$@
diff -ur /home/larry/cvs/busybox/pwd_grp/Makefile bb/pwd_grp/Makefile
--- /home/larry/cvs/busybox/pwd_grp/Makefile	Sat Jan 27 01:33:39 2001
+++ bb/pwd_grp/Makefile	Thu Feb  1 22:07:39 2001
@@ -28,6 +28,8 @@
 	initgroups.c setgroups.c
 COBJS=$(patsubst %.c,%.o, $(CSRC))
 OBJS=$(COBJS)
+INCFLAGS = -I- $(patsubst %,-I%,$(subst :, ,$(VPATH)))
+CFLAGS = $(INCFLAGS) $(CFLAGS_CONFIG) $(CFLAGS_EXTRA)
 
 all: $(OBJS) $(LIBPWD)
 
@@ -36,10 +38,10 @@
 ar-target: $(OBJS)
 	$(AR) $(ARFLAGS) $(LIBPWD) $(OBJS)
 
-$(COBJS):
-	$(CC) $(CFLAGS) $< -c $*.c -o $*.o
+# $(COBJS):
+# 	$(CC) $(CFLAGS) $< -c $*.c -o $*.o
 
-$(OBJ): Makefile
+# $(OBJ): Makefile
 
 __getgrent.c: config.h
 initgroups.c: config.h






More information about the busybox mailing list