osx/Makefile
author Markus Bröker<broeker.markus@googlemail.com>
Sun, 10 Feb 2019 13:17:01 +0100
changeset 173 374a86886bc5
parent 172 43ae72f88d06
permissions -rw-r--r--
LAST-DIGIT-BUG: INCREMENT before LF

      CC = gcc -g -ggdb
      LD = ld
	ARCH = -arch i386
  CFLAGS = -Wall -O2 -Iinclude
 LDFLAGS = $(ARCH) -Wl,-no_pie
    NASM = nasm -f macho32 -Iinclude -g

  TARGETS = helloASM
  TARGETS+= helloC

OBJECTS  = hello.o main.o
ENTRYPOINT = start

.SUFFIXES: .c .asm

.c.o:
	@echo Compiling $< ...
	@$(CC) -c $(CFLAGS) $(ARCH) -o $@ $<

.asm.o:
	@echo Assembling $< ...
	@$(NASM) $< -o $@

all: $(TARGETS)

helloC: $(OBJECTS)
	@echo Linking $(OBJECTS) ...
	$(CC) $(LDFLAGS) $(OBJECTS) -o $@

helloASM: hello.o
	@echo Linking $(OBJECTS) ...
	$(LD) -static -e $(ENTRYPOINT) $< -o $@

.PHONY: clean uninstall

clean:
	$(RM) *.o *~ $(TARGETS)