-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
136 lines (119 loc) · 3.9 KB
/
Makefile
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
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Originally contributed by Mladen Turk <mturk apache.org>
#
CC = cl.exe
LN = link.exe
AR = lib.exe
RC = rc.exe
SRCDIR = .
_CPU = x64
_LIB = lib
!IF !DEFINED(WINVER) || "$(WINVER)" == ""
WINVER = 0x0601
!ENDIF
!IF DEFINED(_STATIC_MSVCRT)
CRT_CFLAGS = -MT
EXTRA_LIBS =
!ELSE
CRT_CFLAGS = -MD
!ENDIF
CFLAGS = $(CFLAGS) -I$(SRCDIR)\include -I$(SRCDIR)\lib -I$(SRCDIR)\libcharset\include
CFLAGS = $(CFLAGS) -DNDEBUG -DWIN32 -D_WIN32_WINNT=$(WINVER) -DWINVER=$(WINVER)
!IF DEFINED(CMSC_VERSION)
CFLAGS = $(CFLAGS) -D_CMSC_VERSION=$(CMSC_VERSION)
!ENDIF
CFLAGS = $(CFLAGS) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE $(EXTRA_CFLAGS)
CFLAGS = $(CFLAGS) -DIN_LIBRARY -DNO_XMALLOC -DHAVE_CONFIG_H
!IF DEFINED(_RELOCATABLE)
CFLAGS = $(CFLAGS) -DENABLE_RELOCATABLE=1
CFLAGS = $(CFLAGS) -Dset_relocation_prefix=libiconv_set_relocation_prefix
CFLAGS = $(CFLAGS) -Drelocate=libiconv_relocate -Drelocate2=libiconv_relocate2
!ENDIF
PROJECT = iconv
!IF DEFINED(_STATIC)
TARGET = lib
OUTNAME = $(PROJECT)static.$(TARGET)
ARFLAGS = /nologo /MACHINE:$(_CPU) $(EXTRA_ARFLAGS)
!UNDEF _PDB
!ELSE
TARGET = dll
OUTNAME = lib$(PROJECT)-1.$(TARGET)
CFLAGS = $(CFLAGS) -DBUILDING_DLL
LDFLAGS = /nologo /INCREMENTAL:NO /OPT:REF /DLL /SUBSYSTEM:WINDOWS /MACHINE:$(_CPU) $(EXTRA_LDFLAGS)
!ENDIF
WORKDIR = $(_CPU)-rel-$(TARGET)
IMPLIB = $(WORKDIR)\$(PROJECT).lib
OUTPUT = $(WORKDIR)\$(OUTNAME)
CLOPTS = /c /nologo /wd4244 /wd4267 /wd4090 /wd4018 /wd4311 $(CRT_CFLAGS) -W3 -O2 -Ob2
RFLAGS = /l 0x409 /n /d NDEBUG /d WIN32 /d WINNT /d WINVER=$(WINVER)
RFLAGS = $(RFLAGS) /d _WIN32_WINNT=$(WINVER) $(EXTRA_RFLAGS)
LDLIBS = kernel32.lib $(EXTRA_LIBS)
!IF DEFINED(_PDB)
PDBNAME = -Fd$(WORKDIR)\$(PROJECT)
OUTPDB = /pdb:$(WORKDIR)\$(PROJECT).pdb
CLOPTS = $(CLOPTS) -Zi
LDFLAGS = $(LDFLAGS) /DEBUG
!ENDIF
!IF DEFINED(_VENDOR_SFX)
RFLAGS = $(RFLAGS) /d _VENDOR_SFX=$(_VENDOR_SFX)
!ENDIF
!IF DEFINED(_VENDOR_NUM)
RFLAGS = $(RFLAGS) /d _VENDOR_NUM=$(_VENDOR_NUM)
!ENDIF
OBJECTS = \
$(WORKDIR)\localcharset.obj \
$(WORKDIR)\iconv.obj \
$(WORKDIR)\relocatable.obj
!IF "$(TARGET)" == "dll"
OBJECTS = $(OBJECTS) $(WORKDIR)\llibiconv.res
!ENDIF
all : $(WORKDIR) $(OUTPUT)
$(WORKDIR) :
@-md $(WORKDIR)
{$(SRCDIR)\lib}.c{$(WORKDIR)}.obj:
$(CC) $(CLOPTS) $(CFLAGS) -Fo$(WORKDIR)\ $(PDBNAME) $<
{$(SRCDIR)\libcharset\lib}.c{$(WORKDIR)}.obj:
$(CC) $(CLOPTS) $(CFLAGS) -Fo$(WORKDIR)\ $(PDBNAME) $<
{$(SRCDIR)\windows}.rc{$(WORKDIR)}.res:
$(RC) $(RFLAGS) /fo $@ $<
$(OUTPUT): $(WORKDIR) $(OBJECTS)
!IF "$(TARGET)" == "dll"
$(LN) $(LDFLAGS) $(OBJECTS) $(LDLIBS) $(OUTPDB) /implib:$(IMPLIB) /out:$(OUTPUT)
!ELSE
$(AR) $(ARFLAGS) $(OBJECTS) /out:$(OUTPUT)
!ENDIF
!IF !DEFINED(PREFIX) || "$(PREFIX)" == ""
install:
@echo PREFIX is not defined
@echo Use `nmake install PREFIX=directory`
@echo.
@exit /B 1
!ELSE
install : all
@-md "$(PREFIX)" 2>NUL
@-md "$(PREFIX)\include" 2>NUL
!IF "$(TARGET)" == "dll"
@xcopy /I /Y /Q "$(WORKDIR)\*.dll" "$(PREFIX)\bin"
!ENDIF
!IF DEFINED(_PDB)
@xcopy /I /Y /Q "$(WORKDIR)\*.pdb" "$(PREFIX)\bin"
!ENDIF
@xcopy /I /Y /Q "$(WORKDIR)\*.lib" "$(PREFIX)\$(_LIB)"
@copy /Y "$(SRCDIR)\include\iconv.h.dist" "$(PREFIX)\include\iconv.h" >NUL
!ENDIF
clean:
@-rd /S /Q $(WORKDIR) 2>NUL