ifeq ($(PLATFORM),win)
BIN := ../ld-acess.exe
+ LINKADDR := 0x70000000
+ LDFLAGS += -lws2_32 -Wl,--image-base,$(LINKADDR)
endif
ifeq ($(PLATFORM),lin)
BIN := ../ld-acess
- LINKADDR := 0x200000
+ LINKADDR := 0x70000000
# LD += -m elf_i386
endif
CFLAGS += -Wall
CFLAGS += -Werror
-CFLAGS += -g
+CFLAGS += -g -std=c99
CPPFLAGS += -DARCHDIR_is_x86_64=1
-LDFLAGS += -g
-# -Wl,-T,obj-$(PLATFORM)/link.ld
+LDFLAGS += -g -Wl,-T,obj-$(PLATFORM)/link.ld
DEPFILES = $(filter %.o,$(OBJ))
DEPFILES := $(DEPFILES:%=%.dep)
$(RM) $(BIN) $(OBJ) $(DEPFILES) obj-$(PLATFORM)/link.ld
$(BIN): obj-$(PLATFORM)/link.ld $(OBJ)
- $(CC) $(LDFLAGS) -o $@ $(OBJ)
+ $(CC) -o $@ $(OBJ) $(LDFLAGS)
obj-$(PLATFORM)/%.o: %.c
# Modify the default makefile to put the executable at 1MB instead
-obj-lin/link.ld:
+obj-lin/link.ld: Makefile
+ @mkdir -p $(dir $@)
+ @echo "Making Linker Script ($@)"
+ $(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' > $@
+
+# Modify the default makefile to put the executable at 1MB instead
+obj-win/link.ld: Makefile
@mkdir -p $(dir $@)
@echo "Making Linker Script ($@)"
$(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' > $@