home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Utilities / vmount-0.6a-I / src / Rules.make < prev    next >
Encoding:
Text File  |  1996-11-14  |  4.5 KB  |  199 lines

  1. # Linux kernel makefile rules.
  2. # This file contains rules which are shared between multiple Makefiles.
  3. #
  4.  
  5. #
  6. # False targets.
  7. #
  8. .PHONY: dummy
  9.  
  10. #
  11. # Special variables which should not be exported
  12. #
  13. unexport EXTRA_ASFLAGS
  14. unexport EXTRA_CFLAGS
  15. unexport EXTRA_LDFLAGS
  16. unexport EXTRA_ARFLAGS
  17. unexport SUBDIRS
  18. unexport SUB_DIRS
  19. unexport ALL_SUB_DIRS
  20. unexport MOD_SUB_DIRS
  21. unexport O_TARGET
  22. unexport O_OBJS
  23. unexport L_OBJS
  24. unexport M_OBJS
  25. unexport ALL_MOBJS
  26. # objects that export symbol tables
  27. unexport OX_OBJS
  28. unexport LX_OBJS
  29. unexport MX_OBJS
  30. unexport SYMTAB_OBJS
  31.  
  32. unexport MOD_LIST_NAME
  33.  
  34. #
  35. # Get things started.
  36. #
  37. first_rule: sub_dirs
  38.     $(MAKE) all_targets
  39.  
  40. #
  41. # Common rules
  42. #
  43.  
  44. %.s: %.c
  45.     $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -S $< -o $@
  46.  
  47. %.o: %.c
  48.     $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
  49.  
  50. %.o: %.s
  51.     $(AS) $(ASFLAGS) $(EXTRA_CFLAGS) -o $@ $<
  52.  
  53. #
  54. #
  55. #
  56. all_targets: $(O_TARGET) $(L_TARGET)
  57.  
  58. #
  59. # Rule to compile a set of .o files into one .o file
  60. #
  61. ifdef O_TARGET
  62. ALL_O = $(OX_OBJS) $(O_OBJS)
  63. $(O_TARGET): $(ALL_O) $(TOPDIR)/include/linux/config.h
  64.     rm -f $@
  65. ifneq "$(strip $(ALL_O))" ""
  66.     $(LD) $(EXTRA_LDFLAGS) -r -o $@ $(ALL_O)
  67. else
  68.     $(AR) rc $@; ranlib $@
  69. endif
  70. endif
  71.  
  72. #
  73. # Rule to compile a set of .o files into one .a file
  74. #
  75. ifdef L_TARGET
  76. $(L_TARGET): $(LX_OBJS) $(L_OBJS) $(TOPDIR)/include/linux/config.h
  77.     rm -f $@
  78.     $(AR) $(EXTRA_ARFLAGS) rc $@ $(LX_OBJS) $(L_OBJS); ranlib $@
  79. endif
  80.  
  81. #
  82. # This make dependencies quickly
  83. #
  84. fastdep: dummy
  85.     if [ -n "$(wildcard *.[chS])" ]; then \
  86.     $(TOPDIR)/scripts/mkdep *.[chS] > .depend; fi
  87. ifdef ALL_SUB_DIRS
  88.     set -e; for i in $(ALL_SUB_DIRS); do $(MAKE) -C $$i fastdep; done
  89. endif
  90.  
  91. #
  92. # A rule to make subdirectories
  93. #
  94. sub_dirs: dummy
  95. ifdef SUB_DIRS
  96.     set -e; for i in $(SUB_DIRS); do $(MAKE) -C $$i; done
  97. endif
  98.  
  99. #
  100. # A rule to make modules
  101. #
  102. ALL_MOBJS = $(MX_OBJS) $(M_OBJS)
  103. ifneq "$(strip $(ALL_MOBJS))" ""
  104. PDWN=$(shell $(CONFIG_SHELL) $(TOPDIR)/scripts/pathdown.sh)
  105. endif
  106. modules: $(ALL_MOBJS) dummy
  107. ifdef MOD_SUB_DIRS
  108.     set -e; for i in $(MOD_SUB_DIRS); do $(MAKE) -C $$i modules; done
  109. endif
  110. ifneq "$(strip $(MOD_LIST_NAME))" ""
  111.     rm -f $$TOPDIR/modules/$(MOD_LIST_NAME)
  112. ifdef MOD_SUB_DIRS
  113.     for i in $(MOD_SUB_DIRS); do \
  114.         echo `basename $$i`.o >> $$TOPDIR/modules/$(MOD_LIST_NAME); done
  115. endif
  116. ifneq "$(strip $(ALL_MOBJS))" ""
  117.     echo $(ALL_MOBJS) >> $$TOPDIR/modules/$(MOD_LIST_NAME)
  118. endif
  119. endif
  120. ifneq "$(strip $(ALL_MOBJS))" ""
  121.     echo $(PDWN)
  122.     cd $$TOPDIR/modules; for i in $(ALL_MOBJS); do \
  123.         ln -sf ../$(PDWN)/$$i .; done
  124. endif
  125.  
  126. #
  127. # A rule to do nothing
  128. #
  129. dummy:
  130.  
  131. #
  132. # This is useful for testing
  133. #
  134. script:
  135.     $(SCRIPT)
  136.  
  137. #
  138. # This sets version suffixes on exported symbols
  139. # Uses SYMTAB_OBJS
  140. # Separate the object into "normal" objects and "exporting" objects
  141. # Exporting objects are: all objects that define symbol tables
  142. #
  143. ifdef CONFIG_MODVERSIONS
  144. SYMTAB_OBJS = $(LX_OBJS) $(OX_OBJS) $(MX_OBJS)
  145. ifneq "$(strip $(SYMTAB_OBJS))" ""
  146.  
  147. MODINCL = $(TOPDIR)/include/linux/modules
  148.  
  149. # The -w option (enable warnings) for /bin/genksyms will return here in 2.1
  150. $(MODINCL)/%.ver: %.c
  151.     @if [ ! -x /sbin/genksyms ]; then echo "Please read: Documentation/modules.txt"; fi
  152.     $(CC) $(CFLAGS) -E -D__GENKSYMS__ $< | /sbin/genksyms $(MODINCL)
  153.  
  154. $(addprefix $(MODINCL)/,$(SYMTAB_OBJS:.o=.ver)): $(TOPDIR)/include/linux/autoconf.h
  155.  
  156. $(TOPDIR)/include/linux/modversions.h: $(addprefix $(MODINCL)/,$(SYMTAB_OBJS:.o=.ver))
  157.     @echo updating $(TOPDIR)/include/linux/modversions.h
  158.     @(echo "#ifdef MODVERSIONS";\
  159.     echo "#undef  CONFIG_MODVERSIONS";\
  160.     echo "#define CONFIG_MODVERSIONS";\
  161.     echo "#ifndef _set_ver";\
  162.     echo "#define _set_ver(sym,vers) sym ## _R ## vers";\
  163.     echo "#endif";\
  164.     cd $(TOPDIR)/include/linux/modules; for f in *.ver;\
  165.     do echo "#include <linux/modules/$${f}>"; done; \
  166.     echo "#undef  CONFIG_MODVERSIONS";\
  167.     echo "#endif") \
  168.     > $(TOPDIR)/include/linux/modversions.h
  169.  
  170. $(MX_OBJS): $(TOPDIR)/include/linux/modversions.h
  171.     $(CC) $(CFLAGS) -DEXPORT_SYMTAB -c $(@:.o=.c)
  172.  
  173. $(LX_OBJS) $(OX_OBJS): $(TOPDIR)/include/linux/modversions.h
  174.     $(CC) $(CFLAGS) -DMODVERSIONS -DEXPORT_SYMTAB -c $(@:.o=.c)
  175.  
  176. dep fastdep: $(TOPDIR)/include/linux/modversions.h
  177.  
  178. endif
  179. $(M_OBJS): $(TOPDIR)/include/linux/modversions.h
  180. ifdef MAKING_MODULES
  181. $(O_OBJS) $(L_OBJS): $(TOPDIR)/include/linux/modversions.h
  182. endif
  183. # This is needed to ensure proper dependency for multipart modules such as
  184. # fs/ext.o.  (Otherwise, not all subobjects will be recompiled when
  185. # version information changes.)
  186.  
  187. endif
  188.  
  189. #
  190. # include dependency files they exist
  191. #
  192. ifeq (.depend,$(wildcard .depend))
  193. include .depend
  194. endif
  195.  
  196. ifeq ($(TOPDIR)/.hdepend,$(wildcard $(TOPDIR)/.hdepend))
  197. include $(TOPDIR)/.hdepend
  198. endif
  199.