Makefile 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
  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. else
  35. .IGNORE: $(executables)
  36. $(executables):
  37. endif
  38. .PHONY: clean
  39. clean:
  40. rm -rf pal_loader $(call expand_target,$(target)) .lib *.cached