Makefile cleanups

From: Jonathan Walther (krooger@debian.org)
Date: Thu Apr 06 2000 - 04:14:07 EST


This patch applies against 2.3.99-pre3; fixes the detection of bash
and libncurses, and lets you compile on systems where GNU make is called
"gmake"

Jonathan

diff -U2 -N -r linux.old/Makefile linux/Makefile
--- linux.old/Makefile Mon Apr 3 23:40:16 2000
+++ linux/Makefile Mon Apr 3 23:31:12 2000
@@ -9,6 +9,6 @@
 
 CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
- else if [ -x /bin/bash ]; then echo /bin/bash; \
- else echo sh; fi ; fi)
+ else if [ -z `which bash` ] ; then echo sh; \
+ else echo `which bash`; fi ; fi)
 TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
 
@@ -34,5 +34,4 @@
 OBJCOPY = $(CROSS_COMPILE)objcopy
 OBJDUMP = $(CROSS_COMPILE)objdump
-MAKE = make
 MAKEFILES = $(TOPDIR)/.config
 GENKSYMS = /sbin/genksyms
@@ -399,5 +398,5 @@
         rm -f $(TOPDIR)/include/linux/modversions.h
         rm -rf $(TOPDIR)/include/linux/modules
- make clean TOPDIR=$(TOPDIR) -C Documentation/DocBook
+ $(MAKE) clean TOPDIR=$(TOPDIR) -C Documentation/DocBook
 
 distclean: mrproper
diff -U2 -N -r linux.old/scripts/lxdialog/Makefile linux/scripts/lxdialog/Makefile
--- linux.old/scripts/lxdialog/Makefile Sat Oct 2 07:49:30 1999
+++ linux/scripts/lxdialog/Makefile Tue Apr 4 00:00:27 2000
@@ -2,22 +2,7 @@
 CPP = $(HOSTCC) -E
 
-CFLAGS = $(HOSTCFLAGS) -DLOCALE
-LDFLAGS = -s -L .
-LDLIBS = -lncurses
-
-ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h))
- CFLAGS += -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"
-else
-ifeq (/usr/include/ncurses/curses.h, $(wildcard /usr/include/ncurses/curses.h))
- CFLAGS += -I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
-else
-ifeq (/usr/include/ncurses.h, $(wildcard /usr/include/ncurses.h))
- CFLAGS += -DCURSES_LOC="<ncurses.h>"
-else
- CFLAGS += -DCURSES_LOC="<curses.h>"
-endif
-endif
-endif
-
+CFLAGS = $(HOSTCFLAGS) -DLOCALE $(shell ./ncurses-header)
+LDFLAGS = -s -L/usr/local/lib
+LDLIBS = $(shell ./ncurses-or-curses)
 
 OBJS = checklist.o menubox.o textbox.o yesno.o inputbox.o \
@@ -32,5 +17,5 @@
 ncurses:
         @echo "main() {}" > lxtemp.c
- @if $(CC) -lncurses lxtemp.c ; then \
+ @if $(CC) $(LDLIBS) lxtemp.c ; then \
                 rm -f lxtemp.c a.out; \
         else \
@@ -38,7 +23,7 @@
                 echo -e "\007" ;\
                 echo ">> Unable to find the Ncurses libraries." ;\
- echo ">>" ;\
- echo ">> You must have Ncurses installed in order" ;\
- echo ">> to use 'make menuconfig'" ;\
+ echo ">> If they are installed, edit the LDFLAGS variable" ;\
+ echo ">> in scripts/lxdialog/Makefile to reflect" ;\
+ echo ">> the right -L/lib/path" ;\
                 echo ;\
                 exit 1 ;\
diff -U2 -N -r linux.old/scripts/lxdialog/ncurses-header linux/scripts/lxdialog/ncurses-header
--- linux.old/scripts/lxdialog/ncurses-header Wed Dec 31 16:00:00 1969
+++ linux/scripts/lxdialog/ncurses-header Mon Apr 3 23:47:03 2000
@@ -0,0 +1,13 @@
+#!/bin/sh
+# Find the header file and return command line settings
+# Apr 2, 2000 Jonathan Walther <krooger@debian.org>
+
+for i in /usr/include{,/ncurses} /usr/local/include{,/ncurses} ; do
+ if [ -f $i/ncurses.h ] ; then
+ echo -I$i -DCURSES_LOC=\"\<ncurses.h\>\"
+ break
+ elif [ -f $i/curses.h ] ; then
+ echo -I$i -DCURSES_LOC=\"\<curses.h\>\"
+ break
+ fi
+done
diff -U2 -N -r linux.old/scripts/lxdialog/ncurses-or-curses linux/scripts/lxdialog/ncurses-or-curses
--- linux.old/scripts/lxdialog/ncurses-or-curses Wed Dec 31 16:00:00 1969
+++ linux/scripts/lxdialog/ncurses-or-curses Mon Apr 3 22:42:10 2000
@@ -0,0 +1,11 @@
+#!/bin/sh
+# Figure out whether to link with ncurses or curses
+# Apr 2, 2000 Jonathan Walther <krooger@debian.org>
+
+echo "main () {}" > lxtemp.c
+if $CC -lncurses lxtemp.c ; then
+ echo -lncurses
+else
+ echo -lcurses
+fi
+rm -f lxtemp.c a.out

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Apr 07 2000 - 21:00:16 EST