AcessNative - Spawn in libacess-native (with AN_GETPATH syscall)
[tpg/acess2.git] / AcessNative / ld-acess_src / Makefile
1 #
2 #
3
4 ifeq ($(PLATFORM),)
5         PLATFORM := lin
6 endif
7
8 OBJ := main.o syscalls.o request.o binary.o memory.o exports.o
9 OBJ += elf.o elf_load.o
10 OBJ := $(addprefix obj-$(PLATFORM)/,$(OBJ))
11
12 ifeq ($(PLATFORM),win)
13         BIN := ../ld-acess.exe
14         LINKADDR := 0x70000000
15         LDFLAGS += -lws2_32 -Wl,--image-base,$(LINKADDR)
16 endif
17 ifeq ($(PLATFORM),lin)
18         BIN := ../ld-acess
19         LINKADDR := 0x70000000
20 #       LD += -m elf_i386
21 endif
22
23 CFLAGS   += -Wall
24 CFLAGS   += -Werror
25 CFLAGS   += -g -std=c99
26 CPPFLAGS += -DARCHDIR_is_x86_64=1
27 LDFLAGS  += -g -Wl,-T,obj-$(PLATFORM)/link.ld
28
29 DEPFILES  = $(filter %.o,$(OBJ))
30 DEPFILES := $(DEPFILES:%=%.dep)
31
32 .PHONY: all clean
33
34 all: $(BIN)
35
36 clean:
37         $(RM) $(BIN) $(OBJ) $(DEPFILES) obj-$(PLATFORM)/link.ld
38
39 $(BIN): obj-$(PLATFORM)/link.ld $(OBJ)
40         $(CC) -o $@ $(OBJ) $(LDFLAGS)
41         objdump -S $@ > [email protected]
42
43 obj-$(PLATFORM)/%.o: %.c
44         @mkdir -p $(dir $@)
45         @echo [CC] -o $@
46         @$(CC) -c $< -o $@ $(CFLAGS) $(CPPFLAGS)
47         @$(CC) -M $(CPPFLAGS) -MT $@ -o [email protected] $<
48
49 # Modify the default makefile to put the executable at 1MB instead
50 obj-lin/link.ld: Makefile
51         @mkdir -p $(dir $@)
52         @echo "Making Linker Script ($@)"
53         $(LD) -g --verbose | awk '{ if( substr($$1,0,5) == "====="){ bPrint = !bPrint; } else { if(bPrint){ print $$0;} } }' | sed 's/\b0x[048][0-9]*\b/$(LINKADDR)/g' | sed 's/CONSTANT (MAXPAGESIZE)/0x1000/g' > $@
54
55 # Modify the default makefile to put the executable at 1MB instead
56 obj-win/link.ld: Makefile
57         @mkdir -p $(dir $@)
58         @echo "Making Linker Script ($@)"
59         $(LD) -g --verbose | awk '{ if( substr($$1,0,5) == "====="){ bPrint = !bPrint; } else { if(bPrint){ print $$0;} } }' | sed 's/\b0x[048][0-9]*\b/$(LINKADDR)/g' | sed 's/CONSTANT (MAXPAGESIZE)/0x1000/g' > $@
60
61 -include $(DEPFILES)
62

UCC git Repository :: git.ucc.asn.au