Makefile 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 = -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. .PHONY: default
  19. default: all
  20. include $(PALDIR)/Makefile.Test
  21. .PHONY: all
  22. all: pal_loader $(target) $(if $(level),,build-subdirs) | $(call expand_target,$(exec_target))
  23. ifeq ($(DEBUG),1)
  24. CC += -g
  25. CXX += -g
  26. endif
  27. export DEBUG
  28. ifeq ($(ABSPATH_IN_MANIFEST),yes)
  29. manifest_rules = \
  30. -e 's:\$$(PAL):$(abspath $(RUNTIME))/$(PAL_LOADER):g' \
  31. -e 's:\$$(PWD):$(PWD):g' \
  32. -e 's:\$$(BIN):$(subst .manifest,,$(notdir $@)):g' \
  33. -e 's:\$$(SHIMPATH):$(abspath $(RUNTIME))/libsysdb.so:g' \
  34. -e 's:\$$(LIBCDIR):$(abspath $(RUNTIME)):g' \
  35. $(extra_rules)
  36. else
  37. manifest_rules= \
  38. -e 's:\$$(PAL):$(abspath $(RUNTIME))/$(PAL_LOADER):g' \
  39. -e 's:\$$(PWD):$(PWD):g' \
  40. -e 's:\$$(BIN):$(subst .manifest,,$(notdir $@)):g' \
  41. -e 's:\$$(SHIMPATH):'$$RELDIR'$(RUNTIME)/libsysdb.so:g' \
  42. -e 's:\$$(LIBCDIR):'$$RELDIR'$(RUNTIME):g' \
  43. $(extra_rules)
  44. endif
  45. pal_loader:
  46. ln -sf $(RUNTIME)/pal_loader
  47. relative-to = $(shell python -c "import os.path; print os.path.relpath(\"$(abspath $2)\",\"$(abspath $1)\")")
  48. %manifest: %manifest.template
  49. @echo [ $@ ]
  50. RELDIR=$(filter-out ./,$(call relative-to,$(dir $@),$(shell pwd))/) && \
  51. sed $(manifest_rules) $< > $@
  52. (grep -q '^#!' $@ && chmod +x $@) || true
  53. manifest: manifest.template
  54. @echo [ $@ ]
  55. sed $(manifest_rules) $< > $@
  56. .PHONY: clean
  57. clean: $(clean-extra) $(if $(level),,clean-subdirs)
  58. rm -rf pal_loader $(call expand_target,$(exec_target)) $(target)
  59. .PHONY: build-subdirs
  60. build-subdirs:
  61. for f in $(subdirs); do (cd $$f; $(MAKE); cd ..); done
  62. .PHONY: clean-subdirs
  63. clean-subdirs:
  64. for f in $(subdirs); do (cd $$f; $(MAKE) clean; cd ..); done