Terminate the nasty build warnings
[striptease.git] / Makefile
blob0369c012ff1d8bba645bf3e558f27d9ce37ff9d0
1 # Makefile for striptease project
2 # Copyright (C) 2011,2012 Kyle J. McKay. All rights reserved.
4 # Permission is hereby granted, free of charge, to any person obtaining a copy
5 # of this software and associated documentation files (the "Software"), to
6 # deal in the Software without restriction, including without limitation the
7 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 # sell copies of the Software, and to permit persons to whom the Software is
9 # furnished to do so, subject to the following conditions:
11 # The above copyright notice and this permission notice shall be included in
12 # all copies or substantial portions of the Software.
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 # Except as contained in this notice, the name of the author(s) shall not
22 # be used in advertising or otherwise to promote the sale, use or other
23 # dealings in this Software without prior written authorization from the
24 # author(s).
26 include version.mak
28 .PHONY : all clean
30 ifeq ($(DEBUG),)
31 DEBUG := 0
32 endif
34 export DEBUG
36 CC = gcc-4.0
37 CINC = -Iinclude
38 XSDK := $(shell xcode-select -print-path 2>/dev/null)
39 ifeq ($(XSDK),)
40 XSDK := /Developer
41 endif
42 ifeq (0,$(shell test -d '$(XSDK)/Platforms/MacOSX.platform/Developer/SDKs'; echo $$?))
43 XSDK := $(XSDK)/Platforms/MacOSX.platform/Developer/SDKs
44 else
45 ifeq (0,$(shell test -d '$(XSDK)/SDKs'; echo $$?))
46 XSDK := $(XSDK)/SDKs
47 else
48 ifeq ($(DEBUG),0)
49 ifneq ($(MAKECMDGOALS),clean)
50 $(error Could not find Developer SDKs directory)
51 endif
52 endif
53 endif
54 endif
56 OSXNUVER := $(shell uname -r | cut -d. -f1)
57 OSXNUVERACTUAL := $(shell uname -r | cut -d. -f1)
59 ifeq (0,$(shell test -d '$(XSDK)/MacOSX10.4u.sdk'; echo $$?))
60 OSXNUVER := 8
61 endif
63 ifeq ($(DEBUG),0)
64 $(shell mkdir -p build/Release/libstuff)
65 DD=build/Release/
66 COPTS=$(ARCH) -Os
67 LDEXTRA=$(ARCH) -Wl,-S -Wl,-x
68 else
69 $(shell mkdir -p build/Debug/libstuff)
70 DD=build/Debug/
71 COPTS=-O0 -g
72 LDEXTRA=-g
73 endif
75 # The 10.4u SDK can be used, but do not require it except on 10.4.x
76 # Always build x86_64 if actually running on 10.5 or later
77 ifeq ($(OSXNUVER),8)
78 ifneq ($(OSXNUVERACTUAL),8)
79 ARCH = -arch x86_64 -arch i386 -arch ppc
80 ARCH += -Xarch_ppc -mmacosx-version-min=10.4
81 ARCH += -Xarch_ppc -isysroot$(XSDK)/MacOSX10.4u.sdk
82 ARCH += -Xarch_i386 -mmacosx-version-min=10.4
83 ARCH += -Xarch_i386 -isysroot$(XSDK)/MacOSX10.4u.sdk
84 ARCH += -Xarch_x86_64 -mmacosx-version-min=10.5
85 ARCH += -Xarch_x86_64 -isysroot$(XSDK)/MacOSX10.5.sdk
86 else
87 ARCH = -arch i386 -arch ppc
88 ARCH += -mmacosx-version-min=10.4 -isysroot$(XSDK)/MacOSX10.4u.sdk
89 endif
90 else
91 ARCH = -arch x86_64 -arch i386 -arch ppc
92 ARCH += -Xarch_ppc -mmacosx-version-min=10.4
93 ARCH += -Xarch_i386 -mmacosx-version-min=10.4
94 ARCH += -Xarch_x86_64 -mmacosx-version-min=10.5
95 ARCH += -isysroot$(XSDK)/MacOSX10.5.sdk
96 endif
98 COPTS += -include preinc.h -DCCTOOLSVER=$(CCTOOLSVER)
100 LDOPTS = -Wl,-no_uuid -Wl,-dead_strip -Wl,-multiply_defined,suppress
101 LDOPTS += $(LDEXTRA)
103 all : $(DD)tease
105 .PHONY : tools tease strip install_name_tool
107 tools : strip install_name_tool tease
109 tease : $(DD)tease
111 strip : $(DD)strip
113 install_name_tool : $(DD)install_name_tool
115 LIBSTUFF_SRC := $(wildcard libstuff/*.c)
117 TEASE_SRC = \
118 tease.c \
119 $(LIBSTUFF_SRC)
121 STRIP_SRC = \
122 strip.c \
123 $(LIBSTUFF_SRC)
125 INSTALL_NAME_TOOL_SRC = \
126 install_name_tool.c \
127 $(LIBSTUFF_SRC)
129 TEASE_OBJS = $(addprefix $(DD),$(TEASE_SRC:.c=.o)) $(DD)version_tease.o
131 STRIP_OBJS = $(addprefix $(DD),$(STRIP_SRC:.c=.o)) $(DD)version_strip.o
133 INSTALL_NAME_TOOL_OBJS = $(addprefix $(DD),$(INSTALL_NAME_TOOL_SRC:.c=.o)) \
134 $(DD)version_install_name_tool.o
136 $(DD)%.o : %.c
137 $(CC) -Wall -c $(COPTS) $(CINC) -o $@ $<
139 $(DD)version_tease.o : version.c
140 $(CC) -Wall -c $(COPTS) $(CINC) -DPROGRAMNAME=tease -o $@ $<
142 $(DD)version_strip.o : version.c
143 $(CC) -Wall -c $(COPTS) $(CINC) -DPROGRAMNAME=strip -o $@ $<
145 $(DD)version_install_name_tool.o : version.c
146 $(CC) -Wall -c $(COPTS) $(CINC) -DPROGRAMNAME=install_name_tool -o $@ $<
148 $(DD)tease : $(TEASE_OBJS)
149 $(CC) -o $@ $(LDOPTS) $^
150 ifneq ($(DEBUG),0)
151 dsymutil $@
152 else
153 strip $@
154 cd '$(@D)' && zip -X -9 '$(@F)-$(CCTOOLSVER).zip' '$(@F)'
155 endif
157 $(DD)strip : $(STRIP_OBJS)
158 $(CC) -o $@ $(LDOPTS) $^
159 ifneq ($(DEBUG),0)
160 dsymutil $@
161 else
162 strip $@
163 cd '$(@D)' && zip -X -9 '$(@F)-$(CCTOOLSVER).zip' '$(@F)'
164 endif
166 $(DD)install_name_tool : $(INSTALL_NAME_TOOL_OBJS)
167 $(CC) -o $@ $(LDOPTS) $^
168 ifneq ($(DEBUG),0)
169 dsymutil $@
170 else
171 strip $@
172 cd '$(@D)' && zip -X -9 '$(@F)-$(CCTOOLSVER).zip' '$(@F)'
173 endif
175 clean :
176 rm -rf build