Debian Codegraph @

libtest/GNUmakefile

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 # -*- makefile -*-
2 BUILD_OS := $(strip $(shell uname -s | tr '[:upper:]' '[:lower:]'))
3 OS ?= $(BUILD_OS)
4
5 # Default value of $OS on Windows is Windows_NT
6 ifeq ($(OS), Windows_NT)
7 # that's how we detect x64...
8 ifneq ($(findstring 64, $(BUILD_OS)),)
9 OS = win64
10 else
11 OS = win32
12 endif
13 endif
14
15 CPU = $(shell uname -m | sed -e 's/i[345678]86/i386/')
16 PLATFORM = $(CPU)-$(OS)
17
18 ifeq ($(OS), sunos)
19 OS = solaris
20 endif
21
22 ifneq ($(findstring cygwin,$(BUILD_OS)),)
23 # cygwin is always x32 for now
24 OS = win32
25 endif
26
27 SRC_DIR = libtest
28 BUILD_DIR ?= build
29 TEST_BUILD_DIR = $(BUILD_DIR)/libtest
30 # Set defaults to unix (linux/solaris/bsd)
31 PREFIX = lib
32 LIBEXT = so
33 LIBNAME = $(PREFIX)test.$(LIBEXT)
34
35 export MACOSX_DEPLOYMENT_TARGET=10.4
36
37 CCACHE := $(ccache -V >/dev/null 2>&1 && echo ccache)
38
39 TEST_SRCS = $(wildcard $(SRC_DIR)/*.c)
40 TEST_OBJS := $(patsubst $(SRC_DIR)/%.c, $(TEST_BUILD_DIR)/%.o, $(TEST_SRCS))
41
42 #
43 # Compiler/linker flags from:
44 # http://weblogs.java.net/blog/kellyohair/archive/2006/01/compilation_of_1.html
45 JFLAGS = -fno-omit-frame-pointer -fno-strict-aliasing
46 OFLAGS = -O2 $(JFLAGS)
47 WFLAGS = -W -Werror -Wall -Wno-unused -Wno-unused-parameter -Wno-parentheses
48 PICFLAGS = -fPIC
49 SOFLAGS = -shared -Wl,-O1
50 LDFLAGS += $(SOFLAGS)
51
52 IFLAGS = -I"$(BUILD_DIR)"
53 CFLAGS = $(OFLAGS) $(WFLAGS) $(IFLAGS) $(PICFLAGS) -D_REENTRANT
54
55 ifeq ($(OS), win64)
56 override CPU = x86_64
57 JDK_INCLUDES=-I$(JNI_DIR)/win32/include -I$(JNI_DIR)/win32/include/win32
58 CC = x86_64-w64-mingw32-gcc -m64
59 PICFLAGS =
60 ifneq ($(findstring cygwin, $(BUILD_OS)),)
61 CC += -mno-cygwin
62 LDFLAGS += -mno-cygwin
63 endif
64 CFLAGS += -mwin32 -D_JNI_IMPLEMENTATION_
65 LDFLAGS += -Wl,--add-stdcall-alias
66 PICFLAGS=
67 SOFLAGS += -shared -static-libgcc
68 PREFIX =
69 LIBEXT = dll
70 endif
71
72 ifeq ($(OS), win32)
73 CC += -mno-cygwin -mwin32
74 LDFLAGS += -mno-cygwin -Wl,--add-stdcall-alias
75 PREFIX =
76 PICFLAGS =
77 LIBEXT = dll
78 endif
79
80 ifeq ($(OS), darwin)
81 ARCHFLAGS =
82 ARCHES = x86_64 arm64
83
84 ifneq ($(realpath $(wildcard /Xcode3/usr/bin/gcc)),)
85 XCODE=/Xcode3
86 else
87 XCODE=$(shell xcode-select -print-path)
88 endif
89 ifneq ($(realpath $(wildcard $(XCODE)/usr/bin/gcc-4.0)),)
90 CC = $(XCODE)/usr/bin/gcc-4.0
91 else
92 CC = $(XCODE)/usr/bin/gcc
93 endif
94
95 MACSDK = /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
96 ARCHFLAGS = $(foreach arch, $(ARCHES),-arch $(arch))
97 CFLAGS += $(ARCHFLAGS) -isysroot $(MACSDK) -DTARGET_RT_MAC_CFM=0
98 CFLAGS += -fno-common
99 LDFLAGS = $(ARCHFLAGS) -dynamiclib -Wl,-syslibroot,$(MACSDK) -mmacosx-version-min=10.4
100 LDFLAGS += $(foreach arch, $(ARCHES),-arch $(arch))
101 # link against the universal libraries on ppc machines
102 LDFLAGS += -L$(MACSDK)/usr/lib
103 LIBEXT = dylib
104 FFI_CFLAGS += -isysroot $(MACSDK)
105 PICFLAGS =
106 SOFLAGS =
107 endif
108
109 ifeq ($(OS), linux)
110 SOFLAGS += -Wl,-soname,$(LIBNAME)
111 endif
112
113 ifeq ($(OS), solaris)
114 CC = gcc
115 CFLAGS += -std=c99
116 LD = /usr/ccs/bin/ld
117 SOFLAGS = -shared -static-libgcc
118 endif
119
120 ifeq ($(OS), aix)
121 LIBEXT = a
122 SOFLAGS = -shared -static-libgcc
123 PICFLAGS += -pthread
124 endif
125
126 ifneq ($(findstring bsd, $(OS)),)
127 SOFLAGS = -shared -static-libgcc
128 CFLAGS += -pthread
129 LDFLAGS += -pthread
130 endif
131
132 ifneq ($(findstring cygwin, $(OS)),)
133 CFLAGS += -mno-cygwin -mwin32
134 LDFLAGS += -mno-cygwin -Wl,--add-stdcall-alias
135 LIBEXT = dll
136 PREFIX =
137 PICFLAGS =
138 endif
139 ifneq ($(findstring mingw, $(OS)),)
140 LIBEXT = dll
141 PICFLAGS=
142 endif
143
144 LIBTEST = $(BUILD_DIR)/$(LIBNAME)
145
146 all: $(LIBTEST)
147
148 $(TEST_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
149 @mkdir -p $(@D)
150 $(CCACHE) $(CC) $(CFLAGS) -c $< -o $@
151
152 $(LIBTEST): $(TEST_OBJS)
153 $(CC) -o $@ $(LDFLAGS) $(TEST_OBJS) -lm
154
155 clean::
156 # nothing to do - ant will delete the build dir
157
158 debug::
159 @echo OS="$(OS)"
160 @echo BUILD_OS="$(BUILD_OS)"
161 @echo JAVA_HOME="$(JAVA_HOME)"
162 @echo JDK_HOME="$(JDK_HOME)"
163 @echo "SRCS=$(TEST_SRCS)"