Home | History | Annotate | Download | only in win32
      1 # Makefile for libxslt, specific for Windows, GCC (mingw) and GNU make.
      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 # make [all]     to build the libxslt and the accompanying utilities.
      7 # make clean     to remove all compiler output files and return to a
      8 #                clean state.
      9 # make rebuild   to rebuild everything from scratch. This basically does
     10 #                a 'make clean' and then a 'make all'.
     11 # make install   to install the library and its header files.
     12 #
     13 # November 2002, Igor Zlatkovic <igor (a] zlatkovic.com>
     14 
     15 AUTOCONF = .\config.mingw
     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.mingw
     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_A = $(XSLT_BASENAME).a
     33 EXSLT_NAME = exslt
     34 EXSLT_BASENAME = lib$(EXSLT_NAME)
     35 EXSLT_SO = $(EXSLT_BASENAME).dll
     36 EXSLT_IMP = $(EXSLT_BASENAME).lib
     37 EXSLT_A = $(EXSLT_BASENAME).a
     38 
     39 # Places where intermediate files produced by the compiler go
     40 XSLT_INTDIR = int.xslt.mingw
     41 XSLT_INTDIR_A = int.xslta.mingw
     42 EXSLT_INTDIR = int.exslt.mingw
     43 EXSLT_INTDIR_A = int.exslta.mingw
     44 UTILS_INTDIR = int.utils.mingw
     45 
     46 # The preprocessor and its options.
     47 CPP = gcc.exe -E
     48 CPPFLAGS += 
     49 
     50 # The compiler and its options.
     51 CC = gcc.exe
     52 CFLAGS += -DWIN32 -D_WINDOWS -D_MBCS
     53 CFLAGS += -I$(BASEDIR) -I$(XSLT_SRCDIR) -I$(INCPREFIX)
     54 
     55 # The linker and its options.
     56 LD = gcc.exe
     57 LDFLAGS += -Wl,-L,$(BINDIR) -Wl,-L,$(LIBPREFIX)
     58 LIBS = -lwsock32
     59 
     60 # The archiver and its options.
     61 AR = ar.exe
     62 ARFLAGS = -r
     63 
     64 # Optimisation and debug symbols.
     65 ifeq ($(DEBUG),1)
     66 CFLAGS += -D_DEBUG -g
     67 LDFLAGS += 
     68 else
     69 CFLAGS += -DNDEBUG -O2 
     70 LDFLAGS += 
     71 endif
     72 
     73 # Libxslt object files.
     74 XSLT_OBJS = $(XSLT_INTDIR)/attributes.o\
     75 	$(XSLT_INTDIR)/documents.o\
     76 	$(XSLT_INTDIR)/extensions.o\
     77 	$(XSLT_INTDIR)/extra.o\
     78 	$(XSLT_INTDIR)/functions.o\
     79 	$(XSLT_INTDIR)/imports.o\
     80 	$(XSLT_INTDIR)/keys.o\
     81 	$(XSLT_INTDIR)/namespaces.o\
     82 	$(XSLT_INTDIR)/numbers.o\
     83 	$(XSLT_INTDIR)/pattern.o\
     84 	$(XSLT_INTDIR)/preproc.o\
     85 	$(XSLT_INTDIR)/security.o\
     86 	$(XSLT_INTDIR)/templates.o\
     87 	$(XSLT_INTDIR)/transform.o\
     88 	$(XSLT_INTDIR)/variables.o\
     89 	$(XSLT_INTDIR)/xslt.o\
     90 	$(XSLT_INTDIR)/xsltlocale.o\
     91 	$(XSLT_INTDIR)/xsltutils.o
     92 XSLT_SRCS = $(subst .o,.c,$(subst $(XSLT_INTDIR),$(XSLT_SRCDIR),$(XSLT_OBJS)))
     93 
     94 # Static libxslt object files.
     95 XSLT_OBJS_A = $(XSLT_INTDIR_A)/attributes.o\
     96 	$(XSLT_INTDIR_A)/documents.o\
     97 	$(XSLT_INTDIR_A)/extensions.o\
     98 	$(XSLT_INTDIR_A)/extra.o\
     99 	$(XSLT_INTDIR_A)/functions.o\
    100 	$(XSLT_INTDIR_A)/imports.o\
    101 	$(XSLT_INTDIR_A)/keys.o\
    102 	$(XSLT_INTDIR_A)/namespaces.o\
    103 	$(XSLT_INTDIR_A)/numbers.o\
    104 	$(XSLT_INTDIR_A)/pattern.o\
    105 	$(XSLT_INTDIR_A)/preproc.o\
    106 	$(XSLT_INTDIR_A)/security.o\
    107 	$(XSLT_INTDIR_A)/templates.o\
    108 	$(XSLT_INTDIR_A)/transform.o\
    109 	$(XSLT_INTDIR_A)/variables.o\
    110 	$(XSLT_INTDIR_A)/xslt.o\
    111 	$(XSLT_INTDIR_A)/xsltlocale.o\
    112 	$(XSLT_INTDIR_A)/xsltutils.o
    113 
    114 # Libexslt object files.
    115 EXSLT_OBJS = $(EXSLT_INTDIR)/common.o\
    116 	$(EXSLT_INTDIR)/crypto.o\
    117 	$(EXSLT_INTDIR)/date.o\
    118 	$(EXSLT_INTDIR)/exslt.o\
    119 	$(EXSLT_INTDIR)/functions.o\
    120 	$(EXSLT_INTDIR)/math.o\
    121 	$(EXSLT_INTDIR)/saxon.o\
    122 	$(EXSLT_INTDIR)/sets.o\
    123 	$(EXSLT_INTDIR)/strings.o\
    124 	$(EXSLT_INTDIR)/dynamic.o
    125 EXSLT_SRCS = $(subst .o,.c,$(subst $(EXSLT_INTDIR)/,$(EXSLT_SRCDIR)/,$(EXSLT_OBJS)))
    126 
    127 # Static libexslt object files.
    128 EXSLT_OBJS_A = $(EXSLT_INTDIR_A)/common.o\
    129 	$(EXSLT_INTDIR_A)/crypto.o\
    130 	$(EXSLT_INTDIR_A)/date.o\
    131 	$(EXSLT_INTDIR_A)/exslt.o\
    132 	$(EXSLT_INTDIR_A)/functions.o\
    133 	$(EXSLT_INTDIR_A)/math.o\
    134 	$(EXSLT_INTDIR_A)/saxon.o\
    135 	$(EXSLT_INTDIR_A)/sets.o\
    136 	$(EXSLT_INTDIR_A)/strings.o\
    137 	$(EXSLT_INTDIR_A)/dynamic.o
    138 
    139 
    140 # Xsltproc and friends executables.
    141 UTILS = $(BINDIR)/xsltproc.exe
    142 
    143 all : dep libxslt libxslta libexslt libexslta utils
    144 
    145 libxslt : $(BINDIR)\$(XSLT_SO) 
    146 
    147 libxslta : $(BINDIR)\$(XSLT_A)
    148 
    149 libexslt : $(BINDIR)\$(EXSLT_SO) 
    150 
    151 libexslta : $(BINDIR)\$(EXSLT_A)
    152 
    153 utils : $(UTILS)
    154 
    155 clean :
    156 	cmd.exe /C if exist $(XSLT_INTDIR) rmdir /S /Q $(XSLT_INTDIR)
    157 	cmd.exe /C if exist $(XSLT_INTDIR_A) rmdir /S /Q $(XSLT_INTDIR_A)
    158 	cmd.exe /C if exist $(EXSLT_INTDIR) rmdir /S /Q $(EXSLT_INTDIR)
    159 	cmd.exe /C if exist $(EXSLT_INTDIR_A) rmdir /S /Q $(EXSLT_INTDIR_A)
    160 	cmd.exe /C if exist $(UTILS_INTDIR) rmdir /S /Q $(UTILS_INTDIR)
    161 	cmd.exe /C if exist $(BINDIR) rmdir /S /Q $(BINDIR)
    162 	cmd.exe /C if exist depends.mingw del depends.mingw
    163 
    164 rebuild : clean all
    165 
    166 distclean : clean
    167 	cmd.exe /C if exist config.* del config.*
    168 	cmd.exe /C if exist depends.* del depends.*
    169 	cmd.exe /C if exist Makefile del Makefile
    170 
    171 install-libs : all
    172 	cmd.exe /C if not exist $(INCPREFIX)\$(XSLT_BASENAME) mkdir $(INCPREFIX)\$(XSLT_BASENAME)
    173 	cmd.exe /C if not exist $(INCPREFIX)\$(EXSLT_BASENAME) mkdir $(INCPREFIX)\$(EXSLT_BASENAME)
    174 	cmd.exe /C if not exist $(BINPREFIX) mkdir $(BINPREFIX)
    175 	cmd.exe /C if not exist $(LIBPREFIX) mkdir $(LIBPREFIX)
    176 	cmd.exe /C copy $(XSLT_SRCDIR)\*.h $(INCPREFIX)\$(XSLT_BASENAME)
    177 	cmd.exe /C copy $(EXSLT_SRCDIR)\*.h $(INCPREFIX)\$(EXSLT_BASENAME)
    178 	cmd.exe /C copy $(BINDIR)\$(XSLT_SO) $(SOPREFIX)
    179 	cmd.exe /C copy $(BINDIR)\$(XSLT_A) $(LIBPREFIX)
    180 	cmd.exe /C copy $(BINDIR)\$(XSLT_IMP) $(LIBPREFIX)
    181 	cmd.exe /C copy $(BINDIR)\$(EXSLT_SO) $(SOPREFIX)
    182 	cmd.exe /C copy $(BINDIR)\$(EXSLT_A) $(LIBPREFIX)
    183 	cmd.exe /C copy $(BINDIR)\$(EXSLT_IMP) $(LIBPREFIX)
    184 
    185 install : install-libs
    186 	cmd.exe /C copy $(BINDIR)\*.exe $(BINPREFIX)
    187 
    188 install-dist : install
    189 
    190 # This is a target for me, to make a binary distribution. Not for the public use,
    191 # keep your hands off :-)
    192 BDVERSION = $(LIBXSLT_MAJOR_VERSION).$(LIBXSLT_MINOR_VERSION).$(LIBXSLT_MICRO_VERSION)
    193 BDPREFIX = $(XSLT_BASENAME)-$(BDVERSION).win32
    194 bindist : all
    195 	$(MAKE) PREFIX=$(BDPREFIX) SOPREFIX=$(BDPREFIX)/bin install-dist
    196 	cscript //NoLogo configure.js genreadme $(XSLT_BASENAME) $(BDVERSION) $(BDPREFIX)\readme.txt
    197 
    198 
    199 # Creates the dependency files
    200 dep :
    201 	$(CC) $(subst \,/,$(CFLAGS)) -MM $(subst \,/,$(XSLT_SRCS)) $(subst \,/,$(EXSLT_SRCS)) > depends.mingw
    202 
    203 
    204 # Makes the compiler output directory.
    205 $(BINDIR) :
    206 	cmd.exe /C if not exist $(BINDIR) mkdir $(BINDIR)
    207 
    208 
    209 # Makes the libxslt intermediate directory.
    210 $(XSLT_INTDIR) :
    211 	cmd.exe /C if not exist $(XSLT_INTDIR) mkdir $(XSLT_INTDIR)
    212 
    213 # Makes the static libxslt intermediate directory.
    214 $(XSLT_INTDIR_A) :
    215 	cmd.exe /C if not exist $(XSLT_INTDIR_A) mkdir $(XSLT_INTDIR_A)
    216 
    217 # An implicit rule for libxslt compilation.
    218 $(XSLT_INTDIR)/%.o : $(XSLT_SRCDIR)/%.c
    219 	$(CC) $(CFLAGS) -c -o $@ $<
    220 
    221 # An implicit rule for static libxslt compilation.
    222 $(XSLT_INTDIR_A)/%.o : $(XSLT_SRCDIR)/%.c
    223 	$(CC) $(CFLAGS) -DLIBXML_STATIC -DLIBXSLT_STATIC -o $@ -c $<
    224 
    225 # Compiles libxslt source. Uses the implicit rule for commands.
    226 $(XSLT_OBJS) : $(XSLT_INTDIR)
    227 
    228 # Compiles static libxslt source. Uses the implicit rule for commands.
    229 $(XSLT_OBJS_A) : $(XSLT_INTDIR_A)
    230 
    231 # Creates the libxslt shared object.
    232 XSLTSO_LDFLAGS = $(LDFLAGS) -shared -Wl,--dll -Wl,--out-implib,$(BINDIR)/$(XSLT_IMP)
    233 XSLTSO_LDFLAGS += -Wl,--major-image-version,$(LIBXSLT_MAJOR_VERSION)
    234 XSLTSO_LDFLAGS += -Wl,--minor-image-version,$(LIBXSLT_MINOR_VERSION)
    235 $(BINDIR)\$(XSLT_SO) : $(BINDIR) $(XSLT_OBJS) 
    236 	$(LD) $(XSLTSO_LDFLAGS) -o $(BINDIR)/$(XSLT_SO) $(XSLT_OBJS) $(LIBS) -llibxml2
    237 
    238 # Creates the libxslt archive.
    239 $(BINDIR)\$(XSLT_A) : $(BINDIR) $(XSLT_OBJS_A)
    240 	$(AR) $(ARFLAGS) $(BINDIR)/$(XSLT_A) $(XSLT_OBJS_A)
    241 
    242 
    243 # Creates the libexslt intermediate directory.
    244 $(EXSLT_INTDIR) :
    245 	cmd.exe /C if not exist $(EXSLT_INTDIR) mkdir $(EXSLT_INTDIR)
    246 
    247 # Creates the static libexslt intermediate directory.
    248 $(EXSLT_INTDIR_A) :
    249 	cmd.exe /C if not exist $(EXSLT_INTDIR_A) mkdir $(EXSLT_INTDIR_A)
    250 
    251 # An implicit rule for libexslt compilation.
    252 $(EXSLT_INTDIR)/%.o : $(EXSLT_SRCDIR)/%.c
    253 	$(CC) $(CFLAGS) -I$(EXSLT_SRCDIR) -o $@ -c $<
    254 
    255 # An implicit rule for static libexslt compilation.
    256 $(EXSLT_INTDIR_A)/%.o : $(EXSLT_SRCDIR)/%.c
    257 	$(CC) $(CFLAGS) -DLIBXML_STATIC -DLIBXSLT_STATIC -DLIBEXSLT_STATIC \
    258 		-I$(EXSLT_SRCDIR) -o $@ -c $<
    259 
    260 # Compiles libxslt source. Uses the implicit rule for commands.
    261 $(EXSLT_OBJS) : $(EXSLT_INTDIR)
    262 
    263 # Compiles libxslt source. Uses the implicit rule for commands.
    264 $(EXSLT_OBJS_A) : $(EXSLT_INTDIR_A)
    265 
    266 # Creates the libexslt shared object.
    267 EXSLTSO_LDFLAGS = $(LDFLAGS) -shared -Wl,--dll -Wl,--out-implib,$(BINDIR)/$(EXSLT_IMP)
    268 EXSLTSO_LDFLAGS += -Wl,--major-image-version,$(LIBEXSLT_MAJOR_VERSION)
    269 EXSLTSO_LDFLAGS += -Wl,--minor-image-version,$(LIBEXSLT_MINOR_VERSION)
    270 $(BINDIR)\$(EXSLT_SO) : $(BINDIR) $(EXSLT_OBJS) libxslt
    271 	$(LD) $(EXSLTSO_LDFLAGS) -o $(BINDIR)/$(EXSLT_SO) $(EXSLT_OBJS) $(LIBS) -l$(XSLT_BASENAME) -llibxml2
    272 
    273 # Creates the libexslt archive.
    274 $(BINDIR)\$(EXSLT_A) : $(BINDIR) $(EXSLT_OBJS_A) libxslta
    275 	$(AR) $(ARFLAGS) $(BINDIR)\$(EXSLT_A) $(EXSLT_OBJS_A)
    276 
    277 
    278 # Creates the utils intermediate directory.
    279 $(UTILS_INTDIR) :
    280 	cmd.exe /C if not exist $(UTILS_INTDIR) mkdir $(UTILS_INTDIR)
    281 
    282 # An implicit rule for xsltproc and friends.
    283 APPLIBS = $(LIBS)
    284 APPLIBS += -llibxml2 -l$(XSLT_BASENAME) -l$(EXSLT_BASENAME)
    285 APP_LDFLAGS = $(LDFLAGS)
    286 APP_LDFLAGS += -Wl,--major-image-version,$(LIBXSLT_MAJOR_VERSION)
    287 APP_LDFLAGS += -Wl,--minor-image-version,$(LIBXSLT_MINOR_VERSION)
    288 ifeq ($(STATIC),1)
    289 CFLAGS += -DLIBXML_STATIC -DLIBXSLT_STATIC -DLIBEXSLT_STATIC
    290 APP_LDFLAGS += -Bstatic
    291 $(BINDIR)/%.exe : $(UTILS_SRCDIR)/%.c
    292 	$(CC) $(CFLAGS) -o $(subst .c,.o,$(UTILS_INTDIR)/$(<F)) -c $< 
    293 	$(LD) $(APP_LDFLAGS) -o $@ $(APPLIBS) $(subst .c,.o,$(UTILS_INTDIR)/$(<F))
    294 else
    295 $(BINDIR)/%.exe : $(UTILS_SRCDIR)/%.c 
    296 	$(CC) $(CFLAGS) -o $(subst .c,.o,$(UTILS_INTDIR)/$(<F)) -c $< 
    297 	$(LD) $(APP_LDFLAGS) -o $@ $(APPLIBS) $(subst .c,.o,$(UTILS_INTDIR)/$(<F)) 
    298 endif
    299 
    300 # Builds xsltproc and friends. Uses the implicit rule for commands.
    301 $(UTILS) : $(UTILS_INTDIR) $(BINDIR) libxslt libxslta libexslt libexslta
    302 
    303 
    304 # Source dependencies, just how?
    305 #-include depends.mingw
    306 
    307