osx/Makefile
author Markus Bröker<broeker.markus@googlemail.com>
Sat, 21 Oct 2017 13:45:05 +0200
changeset 171 c6e0af68825a
parent 168 dfb60716880c
child 172 43ae72f88d06
permissions -rw-r--r--
Entrypoint and RET fixed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
168
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
     1
      CC = gcc -g -ggdb
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
     2
      LD = ld
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
     3
	ARCH = -arch i386
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
     4
  CFLAGS = -Wall -O2 -Iinclude
171
c6e0af68825a Entrypoint and RET fixed
Markus Bröker<broeker.markus@googlemail.com>
parents: 168
diff changeset
     5
 LDFLAGS = $(ARCH) -Wl,-no_pie
c6e0af68825a Entrypoint and RET fixed
Markus Bröker<broeker.markus@googlemail.com>
parents: 168
diff changeset
     6
    NASM = nasm -f macho32 -Iinclude -g
168
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
     7
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
     8
  TARGETS = helloASM
171
c6e0af68825a Entrypoint and RET fixed
Markus Bröker<broeker.markus@googlemail.com>
parents: 168
diff changeset
     9
  TARGETS+= helloC
168
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    10
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    11
OBJECTS  = hello.o main.o
171
c6e0af68825a Entrypoint and RET fixed
Markus Bröker<broeker.markus@googlemail.com>
parents: 168
diff changeset
    12
ENTRYPOINT = _entryPoint
168
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    13
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    14
.SUFFIXES: .c .asm
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    15
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    16
.c.o:
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    17
	@echo Compiling $< ...
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    18
	@$(CC) -c $(CFLAGS) $(ARCH) -o $@ $<
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    19
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    20
.asm.o:
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    21
	@echo Assembling $< ...
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    22
	@$(NASM) $< -o $@
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    23
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    24
all: $(TARGETS)
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    25
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    26
helloC: $(OBJECTS)
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    27
	@echo Linking $(OBJECTS) ...
171
c6e0af68825a Entrypoint and RET fixed
Markus Bröker<broeker.markus@googlemail.com>
parents: 168
diff changeset
    28
	$(CC) $(LDFLAGS) $(OBJECTS) -o $@
168
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    29
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    30
helloASM: hello.o
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    31
	@echo Linking $(OBJECTS) ...
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    32
	$(LD) -static -e $(ENTRYPOINT) $< -o $@
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    33
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    34
.PHONY: clean uninstall
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    35
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    36
clean:
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    37
	$(RM) *.o *~ $(TARGETS)