-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdefs.mak
137 lines (123 loc) · 3.74 KB
/
defs.mak
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# defs.mak - Common makefile definitions.
#
# Original author: David Banas
# Original date: May 9, 2015
#
# Copyright (c) 2015 David Banas; all rights reserved World wide.
# Establish default target.
.PHONY: all clean rebuild
all:
clean:
@echo "Cleaning up previous build..."
-rm *.o *.obj *.lib *.manifest *.so *.exe 2>/dev/null
rebuild:
@$(MAKE) clean
@$(MAKE) all
# Prevent implicit rule searching for makefiles.
$(MAKEFILE_LIST): ;
# Infrastructure tools
AMI_CONFIG := python -m pyibisami.ami_config
RUN_TESTS := python -m pyibisami.run_tests
# Machine dependent definitions
# Note: The "x86_amd64" is NOT an error! It is required, by MSVC v12.0.
MACHINE ?= X86
ifeq ($(MACHINE), X86)
SUFFIX := x86
else
ifeq ($(MACHINE), AMD64)
SUFFIX := x86_amd64
else
$(error Unrecognized machine type: $(MACHINE))
endif
endif
# Handle Windows vs. Linux differences.
OS ?= Linux
ifeq ($(OS), Windows_NT)
ifndef MSVC_BASE_DOS
$(error "Your Microsoft Visual C++ installation is missing or incomplete. Please, see the Getting Started instructions, on the Wiki: https://github.com/capn-freako/ibisami/wiki")
endif
OBJS := $(MODS:%=%_$(SUFFIX).obj)
ENV_SETTER := $(MSVC_BASE_DOS)\vcvarsall.bat
RUN_CMD := "$(ENV_SETTER)" $(SUFFIX) 10.0.18362.0 '&&'
CC := cl.exe
CXX := cl.exe
LIB := lib.exe
LD := link.exe
CFLAGS := //EHsc //Gy //W3 //nologo //c //I. //I"$(IBISAMI_ROOT_DOS)" //I"$(BOOST_ROOT)" //D "WIN32"
LIBFLAGS = //OUT:$@ //DEF
LDFLAGS = //INCREMENTAL:NO //NOLOGO //DLL //SUBSYSTEM:WINDOWS //OUT:$@
ifeq ($(MACHINE), X86)
LDFLAGS += //MACHINE:X86
else
LDFLAGS += //MACHINE:X64
endif
ifdef DEBUG
CFLAGS += //Zi //Od //MTd //D "DEBUG"
LDFLAGS += //DEBUG
else
CFLAGS += //Oi //MT //O2 //D "NDEBUG"
endif
CXXFLAGS = $(CFLAGS)
LDLIBS := kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib \
oleaut32.lib uuid.lib odbc32.lib dbccp32.lib
IBISAMI_LIB := ibisami_$(SUFFIX).lib
else
OBJS = $(MODS:%=%_$(SUFFIX).o)
RUN_CMD =
BIN := /usr/bin
CC := gcc
CXX := g++
LIB := $(CXX)
LD := $(CXX)
CFLAGS := -c -fPIC -std=gnu++11 -I. -I"$(IBISAMI_ROOT)" -I"$(BOOST_ROOT)"
LDFLAGS = -o $@ -shared
ifeq ($(MACHINE), X86)
LDFLAGS += -m32
CFLAGS += -m32
else
LDFLAGS += -m64
CFLAGS += -m64
endif
ifdef DEBUG
CFLAGS += -g
LDFLAGS += -g
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Linux)
LDFLAGS += -s -static-libgcc -static-libstdc++ $(@:%_$(SUFFIX).so=%.exp)
else
ifeq ($(UNAME_S), Darwin)
LDFLAGS += -static-libstdc++ $(@:%_$(SUFFIX).so=%.exp)
else
$(error Unsupported OS: $(UNAME_S))
endif
endif
endif
CXXFLAGS := $(CFLAGS)
IBISAMI_LIB := libibisami_$(SUFFIX).a
endif
# Default rules
LIN_CMD = $(RUN_CMD) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -o $@
%_$(SUFFIX).o : $(SRCDIR)/%.cc
$(LIN_CMD)
%_$(SUFFIX).o : $(SRCDIR)/%.cpp
$(LIN_CMD)
%_$(SUFFIX).o : $(SRCDIR)/%.cxx
$(LIN_CMD)
%_$(SUFFIX).o : $(SRCDIR)/%.c
$(RUN_CMD) $(CC) $(CPPFLAGS) $(CFLAGS) $< -o $@
WIN_CMD = $(RUN_CMD) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $< //Fo$@
%_$(SUFFIX).obj : $(SRCDIR)/%.cc
$(WIN_CMD)
%_$(SUFFIX).obj : $(SRCDIR)/%.cpp
$(WIN_CMD)
%_$(SUFFIX).obj : $(SRCDIR)/%.cxx
$(WIN_CMD)
%_$(SUFFIX).obj : $(SRCDIR)/%.c
$(RUN_CMD) $(CC) $(CPPFLAGS) $(CFLAGS) $< /Fo$@
# Support Python model configurator.
.PRECIOUS: %.cpp # Otherwise, *.CPP files get deleted, after being compiled.
%.cpp %.ami %.ibs :: %.cpp.em %.py
$(AMI_CONFIG) $*.py
# Establish object file dependency on include files.
$(OBJS): $(INCS:%=$(INCDIR)/%)