Makefile 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. subdirs = native
  2. SYS ?= $(shell gcc -dumpmachine)
  3. export SYS
  4. PALDIR = $(level)../../../Pal/src
  5. SHIMDIR = $(level)../src
  6. RUNTIME = $(level)../../../Runtime
  7. ifeq ($(SGX),1)
  8. PAL_LOADER = pal_loader SGX
  9. else
  10. PAL_LOADER = pal_loader
  11. endif
  12. CC = gcc
  13. CXX = g++
  14. CFLAGS = -Wall -std=gnu99
  15. CFLAGS-debug = $(CFLAGS) -I$(SHIMDIR)/../include -I$(PALDIR)/../include/pal -I$(PALDIR)/../lib
  16. LDFLAGS =
  17. LDFLAGS-debug = $(LDFLAGS) -L$(SHIMDIR) -L$(PALDIR) -Wl,-rpath-link=$(abspath $(RUNTIME))
  18. CFLAGS-libos = -I$(SHIMDIR)/../include -L$(SHIMDIR)/../../glibc-build/libos
  19. .PHONY: default
  20. default: all
  21. include $(PALDIR)/Makefile.Test
  22. .PHONY: all
  23. all: pal_loader $(target) $(if $(level),,build-subdirs) | $(call expand_target,$(exec_target))
  24. ifeq ($(DEBUG),1)
  25. CC += -g
  26. CXX += -g
  27. endif
  28. export DEBUG
  29. ifeq ($(WERROR),1)
  30. CFLAGS += -Werror
  31. endif
  32. ifeq ($(ABSPATH_IN_MANIFEST),yes)
  33. manifest_rules = \
  34. -e 's:\$$(PAL):$(abspath $(RUNTIME))/$(PAL_LOADER):g' \
  35. -e 's:\$$(PWD):$(PWD):g' \
  36. -e 's:\$$(BIN):$(subst .manifest,,$(notdir $@)):g' \
  37. -e 's:\$$(SHIMPATH):$(abspath $(RUNTIME))/libsysdb.so:g' \
  38. -e 's:\$$(LIBCDIR):$(abspath $(RUNTIME)):g' \
  39. $(extra_rules)
  40. else
  41. manifest_rules= \
  42. -e 's:\$$(PAL):$(abspath $(RUNTIME))/$(PAL_LOADER):g' \
  43. -e 's:\$$(PWD):$(PWD):g' \
  44. -e 's:\$$(BIN):$(subst .manifest,,$(notdir $@)):g' \
  45. -e 's:\$$(SHIMPATH):'$$RELDIR'$(RUNTIME)/libsysdb.so:g' \
  46. -e 's:\$$(LIBCDIR):'$$RELDIR'$(RUNTIME):g' \
  47. $(extra_rules)
  48. endif
  49. pal_loader:
  50. ln -sf $(RUNTIME)/pal_loader
  51. relative-to = $(shell python -c "import os.path; print os.path.relpath(\"$(abspath $2)\",\"$(abspath $1)\")")
  52. %manifest: %manifest.template
  53. @echo [ $@ ]
  54. RELDIR=$(filter-out ./,$(call relative-to,$(dir $@),$(shell pwd))/) && \
  55. sed $(manifest_rules) $< > $@
  56. (grep -q '^#!' $@ && chmod +x $@) || true
  57. manifest: manifest.template
  58. @echo [ $@ ]
  59. sed $(manifest_rules) $< > $@
  60. .PHONY: clean
  61. clean: $(clean-extra) $(if $(level),,clean-subdirs)
  62. rm -rf pal_loader $(call expand_target,$(exec_target)) $(target)
  63. .PHONY: build-subdirs
  64. build-subdirs:
  65. for f in $(subdirs); do (cd $$f; $(MAKE); cd ..); done
  66. .PHONY: clean-subdirs
  67. clean-subdirs:
  68. for f in $(subdirs); do (cd $$f; $(MAKE) clean; cd ..); done