Makefile 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. SYS ?= $(shell gcc -dumpmachine)
  2. CC = gcc
  3. CFLAGS = -Wall -O2 -std=gnu99 -fgnu89-inline -fno-builtin -nostdlib \
  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 = ../src/libpal.so
  15. headers = $(wildcard ../include/pal/*.h)
  16. .PHONY: all
  17. all: pal_loader $(call expand_target,$(target))
  18. ifeq ($(DEBUG),1)
  19. CC += -g
  20. endif
  21. export DEBUG
  22. pal_loader:
  23. ln -sf ../../Runtime/pal_loader
  24. manifest: manifest.template
  25. cp -f $< $@
  26. %.manifest: %.manifest.template
  27. cp -f $< $@
  28. ifeq ($(SYS),x86_64-linux-gnu)
  29. $(executables): %: %.c $(graphene_lib) $(pal_lib) ../src/user_start.o
  30. @echo [ $@ ]
  31. @$(CC) $(CFLAGS) $(if $(filter Pie,$@),-fPIC -pie,) $^ -o $@
  32. $(graphene_lib):
  33. $(MAKE) -C ../lib target=$(shell pwd)/.lib/
  34. .PHONY: pack
  35. pack: $(executables)
  36. @../../Scripts/pack_binaries.sh test $^
  37. else
  38. $(executables): .packed/test.tar.gz
  39. tar -xmozf $< $@
  40. endif
  41. .PHONY: clean
  42. clean:
  43. rm -rf pal_loader $(call expand_target,$(target)) .lib *.cached