Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 23457288a9
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 67 lines (49 sloc) 1.559 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
GCCFLAGS=-g -Iinclude -Wall -MMD -fno-omit-frame-pointer
CXXFLAGS=$(GCCFLAGS) -W -Werror
CFLAGS=$(GCCFLAGS) -fPIC

EXES=libmac/libmac.so extract macho2elf ld-mac

MAC_C_SRCS=$(wildcard mach/*.c)
MAC_CXX_SRCS=$(wildcard mach/*.cc)
MAC_C_BINS=$(MAC_C_SRCS:.c=.c.bin)
MAC_CXX_BINS=$(MAC_CXX_SRCS:.cc=.cc.bin)
MACBINS=$(MAC_C_BINS) $(MAC_CXX_BINS)
MACTXTS=$(MACBINS:.bin=.txt)

OS=$(shell uname)

ifeq ($(OS), Linux)
MAC_TOOL_DIR=/usr/i686-apple-darwin10
MAC_BIN_DIR=$(MAC_TOOL_DIR)/usr/bin
MAC_CC=PATH=$(MAC_BIN_DIR) ./ld-mac $(MAC_BIN_DIR)/gcc --sysroot=$(MAC_TOOL_DIR)
MAC_CXX=PATH=$(MAC_BIN_DIR) ./ld-mac $(MAC_BIN_DIR)/g++ --sysroot=$(MAC_TOOL_DIR)
MAC_OTOOL=./ld-mac $(MAC_BIN_DIR)/otool
MAC_TARGETS=ld-mac $(MACBINS) $(MACTXTS)
else
MAC_CC=$(CC)
MAC_CXX=$(CXX)
MAC_OTOOL=otool
MAC_TARGETS=$(MACBINS) $(MACTXTS)
endif

all: $(EXES)

mach: $(MAC_TARGETS)

check: all mach
./runtests.sh

$(MAC_C_BINS): %.c.bin: %.c
$(MAC_CC) -g $^ -o $@

$(MAC_CXX_BINS): %.cc.bin: %.cc
$(MAC_CXX) -g $^ -o $@

$(MACTXTS): %.txt: %.bin
$(MAC_OTOOL) -hLltvV $^ > $@

#ok: macho2elf
# ./genelf.sh
# touch $@

extract: extract.o fat.o
$(CXX) $^ -o $@ -g -I. -W -Wall

macho2elf: macho2elf.o mach-o.o fat.o log.o
$(CXX) $^ -o $@ -g

ld-mac: ld-mac.o mach-o.o fat.o log.o
$(CXX) $^ -o $@ -g -ldl -lpthread

# TODO(hamaji): autotoolize?
libmac/libmac.so: libmac/mac.o
$(CC) -shared $^ -o $@ -luuid -lcrypto -lCoreFoundation || (echo "*** libCoreFoundation not found ***"; gcc -shared $^ -o $@ -luuid -lcrypto)

clean:
rm -f *.o *.d */*.o */*.d $(EXES)

-include *.d */*.d
Something went wrong with that request. Please try again.