Merge branch 'master' of git://git.ucc.asn.au/tpg/acess2
[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         LDFLAGS += -lws2_32
15 endif
16 ifeq ($(PLATFORM),lin)
17         BIN := ../ld-acess
18         LINKADDR := 0x70000000
19 #       LD += -m elf_i386
20 endif
21
22 CFLAGS   += -Wall
23 CFLAGS   += -Werror
24 CFLAGS   += -g
25 CPPFLAGS += -DARCHDIR_is_x86_64=1
26 LDFLAGS  += -g -Wl,-T,obj-$(PLATFORM)/link.ld
27
28 DEPFILES  = $(filter %.o,$(OBJ))
29 DEPFILES := $(DEPFILES:%=%.dep)
30
31 .PHONY: all clean
32
33 all: $(BIN)
34
35 clean:
36         $(RM) $(BIN) $(OBJ) $(DEPFILES) obj-$(PLATFORM)/link.ld
37
38 $(BIN): obj-$(PLATFORM)/link.ld $(OBJ)
39         $(CC) -o $@ $(OBJ) $(LDFLAGS)
40         objdump -S $@ > [email protected]
41
42 obj-$(PLATFORM)/%.o: %.c
43         @mkdir -p $(dir $@)
44         @echo [CC] -o $@
45         @$(CC) -c $< -o $@ $(CFLAGS) $(CPPFLAGS)
46         @$(CC) -M $(CPPFLAGS) -MT $@ -o [email protected] $<
47
48 # Modify the default makefile to put the executable at 1MB instead
49 obj-lin/link.ld: Makefile
50         @mkdir -p $(dir $@)
51         @echo "Making Linker Script ($@)"
52         $(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' > $@
53
54 # Modify the default makefile to put the executable at 1MB instead
55 obj-win/link.ld: Makefile
56         @mkdir -p $(dir $@)
57         @echo "Making Linker Script ($@)"
58         $(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' > $@
59
60 -include $(DEPFILES)
61

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