blob: 6ef284f49b785b486f71ddb3f3188a655b315ec6 [file] [log] [blame]
robert.swiecki3bb518c2010-10-14 00:48:24 +00001# honggfuzz - Makefile
2# -----------------------------------------
3#
4# Author: Robert Swiecki <swiecki@google.com>
5#
robert.swiecki@gmail.comba85c3e2015-02-02 14:55:16 +00006# Copyright 2010-2015 by Google Inc. All Rights Reserved.
robert.swiecki3bb518c2010-10-14 00:48:24 +00007#
8# Licensed under the Apache License, Version 2.0 (the "License");
9# you may not use this file except in compliance with the License.
10# You may obtain a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing, software
15# distributed under the License is distributed on an "AS IS" BASIS,
16# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17# See the License for the specific language governing permissions and
18# limitations under the License.
19
20
robert.swiecki@gmail.comef829fa2011-06-22 13:51:57 +000021CC = gcc
robert.swiecki@gmail.com4c1ad432015-02-03 11:04:13 +000022CFLAGS += -c -std=c11 -I. -I/usr/local/include -I/usr/include \
robert.swiecki3bb518c2010-10-14 00:48:24 +000023 -D_GNU_SOURCE \
robert.swiecki@gmail.com71a2f9d2015-02-02 21:32:23 +000024 -Wall -Wextra -Wno-override-init -Werror
robert.swiecki3bb518c2010-10-14 00:48:24 +000025
robert.swiecki@gmail.comef829fa2011-06-22 13:51:57 +000026LD = gcc
robert.swiecki@gmail.com882900b2015-02-11 13:56:22 +000027LDFLAGS += -lm -lpthread -L/usr/local/include -L/usr/include
robert.swiecki3bb518c2010-10-14 00:48:24 +000028
robert.swiecki@gmail.come7190b92015-02-14 23:05:42 +000029SRCS = honggfuzz.c log.c files.c fuzz.c util.c report.c
robert.swiecki3bb518c2010-10-14 00:48:24 +000030
groebert@google.com1bd4c212013-06-19 11:13:56 +000031OBJS = $(SRCS:.c=.o)
32BIN = honggfuzz
33
robert.swiecki@gmail.com448d2812015-02-02 20:57:13 +000034OS ?= $(shell uname -s)
groebert@google.com1bd4c212013-06-19 11:13:56 +000035
robert.swiecki@gmail.coma0d87142015-02-14 13:11:18 +000036ARCH_SRCS := $(wildcard posix/*.c)
robert.swiecki@gmail.comb0cac5b2015-02-17 00:19:59 +000037ARCH = POSIX
groebert@google.com1bd4c212013-06-19 11:13:56 +000038
robert.swiecki3bb518c2010-10-14 00:48:24 +000039ifeq ($(OS),Linux)
robert.swiecki@gmail.comc5f5be62015-02-15 17:17:21 +000040 ifeq ("$(wildcard /usr/include/bfd.h)","")
41 WARN_LIBRARY += "binutils-dev "
42 endif
43 ifeq ("$(wildcard /usr/include/libunwind-ptrace.h)","")
robert.swiecki@gmail.com66ee2752015-02-16 20:49:44 +000044 WARN_LIBRARY += "libunwind-dev/libunwind8-dev "
robert.swiecki@gmail.comf8440e02015-02-03 14:44:35 +000045 endif
robert.swiecki@gmail.com26eee242015-02-16 12:21:36 +000046 LDFLAGS += -lunwind-ptrace -lunwind-generic -lbfd -lopcodes
robert.swiecki@gmail.coma0d87142015-02-14 13:11:18 +000047 ARCH_SRCS := $(wildcard linux/*.c)
robert.swiecki@gmail.comb0cac5b2015-02-17 00:19:59 +000048 ARCH = LINUX
robert.swiecki3bb518c2010-10-14 00:48:24 +000049endif
50ifeq ($(OS),Darwin)
robert.swiecki@gmail.comcc050fd2015-02-02 20:00:42 +000051 CC ?= cc
robert.swiecki@gmail.com65fa9112015-02-02 20:55:36 +000052 CFLAGS = -arch x86_64 -O3 -g -ggdb -c -std=c99 -I. -I~/.homebrew/include -I/usr/include \
groebert@google.com1bd4c212013-06-19 11:13:56 +000053 -x objective-c \
54 -D_GNU_SOURCE \
55 -pedantic \
56 -Wall -Werror -Wimplicit -Wunused -Wcomment -Wchar-subscripts -Wuninitialized -Wcast-align \
57 -Wreturn-type -Wpointer-arith
robert.swiecki@gmail.comcc050fd2015-02-02 20:00:42 +000058 LD ?= cc
robert.swiecki@gmail.com65fa9112015-02-02 20:55:36 +000059 LDFLAGS = -F/System/Library/PrivateFrameworks -framework CoreSymbolication -framework IOKit \
groebert@google.com1bd4c212013-06-19 11:13:56 +000060 -framework Foundation -framework ApplicationServices -framework Symbolication \
61 -framework CoreServices -framework CrashReporterSupport -framework CoreFoundation \
62 -framework CommerceKit -lm -L/usr/include -L$(shell echo ~)/.homebrew/lib
robert.swiecki@gmail.coma0d87142015-02-14 13:11:18 +000063 ARCH_SRCS = $(wildcard mac/*.c)
groebert@google.com1bd4c212013-06-19 11:13:56 +000064 MIG_OUTPUT = mach_exc.h mach_excUser.c mach_excServer.h mach_excServer.c
65 MIG_OBJECTS = mach_excUser.o mach_excServer.o
groebert@google.com43216c82015-02-13 11:11:38 +000066 #CRASH_REPORT = third_party/CrashReport_Yosemite.o
67 CRASH_REPORT = third_party/CrashReport_Mavericks.o
robert.swiecki@gmail.comb0cac5b2015-02-17 00:19:59 +000068 ARCH = DARWIN
robert.swiecki3bb518c2010-10-14 00:48:24 +000069endif
robert.swiecki@gmail.comb0cac5b2015-02-17 00:19:59 +000070
robert.swiecki3bb518c2010-10-14 00:48:24 +000071SRCS += $(ARCH_SRCS)
robert.swiecki@gmail.comb0cac5b2015-02-17 00:19:59 +000072CFLAGS += -D_HF_ARCH=${ARCH}
robert.swiecki3bb518c2010-10-14 00:48:24 +000073
robert.swiecki@gmail.comf7610522015-02-16 10:52:02 +000074all: warn_libs $(BIN)
75
76.c.o: %.c
77 $(CC) $(CFLAGS) -o $@ $<
78
robert.swiecki@gmail.comc5f5be62015-02-15 17:17:21 +000079warn_libs:
80ifdef WARN_LIBRARY
robert.swiecki@gmail.com66ee2752015-02-16 20:49:44 +000081 @/bin/echo -e "*********************************************************"
82 @/bin/echo -e "Development libraries which are most likely missing on your OS:"
83 @/bin/echo "$(WARN_LIBRARY)"
84 @/bin/echo -e "*********************************************************"
robert.swiecki@gmail.comc5f5be62015-02-15 17:17:21 +000085else
86 @/bin/true
87endif
88
groebert@google.com1bd4c212013-06-19 11:13:56 +000089$(BIN): $(MIG_OBJECTS) $(OBJS)
robert.swiecki@gmail.comcc050fd2015-02-02 20:00:42 +000090 $(LD) -o $(BIN) $(OBJS) $(MIG_OBJECTS) $(CRASH_REPORT) $(LDFLAGS)
groebert@google.com1bd4c212013-06-19 11:13:56 +000091
92$(MIG_OUTPUT): /usr/include/mach/mach_exc.defs
93 mig -header mach_exc.h -user mach_excUser.c -sheader mach_excServer.h -server mach_excServer.c /usr/include/mach/mach_exc.defs
94
95$(MIG_OBJECTS): $(MIG_OUTPUT)
96 $(CC) $(CFLAGS) mach_excUser.c
97 $(CC) $(CFLAGS) mach_excServer.c
robert.swiecki3bb518c2010-10-14 00:48:24 +000098
99clean:
robert.swiecki@gmail.comcc050fd2015-02-02 20:00:42 +0000100 $(RM) core $(OBJS) $(BIN) $(MIG_OUTPUT) $(MIG_OBJECTS)
robert.swiecki3bb518c2010-10-14 00:48:24 +0000101
102indent:
robert.swiecki@gmail.com5be88822015-02-14 13:12:09 +0000103 indent -linux -l100 -lc100 -nut -i4 -sob -c33 -cp33 *.c *.h */*.c */*.h; rm -f *~ */*~
robert.swiecki@gmail.comcc050fd2015-02-02 20:00:42 +0000104
105depend:
robert.swiecki@gmail.com42f2a3e2015-02-17 00:20:49 +0000106 makedepend -Y. -Y* -- $(SRCS)
robert.swiecki@gmail.comcc050fd2015-02-02 20:00:42 +0000107
robert.swiecki3bb518c2010-10-14 00:48:24 +0000108# DO NOT DELETE
robert.swiecki@gmail.comcc050fd2015-02-02 20:00:42 +0000109
110honggfuzz.o: common.h log.h files.h fuzz.h util.h
111log.o: common.h log.h
112files.o: common.h files.h log.h
robert.swiecki@gmail.com42f2a3e2015-02-17 00:20:49 +0000113fuzz.o: common.h fuzz.h arch.h files.h log.h report.h util.h
robert.swiecki@gmail.comcc050fd2015-02-02 20:00:42 +0000114util.o: common.h log.h
robert.swiecki@gmail.com42f2a3e2015-02-17 00:20:49 +0000115report.o: common.h report.h log.h util.h
116linux/ptrace.o: common.h linux/ptrace.h files.h linux/bfd.h linux/unwind.h
117linux/ptrace.o: log.h util.h
118linux/arch.o: common.h arch.h linux/ptrace.h log.h util.h
119linux/bfd.o: common.h linux/bfd.h files.h log.h util.h
120linux/unwind.o: common.h linux/unwind.h log.h