Home | History | Annotate | Download | only in win32
      1 # Makefile for libxslt, specific for Windows, MSVC and NMAKE.
      2 #
      3 # Take a look at the beginning and modify the variables to suit your 
      4 # environment. Having done that, you can do a
      5 #
      6 # nmake [all]     to build the libxslt and the accompanying utilities.
      7 # nmake clean     to remove all compiler output files and return to a
      8 #                 clean state.
      9 # nmake rebuild   to rebuild everything from scratch. This basically does
     10 #                 a 'nmake clean' and then a 'nmake all'.
     11 # nmake install   to install the library and its header files.
     12 #
     13 # March 2002, Igor Zlatkovic <igor (a] zlatkovic.com>
     14 
     15 AUTOCONF = .\config.msvc
     16 !include $(AUTOCONF)
     17 
     18 # There should never be a need to modify anything below this line.
     19 # ----------------------------------------------------------------
     20 
     21 BASEDIR = ..
     22 XSLT_SRCDIR = $(BASEDIR)\libxslt
     23 EXSLT_SRCDIR = $(BASEDIR)\libexslt
     24 UTILS_SRCDIR = $(BASEDIR)\xsltproc
     25 BINDIR = bin.msvc
     26 
     27 # Names of various input and output components.
     28 XSLT_NAME = xslt
     29 XSLT_BASENAME = lib$(XSLT_NAME)
     30 XSLT_SO = $(XSLT_BASENAME).dll
     31 XSLT_IMP = $(XSLT_BASENAME).lib
     32 XSLT_DEF = $(XSLT_BASENAME).def
     33 XSLT_A = $(XSLT_BASENAME)_a.lib
     34 EXSLT_NAME = exslt
     35 EXSLT_BASENAME = lib$(EXSLT_NAME)
     36 EXSLT_SO = $(EXSLT_BASENAME).dll
     37 EXSLT_IMP = $(EXSLT_BASENAME).lib
     38 EXSLT_DEF = $(EXSLT_BASENAME).def
     39 EXSLT_A = $(EXSLT_BASENAME)_a.lib
     40 
     41 # Places where intermediate files produced by the compiler go
     42 XSLT_INTDIR = int.xslt.msvc
     43 XSLT_INTDIR_A = int.xslta.msvc
     44 EXSLT_INTDIR = int.exslt.msvc
     45 EXSLT_INTDIR_A = int.exslta.msvc
     46 UTILS_INTDIR = int.utils.msvc
     47 
     48 # The preprocessor and its options.
     49 CPP = cl.exe /EP
     50 CPPFLAGS = /nologo
     51 
     52 # The compiler and its options.
     53 CC = cl.exe
     54 CFLAGS = /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" /W3 $(CRUNTIME) /D "_REENTRANT"
     55 CFLAGS = $(CFLAGS) /I$(BASEDIR) /I$(XSLT_SRCDIR) /I$(INCPREFIX)
     56 CFLAGS = $(CFLAGS) /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE
     57 
     58 # The linker and its options.
     59 LD = link.exe
     60 LDFLAGS = /nologo
     61 LDFLAGS = $(LDFLAGS) /LIBPATH:$(BINDIR) /LIBPATH:$(LIBPREFIX)
     62 LIBS = wsock32.lib
     63 
     64 # The archiver and its options.
     65 AR = lib.exe
     66 ARFLAGS = /nologo
     67 
     68 # Optimisation and debug symbols.
     69 !if "$(DEBUG)" == "1"
     70 CFLAGS = $(CFLAGS) /D "_DEBUG" /Od /Z7
     71 LDFLAGS = $(LDFLAGS) /DEBUG
     72 !else
     73 CFLAGS = $(CFLAGS) /D "NDEBUG" /O2 
     74 LDFLAGS = $(LDFLAGS) /OPT:NOWIN98
     75 !endif
     76 
     77 # Libxslt object files.
     78 XSLT_OBJS = $(XSLT_INTDIR)\attributes.obj\
     79 	$(XSLT_INTDIR)\documents.obj\
     80 	$(XSLT_INTDIR)\extensions.obj\
     81 	$(XSLT_INTDIR)\extra.obj\
     82 	$(XSLT_INTDIR)\functions.obj\
     83 	$(XSLT_INTDIR)\imports.obj\
     84 	$(XSLT_INTDIR)\keys.obj\
     85 	$(XSLT_INTDIR)\namespaces.obj\
     86 	$(XSLT_INTDIR)\numbers.obj\
     87 	$(XSLT_INTDIR)\pattern.obj\
     88 	$(XSLT_INTDIR)\preproc.obj\
     89 	$(XSLT_INTDIR)\security.obj\
     90 	$(XSLT_INTDIR)\templates.obj\
     91 	$(XSLT_INTDIR)\transform.obj\
     92 	$(XSLT_INTDIR)\variables.obj\
     93 	$(XSLT_INTDIR)\xslt.obj\
     94 	$(XSLT_INTDIR)\xsltlocale.obj\
     95 	$(XSLT_INTDIR)\xsltutils.obj\
     96 	$(XSLT_INTDIR)\attrvt.obj
     97 
     98 # Static libxslt object files.
     99 XSLT_OBJS_A = $(XSLT_INTDIR_A)\attributes.obj\
    100 	$(XSLT_INTDIR_A)\documents.obj\
    101 	$(XSLT_INTDIR_A)\extensions.obj\
    102 	$(XSLT_INTDIR_A)\extra.obj\
    103 	$(XSLT_INTDIR_A)\functions.obj\
    104 	$(XSLT_INTDIR_A)\imports.obj\
    105 	$(XSLT_INTDIR_A)\keys.obj\
    106 	$(XSLT_INTDIR_A)\namespaces.obj\
    107 	$(XSLT_INTDIR_A)\numbers.obj\
    108 	$(XSLT_INTDIR_A)\pattern.obj\
    109 	$(XSLT_INTDIR_A)\preproc.obj\
    110 	$(XSLT_INTDIR_A)\security.obj\
    111 	$(XSLT_INTDIR_A)\templates.obj\
    112 	$(XSLT_INTDIR_A)\transform.obj\
    113 	$(XSLT_INTDIR_A)\variables.obj\
    114 	$(XSLT_INTDIR_A)\xslt.obj\
    115 	$(XSLT_INTDIR_A)\xsltlocale.obj\
    116 	$(XSLT_INTDIR_A)\xsltutils.obj\
    117 	$(XSLT_INTDIR_A)\attrvt.obj
    118 
    119 # Libexslt object files.
    120 EXSLT_OBJS = $(EXSLT_INTDIR)\common.obj\
    121 	$(EXSLT_INTDIR)\crypto.obj\
    122 	$(EXSLT_INTDIR)\date.obj\
    123 	$(EXSLT_INTDIR)\exslt.obj\
    124 	$(EXSLT_INTDIR)\functions.obj\
    125 	$(EXSLT_INTDIR)\math.obj\
    126 	$(EXSLT_INTDIR)\saxon.obj\
    127 	$(EXSLT_INTDIR)\sets.obj\
    128 	$(EXSLT_INTDIR)\strings.obj\
    129 	$(EXSLT_INTDIR)\dynamic.obj
    130 
    131 # Static libexslt object files.
    132 EXSLT_OBJS_A = $(EXSLT_INTDIR_A)\common.obj\
    133 	$(EXSLT_INTDIR_A)\crypto.obj\
    134 	$(EXSLT_INTDIR_A)\date.obj\
    135 	$(EXSLT_INTDIR_A)\exslt.obj\
    136 	$(EXSLT_INTDIR_A)\functions.obj\
    137 	$(EXSLT_INTDIR_A)\math.obj\
    138 	$(EXSLT_INTDIR_A)\saxon.obj\
    139 	$(EXSLT_INTDIR_A)\sets.obj\
    140 	$(EXSLT_INTDIR_A)\strings.obj\
    141 	$(EXSLT_INTDIR_A)\dynamic.obj
    142 
    143 
    144 # Xsltproc and friends executables.
    145 UTILS = $(BINDIR)\xsltproc.exe
    146 
    147 !if "$(VCMANIFEST)" == "1"
    148 _VC_MANIFEST_EMBED_EXE= if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1
    149 _VC_MANIFEST_EMBED_DLL= if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;2
    150 !else
    151 _VC_MANIFEST_EMBED_EXE=
    152 _VC_MANIFEST_EMBED_DLL=
    153 !endif
    154 
    155 all : libxslt libxslta libexslt libexslta utils
    156 
    157 libxslt : $(BINDIR)\$(XSLT_SO) 
    158 
    159 libxslta : $(BINDIR)\$(XSLT_A)
    160 
    161 libexslt : $(BINDIR)\$(EXSLT_SO) 
    162 
    163 libexslta : $(BINDIR)\$(EXSLT_A)
    164 
    165 utils : $(UTILS)
    166 
    167 clean :
    168 	if exist $(XSLT_INTDIR) rmdir /S /Q $(XSLT_INTDIR)
    169 	if exist $(XSLT_INTDIR_A) rmdir /S /Q $(XSLT_INTDIR_A)
    170 	if exist $(EXSLT_INTDIR) rmdir /S /Q $(EXSLT_INTDIR)
    171 	if exist $(EXSLT_INTDIR_A) rmdir /S /Q $(EXSLT_INTDIR_A)
    172 	if exist $(UTILS_INTDIR) rmdir /S /Q $(UTILS_INTDIR)
    173 	if exist $(BINDIR) rmdir /S /Q $(BINDIR)
    174 
    175 rebuild : clean all
    176 
    177 distclean : clean
    178 	if exist config.* del config.*
    179 	if exist Makefile del Makefile
    180 
    181 install-libs : all
    182 	if not exist $(INCPREFIX)\$(XSLT_BASENAME) mkdir $(INCPREFIX)\$(XSLT_BASENAME)
    183 	if not exist $(INCPREFIX)\$(EXSLT_BASENAME) mkdir $(INCPREFIX)\$(EXSLT_BASENAME)
    184 	if not exist $(BINPREFIX) mkdir $(BINPREFIX)
    185 	if not exist $(LIBPREFIX) mkdir $(LIBPREFIX)
    186 	copy $(XSLT_SRCDIR)\*.h $(INCPREFIX)\$(XSLT_BASENAME)
    187 	copy $(EXSLT_SRCDIR)\*.h $(INCPREFIX)\$(EXSLT_BASENAME)
    188 	copy $(BINDIR)\$(XSLT_SO) $(SOPREFIX)
    189 	copy $(BINDIR)\$(XSLT_A) $(LIBPREFIX)
    190 	copy $(BINDIR)\$(XSLT_IMP) $(LIBPREFIX)
    191 	copy $(BINDIR)\$(EXSLT_SO) $(SOPREFIX)
    192 	copy $(BINDIR)\$(EXSLT_A) $(LIBPREFIX)
    193 	copy $(BINDIR)\$(EXSLT_IMP) $(LIBPREFIX)
    194 
    195 install : install-libs
    196 	copy $(BINDIR)\*.exe $(BINPREFIX)
    197 	-copy $(BINDIR)\*.pdb $(BINPREFIX)
    198 
    199 install-dist : install
    200 
    201 # This is a target for me, to make a binary distribution. Not for the public use,
    202 # keep your hands off :-)
    203 BDVERSION = $(LIBXSLT_MAJOR_VERSION).$(LIBXSLT_MINOR_VERSION).$(LIBXSLT_MICRO_VERSION)
    204 BDPREFIX = $(XSLT_BASENAME)-$(BDVERSION).win32
    205 bindist : all
    206 	$(MAKE) /nologo PREFIX=$(BDPREFIX) SOPREFIX=$(BDPREFIX)\bin install-dist
    207 	cscript //NoLogo configure.js genreadme $(XSLT_BASENAME) $(BDVERSION) $(BDPREFIX)\readme.txt
    208 
    209 # Makes the compiler output directory.
    210 $(BINDIR) :
    211 	if not exist $(BINDIR) mkdir $(BINDIR)
    212 
    213 
    214 # Makes the libxslt intermediate directory.
    215 $(XSLT_INTDIR) :
    216 	if not exist $(XSLT_INTDIR) mkdir $(XSLT_INTDIR)
    217 
    218 # Makes the static libxslt intermediate directory.
    219 $(XSLT_INTDIR_A) :
    220 	if not exist $(XSLT_INTDIR_A) mkdir $(XSLT_INTDIR_A)
    221 
    222 # An implicit rule for libxslt compilation.
    223 {$(XSLT_SRCDIR)}.c{$(XSLT_INTDIR)}.obj::
    224 	$(CC) $(CFLAGS) /Fo$(XSLT_INTDIR)\ /c $<
    225 
    226 # An implicit rule for static libxslt compilation.
    227 {$(XSLT_SRCDIR)}.c{$(XSLT_INTDIR_A)}.obj::
    228 	$(CC) $(CFLAGS) /D "LIBXML_STATIC" /D "LIBXSLT_STATIC" \
    229 		/Fo$(XSLT_INTDIR_A)\ /c $<
    230 
    231 # Compiles libxslt source. Uses the implicit rule for commands.
    232 $(XSLT_OBJS) : $(XSLT_INTDIR)
    233 
    234 # Compiles static libxslt source. Uses the implicit rule for commands.
    235 $(XSLT_OBJS_A) : $(XSLT_INTDIR_A)
    236 
    237 # Creates the export definition file (DEF) for libxslt.
    238 $(XSLT_INTDIR)\$(XSLT_DEF) : $(XSLT_INTDIR) $(XSLT_DEF).src
    239 	$(CPP) $(CPPFLAGS) $(XSLT_DEF).src > $(XSLT_INTDIR)\$(XSLT_DEF)
    240 
    241 # Creates the libxslt shared object.
    242 $(BINDIR)\$(XSLT_SO) : $(BINDIR) $(XSLT_OBJS) $(XSLT_INTDIR)\$(XSLT_DEF)
    243 	$(LD) $(LDFLAGS) /DLL \
    244 		/VERSION:$(LIBXSLT_MAJOR_VERSION).$(LIBXSLT_MINOR_VERSION) \
    245 		/IMPLIB:$(BINDIR)\$(XSLT_IMP) /OUT:$(BINDIR)\$(XSLT_SO) \
    246 		$(XSLT_OBJS) $(LIBS) libxml2.lib
    247 			@$(_VC_MANIFEST_EMBED_DLL)
    248 
    249 #$(BINDIR)\$(XSLT_SO) : $(BINDIR) $(XSLT_OBJS) $(XSLT_INTDIR)\$(XSLT_DEF)
    250 #	$(LD) $(LDFLAGS) /DLL /DEF:$(XSLT_INTDIR)\$(XSLT_DEF) \
    251 #		/VERSION:$(LIBXSLT_MAJOR_VERSION).$(LIBXSLT_MINOR_VERSION) \
    252 #		/IMPLIB:$(BINDIR)\$(XSLT_IMP) /OUT:$(BINDIR)\$(XSLT_SO) \
    253 #		$(XSLT_OBJS) $(LIBS) libxml2.lib
    254 
    255 # Creates the libxslt archive.
    256 $(BINDIR)\$(XSLT_A) : $(BINDIR) $(XSLT_OBJS_A)
    257 	$(AR) $(ARFLAGS) /OUT:$(BINDIR)\$(XSLT_A) $(XSLT_OBJS_A)
    258 
    259 
    260 # Creates the libexslt intermediate directory.
    261 $(EXSLT_INTDIR) :
    262 	if not exist $(EXSLT_INTDIR) mkdir $(EXSLT_INTDIR)
    263 
    264 # Creates the static libexslt intermediate directory.
    265 $(EXSLT_INTDIR_A) :
    266 	if not exist $(EXSLT_INTDIR_A) mkdir $(EXSLT_INTDIR_A)
    267 
    268 # An implicit rule for libexslt compilation.
    269 {$(EXSLT_SRCDIR)}.c{$(EXSLT_INTDIR)}.obj::
    270 	$(CC) /I$(EXSLT_SRCDIR) $(CFLAGS) /Fo$(EXSLT_INTDIR)\ /c $<
    271 
    272 # An implicit rule for static libexslt compilation.
    273 {$(EXSLT_SRCDIR)}.c{$(EXSLT_INTDIR_A)}.obj::
    274 	$(CC) /D "LIBXML_STATIC" /D "LIBXSLT_STATIC" /D "LIBEXSLT_STATIC" \
    275 		/I$(EXSLT_SRCDIR) $(CFLAGS) /Fo$(EXSLT_INTDIR_A)\ /c $<
    276 
    277 # Compiles libxslt source. Uses the implicit rule for commands.
    278 $(EXSLT_OBJS) : $(EXSLT_INTDIR)
    279 
    280 # Compiles libxslt source. Uses the implicit rule for commands.
    281 $(EXSLT_OBJS_A) : $(EXSLT_INTDIR_A)
    282 
    283 # Creates the export definition file (DEF) for libxslt.
    284 $(EXSLT_INTDIR)\$(EXSLT_DEF) : $(EXSLT_INTDIR) $(EXSLT_DEF).src
    285 	$(CPP) $(CPPFLAGS) $(EXSLT_DEF).src > $(EXSLT_INTDIR)\$(EXSLT_DEF)
    286 
    287 # Creates the libexslt shared object.
    288 $(BINDIR)\$(EXSLT_SO) : $(BINDIR) $(EXSLT_OBJS) $(EXSLT_INTDIR)\$(EXSLT_DEF) libxslt
    289 	$(LD) $(LDFLAGS) /DLL \
    290 		/VERSION:$(LIBEXSLT_MAJOR_VERSION).$(LIBEXSLT_MINOR_VERSION) \
    291 		/IMPLIB:$(BINDIR)\$(EXSLT_IMP) /OUT:$(BINDIR)\$(EXSLT_SO) \
    292 		$(EXSLT_OBJS) $(XSLT_IMP) $(LIBS) libxml2.lib
    293 			@$(_VC_MANIFEST_EMBED_DLL)
    294 
    295 #$(BINDIR)\$(EXSLT_SO) : $(BINDIR) $(EXSLT_OBJS) $(EXSLT_INTDIR)\$(EXSLT_DEF) libxslt
    296 #	$(LD) $(LDFLAGS) /DLL /DEF:$(EXSLT_INTDIR)\$(EXSLT_DEF) \
    297 #		/VERSION:$(LIBEXSLT_MAJOR_VERSION).$(LIBEXSLT_MINOR_VERSION) \
    298 #		/IMPLIB:$(BINDIR)\$(EXSLT_IMP) /OUT:$(BINDIR)\$(EXSLT_SO) \
    299 #		$(EXSLT_OBJS) $(XSLT_IMP) $(LIBS) libxml2.lib
    300 
    301 # Creates the libexslt archive.
    302 $(BINDIR)\$(EXSLT_A) : $(BINDIR) $(EXSLT_OBJS_A) libxslta
    303 	$(AR) $(ARFLAGS) /OUT:$(BINDIR)\$(EXSLT_A) $(EXSLT_OBJS_A)
    304 
    305 
    306 # Creates the utils intermediate directory.
    307 $(UTILS_INTDIR) :
    308 	if not exist $(UTILS_INTDIR) mkdir $(UTILS_INTDIR)
    309 
    310 # An implicit rule for xsltproc and friends.
    311 APPLIBS = $(LIBS)
    312 !if "$(STATIC)" == "1"
    313 APPLIBS = $(LIBS) libxml2_a.lib
    314 !if "$(WITH_ICONV)" == "1"
    315 APPLIBS = $(APPLIBS) iconv.lib
    316 !endif
    317 !if "$(WITH_ZLIB)" == "1"
    318 APPLIBS = $(APPLIBS) zlib.lib
    319 !endif
    320 {$(UTILS_SRCDIR)}.c{$(BINDIR)}.exe:
    321 	$(CC) /D "LIBXML_STATIC" /D "LIBXSLT_STATIC" /D "LIBEXSLT_STATIC" \
    322 		$(CFLAGS) /Fo$(UTILS_INTDIR)\ /c $< 
    323 	$(LD) $(LDFLAGS) /OUT:$@ $(XSLT_A) $(EXSLT_A) $(APPLIBS) $(UTILS_INTDIR)\$(<B).obj
    324 	@$(_VC_MANIFEST_EMBED_EXE)
    325 !else
    326 APPLIBS = $(LIBS) libxml2.lib
    327 {$(UTILS_SRCDIR)}.c{$(BINDIR)}.exe:
    328 	$(CC) $(CFLAGS) /Fo$(UTILS_INTDIR)\ /c $< 
    329 	$(LD) $(LDFLAGS) /OUT:$@ $(XSLT_IMP) $(EXSLT_IMP) $(APPLIBS) $(UTILS_INTDIR)\$(<B).obj
    330 	@$(_VC_MANIFEST_EMBED_EXE)
    331 !endif
    332 
    333 # Builds xsltproc and friends. Uses the implicit rule for commands.
    334 $(UTILS) : $(UTILS_INTDIR) $(BINDIR) libxslt libxslta libexslt libexslta
    335 
    336 # plugins only work with non-static builds currently.
    337 !if "$(STATIC)" == "0"
    338 
    339 TESTPLUGIN_SRCDIR = $(BASEDIR)\tests\plugins
    340 TESTPLUGIN_DIR = $(TESTPLUGIN_SRCDIR)\plugin
    341 TESTPLUGIN_SO = xmlsoft_org_xslt_testplugin.dll
    342 TESTPLUGIN_OBJS = $(TESTPLUGIN_DIR)\testplugin.obj
    343 
    344 testplugin: 
    345 	if exist $(TESTPLUGIN_DIR) rmdir /S /Q $(TESTPLUGIN_DIR)
    346 	$(MAKE) $(TESTPLUGIN_DIR)\$(TESTPLUGIN_SO)
    347 
    348 $(TESTPLUGIN_DIR) :
    349 	if not exist $(TESTPLUGIN_DIR) mkdir $(TESTPLUGIN_DIR)
    350 
    351 {$(TESTPLUGIN_SRCDIR)}.c{$(TESTPLUGIN_DIR)}.obj::
    352 	$(CC) $(CFLAGS) /Fo$(TESTPLUGIN_DIR)\ /c $<
    353 
    354 # Creates the testplugin archive.
    355 $(TESTPLUGIN_DIR)\$(TESTPLUGIN_SO) : $(TESTPLUGIN_DIR) $(TESTPLUGIN_OBJS) libxslt
    356 	$(LD) $(LDFLAGS) /DLL $(XSLT_IMP) $(APPLIBS) $(LIBS)\
    357 		/OUT:$(TESTPLUGIN_DIR)\$(TESTPLUGIN_SO) \
    358 		$(TESTPLUGIN_OBJS)
    359 
    360 !else
    361 
    362 testplugin:
    363 	@echo "plugins are disabled with static=yes" 
    364 
    365 !endif
    366 
    367 
    368 # Source dependences should be autogenerated somehow here, but how to
    369 # do it? I have no clue.
    370 
    371