New bin/minstall script - a minimal replacement for 'install'.
authorBrian Paul <brian.paul@tungstengraphics.com>
Thu, 19 Oct 2006 20:09:05 +0000 (20:09 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Thu, 19 Oct 2006 20:09:05 +0000 (20:09 +0000)
Correctly handles symlinks so we can get rid of the COPY_LIBS stuff.

bin/minstall [new file with mode: 0755]
configs/aix
configs/default
configs/freebsd
src/glu/Makefile
src/glut/fbdev/Makefile
src/glut/glx/Makefile
src/glw/Makefile
src/mesa/Makefile

diff --git a/bin/minstall b/bin/minstall
new file mode 100755 (executable)
index 0000000..9795263
--- /dev/null
@@ -0,0 +1,88 @@
+#!/bin/sh
+
+
+# A minimal replacement for 'install' that supports installing symbolic links.
+# Only a limited number of options are supported:
+# -d dir          Create a directory
+# -m mode         Sets a file's mode when installing
+
+
+# If these commands aren't portable, we'll need some "if (arch)" type stuff
+SYMLINK="ln -s"
+MKDIR="mkdir -p"
+RM="rm -f"
+
+MODE=""
+
+if [ "$1" = "-d" ] ; then
+       # make a directory path
+       $MKDIR "$2"
+       exit 0
+fi
+
+if [ "$1" = "-m" ] ; then
+       # set file mode
+       MODE=$2
+       shift 2
+fi
+
+# install file(s) into destination
+if [ $# -ge 2 ] ; then
+
+       # Last cmd line arg is the dest dir
+       for FILE in $@ ; do
+               DEST="$FILE"
+       done
+
+       # Loop over args, moving them to DEST directory
+       I=1
+       for FILE in $@ ; do
+               if [ $I = $# ] ; then
+                       # stop, don't want to install $DEST into $DEST
+                       exit 0
+               fi
+
+               # determine file's type
+               if [ -h "$FILE" ] ; then
+                       #echo $FILE is a symlink
+                       # Unfortunately, cp -d isn't universal so we have to
+                       # use a work-around.
+
+                       # Use ls -l to find the target that the link points to
+                       LL=`ls -l "$FILE"`
+                       for L in $LL ; do
+                               TARGET=$L
+                       done
+                       #echo $FILE is a symlink pointing to $TARGET
+
+                       FILE=`basename "$FILE"`
+                       # Go to $DEST and make the link
+                       PWDSAVE="$PWD"
+                       cd "$DEST"        # pushd
+                               $RM "$FILE"
+                               $SYMLINK "$TARGET" "$FILE"
+                       cd "$PWDSAVE"     # popd
+
+               elif [ -f "$FILE" ] ; then
+                       #echo "$FILE" is a regular file
+                       cp "$FILE" "$DEST"
+                       if [ $MODE ] ; then
+                               FILE=`basename "$FILE"`
+                               chmod $MODE "$DEST/$FILE"
+                       fi
+               else
+                       echo "Unknown type of argument: " "$FILE"
+                       exit 1
+               fi
+
+               I=`expr $I + 1`
+       done
+
+       exit 0
+fi
+
+# If we get here, we didn't find anything to do
+echo "Usage:"
+echo "  install -d dir                      Create named directory"
+echo "  install [-m mode] file [...] dest   Install files in destination"
+
index 313d4c4fdb39d6eb254bc02bded91673303e0b2c..ebbf5837455c24e9f2eafcbad0e6123422bfda43 100644 (file)
@@ -13,7 +13,6 @@ CXXFLAGS = -O -DAIXV3 -DPTHREADS
 
 # Misc tools and flags
 MKLIB_OPTIONS =
-COPY_LIBS = cp -f -h
 
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
index 8431fff0b8c32120f0c745cfd46bf3a9f1e7ad8b..aa6cef9e3cc5aa9b6a885457fa4e219a60e0b37f 100644 (file)
@@ -27,8 +27,7 @@ MKLIB_OPTIONS =
 MKDEP = makedepend
 MKDEP_OPTIONS = -fdepend
 MAKE = make
-INSTALL = install
-COPY_LIBS = cp -f -d
+INSTALL = $(TOP)/bin/minstall
 
 # Python and flags (generally only needed by the developers)
 PYTHON2 = python
@@ -79,7 +78,8 @@ APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
 
 
 # Installation directories (for make install)
-INSTALL_DIR = /usr/local
+#INSTALL_DIR = /usr/local
+INSTALL_DIR = /tmp/mesa2
 DRI_DRIVER_INSTALL_DIR = /usr/X11R6/lib/modules/dri
 
 # Where libGL will look for DRI hardware drivers
index 38806ab946d6b2be08292a0dec6cd176d27f7930..db7dd3b78a04277d16559129199697fe9e6d2532 100644 (file)
@@ -9,9 +9,6 @@ CC = cc
 CXX = c++
 MAKE = gmake
 
-# cp -d not supported on FreeBSD (see bug 4435)
-COPY_LIBS = cp -f
-
 OPT_FLAGS  = -O2
 PIC_FLAGS  = -fPIC
 
index ca9ad39442c48eda3469499f4a5bc7476dedd739..5ddc50946aab2f5dae68962d6d2dc88fc068e1eb 100644 (file)
@@ -15,7 +15,7 @@ default: $(TOP)/configs/current
 
 install:
        $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
-       $(COPY_LIBS) $(TOP)/$(LIB_DIR)/libGLU.* $(INSTALL_DIR)/$(LIB_DIR)
+       $(INSTALL) $(TOP)/$(LIB_DIR)/libGLU.* $(INSTALL_DIR)/$(LIB_DIR)
 
 clean:
        @for dir in $(SUBDIRS) ; do \
index 11d95665adbf68f965235d1a1770d17a01ae4ee6..254ff8c098fdd1edd42d906283b661dd31a80627 100644 (file)
@@ -72,7 +72,7 @@ install:
        $(INSTALL) -d $(INSTALL_DIR)/include/GL
        $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
        $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(INSTALL_DIR)/include/GL
-       $(COPY_LIBS) $(TOP)/$(LIB_DIR)/libglut* $(INSTALL_DIR)/$(LIB_DIR)
+       $(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(INSTALL_DIR)/$(LIB_DIR)
 
 # Run 'make -f Makefile.solo dep' to update the dependencies if you change
 # what's included by any source file.
index 6fac92fa0cb89b6806813ff4d83bb28862b42eb2..7e1d56b3278271d70ee91d18ea83b7fd936271e3 100644 (file)
@@ -100,7 +100,7 @@ install:
        $(INSTALL) -d $(INSTALL_DIR)/include/GL
        $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
        $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(INSTALL_DIR)/include/GL
-       $(COPY_LIBS) $(TOP)/$(LIB_DIR)/libglut* $(INSTALL_DIR)/$(LIB_DIR)
+       $(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(INSTALL_DIR)/$(LIB_DIR)
 
 
 clean:
index 356351a1ced81a3f3ed25c96ad7f66a2d20c6657..5228cbbb7219c5a07e647eece23108f5061bb50c 100644 (file)
@@ -29,7 +29,7 @@ install:
        $(INSTALL) -d $(INSTALL_DIR)/include/GL
        $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
        $(INSTALL) -m 644 *.h $(INSTALL_DIR)/include/GL
-       $(COPY_LIBS) $(TOP)/$(LIB_DIR)/libGLw.* $(INSTALL_DIR)/$(LIB_DIR)
+       $(INSTALL) $(TOP)/$(LIB_DIR)/libGLw.* $(INSTALL_DIR)/$(LIB_DIR)
 
 clean:
        -rm depend depend.bak
index e1046bb8ad705ec7cca4b50a167603e6af7b2068..3f65ecf5cc9df3fe0f3ef27069d9e4158b33c37b 100644 (file)
@@ -155,10 +155,10 @@ install: default
        $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
        $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(INSTALL_DIR)/include/GL
        @if [ -e $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) ]; then \
-               $(COPY_LIBS) $(TOP)/$(LIB_DIR)/libGL* $(INSTALL_DIR)/$(LIB_DIR); \
+               $(INSTALL) $(TOP)/$(LIB_DIR)/libGL* $(INSTALL_DIR)/$(LIB_DIR); \
        fi
        @if [ -e $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME) ]; then \
-               $(COPY_LIBS) $(TOP)/$(LIB_DIR)/libOSMesa* $(INSTALL_DIR)/$(LIB_DIR); \
+               $(INSTALL) $(TOP)/$(LIB_DIR)/libOSMesa* $(INSTALL_DIR)/$(LIB_DIR); \
        fi
        @if [ "${DRIVER_DIRS}" = "dri" ] ; then \
                cd drivers/dri ; $(MAKE) install ; \