Makefile 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. ############################################################################
  2. # libs/libc/Makefile
  3. #
  4. # Licensed to the Apache Software Foundation (ASF) under one or more
  5. # contributor license agreements. See the NOTICE file distributed with
  6. # this work for additional information regarding copyright ownership. The
  7. # ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. # "License"); you may not use this file except in compliance with the
  9. # License. You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. # License for the specific language governing permissions and limitations
  17. # under the License.
  18. #
  19. ###########################################################################
  20. include $(TOPDIR)/Make.defs
  21. include aio/Make.defs
  22. include assert/Make.defs
  23. include audio/Make.defs
  24. include builtin/Make.defs
  25. include ctype/Make.defs
  26. include dirent/Make.defs
  27. include dlfcn/Make.defs
  28. include endian/Make.defs
  29. include errno/Make.defs
  30. include eventfd/Make.defs
  31. include fixedmath/Make.defs
  32. include grp/Make.defs
  33. include hex2bin/Make.defs
  34. include inttypes/Make.defs
  35. include libgen/Make.defs
  36. include locale/Make.defs
  37. include lzf/Make.defs
  38. include machine/Make.defs
  39. include math/Make.defs
  40. include misc/Make.defs
  41. include modlib/Make.defs
  42. include net/Make.defs
  43. include netdb/Make.defs
  44. include pthread/Make.defs
  45. include pwd/Make.defs
  46. include queue/Make.defs
  47. include sched/Make.defs
  48. include semaphore/Make.defs
  49. include signal/Make.defs
  50. include spawn/Make.defs
  51. include stdio/Make.defs
  52. include stdlib/Make.defs
  53. include string/Make.defs
  54. include symtab/Make.defs
  55. include syslog/Make.defs
  56. include termios/Make.defs
  57. include time/Make.defs
  58. include tls/Make.defs
  59. include uio/Make.defs
  60. include unistd/Make.defs
  61. include userfs/Make.defs
  62. include uuid/Make.defs
  63. include wchar/Make.defs
  64. include wctype/Make.defs
  65. include wqueue/Make.defs
  66. CFLAGS += ${shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)libs$(DELIM)libc}
  67. # Rule for the symbol table generation
  68. MKSYMTAB = $(TOPDIR)$(DELIM)tools$(DELIM)mksymtab$(HOSTEXEEXT)
  69. $(MKSYMTAB):
  70. $(Q) $(MAKE) -C $(TOPDIR)$(DELIM)tools -f Makefile.host mksymtab
  71. # C library and math library symbols should be available in the FLAT
  72. # and PROTECTED builds. KERNEL builds are separately linked and so should
  73. # not need symbol tables.
  74. CSVFILES = $(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)libc.csv
  75. CSVFILES += $(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)math.csv
  76. # In the PROTECTED and KERNEL builds, the applications could link with
  77. # libproxy which will provide symbol-compatible access to OS functions
  78. # via a call gate, but the applications which link with these functions
  79. # directly could remove the repeat proxy code to save the space.
  80. CSVFILES += $(TOPDIR)$(DELIM)syscall$(DELIM)syscall.csv
  81. ifeq ($(CONFIG_EXECFUNCS_SYSTEM_SYMTAB),y)
  82. exec_symtab.c : $(CSVFILES) $(MKSYMTAB)
  83. $(Q) cat $(CSVFILES) | LC_ALL=C sort >$@.csv
  84. $(Q) $(MKSYMTAB) $@.csv $@ $(CONFIG_EXECFUNCS_SYMTAB_ARRAY) $(CONFIG_EXECFUNCS_NSYMBOLS_VAR)
  85. $(Q) rm -f $@.csv
  86. CSRCS += exec_symtab.c
  87. endif
  88. ifeq ($(CONFIG_MODLIB_SYSTEM_SYMTAB),y)
  89. modlib_sys_symtab.c : $(CSVFILES) $(MKSYMTAB)
  90. $(Q) cat $(CSVFILES) | LC_ALL=C sort >$@.csv
  91. $(Q) $(MKSYMTAB) $@.csv $@ $(CONFIG_MODLIB_SYMTAB_ARRAY) $(CONFIG_MODLIB_NSYMBOLS_VAR)
  92. $(Q) rm -f $@.csv
  93. CSRCS += modlib_sys_symtab.c
  94. endif
  95. BINDIR ?= bin
  96. AOBJS = $(patsubst %.S, $(BINDIR)$(DELIM)%$(OBJEXT), $(ASRCS))
  97. COBJS = $(patsubst %.c, $(BINDIR)$(DELIM)%$(OBJEXT), $(CSRCS))
  98. SRCS = $(ASRCS) $(CSRCS)
  99. OBJS = $(AOBJS) $(COBJS)
  100. KBIN = libkc$(LIBEXT)
  101. BIN ?= libc$(LIBEXT)
  102. all: $(BIN)
  103. .PHONY: clean distclean
  104. $(AOBJS): $(BINDIR)$(DELIM)%$(OBJEXT): %.S
  105. $(call ASSEMBLE, $<, $@)
  106. $(COBJS): $(BINDIR)$(DELIM)%$(OBJEXT): %.c
  107. $(call COMPILE, $<, $@)
  108. # C library for the flat build and
  109. # the user phase of the two-pass kernel build
  110. $(BIN): $(OBJS)
  111. $(call ARCHIVE, $@, $(OBJS))
  112. ifeq ($(CONFIG_LIB_ZONEINFO_ROMFS),y)
  113. $(Q) $(MAKE) -C zoneinfo all TOPDIR=$(TOPDIR) BIN=$(BIN)
  114. endif
  115. # C library for the kernel phase of the two-pass kernel build
  116. ifneq ($(BIN),$(KBIN))
  117. $(KBIN):
  118. $(Q) $(MAKE) $(KBIN) BIN=$(KBIN) BINDIR=kbin TOPDIR=$(TOPDIR) EXTRAFLAGS="$(EXTRAFLAGS)"
  119. endif
  120. # Context
  121. context:
  122. ifeq ($(CONFIG_LIB_ZONEINFO_ROMFS),y)
  123. $(Q) $(MAKE) -C zoneinfo context TOPDIR=$(TOPDIR) BIN=$(BIN)
  124. endif
  125. # Dependencies
  126. .depend: Makefile $(SRCS) $(TOPDIR)$(DELIM).config
  127. $(Q) $(MKDEP) --obj-path bin --obj-suffix $(OBJEXT) $(DEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >bin/Make.dep
  128. ifneq ($(CONFIG_BUILD_FLAT),y)
  129. $(Q) $(MKDEP) --obj-path kbin --obj-suffix $(OBJEXT) $(DEPPATH) "$(CC)" -- $(CFLAGS) $(KDEFINE) -- $(SRCS) >kbin/Make.dep
  130. endif
  131. ifeq ($(CONFIG_LIB_ZONEINFO_ROMFS),y)
  132. $(Q) $(MAKE) -C zoneinfo depend TOPDIR=$(TOPDIR) BIN=$(BIN)
  133. endif
  134. $(Q) touch $@
  135. depend: .depend
  136. # Clean most derived files, retaining the configuration
  137. clean:
  138. $(Q) $(MAKE) -C bin clean TOPDIR=$(TOPDIR)
  139. $(Q) $(MAKE) -C kbin clean TOPDIR=$(TOPDIR)
  140. $(Q) $(MAKE) -C zoneinfo clean TOPDIR=$(TOPDIR) BIN=$(BIN)
  141. $(call DELFILE, $(BIN))
  142. $(call DELFILE, $(KBIN))
  143. $(call CLEAN)
  144. # Deep clean -- removes all traces of the configuration
  145. distclean: clean
  146. $(Q) $(MAKE) -C bin distclean TOPDIR=$(TOPDIR)
  147. $(Q) $(MAKE) -C kbin distclean TOPDIR=$(TOPDIR)
  148. $(Q) $(MAKE) -C zoneinfo distclean TOPDIR=$(TOPDIR) BIN=$(BIN)
  149. $(call DELFILE, exec_symtab.c)
  150. $(call DELFILE, bin/Make.dep)
  151. $(call DELFILE, kbin/Make.dep)
  152. $(call DELFILE, .depend)
  153. -include bin/Make.dep
  154. -include kbin/Make.dep