Makefile 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. include ../src/Makefile.Host
  2. CC = gcc
  3. CFLAGS = -Wall -O2 -std=c11 -fno-builtin -nostdlib -no-pie \
  4. -I../include/pal -I../lib
  5. .PHONY: default
  6. default: all
  7. include ../src/Makefile.Test
  8. executables = HelloWorld File Failure Thread Fork Event Process Exception \
  9. Memory Pipe Tcp Udp Yield Broadcast Ipc Server Wait HandleSend \
  10. Select Segment Sleep Cpuid Pie
  11. manifests = manifest
  12. target = $(executables) $(manifests)
  13. graphene_lib = .lib/graphene-lib.a
  14. pal_lib = ../../Runtime/libpal-$(PAL_HOST).so
  15. .PHONY: all
  16. all: pal_loader $(call expand_target,$(target))
  17. ifeq ($(DEBUG),1)
  18. CC += -g
  19. endif
  20. export DEBUG
  21. ifeq ($(WERROR),1)
  22. CFLAGS += -Werror
  23. endif
  24. pal_loader:
  25. ln -sf ../../Runtime/pal_loader
  26. manifest: manifest.template
  27. cp -f $< $@
  28. %.manifest: %.manifest.template
  29. cp -f $< $@
  30. ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
  31. $(executables): %: %.c $(graphene_lib) $(pal_lib) ../src/user_start.o
  32. @echo [ $@ ]
  33. @$(CC) -MD -MP $(CFLAGS) $(if $(filter Pie,$@),-fPIC -pie,) $^ -o $@
  34. .lib/host_endian.h: ../src/host/$(PAL_HOST)/host_endian.h
  35. @mkdir -p .lib
  36. cp -f $< $@
  37. $(graphene_lib): .lib/host_endian.h
  38. $(MAKE) -C ../lib target=$(abspath .lib)/
  39. else
  40. .IGNORE: $(executables)
  41. $(executables):
  42. endif
  43. -include $(addsuffix .d, $(executables)) $(addsuffix .i.d, $(executables)) $(addsuffix .s.d, $(executables))
  44. .PHONY: clean
  45. clean:
  46. rm -rf pal_loader $(call expand_target,$(target)) .lib *.cached \
  47. $(addsuffix .d, $(executables)) $(addsuffix .i.d, $(executables)) \
  48. $(addsuffix .s.d, $(executables))