Makefile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. MAKEFLAGS += --check-symlink-times
  2. CC = gcc
  3. AS = gcc
  4. AR = ar rcs
  5. LD = ld
  6. OMIT_FRAME_POINTER = no
  7. CFLAGS = -Wall -fPIC -std=gnu99 -fgnu89-inline -Winline -Wwrite-strings \
  8. -fmerge-all-constants -Wstrict-prototypes \
  9. -Werror=implicit-function-declaration \
  10. -fno-stack-protector -fno-builtin -Wno-inline \
  11. -I../include -I../../../Pal/lib -I../../../Pal/include/pal
  12. ifeq ($(OMIT_FRAME_POINTER),yes)
  13. CFLAGS += -DOMIT_FRAME_POINTER=1
  14. else
  15. CFLAGS += -fno-omit-frame-pointer -DOMIT_FRAME_POINTER=0
  16. endif
  17. ASFLAGS = -Wa,--noexecstack -x assembler-with-cpp -I../include
  18. LDFLAGS = -shared -nostdlib --version-script shim.map -T shim.lds \
  19. -z combreloc -z relro -z defs \
  20. -dynamic-link=libpal.so \
  21. -rpath-link=$(abspath ../../../Pal/src)
  22. LDFLAGS-debug = $(patsubst shim.map,shim-debug.map,$(LDFLAGS))
  23. ARFLAGS =
  24. shim_target = libsysdb.a libsysdb.so libsysdb_debug.so
  25. defs = -DIN_SHIM
  26. fs = chroot str pipe socket proc dev
  27. ipcns = pid sysv
  28. objs = $(addprefix bookkeep/shim_,handle vma thread signal) \
  29. $(patsubst %.c,%,$(wildcard utils/*.c)) \
  30. $(addprefix fs/shim_,dcache namei fs_hash fs) \
  31. $(patsubst %.c,%,$(foreach f,$(fs),$(wildcard fs/$(f)/*.c))) \
  32. $(addprefix ipc/shim_,ipc ipc_helper ipc_child) \
  33. $(addprefix ipc/shim_ipc_,$(ipcns)) \
  34. elf/shim_rtld \
  35. $(addprefix shim_,init table syscalls checkpoint random malloc \
  36. async parser debug) syscallas start \
  37. $(patsubst %.c,%,$(wildcard sys/*.c))
  38. graphene_lib = ../../../Pal/lib/graphene-lib.a
  39. pal_lib = $(abspath ../../../Pal/src/libpal.so)
  40. headers = ../include/*.h ../../../Pal/lib/*.h ../../../Pal/include/pal/*.h
  41. all: $(shim_target)
  42. debug: debug = debug
  43. debug: CC = gcc -gdwarf-2 -g3
  44. debug: CFLAGS += -DDEBUG
  45. debug: $(shim_target)
  46. profile: CC = gcc
  47. profile: CFLAGS += -DPROFILE
  48. profile: $(shim_target)
  49. $(graphene_lib):
  50. make -C ../../../Pal/lib $(debug)
  51. libsysdb.so: $(addsuffix .o,$(objs)) $(filter %.map %.lds,$(LDFLAGS)) \
  52. $(graphene_lib) $(pal_lib)
  53. @echo [ $@ ]
  54. $(LD) $(LDFLAGS) -o $@ $(filter-out %.map %.lds,$^) -soname $@ \
  55. -e shim_start
  56. libsysdb_debug.so: $(addsuffix .o,$(filter-out syscallas,$(objs))) \
  57. $(filter %.map %.lds,$($LDFLAGS-debug)) \
  58. $(graphene_lib) $(pal_lib)
  59. @echo [ $@ ]
  60. $(LD) $(LDFLAGS-debug) -o $@ $(filter-out %.map %.lds,$^) -soname $@ \
  61. -e shim_start
  62. libsysdb.a: $(addsuffix .o,$(objs))
  63. @echo [ $@ ]
  64. $(AR) $(ARFLAGS) $@ $^
  65. %.asm: %.c $(headers)
  66. @echo [ $@ ]
  67. @$(CC) $(CFLAGS) $(defs) -c $< -o $<.o
  68. @objdump -S $<.o > $@
  69. @rm $<.o
  70. $(addsuffix .o,$(addprefix ipc/shim_ipc_,$(ipcns))): ipc/*.h
  71. %.o: %.c $(headers)
  72. @echo [ $@ ]
  73. @$(CC) $(CFLAGS) $(defs) -c $< -o $@
  74. %.e: %.c $(headers)
  75. @echo [ $@ ]
  76. @$(CC) $(CFLAGS) $(defs) -E $< -o $@
  77. %.o: %.S $(headers)
  78. @echo [ $@ ]
  79. @$(AS) $(ASFLAGS) $(defs) -c $< -o $@
  80. %.e: %.S $(headers)
  81. @echo [ $@ ]
  82. @$(AS) $(ASFLAGS) $(defs) -E $< -o $@
  83. clean:
  84. rm -f $(addsuffix .o,$(objs)) $(shim_target)