home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / ncurses-1.9.9e-src.tgz / tar.out / fsf / ncurses / mk-1st.awk < prev    next >
Text File  |  1996-09-28  |  4KB  |  127 lines

  1. # Generate list of objects for a given model library
  2. # Variables:
  3. #    name (library name, e.g., "ncurses", "panel", "forms", "menus")
  4. #    model (directory into which we compile, e.g., "obj")
  5. #    suffix (e.g., "_g.a", for debug libraries)
  6. #    MODEL (e.g., "DEBUG", uppercase; toupper is not portable)
  7. #    DoLinks ("yes" or "no", flag to add symbolic links)
  8. #    rmSoLocs ("yes" or "no", flag to add extra clean target)
  9. #    overwrite ("yes" or "no", flag to add link to libcurses.a
  10. #
  11. # Notes:
  12. #    CLIXs nawk does not like underscores in command-line variable names.
  13. #    Mixed-case is ok.
  14. #    HP/UX requires shared libraries to have executable permissions.
  15. #
  16. function symlink(src,dst) {
  17.         if ( src != dst ) {
  18.             printf "rm -f %s; ", dst
  19.             printf "$(LN_S) %s %s; ", src, dst
  20.         }
  21.     }
  22. function sharedlinks(directory) {
  23.         if ( end_name != lib_name ) {
  24.             printf "\tcd %s && (", directory
  25.             abi_name = sprintf("%s.$(ABI_VERSION)", lib_name);
  26.             symlink(end_name, abi_name);
  27.             symlink(abi_name, lib_name);
  28.             printf ")\n"
  29.         }
  30.     }
  31. function removelinks() {
  32.         if ( end_name != lib_name ) {
  33.             printf "\trm -f ../lib/%s ../lib/%s\n", abi_name, end_name
  34.         }
  35.     }
  36. function installed_name() {
  37.         if ( DO_LINKS == "yes" ) {
  38.             return sprintf("%s.$(REL_VERSION)", lib_name);
  39.         } else {
  40.             return lib_name;
  41.         }
  42.     }
  43. BEGIN    {
  44.         print  ""
  45.         found = 0;
  46.     }
  47.     {
  48.         if ( $1 != "#" && ( $2 == "lib" || $2 == "progs" ))
  49.         {
  50.             if ( found == 0 )
  51.             {
  52.                 printf "%s_OBJS =", MODEL
  53.                 if ( $2 == "lib" )
  54.                     found = 1
  55.                 else
  56.                     found = 2
  57.             }
  58.             printf " \\\n\t../%s/%s.o", model, $1
  59.         }
  60.     }
  61. END    {
  62.         print  ""
  63.         if ( found == 1 )
  64.         {
  65.             print  ""
  66.             lib_name = sprintf("lib%s%s", name, suffix)
  67.             if ( MODEL == "SHARED" )
  68.             {
  69.                 if ( DoLinks == "yes" ) {
  70.                     end_name = sprintf("%s.$(REL_VERSION)", lib_name);
  71.                 } else {
  72.                     end_name = lib_name;
  73.                 }
  74.                 printf "../lib/%s : $(%s_OBJS)\n", lib_name, MODEL
  75.                 print  "\t@-rm -f $@"
  76.                 printf "\t$(MK_SHARED_LIB) $(%s_OBJS)\n", MODEL
  77.                 sharedlinks("../lib")
  78.                 print  ""
  79.                 print  "install.libs \\"
  80.                 printf "install.%s :: $(libdir) ../lib/%s\n", name, end_name
  81.                 printf "\t@echo installing ../lib/%s as $(libdir)/%s \n", lib_name, end_name
  82.                 printf "\t$(INSTALL) ../lib/%s $(libdir)/%s \n", lib_name, end_name
  83.                 sharedlinks("$(libdir)")
  84.                 if ( rmSoLocs == "yes" ) {
  85.                     print  ""
  86.                     print  "clean ::"
  87.                     printf "\t@-rm -f so_locations\n"
  88.                 }
  89.             }
  90.             else
  91.             {
  92.                 end_name = lib_name;
  93.                 printf "../lib/%s : $(%s_OBJS)\n", lib_name, MODEL
  94.                 printf "\tar rv $@ $?\n"
  95.                 printf "\t$(RANLIB) $@\n"
  96.                 print  ""
  97.                 print  "install.libs \\"
  98.                 printf "install.%s :: $(libdir) ../lib/%s\n", name, lib_name
  99.                 printf "\t@echo installing ../lib/%s as $(libdir)/%s \n", lib_name, lib_name
  100.                 printf "\t$(INSTALL_DATA) ../lib/%s $(libdir)/%s \n", lib_name, lib_name
  101.                 if ( overwrite == "yes" && lib_name == "libncurses.a" )
  102.                 {
  103.                     printf "\t@echo linking libcurses.a to libncurses.a \n"
  104.                     printf "\trm -f $(libdir)/libcurses.a \n"
  105.                     # Amiga hack - although we have symlinks, and it's ok to
  106.                     # use them in the build dir, it is not a good idea to use
  107.                     # them in the install dir, since the standard AmigaOS
  108.                     # tools like "copy" don't understand them.
  109.                     printf "\tcp $(libdir)/libncurses.a $(libdir)/libcurses.a \n"
  110.                     printf "\t$(RANLIB) $(libdir)/libcurses.a\n"
  111.                 }
  112.                 printf "\t$(RANLIB) $(libdir)/%s\n", lib_name
  113.             }
  114.             print ""
  115.             print "clean ::"
  116.             printf "\trm -f ../lib/%s\n", lib_name
  117.             printf "\trm -f $(%s_OBJS)\n", MODEL
  118.             removelinks();
  119.         }
  120.         else if ( found == 2 )
  121.         {
  122.             print ""
  123.             print "clean ::"
  124.             printf "\trm -f $(%s_OBJS)\n", MODEL
  125.         }
  126.     }
  127.